babylon.max.js 7.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs", [], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs"] = factory();
  8. else
  9. root["BABYLON"] = factory();
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./Legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../node_modules/tslib/tslib.es6.js":
  99. /*!******************************************!*\
  100. !*** ../node_modules/tslib/tslib.es6.js ***!
  101. \******************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../node_modules/webpack/buildin/global.js":
  291. /*!*************************************************!*\
  292. !*** ../node_modules/webpack/buildin/global.js ***!
  293. \*************************************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./Actions/abstractActionManager.ts":
  314. /*!******************************************!*\
  315. !*** ./Actions/abstractActionManager.ts ***!
  316. \******************************************/
  317. /*! exports provided: AbstractActionManager */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractActionManager", function() { return AbstractActionManager; });
  322. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  323. /**
  324. * Abstract class used to decouple action Manager from scene and meshes.
  325. * Do not instantiate.
  326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  327. */
  328. var AbstractActionManager = /** @class */ (function () {
  329. function AbstractActionManager() {
  330. /** Gets the cursor to use when hovering items */
  331. this.hoverCursor = '';
  332. /** Gets the list of actions */
  333. this.actions = new Array();
  334. /**
  335. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  336. */
  337. this.isRecursive = false;
  338. }
  339. Object.defineProperty(AbstractActionManager, "HasTriggers", {
  340. /**
  341. * Does exist one action manager with at least one trigger
  342. **/
  343. get: function () {
  344. for (var t in AbstractActionManager.Triggers) {
  345. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  346. return true;
  347. }
  348. }
  349. return false;
  350. },
  351. enumerable: true,
  352. configurable: true
  353. });
  354. Object.defineProperty(AbstractActionManager, "HasPickTriggers", {
  355. /**
  356. * Does exist one action manager with at least one pick trigger
  357. **/
  358. get: function () {
  359. for (var t in AbstractActionManager.Triggers) {
  360. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  361. var t_int = parseInt(t);
  362. if (t_int >= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickTrigger && t_int <= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickUpTrigger) {
  363. return true;
  364. }
  365. }
  366. }
  367. return false;
  368. },
  369. enumerable: true,
  370. configurable: true
  371. });
  372. /**
  373. * Does exist one action manager that handles actions of a given trigger
  374. * @param trigger defines the trigger to be tested
  375. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  376. **/
  377. AbstractActionManager.HasSpecificTrigger = function (trigger) {
  378. for (var t in AbstractActionManager.Triggers) {
  379. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  380. var t_int = parseInt(t);
  381. if (t_int === trigger) {
  382. return true;
  383. }
  384. }
  385. }
  386. return false;
  387. };
  388. /** Gets the list of active triggers */
  389. AbstractActionManager.Triggers = {};
  390. return AbstractActionManager;
  391. }());
  392. /***/ }),
  393. /***/ "./Actions/action.ts":
  394. /*!***************************!*\
  395. !*** ./Actions/action.ts ***!
  396. \***************************/
  397. /*! exports provided: Action */
  398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  399. "use strict";
  400. __webpack_require__.r(__webpack_exports__);
  401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return Action; });
  402. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  403. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  404. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  405. /**
  406. * The action to be carried out following a trigger
  407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  408. */
  409. var Action = /** @class */ (function () {
  410. /**
  411. * Creates a new Action
  412. * @param triggerOptions the trigger, with or without parameters, for the action
  413. * @param condition an optional determinant of action
  414. */
  415. function Action(
  416. /** the trigger, with or without parameters, for the action */
  417. triggerOptions, condition) {
  418. this.triggerOptions = triggerOptions;
  419. /**
  420. * An event triggered prior to action being executed.
  421. */
  422. this.onBeforeExecuteObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  423. if (triggerOptions.parameter) {
  424. this.trigger = triggerOptions.trigger;
  425. this._triggerParameter = triggerOptions.parameter;
  426. }
  427. else if (triggerOptions.trigger) {
  428. this.trigger = triggerOptions.trigger;
  429. }
  430. else {
  431. this.trigger = triggerOptions;
  432. }
  433. this._nextActiveAction = this;
  434. this._condition = condition;
  435. }
  436. /**
  437. * Internal only
  438. * @hidden
  439. */
  440. Action.prototype._prepare = function () {
  441. };
  442. /**
  443. * Gets the trigger parameters
  444. * @returns the trigger parameters
  445. */
  446. Action.prototype.getTriggerParameter = function () {
  447. return this._triggerParameter;
  448. };
  449. /**
  450. * Internal only - executes current action event
  451. * @hidden
  452. */
  453. Action.prototype._executeCurrent = function (evt) {
  454. if (this._nextActiveAction._condition) {
  455. var condition = this._nextActiveAction._condition;
  456. var currentRenderId = this._actionManager.getScene().getRenderId();
  457. // We cache the current evaluation for the current frame
  458. if (condition._evaluationId === currentRenderId) {
  459. if (!condition._currentResult) {
  460. return;
  461. }
  462. }
  463. else {
  464. condition._evaluationId = currentRenderId;
  465. if (!condition.isValid()) {
  466. condition._currentResult = false;
  467. return;
  468. }
  469. condition._currentResult = true;
  470. }
  471. }
  472. this.onBeforeExecuteObservable.notifyObservers(this);
  473. this._nextActiveAction.execute(evt);
  474. this.skipToNextActiveAction();
  475. };
  476. /**
  477. * Execute placeholder for child classes
  478. * @param evt optional action event
  479. */
  480. Action.prototype.execute = function (evt) {
  481. };
  482. /**
  483. * Skips to next active action
  484. */
  485. Action.prototype.skipToNextActiveAction = function () {
  486. if (this._nextActiveAction._child) {
  487. if (!this._nextActiveAction._child._actionManager) {
  488. this._nextActiveAction._child._actionManager = this._actionManager;
  489. }
  490. this._nextActiveAction = this._nextActiveAction._child;
  491. }
  492. else {
  493. this._nextActiveAction = this;
  494. }
  495. };
  496. /**
  497. * Adds action to chain of actions, may be a DoNothingAction
  498. * @param action defines the next action to execute
  499. * @returns The action passed in
  500. * @see https://www.babylonjs-playground.com/#1T30HR#0
  501. */
  502. Action.prototype.then = function (action) {
  503. this._child = action;
  504. action._actionManager = this._actionManager;
  505. action._prepare();
  506. return action;
  507. };
  508. /**
  509. * Internal only
  510. * @hidden
  511. */
  512. Action.prototype._getProperty = function (propertyPath) {
  513. return this._actionManager._getProperty(propertyPath);
  514. };
  515. /**
  516. * Internal only
  517. * @hidden
  518. */
  519. Action.prototype._getEffectiveTarget = function (target, propertyPath) {
  520. return this._actionManager._getEffectiveTarget(target, propertyPath);
  521. };
  522. /**
  523. * Serialize placeholder for child classes
  524. * @param parent of child
  525. * @returns the serialized object
  526. */
  527. Action.prototype.serialize = function (parent) {
  528. };
  529. /**
  530. * Internal only called by serialize
  531. * @hidden
  532. */
  533. Action.prototype._serialize = function (serializedAction, parent) {
  534. var serializationObject = {
  535. type: 1,
  536. children: [],
  537. name: serializedAction.name,
  538. properties: serializedAction.properties || []
  539. };
  540. // Serialize child
  541. if (this._child) {
  542. this._child.serialize(serializationObject);
  543. }
  544. // Check if "this" has a condition
  545. if (this._condition) {
  546. var serializedCondition = this._condition.serialize();
  547. serializedCondition.children.push(serializationObject);
  548. if (parent) {
  549. parent.children.push(serializedCondition);
  550. }
  551. return serializedCondition;
  552. }
  553. if (parent) {
  554. parent.children.push(serializationObject);
  555. }
  556. return serializationObject;
  557. };
  558. /**
  559. * Internal only
  560. * @hidden
  561. */
  562. Action._SerializeValueAsString = function (value) {
  563. if (typeof value === "number") {
  564. return value.toString();
  565. }
  566. if (typeof value === "boolean") {
  567. return value ? "true" : "false";
  568. }
  569. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]) {
  570. return value.x + ", " + value.y;
  571. }
  572. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  573. return value.x + ", " + value.y + ", " + value.z;
  574. }
  575. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  576. return value.r + ", " + value.g + ", " + value.b;
  577. }
  578. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  579. return value.r + ", " + value.g + ", " + value.b + ", " + value.a;
  580. }
  581. return value; // string
  582. };
  583. /**
  584. * Internal only
  585. * @hidden
  586. */
  587. Action._GetTargetProperty = function (target) {
  588. return {
  589. name: "target",
  590. targetType: target._isMesh ? "MeshProperties"
  591. : target._isLight ? "LightProperties"
  592. : target._isCamera ? "CameraProperties"
  593. : "SceneProperties",
  594. value: target._isScene ? "Scene" : target.name
  595. };
  596. };
  597. return Action;
  598. }());
  599. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.Action"] = Action;
  600. /***/ }),
  601. /***/ "./Actions/actionEvent.ts":
  602. /*!********************************!*\
  603. !*** ./Actions/actionEvent.ts ***!
  604. \********************************/
  605. /*! exports provided: ActionEvent */
  606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  607. "use strict";
  608. __webpack_require__.r(__webpack_exports__);
  609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return ActionEvent; });
  610. /**
  611. * ActionEvent is the event being sent when an action is triggered.
  612. */
  613. var ActionEvent = /** @class */ (function () {
  614. /**
  615. * Creates a new ActionEvent
  616. * @param source The mesh or sprite that triggered the action
  617. * @param pointerX The X mouse cursor position at the time of the event
  618. * @param pointerY The Y mouse cursor position at the time of the event
  619. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  620. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  621. * @param additionalData additional data for the event
  622. */
  623. function ActionEvent(
  624. /** The mesh or sprite that triggered the action */
  625. source,
  626. /** The X mouse cursor position at the time of the event */
  627. pointerX,
  628. /** The Y mouse cursor position at the time of the event */
  629. pointerY,
  630. /** The mesh that is currently pointed at (can be null) */
  631. meshUnderPointer,
  632. /** the original (browser) event that triggered the ActionEvent */
  633. sourceEvent,
  634. /** additional data for the event */
  635. additionalData) {
  636. this.source = source;
  637. this.pointerX = pointerX;
  638. this.pointerY = pointerY;
  639. this.meshUnderPointer = meshUnderPointer;
  640. this.sourceEvent = sourceEvent;
  641. this.additionalData = additionalData;
  642. }
  643. /**
  644. * Helper function to auto-create an ActionEvent from a source mesh.
  645. * @param source The source mesh that triggered the event
  646. * @param evt The original (browser) event
  647. * @param additionalData additional data for the event
  648. * @returns the new ActionEvent
  649. */
  650. ActionEvent.CreateNew = function (source, evt, additionalData) {
  651. var scene = source.getScene();
  652. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer || source, evt, additionalData);
  653. };
  654. /**
  655. * Helper function to auto-create an ActionEvent from a source sprite
  656. * @param source The source sprite that triggered the event
  657. * @param scene Scene associated with the sprite
  658. * @param evt The original (browser) event
  659. * @param additionalData additional data for the event
  660. * @returns the new ActionEvent
  661. */
  662. ActionEvent.CreateNewFromSprite = function (source, scene, evt, additionalData) {
  663. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  664. };
  665. /**
  666. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  667. * @param scene the scene where the event occurred
  668. * @param evt The original (browser) event
  669. * @returns the new ActionEvent
  670. */
  671. ActionEvent.CreateNewFromScene = function (scene, evt) {
  672. return new ActionEvent(null, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt);
  673. };
  674. /**
  675. * Helper function to auto-create an ActionEvent from a primitive
  676. * @param prim defines the target primitive
  677. * @param pointerPos defines the pointer position
  678. * @param evt The original (browser) event
  679. * @param additionalData additional data for the event
  680. * @returns the new ActionEvent
  681. */
  682. ActionEvent.CreateNewFromPrimitive = function (prim, pointerPos, evt, additionalData) {
  683. return new ActionEvent(prim, pointerPos.x, pointerPos.y, null, evt, additionalData);
  684. };
  685. return ActionEvent;
  686. }());
  687. /***/ }),
  688. /***/ "./Actions/actionManager.ts":
  689. /*!**********************************!*\
  690. !*** ./Actions/actionManager.ts ***!
  691. \**********************************/
  692. /*! exports provided: ActionManager */
  693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  694. "use strict";
  695. __webpack_require__.r(__webpack_exports__);
  696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return ActionManager; });
  697. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  698. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  699. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  700. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  701. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  702. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  703. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  704. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  705. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  706. /* harmony import */ var _abstractActionManager__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./abstractActionManager */ "./Actions/abstractActionManager.ts");
  707. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  708. /**
  709. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  710. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  712. */
  713. var ActionManager = /** @class */ (function (_super) {
  714. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ActionManager, _super);
  715. /**
  716. * Creates a new action manager
  717. * @param scene defines the hosting scene
  718. */
  719. function ActionManager(scene) {
  720. var _this = _super.call(this) || this;
  721. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  722. scene.actionManagers.push(_this);
  723. return _this;
  724. }
  725. // Methods
  726. /**
  727. * Releases all associated resources
  728. */
  729. ActionManager.prototype.dispose = function () {
  730. var index = this._scene.actionManagers.indexOf(this);
  731. for (var i = 0; i < this.actions.length; i++) {
  732. var action = this.actions[i];
  733. ActionManager.Triggers[action.trigger]--;
  734. if (ActionManager.Triggers[action.trigger] === 0) {
  735. delete ActionManager.Triggers[action.trigger];
  736. }
  737. }
  738. if (index > -1) {
  739. this._scene.actionManagers.splice(index, 1);
  740. }
  741. };
  742. /**
  743. * Gets hosting scene
  744. * @returns the hosting scene
  745. */
  746. ActionManager.prototype.getScene = function () {
  747. return this._scene;
  748. };
  749. /**
  750. * Does this action manager handles actions of any of the given triggers
  751. * @param triggers defines the triggers to be tested
  752. * @return a boolean indicating whether one (or more) of the triggers is handled
  753. */
  754. ActionManager.prototype.hasSpecificTriggers = function (triggers) {
  755. for (var index = 0; index < this.actions.length; index++) {
  756. var action = this.actions[index];
  757. if (triggers.indexOf(action.trigger) > -1) {
  758. return true;
  759. }
  760. }
  761. return false;
  762. };
  763. /**
  764. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  765. * speed.
  766. * @param triggerA defines the trigger to be tested
  767. * @param triggerB defines the trigger to be tested
  768. * @return a boolean indicating whether one (or more) of the triggers is handled
  769. */
  770. ActionManager.prototype.hasSpecificTriggers2 = function (triggerA, triggerB) {
  771. for (var index = 0; index < this.actions.length; index++) {
  772. var action = this.actions[index];
  773. if (triggerA == action.trigger || triggerB == action.trigger) {
  774. return true;
  775. }
  776. }
  777. return false;
  778. };
  779. /**
  780. * Does this action manager handles actions of a given trigger
  781. * @param trigger defines the trigger to be tested
  782. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  783. * @return whether the trigger is handled
  784. */
  785. ActionManager.prototype.hasSpecificTrigger = function (trigger, parameterPredicate) {
  786. for (var index = 0; index < this.actions.length; index++) {
  787. var action = this.actions[index];
  788. if (action.trigger === trigger) {
  789. if (parameterPredicate) {
  790. if (parameterPredicate(action.getTriggerParameter())) {
  791. return true;
  792. }
  793. }
  794. else {
  795. return true;
  796. }
  797. }
  798. }
  799. return false;
  800. };
  801. Object.defineProperty(ActionManager.prototype, "hasPointerTriggers", {
  802. /**
  803. * Does this action manager has pointer triggers
  804. */
  805. get: function () {
  806. for (var index = 0; index < this.actions.length; index++) {
  807. var action = this.actions[index];
  808. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPointerOutTrigger) {
  809. return true;
  810. }
  811. }
  812. return false;
  813. },
  814. enumerable: true,
  815. configurable: true
  816. });
  817. Object.defineProperty(ActionManager.prototype, "hasPickTriggers", {
  818. /**
  819. * Does this action manager has pick triggers
  820. */
  821. get: function () {
  822. for (var index = 0; index < this.actions.length; index++) {
  823. var action = this.actions[index];
  824. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPickUpTrigger) {
  825. return true;
  826. }
  827. }
  828. return false;
  829. },
  830. enumerable: true,
  831. configurable: true
  832. });
  833. /**
  834. * Registers an action to this action manager
  835. * @param action defines the action to be registered
  836. * @return the action amended (prepared) after registration
  837. */
  838. ActionManager.prototype.registerAction = function (action) {
  839. if (action.trigger === ActionManager.OnEveryFrameTrigger) {
  840. if (this.getScene().actionManager !== this) {
  841. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Warn("OnEveryFrameTrigger can only be used with scene.actionManager");
  842. return null;
  843. }
  844. }
  845. this.actions.push(action);
  846. if (ActionManager.Triggers[action.trigger]) {
  847. ActionManager.Triggers[action.trigger]++;
  848. }
  849. else {
  850. ActionManager.Triggers[action.trigger] = 1;
  851. }
  852. action._actionManager = this;
  853. action._prepare();
  854. return action;
  855. };
  856. /**
  857. * Unregisters an action to this action manager
  858. * @param action defines the action to be unregistered
  859. * @return a boolean indicating whether the action has been unregistered
  860. */
  861. ActionManager.prototype.unregisterAction = function (action) {
  862. var index = this.actions.indexOf(action);
  863. if (index !== -1) {
  864. this.actions.splice(index, 1);
  865. ActionManager.Triggers[action.trigger] -= 1;
  866. if (ActionManager.Triggers[action.trigger] === 0) {
  867. delete ActionManager.Triggers[action.trigger];
  868. }
  869. delete action._actionManager;
  870. return true;
  871. }
  872. return false;
  873. };
  874. /**
  875. * Process a specific trigger
  876. * @param trigger defines the trigger to process
  877. * @param evt defines the event details to be processed
  878. */
  879. ActionManager.prototype.processTrigger = function (trigger, evt) {
  880. for (var index = 0; index < this.actions.length; index++) {
  881. var action = this.actions[index];
  882. if (action.trigger === trigger) {
  883. if (evt) {
  884. if (trigger === ActionManager.OnKeyUpTrigger
  885. || trigger === ActionManager.OnKeyDownTrigger) {
  886. var parameter = action.getTriggerParameter();
  887. if (parameter && parameter !== evt.sourceEvent.keyCode) {
  888. if (!parameter.toLowerCase) {
  889. continue;
  890. }
  891. var lowerCase = parameter.toLowerCase();
  892. if (lowerCase !== evt.sourceEvent.key) {
  893. var unicode = evt.sourceEvent.charCode ? evt.sourceEvent.charCode : evt.sourceEvent.keyCode;
  894. var actualkey = String.fromCharCode(unicode).toLowerCase();
  895. if (actualkey !== lowerCase) {
  896. continue;
  897. }
  898. }
  899. }
  900. }
  901. }
  902. action._executeCurrent(evt);
  903. }
  904. }
  905. };
  906. /** @hidden */
  907. ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
  908. var properties = propertyPath.split(".");
  909. for (var index = 0; index < properties.length - 1; index++) {
  910. target = target[properties[index]];
  911. }
  912. return target;
  913. };
  914. /** @hidden */
  915. ActionManager.prototype._getProperty = function (propertyPath) {
  916. var properties = propertyPath.split(".");
  917. return properties[properties.length - 1];
  918. };
  919. /**
  920. * Serialize this manager to a JSON object
  921. * @param name defines the property name to store this manager
  922. * @returns a JSON representation of this manager
  923. */
  924. ActionManager.prototype.serialize = function (name) {
  925. var root = {
  926. children: new Array(),
  927. name: name,
  928. type: 3,
  929. properties: new Array() // Empty for root but required
  930. };
  931. for (var i = 0; i < this.actions.length; i++) {
  932. var triggerObject = {
  933. type: 0,
  934. children: new Array(),
  935. name: ActionManager.GetTriggerName(this.actions[i].trigger),
  936. properties: new Array()
  937. };
  938. var triggerOptions = this.actions[i].triggerOptions;
  939. if (triggerOptions && typeof triggerOptions !== "number") {
  940. if (triggerOptions.parameter instanceof Node) {
  941. triggerObject.properties.push(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(triggerOptions.parameter));
  942. }
  943. else {
  944. var parameter = {};
  945. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__["DeepCopier"].DeepCopy(triggerOptions.parameter, parameter, ["mesh"]);
  946. if (triggerOptions.parameter && triggerOptions.parameter.mesh) {
  947. parameter._meshId = triggerOptions.parameter.mesh.id;
  948. }
  949. triggerObject.properties.push({ name: "parameter", targetType: null, value: parameter });
  950. }
  951. }
  952. // Serialize child action, recursively
  953. this.actions[i].serialize(triggerObject);
  954. // Add serialized trigger
  955. root.children.push(triggerObject);
  956. }
  957. return root;
  958. };
  959. /**
  960. * Creates a new ActionManager from a JSON data
  961. * @param parsedActions defines the JSON data to read from
  962. * @param object defines the hosting mesh
  963. * @param scene defines the hosting scene
  964. */
  965. ActionManager.Parse = function (parsedActions, object, scene) {
  966. var actionManager = new ActionManager(scene);
  967. if (object === null) {
  968. scene.actionManager = actionManager;
  969. }
  970. else {
  971. object.actionManager = actionManager;
  972. }
  973. // instanciate a new object
  974. var instanciate = function (name, params) {
  975. var internalClassType = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON." + name);
  976. if (internalClassType) {
  977. var newInstance = Object.create(internalClassType.prototype);
  978. newInstance.constructor.apply(newInstance, params);
  979. return newInstance;
  980. }
  981. };
  982. var parseParameter = function (name, value, target, propertyPath) {
  983. if (propertyPath === null) {
  984. // String, boolean or float
  985. var floatValue = parseFloat(value);
  986. if (value === "true" || value === "false") {
  987. return value === "true";
  988. }
  989. else {
  990. return isNaN(floatValue) ? value : floatValue;
  991. }
  992. }
  993. var effectiveTarget = propertyPath.split(".");
  994. var values = value.split(",");
  995. // Get effective Target
  996. for (var i = 0; i < effectiveTarget.length; i++) {
  997. target = target[effectiveTarget[i]];
  998. }
  999. // Return appropriate value with its type
  1000. if (typeof (target) === "boolean") {
  1001. return values[0] === "true";
  1002. }
  1003. if (typeof (target) === "string") {
  1004. return values[0];
  1005. }
  1006. // Parameters with multiple values such as Vector3 etc.
  1007. var split = new Array();
  1008. for (var i = 0; i < values.length; i++) {
  1009. split.push(parseFloat(values[i]));
  1010. }
  1011. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  1012. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(split);
  1013. }
  1014. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]) {
  1015. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"].FromArray(split);
  1016. }
  1017. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  1018. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(split);
  1019. }
  1020. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  1021. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(split);
  1022. }
  1023. return parseFloat(values[0]);
  1024. };
  1025. // traverse graph per trigger
  1026. var traverse = function (parsedAction, trigger, condition, action, combineArray) {
  1027. if (combineArray === void 0) { combineArray = null; }
  1028. if (parsedAction.detached) {
  1029. return;
  1030. }
  1031. var parameters = new Array();
  1032. var target = null;
  1033. var propertyPath = null;
  1034. var combine = parsedAction.combine && parsedAction.combine.length > 0;
  1035. // Parameters
  1036. if (parsedAction.type === 2) {
  1037. parameters.push(actionManager);
  1038. }
  1039. else {
  1040. parameters.push(trigger);
  1041. }
  1042. if (combine) {
  1043. var actions = new Array();
  1044. for (var j = 0; j < parsedAction.combine.length; j++) {
  1045. traverse(parsedAction.combine[j], ActionManager.NothingTrigger, condition, action, actions);
  1046. }
  1047. parameters.push(actions);
  1048. }
  1049. else {
  1050. for (var i = 0; i < parsedAction.properties.length; i++) {
  1051. var value = parsedAction.properties[i].value;
  1052. var name = parsedAction.properties[i].name;
  1053. var targetType = parsedAction.properties[i].targetType;
  1054. if (name === "target") {
  1055. if (targetType !== null && targetType === "SceneProperties") {
  1056. value = target = scene;
  1057. }
  1058. else {
  1059. value = target = scene.getNodeByName(value);
  1060. }
  1061. }
  1062. else if (name === "parent") {
  1063. value = scene.getNodeByName(value);
  1064. }
  1065. else if (name === "sound") {
  1066. // Can not externalize to component, so only checks for the presence off the API.
  1067. if (scene.getSoundByName) {
  1068. value = scene.getSoundByName(value);
  1069. }
  1070. }
  1071. else if (name !== "propertyPath") {
  1072. if (parsedAction.type === 2 && name === "operator") {
  1073. value = _condition__WEBPACK_IMPORTED_MODULE_2__["ValueCondition"][value];
  1074. }
  1075. else {
  1076. value = parseParameter(name, value, target, name === "value" ? propertyPath : null);
  1077. }
  1078. }
  1079. else {
  1080. propertyPath = value;
  1081. }
  1082. parameters.push(value);
  1083. }
  1084. }
  1085. if (combineArray === null) {
  1086. parameters.push(condition);
  1087. }
  1088. else {
  1089. parameters.push(null);
  1090. }
  1091. // If interpolate value action
  1092. if (parsedAction.name === "InterpolateValueAction") {
  1093. var param = parameters[parameters.length - 2];
  1094. parameters[parameters.length - 1] = param;
  1095. parameters[parameters.length - 2] = condition;
  1096. }
  1097. // Action or condition(s) and not CombineAction
  1098. var newAction = instanciate(parsedAction.name, parameters);
  1099. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"] && condition !== null) {
  1100. var nothing = new _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"](trigger, condition);
  1101. if (action) {
  1102. action.then(nothing);
  1103. }
  1104. else {
  1105. actionManager.registerAction(nothing);
  1106. }
  1107. action = nothing;
  1108. }
  1109. if (combineArray === null) {
  1110. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"]) {
  1111. condition = newAction;
  1112. newAction = action;
  1113. }
  1114. else {
  1115. condition = null;
  1116. if (action) {
  1117. action.then(newAction);
  1118. }
  1119. else {
  1120. actionManager.registerAction(newAction);
  1121. }
  1122. }
  1123. }
  1124. else {
  1125. combineArray.push(newAction);
  1126. }
  1127. for (var i = 0; i < parsedAction.children.length; i++) {
  1128. traverse(parsedAction.children[i], trigger, condition, newAction, null);
  1129. }
  1130. };
  1131. // triggers
  1132. for (var i = 0; i < parsedActions.children.length; i++) {
  1133. var triggerParams;
  1134. var trigger = parsedActions.children[i];
  1135. if (trigger.properties.length > 0) {
  1136. var param = trigger.properties[0].value;
  1137. var value = trigger.properties[0].targetType === null ? param : scene.getMeshByName(param);
  1138. if (value._meshId) {
  1139. value.mesh = scene.getMeshByID(value._meshId);
  1140. }
  1141. triggerParams = { trigger: ActionManager[trigger.name], parameter: value };
  1142. }
  1143. else {
  1144. triggerParams = ActionManager[trigger.name];
  1145. }
  1146. for (var j = 0; j < trigger.children.length; j++) {
  1147. if (!trigger.detached) {
  1148. traverse(trigger.children[j], triggerParams, null, null);
  1149. }
  1150. }
  1151. }
  1152. };
  1153. /**
  1154. * Get a trigger name by index
  1155. * @param trigger defines the trigger index
  1156. * @returns a trigger name
  1157. */
  1158. ActionManager.GetTriggerName = function (trigger) {
  1159. switch (trigger) {
  1160. case 0: return "NothingTrigger";
  1161. case 1: return "OnPickTrigger";
  1162. case 2: return "OnLeftPickTrigger";
  1163. case 3: return "OnRightPickTrigger";
  1164. case 4: return "OnCenterPickTrigger";
  1165. case 5: return "OnPickDownTrigger";
  1166. case 6: return "OnPickUpTrigger";
  1167. case 7: return "OnLongPressTrigger";
  1168. case 8: return "OnPointerOverTrigger";
  1169. case 9: return "OnPointerOutTrigger";
  1170. case 10: return "OnEveryFrameTrigger";
  1171. case 11: return "OnIntersectionEnterTrigger";
  1172. case 12: return "OnIntersectionExitTrigger";
  1173. case 13: return "OnKeyDownTrigger";
  1174. case 14: return "OnKeyUpTrigger";
  1175. case 15: return "OnPickOutTrigger";
  1176. default: return "";
  1177. }
  1178. };
  1179. /**
  1180. * Nothing
  1181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1182. */
  1183. ActionManager.NothingTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_NothingTrigger;
  1184. /**
  1185. * On pick
  1186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1187. */
  1188. ActionManager.OnPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickTrigger;
  1189. /**
  1190. * On left pick
  1191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1192. */
  1193. ActionManager.OnLeftPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLeftPickTrigger;
  1194. /**
  1195. * On right pick
  1196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1197. */
  1198. ActionManager.OnRightPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnRightPickTrigger;
  1199. /**
  1200. * On center pick
  1201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1202. */
  1203. ActionManager.OnCenterPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnCenterPickTrigger;
  1204. /**
  1205. * On pick down
  1206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1207. */
  1208. ActionManager.OnPickDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickDownTrigger;
  1209. /**
  1210. * On double pick
  1211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1212. */
  1213. ActionManager.OnDoublePickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnDoublePickTrigger;
  1214. /**
  1215. * On pick up
  1216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1217. */
  1218. ActionManager.OnPickUpTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickUpTrigger;
  1219. /**
  1220. * On pick out.
  1221. * This trigger will only be raised if you also declared a OnPickDown
  1222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1223. */
  1224. ActionManager.OnPickOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickOutTrigger;
  1225. /**
  1226. * On long press
  1227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1228. */
  1229. ActionManager.OnLongPressTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLongPressTrigger;
  1230. /**
  1231. * On pointer over
  1232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1233. */
  1234. ActionManager.OnPointerOverTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOverTrigger;
  1235. /**
  1236. * On pointer out
  1237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1238. */
  1239. ActionManager.OnPointerOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOutTrigger;
  1240. /**
  1241. * On every frame
  1242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1243. */
  1244. ActionManager.OnEveryFrameTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnEveryFrameTrigger;
  1245. /**
  1246. * On intersection enter
  1247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1248. */
  1249. ActionManager.OnIntersectionEnterTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionEnterTrigger;
  1250. /**
  1251. * On intersection exit
  1252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1253. */
  1254. ActionManager.OnIntersectionExitTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionExitTrigger;
  1255. /**
  1256. * On key down
  1257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1258. */
  1259. ActionManager.OnKeyDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnKeyDownTrigger;
  1260. /**
  1261. * On key up
  1262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1263. */
  1264. ActionManager.OnKeyUpTrigger = 15;
  1265. return ActionManager;
  1266. }(_abstractActionManager__WEBPACK_IMPORTED_MODULE_9__["AbstractActionManager"]));
  1267. /***/ }),
  1268. /***/ "./Actions/condition.ts":
  1269. /*!******************************!*\
  1270. !*** ./Actions/condition.ts ***!
  1271. \******************************/
  1272. /*! exports provided: Condition, ValueCondition, PredicateCondition, StateCondition */
  1273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1274. "use strict";
  1275. __webpack_require__.r(__webpack_exports__);
  1276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return Condition; });
  1277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return ValueCondition; });
  1278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return PredicateCondition; });
  1279. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return StateCondition; });
  1280. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1281. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1282. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1283. /**
  1284. * A Condition applied to an Action
  1285. */
  1286. var Condition = /** @class */ (function () {
  1287. /**
  1288. * Creates a new Condition
  1289. * @param actionManager the manager of the action the condition is applied to
  1290. */
  1291. function Condition(actionManager) {
  1292. this._actionManager = actionManager;
  1293. }
  1294. /**
  1295. * Check if the current condition is valid
  1296. * @returns a boolean
  1297. */
  1298. Condition.prototype.isValid = function () {
  1299. return true;
  1300. };
  1301. /**
  1302. * Internal only
  1303. * @hidden
  1304. */
  1305. Condition.prototype._getProperty = function (propertyPath) {
  1306. return this._actionManager._getProperty(propertyPath);
  1307. };
  1308. /**
  1309. * Internal only
  1310. * @hidden
  1311. */
  1312. Condition.prototype._getEffectiveTarget = function (target, propertyPath) {
  1313. return this._actionManager._getEffectiveTarget(target, propertyPath);
  1314. };
  1315. /**
  1316. * Serialize placeholder for child classes
  1317. * @returns the serialized object
  1318. */
  1319. Condition.prototype.serialize = function () {
  1320. };
  1321. /**
  1322. * Internal only
  1323. * @hidden
  1324. */
  1325. Condition.prototype._serialize = function (serializedCondition) {
  1326. return {
  1327. type: 2,
  1328. children: [],
  1329. name: serializedCondition.name,
  1330. properties: serializedCondition.properties
  1331. };
  1332. };
  1333. return Condition;
  1334. }());
  1335. /**
  1336. * Defines specific conditional operators as extensions of Condition
  1337. */
  1338. var ValueCondition = /** @class */ (function (_super) {
  1339. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ValueCondition, _super);
  1340. /**
  1341. * Creates a new ValueCondition
  1342. * @param actionManager manager for the action the condition applies to
  1343. * @param target for the action
  1344. * @param propertyPath path to specify the property of the target the conditional operator uses
  1345. * @param value the value compared by the conditional operator against the current value of the property
  1346. * @param operator the conditional operator, default ValueCondition.IsEqual
  1347. */
  1348. function ValueCondition(actionManager, target,
  1349. /** path to specify the property of the target the conditional operator uses */
  1350. propertyPath,
  1351. /** the value compared by the conditional operator against the current value of the property */
  1352. value,
  1353. /** the conditional operator, default ValueCondition.IsEqual */
  1354. operator) {
  1355. if (operator === void 0) { operator = ValueCondition.IsEqual; }
  1356. var _this = _super.call(this, actionManager) || this;
  1357. _this.propertyPath = propertyPath;
  1358. _this.value = value;
  1359. _this.operator = operator;
  1360. _this._target = target;
  1361. _this._effectiveTarget = _this._getEffectiveTarget(target, _this.propertyPath);
  1362. _this._property = _this._getProperty(_this.propertyPath);
  1363. return _this;
  1364. }
  1365. Object.defineProperty(ValueCondition, "IsEqual", {
  1366. /**
  1367. * returns the number for IsEqual
  1368. */
  1369. get: function () {
  1370. return ValueCondition._IsEqual;
  1371. },
  1372. enumerable: true,
  1373. configurable: true
  1374. });
  1375. Object.defineProperty(ValueCondition, "IsDifferent", {
  1376. /**
  1377. * Returns the number for IsDifferent
  1378. */
  1379. get: function () {
  1380. return ValueCondition._IsDifferent;
  1381. },
  1382. enumerable: true,
  1383. configurable: true
  1384. });
  1385. Object.defineProperty(ValueCondition, "IsGreater", {
  1386. /**
  1387. * Returns the number for IsGreater
  1388. */
  1389. get: function () {
  1390. return ValueCondition._IsGreater;
  1391. },
  1392. enumerable: true,
  1393. configurable: true
  1394. });
  1395. Object.defineProperty(ValueCondition, "IsLesser", {
  1396. /**
  1397. * Returns the number for IsLesser
  1398. */
  1399. get: function () {
  1400. return ValueCondition._IsLesser;
  1401. },
  1402. enumerable: true,
  1403. configurable: true
  1404. });
  1405. /**
  1406. * Compares the given value with the property value for the specified conditional operator
  1407. * @returns the result of the comparison
  1408. */
  1409. ValueCondition.prototype.isValid = function () {
  1410. switch (this.operator) {
  1411. case ValueCondition.IsGreater:
  1412. return this._effectiveTarget[this._property] > this.value;
  1413. case ValueCondition.IsLesser:
  1414. return this._effectiveTarget[this._property] < this.value;
  1415. case ValueCondition.IsEqual:
  1416. case ValueCondition.IsDifferent:
  1417. var check;
  1418. if (this.value.equals) {
  1419. check = this.value.equals(this._effectiveTarget[this._property]);
  1420. }
  1421. else {
  1422. check = this.value === this._effectiveTarget[this._property];
  1423. }
  1424. return this.operator === ValueCondition.IsEqual ? check : !check;
  1425. }
  1426. return false;
  1427. };
  1428. /**
  1429. * Serialize the ValueCondition into a JSON compatible object
  1430. * @returns serialization object
  1431. */
  1432. ValueCondition.prototype.serialize = function () {
  1433. return this._serialize({
  1434. name: "ValueCondition",
  1435. properties: [
  1436. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1437. { name: "propertyPath", value: this.propertyPath },
  1438. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  1439. { name: "operator", value: ValueCondition.GetOperatorName(this.operator) }
  1440. ]
  1441. });
  1442. };
  1443. /**
  1444. * Gets the name of the conditional operator for the ValueCondition
  1445. * @param operator the conditional operator
  1446. * @returns the name
  1447. */
  1448. ValueCondition.GetOperatorName = function (operator) {
  1449. switch (operator) {
  1450. case ValueCondition._IsEqual: return "IsEqual";
  1451. case ValueCondition._IsDifferent: return "IsDifferent";
  1452. case ValueCondition._IsGreater: return "IsGreater";
  1453. case ValueCondition._IsLesser: return "IsLesser";
  1454. default: return "";
  1455. }
  1456. };
  1457. /**
  1458. * Internal only
  1459. * @hidden
  1460. */
  1461. ValueCondition._IsEqual = 0;
  1462. /**
  1463. * Internal only
  1464. * @hidden
  1465. */
  1466. ValueCondition._IsDifferent = 1;
  1467. /**
  1468. * Internal only
  1469. * @hidden
  1470. */
  1471. ValueCondition._IsGreater = 2;
  1472. /**
  1473. * Internal only
  1474. * @hidden
  1475. */
  1476. ValueCondition._IsLesser = 3;
  1477. return ValueCondition;
  1478. }(Condition));
  1479. /**
  1480. * Defines a predicate condition as an extension of Condition
  1481. */
  1482. var PredicateCondition = /** @class */ (function (_super) {
  1483. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PredicateCondition, _super);
  1484. /**
  1485. * Creates a new PredicateCondition
  1486. * @param actionManager manager for the action the condition applies to
  1487. * @param predicate defines the predicate function used to validate the condition
  1488. */
  1489. function PredicateCondition(actionManager,
  1490. /** defines the predicate function used to validate the condition */
  1491. predicate) {
  1492. var _this = _super.call(this, actionManager) || this;
  1493. _this.predicate = predicate;
  1494. return _this;
  1495. }
  1496. /**
  1497. * @returns the validity of the predicate condition
  1498. */
  1499. PredicateCondition.prototype.isValid = function () {
  1500. return this.predicate();
  1501. };
  1502. return PredicateCondition;
  1503. }(Condition));
  1504. /**
  1505. * Defines a state condition as an extension of Condition
  1506. */
  1507. var StateCondition = /** @class */ (function (_super) {
  1508. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StateCondition, _super);
  1509. /**
  1510. * Creates a new StateCondition
  1511. * @param actionManager manager for the action the condition applies to
  1512. * @param target of the condition
  1513. * @param value to compare with target state
  1514. */
  1515. function StateCondition(actionManager, target,
  1516. /** Value to compare with target state */
  1517. value) {
  1518. var _this = _super.call(this, actionManager) || this;
  1519. _this.value = value;
  1520. _this._target = target;
  1521. return _this;
  1522. }
  1523. /**
  1524. * Gets a boolean indicating if the current condition is met
  1525. * @returns the validity of the state
  1526. */
  1527. StateCondition.prototype.isValid = function () {
  1528. return this._target.state === this.value;
  1529. };
  1530. /**
  1531. * Serialize the StateCondition into a JSON compatible object
  1532. * @returns serialization object
  1533. */
  1534. StateCondition.prototype.serialize = function () {
  1535. return this._serialize({
  1536. name: "StateCondition",
  1537. properties: [
  1538. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1539. { name: "value", value: this.value }
  1540. ]
  1541. });
  1542. };
  1543. return StateCondition;
  1544. }(Condition));
  1545. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.ValueCondition"] = ValueCondition;
  1546. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PredicateCondition"] = PredicateCondition;
  1547. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StateCondition"] = StateCondition;
  1548. /***/ }),
  1549. /***/ "./Actions/directActions.ts":
  1550. /*!**********************************!*\
  1551. !*** ./Actions/directActions.ts ***!
  1552. \**********************************/
  1553. /*! exports provided: SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction */
  1554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1555. "use strict";
  1556. __webpack_require__.r(__webpack_exports__);
  1557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return SwitchBooleanAction; });
  1558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return SetStateAction; });
  1559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return SetValueAction; });
  1560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return IncrementValueAction; });
  1561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return PlayAnimationAction; });
  1562. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return StopAnimationAction; });
  1563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return DoNothingAction; });
  1564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return CombineAction; });
  1565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return ExecuteCodeAction; });
  1566. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return SetParentAction; });
  1567. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1568. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  1569. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  1570. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1571. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  1572. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1573. /**
  1574. * This defines an action responsible to toggle a boolean once triggered.
  1575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1576. */
  1577. var SwitchBooleanAction = /** @class */ (function (_super) {
  1578. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SwitchBooleanAction, _super);
  1579. /**
  1580. * Instantiate the action
  1581. * @param triggerOptions defines the trigger options
  1582. * @param target defines the object containing the boolean
  1583. * @param propertyPath defines the path to the boolean property in the target object
  1584. * @param condition defines the trigger related conditions
  1585. */
  1586. function SwitchBooleanAction(triggerOptions, target, propertyPath, condition) {
  1587. var _this = _super.call(this, triggerOptions, condition) || this;
  1588. _this.propertyPath = propertyPath;
  1589. _this._target = _this._effectiveTarget = target;
  1590. return _this;
  1591. }
  1592. /** @hidden */
  1593. SwitchBooleanAction.prototype._prepare = function () {
  1594. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1595. this._property = this._getProperty(this.propertyPath);
  1596. };
  1597. /**
  1598. * Execute the action toggle the boolean value.
  1599. */
  1600. SwitchBooleanAction.prototype.execute = function () {
  1601. this._effectiveTarget[this._property] = !this._effectiveTarget[this._property];
  1602. };
  1603. /**
  1604. * Serializes the actions and its related information.
  1605. * @param parent defines the object to serialize in
  1606. * @returns the serialized object
  1607. */
  1608. SwitchBooleanAction.prototype.serialize = function (parent) {
  1609. return _super.prototype._serialize.call(this, {
  1610. name: "SwitchBooleanAction",
  1611. properties: [
  1612. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1613. { name: "propertyPath", value: this.propertyPath }
  1614. ]
  1615. }, parent);
  1616. };
  1617. return SwitchBooleanAction;
  1618. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1619. /**
  1620. * This defines an action responsible to set a the state field of the target
  1621. * to a desired value once triggered.
  1622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1623. */
  1624. var SetStateAction = /** @class */ (function (_super) {
  1625. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetStateAction, _super);
  1626. /**
  1627. * Instantiate the action
  1628. * @param triggerOptions defines the trigger options
  1629. * @param target defines the object containing the state property
  1630. * @param value defines the value to store in the state field
  1631. * @param condition defines the trigger related conditions
  1632. */
  1633. function SetStateAction(triggerOptions, target, value, condition) {
  1634. var _this = _super.call(this, triggerOptions, condition) || this;
  1635. _this.value = value;
  1636. _this._target = target;
  1637. return _this;
  1638. }
  1639. /**
  1640. * Execute the action and store the value on the target state property.
  1641. */
  1642. SetStateAction.prototype.execute = function () {
  1643. this._target.state = this.value;
  1644. };
  1645. /**
  1646. * Serializes the actions and its related information.
  1647. * @param parent defines the object to serialize in
  1648. * @returns the serialized object
  1649. */
  1650. SetStateAction.prototype.serialize = function (parent) {
  1651. return _super.prototype._serialize.call(this, {
  1652. name: "SetStateAction",
  1653. properties: [
  1654. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1655. { name: "value", value: this.value }
  1656. ]
  1657. }, parent);
  1658. };
  1659. return SetStateAction;
  1660. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1661. /**
  1662. * This defines an action responsible to set a property of the target
  1663. * to a desired value once triggered.
  1664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1665. */
  1666. var SetValueAction = /** @class */ (function (_super) {
  1667. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetValueAction, _super);
  1668. /**
  1669. * Instantiate the action
  1670. * @param triggerOptions defines the trigger options
  1671. * @param target defines the object containing the property
  1672. * @param propertyPath defines the path of the property to set in the target
  1673. * @param value defines the value to set in the property
  1674. * @param condition defines the trigger related conditions
  1675. */
  1676. function SetValueAction(triggerOptions, target, propertyPath, value, condition) {
  1677. var _this = _super.call(this, triggerOptions, condition) || this;
  1678. _this.propertyPath = propertyPath;
  1679. _this.value = value;
  1680. _this._target = _this._effectiveTarget = target;
  1681. return _this;
  1682. }
  1683. /** @hidden */
  1684. SetValueAction.prototype._prepare = function () {
  1685. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1686. this._property = this._getProperty(this.propertyPath);
  1687. };
  1688. /**
  1689. * Execute the action and set the targetted property to the desired value.
  1690. */
  1691. SetValueAction.prototype.execute = function () {
  1692. this._effectiveTarget[this._property] = this.value;
  1693. if (this._target.markAsDirty) {
  1694. this._target.markAsDirty(this._property);
  1695. }
  1696. };
  1697. /**
  1698. * Serializes the actions and its related information.
  1699. * @param parent defines the object to serialize in
  1700. * @returns the serialized object
  1701. */
  1702. SetValueAction.prototype.serialize = function (parent) {
  1703. return _super.prototype._serialize.call(this, {
  1704. name: "SetValueAction",
  1705. properties: [
  1706. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1707. { name: "propertyPath", value: this.propertyPath },
  1708. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1709. ]
  1710. }, parent);
  1711. };
  1712. return SetValueAction;
  1713. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1714. /**
  1715. * This defines an action responsible to increment the target value
  1716. * to a desired value once triggered.
  1717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1718. */
  1719. var IncrementValueAction = /** @class */ (function (_super) {
  1720. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IncrementValueAction, _super);
  1721. /**
  1722. * Instantiate the action
  1723. * @param triggerOptions defines the trigger options
  1724. * @param target defines the object containing the property
  1725. * @param propertyPath defines the path of the property to increment in the target
  1726. * @param value defines the value value we should increment the property by
  1727. * @param condition defines the trigger related conditions
  1728. */
  1729. function IncrementValueAction(triggerOptions, target, propertyPath, value, condition) {
  1730. var _this = _super.call(this, triggerOptions, condition) || this;
  1731. _this.propertyPath = propertyPath;
  1732. _this.value = value;
  1733. _this._target = _this._effectiveTarget = target;
  1734. return _this;
  1735. }
  1736. /** @hidden */
  1737. IncrementValueAction.prototype._prepare = function () {
  1738. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1739. this._property = this._getProperty(this.propertyPath);
  1740. if (typeof this._effectiveTarget[this._property] !== "number") {
  1741. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Warning: IncrementValueAction can only be used with number values");
  1742. }
  1743. };
  1744. /**
  1745. * Execute the action and increment the target of the value amount.
  1746. */
  1747. IncrementValueAction.prototype.execute = function () {
  1748. this._effectiveTarget[this._property] += this.value;
  1749. if (this._target.markAsDirty) {
  1750. this._target.markAsDirty(this._property);
  1751. }
  1752. };
  1753. /**
  1754. * Serializes the actions and its related information.
  1755. * @param parent defines the object to serialize in
  1756. * @returns the serialized object
  1757. */
  1758. IncrementValueAction.prototype.serialize = function (parent) {
  1759. return _super.prototype._serialize.call(this, {
  1760. name: "IncrementValueAction",
  1761. properties: [
  1762. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1763. { name: "propertyPath", value: this.propertyPath },
  1764. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1765. ]
  1766. }, parent);
  1767. };
  1768. return IncrementValueAction;
  1769. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1770. /**
  1771. * This defines an action responsible to start an animation once triggered.
  1772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1773. */
  1774. var PlayAnimationAction = /** @class */ (function (_super) {
  1775. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlayAnimationAction, _super);
  1776. /**
  1777. * Instantiate the action
  1778. * @param triggerOptions defines the trigger options
  1779. * @param target defines the target animation or animation name
  1780. * @param from defines from where the animation should start (animation frame)
  1781. * @param end defines where the animation should stop (animation frame)
  1782. * @param loop defines if the animation should loop or stop after the first play
  1783. * @param condition defines the trigger related conditions
  1784. */
  1785. function PlayAnimationAction(triggerOptions, target, from, to, loop, condition) {
  1786. var _this = _super.call(this, triggerOptions, condition) || this;
  1787. _this.from = from;
  1788. _this.to = to;
  1789. _this.loop = loop;
  1790. _this._target = target;
  1791. return _this;
  1792. }
  1793. /** @hidden */
  1794. PlayAnimationAction.prototype._prepare = function () {
  1795. };
  1796. /**
  1797. * Execute the action and play the animation.
  1798. */
  1799. PlayAnimationAction.prototype.execute = function () {
  1800. var scene = this._actionManager.getScene();
  1801. scene.beginAnimation(this._target, this.from, this.to, this.loop);
  1802. };
  1803. /**
  1804. * Serializes the actions and its related information.
  1805. * @param parent defines the object to serialize in
  1806. * @returns the serialized object
  1807. */
  1808. PlayAnimationAction.prototype.serialize = function (parent) {
  1809. return _super.prototype._serialize.call(this, {
  1810. name: "PlayAnimationAction",
  1811. properties: [
  1812. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1813. { name: "from", value: String(this.from) },
  1814. { name: "to", value: String(this.to) },
  1815. { name: "loop", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.loop) || false }
  1816. ]
  1817. }, parent);
  1818. };
  1819. return PlayAnimationAction;
  1820. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1821. /**
  1822. * This defines an action responsible to stop an animation once triggered.
  1823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1824. */
  1825. var StopAnimationAction = /** @class */ (function (_super) {
  1826. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopAnimationAction, _super);
  1827. /**
  1828. * Instantiate the action
  1829. * @param triggerOptions defines the trigger options
  1830. * @param target defines the target animation or animation name
  1831. * @param condition defines the trigger related conditions
  1832. */
  1833. function StopAnimationAction(triggerOptions, target, condition) {
  1834. var _this = _super.call(this, triggerOptions, condition) || this;
  1835. _this._target = target;
  1836. return _this;
  1837. }
  1838. /** @hidden */
  1839. StopAnimationAction.prototype._prepare = function () {
  1840. };
  1841. /**
  1842. * Execute the action and stop the animation.
  1843. */
  1844. StopAnimationAction.prototype.execute = function () {
  1845. var scene = this._actionManager.getScene();
  1846. scene.stopAnimation(this._target);
  1847. };
  1848. /**
  1849. * Serializes the actions and its related information.
  1850. * @param parent defines the object to serialize in
  1851. * @returns the serialized object
  1852. */
  1853. StopAnimationAction.prototype.serialize = function (parent) {
  1854. return _super.prototype._serialize.call(this, {
  1855. name: "StopAnimationAction",
  1856. properties: [_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target)]
  1857. }, parent);
  1858. };
  1859. return StopAnimationAction;
  1860. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1861. /**
  1862. * This defines an action responsible that does nothing once triggered.
  1863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1864. */
  1865. var DoNothingAction = /** @class */ (function (_super) {
  1866. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DoNothingAction, _super);
  1867. /**
  1868. * Instantiate the action
  1869. * @param triggerOptions defines the trigger options
  1870. * @param condition defines the trigger related conditions
  1871. */
  1872. function DoNothingAction(triggerOptions, condition) {
  1873. if (triggerOptions === void 0) { triggerOptions = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_NothingTrigger; }
  1874. return _super.call(this, triggerOptions, condition) || this;
  1875. }
  1876. /**
  1877. * Execute the action and do nothing.
  1878. */
  1879. DoNothingAction.prototype.execute = function () {
  1880. };
  1881. /**
  1882. * Serializes the actions and its related information.
  1883. * @param parent defines the object to serialize in
  1884. * @returns the serialized object
  1885. */
  1886. DoNothingAction.prototype.serialize = function (parent) {
  1887. return _super.prototype._serialize.call(this, {
  1888. name: "DoNothingAction",
  1889. properties: []
  1890. }, parent);
  1891. };
  1892. return DoNothingAction;
  1893. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1894. /**
  1895. * This defines an action responsible to trigger several actions once triggered.
  1896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1897. */
  1898. var CombineAction = /** @class */ (function (_super) {
  1899. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CombineAction, _super);
  1900. /**
  1901. * Instantiate the action
  1902. * @param triggerOptions defines the trigger options
  1903. * @param children defines the list of aggregated animations to run
  1904. * @param condition defines the trigger related conditions
  1905. */
  1906. function CombineAction(triggerOptions, children, condition) {
  1907. var _this = _super.call(this, triggerOptions, condition) || this;
  1908. _this.children = children;
  1909. return _this;
  1910. }
  1911. /** @hidden */
  1912. CombineAction.prototype._prepare = function () {
  1913. for (var index = 0; index < this.children.length; index++) {
  1914. this.children[index]._actionManager = this._actionManager;
  1915. this.children[index]._prepare();
  1916. }
  1917. };
  1918. /**
  1919. * Execute the action and executes all the aggregated actions.
  1920. */
  1921. CombineAction.prototype.execute = function (evt) {
  1922. for (var index = 0; index < this.children.length; index++) {
  1923. this.children[index].execute(evt);
  1924. }
  1925. };
  1926. /**
  1927. * Serializes the actions and its related information.
  1928. * @param parent defines the object to serialize in
  1929. * @returns the serialized object
  1930. */
  1931. CombineAction.prototype.serialize = function (parent) {
  1932. var serializationObject = _super.prototype._serialize.call(this, {
  1933. name: "CombineAction",
  1934. properties: [],
  1935. combine: []
  1936. }, parent);
  1937. for (var i = 0; i < this.children.length; i++) {
  1938. serializationObject.combine.push(this.children[i].serialize(null));
  1939. }
  1940. return serializationObject;
  1941. };
  1942. return CombineAction;
  1943. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1944. /**
  1945. * This defines an action responsible to run code (external event) once triggered.
  1946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1947. */
  1948. var ExecuteCodeAction = /** @class */ (function (_super) {
  1949. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExecuteCodeAction, _super);
  1950. /**
  1951. * Instantiate the action
  1952. * @param triggerOptions defines the trigger options
  1953. * @param func defines the callback function to run
  1954. * @param condition defines the trigger related conditions
  1955. */
  1956. function ExecuteCodeAction(triggerOptions, func, condition) {
  1957. var _this = _super.call(this, triggerOptions, condition) || this;
  1958. _this.func = func;
  1959. return _this;
  1960. }
  1961. /**
  1962. * Execute the action and run the attached code.
  1963. */
  1964. ExecuteCodeAction.prototype.execute = function (evt) {
  1965. this.func(evt);
  1966. };
  1967. return ExecuteCodeAction;
  1968. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1969. /**
  1970. * This defines an action responsible to set the parent property of the target once triggered.
  1971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1972. */
  1973. var SetParentAction = /** @class */ (function (_super) {
  1974. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetParentAction, _super);
  1975. /**
  1976. * Instantiate the action
  1977. * @param triggerOptions defines the trigger options
  1978. * @param target defines the target containing the parent property
  1979. * @param parent defines from where the animation should start (animation frame)
  1980. * @param condition defines the trigger related conditions
  1981. */
  1982. function SetParentAction(triggerOptions, target, parent, condition) {
  1983. var _this = _super.call(this, triggerOptions, condition) || this;
  1984. _this._target = target;
  1985. _this._parent = parent;
  1986. return _this;
  1987. }
  1988. /** @hidden */
  1989. SetParentAction.prototype._prepare = function () {
  1990. };
  1991. /**
  1992. * Execute the action and set the parent property.
  1993. */
  1994. SetParentAction.prototype.execute = function () {
  1995. if (this._target.parent === this._parent) {
  1996. return;
  1997. }
  1998. var invertParentWorldMatrix = this._parent.getWorldMatrix().clone();
  1999. invertParentWorldMatrix.invert();
  2000. this._target.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this._target.position, invertParentWorldMatrix);
  2001. this._target.parent = this._parent;
  2002. };
  2003. /**
  2004. * Serializes the actions and its related information.
  2005. * @param parent defines the object to serialize in
  2006. * @returns the serialized object
  2007. */
  2008. SetParentAction.prototype.serialize = function (parent) {
  2009. return _super.prototype._serialize.call(this, {
  2010. name: "SetParentAction",
  2011. properties: [
  2012. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  2013. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._parent),
  2014. ]
  2015. }, parent);
  2016. };
  2017. return SetParentAction;
  2018. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  2019. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2020. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.ExecuteCodeAction"] = ExecuteCodeAction;
  2021. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.DoNothingAction"] = DoNothingAction;
  2022. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.StopAnimationAction"] = StopAnimationAction;
  2023. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PlayAnimationAction"] = PlayAnimationAction;
  2024. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.IncrementValueAction"] = IncrementValueAction;
  2025. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetValueAction"] = SetValueAction;
  2026. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetStateAction"] = SetStateAction;
  2027. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2028. /***/ }),
  2029. /***/ "./Actions/directAudioActions.ts":
  2030. /*!***************************************!*\
  2031. !*** ./Actions/directAudioActions.ts ***!
  2032. \***************************************/
  2033. /*! exports provided: PlaySoundAction, StopSoundAction */
  2034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2035. "use strict";
  2036. __webpack_require__.r(__webpack_exports__);
  2037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return PlaySoundAction; });
  2038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return StopSoundAction; });
  2039. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2040. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2041. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2042. /**
  2043. * This defines an action helpful to play a defined sound on a triggered action.
  2044. */
  2045. var PlaySoundAction = /** @class */ (function (_super) {
  2046. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaySoundAction, _super);
  2047. /**
  2048. * Instantiate the action
  2049. * @param triggerOptions defines the trigger options
  2050. * @param sound defines the sound to play
  2051. * @param condition defines the trigger related conditions
  2052. */
  2053. function PlaySoundAction(triggerOptions, sound, condition) {
  2054. var _this = _super.call(this, triggerOptions, condition) || this;
  2055. _this._sound = sound;
  2056. return _this;
  2057. }
  2058. /** @hidden */
  2059. PlaySoundAction.prototype._prepare = function () {
  2060. };
  2061. /**
  2062. * Execute the action and play the sound.
  2063. */
  2064. PlaySoundAction.prototype.execute = function () {
  2065. if (this._sound !== undefined) {
  2066. this._sound.play();
  2067. }
  2068. };
  2069. /**
  2070. * Serializes the actions and its related information.
  2071. * @param parent defines the object to serialize in
  2072. * @returns the serialized object
  2073. */
  2074. PlaySoundAction.prototype.serialize = function (parent) {
  2075. return _super.prototype._serialize.call(this, {
  2076. name: "PlaySoundAction",
  2077. properties: [{ name: "sound", value: this._sound.name }]
  2078. }, parent);
  2079. };
  2080. return PlaySoundAction;
  2081. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2082. /**
  2083. * This defines an action helpful to stop a defined sound on a triggered action.
  2084. */
  2085. var StopSoundAction = /** @class */ (function (_super) {
  2086. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopSoundAction, _super);
  2087. /**
  2088. * Instantiate the action
  2089. * @param triggerOptions defines the trigger options
  2090. * @param sound defines the sound to stop
  2091. * @param condition defines the trigger related conditions
  2092. */
  2093. function StopSoundAction(triggerOptions, sound, condition) {
  2094. var _this = _super.call(this, triggerOptions, condition) || this;
  2095. _this._sound = sound;
  2096. return _this;
  2097. }
  2098. /** @hidden */
  2099. StopSoundAction.prototype._prepare = function () {
  2100. };
  2101. /**
  2102. * Execute the action and stop the sound.
  2103. */
  2104. StopSoundAction.prototype.execute = function () {
  2105. if (this._sound !== undefined) {
  2106. this._sound.stop();
  2107. }
  2108. };
  2109. /**
  2110. * Serializes the actions and its related information.
  2111. * @param parent defines the object to serialize in
  2112. * @returns the serialized object
  2113. */
  2114. StopSoundAction.prototype.serialize = function (parent) {
  2115. return _super.prototype._serialize.call(this, {
  2116. name: "StopSoundAction",
  2117. properties: [{ name: "sound", value: this._sound.name }]
  2118. }, parent);
  2119. };
  2120. return StopSoundAction;
  2121. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2122. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PlaySoundAction"] = StopSoundAction;
  2123. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StopSoundAction"] = StopSoundAction;
  2124. /***/ }),
  2125. /***/ "./Actions/index.ts":
  2126. /*!**************************!*\
  2127. !*** ./Actions/index.ts ***!
  2128. \**************************/
  2129. /*! exports provided: Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction */
  2130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2131. "use strict";
  2132. __webpack_require__.r(__webpack_exports__);
  2133. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _action__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  2135. /* harmony import */ var _actionEvent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actionEvent */ "./Actions/actionEvent.ts");
  2136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _actionEvent__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  2137. /* harmony import */ var _actionManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actionManager */ "./Actions/actionManager.ts");
  2138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _actionManager__WEBPACK_IMPORTED_MODULE_2__["ActionManager"]; });
  2139. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  2140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["Condition"]; });
  2141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["ValueCondition"]; });
  2142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["PredicateCondition"]; });
  2143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["StateCondition"]; });
  2144. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  2145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SwitchBooleanAction"]; });
  2146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetStateAction"]; });
  2147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetValueAction"]; });
  2148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["IncrementValueAction"]; });
  2149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["PlayAnimationAction"]; });
  2150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["StopAnimationAction"]; });
  2151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"]; });
  2152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["CombineAction"]; });
  2153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["ExecuteCodeAction"]; });
  2154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetParentAction"]; });
  2155. /* harmony import */ var _directAudioActions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./directAudioActions */ "./Actions/directAudioActions.ts");
  2156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["PlaySoundAction"]; });
  2157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["StopSoundAction"]; });
  2158. /* harmony import */ var _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./interpolateValueAction */ "./Actions/interpolateValueAction.ts");
  2159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__["InterpolateValueAction"]; });
  2160. /***/ }),
  2161. /***/ "./Actions/interpolateValueAction.ts":
  2162. /*!*******************************************!*\
  2163. !*** ./Actions/interpolateValueAction.ts ***!
  2164. \*******************************************/
  2165. /*! exports provided: InterpolateValueAction */
  2166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2167. "use strict";
  2168. __webpack_require__.r(__webpack_exports__);
  2169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return InterpolateValueAction; });
  2170. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2171. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2172. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  2173. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2174. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2175. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  2176. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2177. /**
  2178. * This defines an action responsible to change the value of a property
  2179. * by interpolating between its current value and the newly set one once triggered.
  2180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2181. */
  2182. var InterpolateValueAction = /** @class */ (function (_super) {
  2183. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InterpolateValueAction, _super);
  2184. /**
  2185. * Instantiate the action
  2186. * @param triggerOptions defines the trigger options
  2187. * @param target defines the object containing the value to interpolate
  2188. * @param propertyPath defines the path to the property in the target object
  2189. * @param value defines the target value at the end of the interpolation
  2190. * @param duration deines the time it will take for the property to interpolate to the value.
  2191. * @param condition defines the trigger related conditions
  2192. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  2193. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  2194. */
  2195. function InterpolateValueAction(triggerOptions, target, propertyPath, value, duration, condition, stopOtherAnimations, onInterpolationDone) {
  2196. if (duration === void 0) { duration = 1000; }
  2197. var _this = _super.call(this, triggerOptions, condition) || this;
  2198. /**
  2199. * Defines the time it will take for the property to interpolate to the value.
  2200. */
  2201. _this.duration = 1000;
  2202. /**
  2203. * Observable triggered once the interpolation animation has been done.
  2204. */
  2205. _this.onInterpolationDoneObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  2206. _this.propertyPath = propertyPath;
  2207. _this.value = value;
  2208. _this.duration = duration;
  2209. _this.stopOtherAnimations = stopOtherAnimations;
  2210. _this.onInterpolationDone = onInterpolationDone;
  2211. _this._target = _this._effectiveTarget = target;
  2212. return _this;
  2213. }
  2214. /** @hidden */
  2215. InterpolateValueAction.prototype._prepare = function () {
  2216. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  2217. this._property = this._getProperty(this.propertyPath);
  2218. };
  2219. /**
  2220. * Execute the action starts the value interpolation.
  2221. */
  2222. InterpolateValueAction.prototype.execute = function () {
  2223. var _this = this;
  2224. var scene = this._actionManager.getScene();
  2225. var keys = [
  2226. {
  2227. frame: 0,
  2228. value: this._effectiveTarget[this._property]
  2229. }, {
  2230. frame: 100,
  2231. value: this.value
  2232. }
  2233. ];
  2234. var dataType;
  2235. if (typeof this.value === "number") {
  2236. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT;
  2237. }
  2238. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"]) {
  2239. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_COLOR3;
  2240. }
  2241. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"]) {
  2242. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3;
  2243. }
  2244. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]) {
  2245. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_MATRIX;
  2246. }
  2247. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]) {
  2248. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_QUATERNION;
  2249. }
  2250. else {
  2251. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
  2252. return;
  2253. }
  2254. var animation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"]("InterpolateValueAction", this._property, 100 * (1000.0 / this.duration), dataType, _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  2255. animation.setKeys(keys);
  2256. if (this.stopOtherAnimations) {
  2257. scene.stopAnimation(this._effectiveTarget);
  2258. }
  2259. var wrapper = function () {
  2260. _this.onInterpolationDoneObservable.notifyObservers(_this);
  2261. if (_this.onInterpolationDone) {
  2262. _this.onInterpolationDone();
  2263. }
  2264. };
  2265. scene.beginDirectAnimation(this._effectiveTarget, [animation], 0, 100, false, 1, wrapper);
  2266. };
  2267. /**
  2268. * Serializes the actions and its related information.
  2269. * @param parent defines the object to serialize in
  2270. * @returns the serialized object
  2271. */
  2272. InterpolateValueAction.prototype.serialize = function (parent) {
  2273. return _super.prototype._serialize.call(this, {
  2274. name: "InterpolateValueAction",
  2275. properties: [
  2276. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  2277. { name: "propertyPath", value: this.propertyPath },
  2278. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  2279. { name: "duration", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.duration) },
  2280. { name: "stopOtherAnimations", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.stopOtherAnimations) || false }
  2281. ]
  2282. }, parent);
  2283. };
  2284. return InterpolateValueAction;
  2285. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2286. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__["_TypeStore"].RegisteredTypes["BABYLON.InterpolateValueAction"] = InterpolateValueAction;
  2287. /***/ }),
  2288. /***/ "./Animations/animatable.ts":
  2289. /*!**********************************!*\
  2290. !*** ./Animations/animatable.ts ***!
  2291. \**********************************/
  2292. /*! exports provided: Animatable */
  2293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2294. "use strict";
  2295. __webpack_require__.r(__webpack_exports__);
  2296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return Animatable; });
  2297. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  2298. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  2299. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2300. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  2301. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2302. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/precisionDate */ "./Misc/precisionDate.ts");
  2303. /* harmony import */ var _Bones_bone__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Bones/bone */ "./Bones/bone.ts");
  2304. /**
  2305. * Class used to store an actual running animation
  2306. */
  2307. var Animatable = /** @class */ (function () {
  2308. /**
  2309. * Creates a new Animatable
  2310. * @param scene defines the hosting scene
  2311. * @param target defines the target object
  2312. * @param fromFrame defines the starting frame number (default is 0)
  2313. * @param toFrame defines the ending frame number (default is 100)
  2314. * @param loopAnimation defines if the animation must loop (default is false)
  2315. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2316. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2317. * @param animations defines a group of animation to add to the new Animatable
  2318. * @param onAnimationLoop defines a callback to call when animation loops
  2319. */
  2320. function Animatable(scene,
  2321. /** defines the target object */
  2322. target,
  2323. /** defines the starting frame number (default is 0) */
  2324. fromFrame,
  2325. /** defines the ending frame number (default is 100) */
  2326. toFrame,
  2327. /** defines if the animation must loop (default is false) */
  2328. loopAnimation, speedRatio,
  2329. /** defines a callback to call when animation ends if it is not looping */
  2330. onAnimationEnd, animations,
  2331. /** defines a callback to call when animation loops */
  2332. onAnimationLoop) {
  2333. if (fromFrame === void 0) { fromFrame = 0; }
  2334. if (toFrame === void 0) { toFrame = 100; }
  2335. if (loopAnimation === void 0) { loopAnimation = false; }
  2336. if (speedRatio === void 0) { speedRatio = 1.0; }
  2337. this.target = target;
  2338. this.fromFrame = fromFrame;
  2339. this.toFrame = toFrame;
  2340. this.loopAnimation = loopAnimation;
  2341. this.onAnimationEnd = onAnimationEnd;
  2342. this.onAnimationLoop = onAnimationLoop;
  2343. this._localDelayOffset = null;
  2344. this._pausedDelay = null;
  2345. this._runtimeAnimations = new Array();
  2346. this._paused = false;
  2347. this._speedRatio = 1;
  2348. this._weight = -1.0;
  2349. /**
  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 = this.speedRatio !== 0 ? adjustTime * 1000 / (fps * this.speedRatio) : 0;
  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._noBlendingProcessor = function (currentValue) {
  5129. _this._currentValue = currentValue;
  5130. };
  5131. this._blendingProcessor = function (currentValue, target) {
  5132. if (_this._blendingFactor <= 1.0) {
  5133. if (!_this._originalBlendValue) {
  5134. var originalValue = _this._currentActiveTarget[_this._targetPath];
  5135. if (originalValue.clone) {
  5136. _this._originalBlendValue = originalValue.clone();
  5137. }
  5138. else {
  5139. _this._originalBlendValue = originalValue;
  5140. }
  5141. }
  5142. if (_this._originalBlendValue.m) { // Matrix
  5143. if (_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].AllowMatrixDecomposeForInterpolation) {
  5144. if (_this._currentValue) {
  5145. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(_this._originalBlendValue, currentValue, _this._blendingFactor, _this._currentValue);
  5146. }
  5147. else {
  5148. _this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(_this._originalBlendValue, currentValue, _this._blendingFactor);
  5149. }
  5150. }
  5151. else {
  5152. if (_this._currentValue) {
  5153. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(_this._originalBlendValue, currentValue, _this._blendingFactor, _this._currentValue);
  5154. }
  5155. else {
  5156. _this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(_this._originalBlendValue, currentValue, _this._blendingFactor);
  5157. }
  5158. }
  5159. }
  5160. else {
  5161. _this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]._UniversalLerp(_this._originalBlendValue, currentValue, _this._blendingFactor);
  5162. }
  5163. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : _this._animation.blendingSpeed;
  5164. _this._blendingFactor += blendingSpeed;
  5165. }
  5166. else {
  5167. _this._currentValue = currentValue;
  5168. }
  5169. };
  5170. this._animation = animation;
  5171. this._target = target;
  5172. this._scene = scene;
  5173. this._host = host;
  5174. this._activeTargets = [];
  5175. animation._runtimeAnimations.push(this);
  5176. // Check data
  5177. if (this._target instanceof Array) {
  5178. var index = 0;
  5179. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5180. var target_1 = _a[_i];
  5181. this._preparePath(target_1, index);
  5182. this._getOriginalValues(index);
  5183. index++;
  5184. }
  5185. }
  5186. else {
  5187. this._preparePath(this._target);
  5188. this._getOriginalValues();
  5189. }
  5190. // Cloning events locally
  5191. var events = animation.getEvents();
  5192. if (events && events.length > 0) {
  5193. events.forEach(function (e) {
  5194. _this._events.push(e._clone());
  5195. });
  5196. }
  5197. this._correctLoopMode = this._getCorrectLoopMode();
  5198. this._enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  5199. if (this._enableBlending) {
  5200. this._activeBlendingProcessor = this._blendingProcessor;
  5201. }
  5202. else {
  5203. this._activeBlendingProcessor = this._noBlendingProcessor;
  5204. }
  5205. }
  5206. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  5207. /**
  5208. * Gets the current frame of the runtime animation
  5209. */
  5210. get: function () {
  5211. return this._currentFrame;
  5212. },
  5213. enumerable: true,
  5214. configurable: true
  5215. });
  5216. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  5217. /**
  5218. * Gets the weight of the runtime animation
  5219. */
  5220. get: function () {
  5221. return this._weight;
  5222. },
  5223. enumerable: true,
  5224. configurable: true
  5225. });
  5226. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  5227. /**
  5228. * Gets the current value of the runtime animation
  5229. */
  5230. get: function () {
  5231. return this._currentValue;
  5232. },
  5233. enumerable: true,
  5234. configurable: true
  5235. });
  5236. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  5237. /**
  5238. * Gets the target path of the runtime animation
  5239. */
  5240. get: function () {
  5241. return this._targetPath;
  5242. },
  5243. enumerable: true,
  5244. configurable: true
  5245. });
  5246. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  5247. /**
  5248. * Gets the actual target of the runtime animation
  5249. */
  5250. get: function () {
  5251. return this._currentActiveTarget;
  5252. },
  5253. enumerable: true,
  5254. configurable: true
  5255. });
  5256. RuntimeAnimation.prototype._preparePath = function (target, targetIndex) {
  5257. if (targetIndex === void 0) { targetIndex = 0; }
  5258. var targetPropertyPath = this._animation.targetPropertyPath;
  5259. if (targetPropertyPath.length > 1) {
  5260. var property = target[targetPropertyPath[0]];
  5261. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  5262. property = property[targetPropertyPath[index]];
  5263. }
  5264. this._targetPath = targetPropertyPath[targetPropertyPath.length - 1];
  5265. this._activeTargets[targetIndex] = property;
  5266. }
  5267. else {
  5268. this._targetPath = targetPropertyPath[0];
  5269. this._activeTargets[targetIndex] = target;
  5270. }
  5271. };
  5272. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  5273. /**
  5274. * Gets the animation from the runtime animation
  5275. */
  5276. get: function () {
  5277. return this._animation;
  5278. },
  5279. enumerable: true,
  5280. configurable: true
  5281. });
  5282. /**
  5283. * Resets the runtime animation to the beginning
  5284. * @param restoreOriginal defines whether to restore the target property to the original value
  5285. */
  5286. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  5287. if (restoreOriginal === void 0) { restoreOriginal = false; }
  5288. if (restoreOriginal) {
  5289. if (this._target instanceof Array) {
  5290. var index = 0;
  5291. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5292. var target = _a[_i];
  5293. if (this._originalValue[index] !== undefined) {
  5294. this._setValue(target, this._originalValue[index], -1);
  5295. }
  5296. index++;
  5297. }
  5298. }
  5299. else {
  5300. if (this._originalValue[0] !== undefined) {
  5301. this._setValue(this._target, this._originalValue[0], -1);
  5302. }
  5303. }
  5304. }
  5305. this._offsetsCache = {};
  5306. this._highLimitsCache = {};
  5307. this._currentFrame = 0;
  5308. this._blendingFactor = 0;
  5309. this._originalValue = new Array();
  5310. // Events
  5311. for (var index = 0; index < this._events.length; index++) {
  5312. this._events[index].isDone = false;
  5313. }
  5314. };
  5315. /**
  5316. * Specifies if the runtime animation is stopped
  5317. * @returns Boolean specifying if the runtime animation is stopped
  5318. */
  5319. RuntimeAnimation.prototype.isStopped = function () {
  5320. return this._stopped;
  5321. };
  5322. /**
  5323. * Disposes of the runtime animation
  5324. */
  5325. RuntimeAnimation.prototype.dispose = function () {
  5326. var index = this._animation.runtimeAnimations.indexOf(this);
  5327. if (index > -1) {
  5328. this._animation.runtimeAnimations.splice(index, 1);
  5329. }
  5330. };
  5331. /**
  5332. * Interpolates the animation from the current frame
  5333. * @param currentFrame The frame to interpolate the animation to
  5334. * @param repeatCount The number of times that the animation should loop
  5335. * @param loopMode The type of looping mode to use
  5336. * @param offsetValue Animation offset value
  5337. * @param highLimitValue The high limit value
  5338. * @returns The interpolated value
  5339. */
  5340. RuntimeAnimation.prototype._interpolate = function (currentFrame, repeatCount, loopMode, offsetValue, highLimitValue) {
  5341. this._currentFrame = currentFrame;
  5342. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX && !this._workValue) {
  5343. this._workValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  5344. }
  5345. return this._animation._interpolate(currentFrame, repeatCount, this._workValue, loopMode, offsetValue, highLimitValue);
  5346. };
  5347. /**
  5348. * Apply the interpolated value to the target
  5349. * @param currentValue defines the value computed by the animation
  5350. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5351. */
  5352. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  5353. if (weight === void 0) { weight = 1.0; }
  5354. if (this._target instanceof Array) {
  5355. var index = 0;
  5356. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5357. var target = _a[_i];
  5358. this._setValue(target, currentValue, weight, index);
  5359. index++;
  5360. }
  5361. }
  5362. else {
  5363. this._setValue(this._target, currentValue, weight);
  5364. }
  5365. };
  5366. RuntimeAnimation.prototype._getOriginalValues = function (targetIndex) {
  5367. if (targetIndex === void 0) { targetIndex = 0; }
  5368. var originalValue;
  5369. var target = this._activeTargets[targetIndex];
  5370. if (target.getRestPose && this._targetPath === "_matrix") { // For bones
  5371. originalValue = target.getRestPose();
  5372. }
  5373. else {
  5374. originalValue = target[this._targetPath];
  5375. }
  5376. if (originalValue && originalValue.clone) {
  5377. this._originalValue[targetIndex] = originalValue.clone();
  5378. }
  5379. else {
  5380. this._originalValue[targetIndex] = originalValue;
  5381. }
  5382. };
  5383. RuntimeAnimation.prototype._setValue = function (target, currentValue, weight, targetIndex) {
  5384. if (targetIndex === void 0) { targetIndex = 0; }
  5385. // Set value
  5386. var path = this._targetPath;
  5387. var destination = this._activeTargets[targetIndex];
  5388. this._currentActiveTarget = destination;
  5389. this._weight = weight;
  5390. this._activeBlendingProcessor(currentValue, target);
  5391. if (weight !== -1.0) {
  5392. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5393. }
  5394. else {
  5395. destination[path] = this._currentValue;
  5396. }
  5397. if (target.markAsDirty) {
  5398. target.markAsDirty(this._animation.targetProperty);
  5399. }
  5400. };
  5401. /**
  5402. * Gets the loop pmode of the runtime animation
  5403. * @returns Loop Mode
  5404. */
  5405. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5406. if (this._target && this._target.animationPropertiesOverride) {
  5407. return this._target.animationPropertiesOverride.loopMode;
  5408. }
  5409. return this._animation.loopMode;
  5410. };
  5411. /**
  5412. * Move the current animation to a given frame
  5413. * @param frame defines the frame to move to
  5414. */
  5415. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5416. var keys = this._animation.getKeys();
  5417. if (frame < keys[0].frame) {
  5418. frame = keys[0].frame;
  5419. }
  5420. else if (frame > keys[keys.length - 1].frame) {
  5421. frame = keys[keys.length - 1].frame;
  5422. }
  5423. var currentValue = this._interpolate(frame, 0, this._correctLoopMode);
  5424. this.setValue(currentValue, -1);
  5425. };
  5426. /**
  5427. * @hidden Internal use only
  5428. */
  5429. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5430. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5431. this._ratioOffset = this._previousRatio - newRatio;
  5432. };
  5433. /**
  5434. * Execute the current animation
  5435. * @param delay defines the delay to add to the current frame
  5436. * @param from defines the lower bound of the animation range
  5437. * @param to defines the upper bound of the animation range
  5438. * @param loop defines if the current animation must loop
  5439. * @param speedRatio defines the current speed ratio
  5440. * @param weight defines the weight of the animation (default is -1 so no weight)
  5441. * @param onLoop optional callback called when animation loops
  5442. * @returns a boolean indicating if the animation is running
  5443. */
  5444. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight, onLoop) {
  5445. if (weight === void 0) { weight = -1.0; }
  5446. var targetPropertyPath = this._animation.targetPropertyPath;
  5447. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5448. this._stopped = true;
  5449. return false;
  5450. }
  5451. var returnValue = true;
  5452. var keys = this._animation.getKeys();
  5453. var min = keys[0].frame;
  5454. var max = keys[keys.length - 1].frame;
  5455. // Add a start key at frame 0 if missing
  5456. if (min !== 0) {
  5457. var newKey = { frame: 0, value: keys[0].value };
  5458. keys.splice(0, 0, newKey);
  5459. }
  5460. // Check limits
  5461. if (from < min || from > max) {
  5462. from = min;
  5463. }
  5464. if (to < min || to > max) {
  5465. to = max;
  5466. }
  5467. var range = to - from;
  5468. var offsetValue;
  5469. // Compute ratio which represents the frame delta between from and to
  5470. var ratio = (delay * (this._animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5471. var highLimitValue = 0;
  5472. this._previousDelay = delay;
  5473. this._previousRatio = ratio;
  5474. if ((to > from && ratio >= range) && !loop) { // If we are out of range and not looping get back to caller
  5475. returnValue = false;
  5476. highLimitValue = this._animation._getKeyValue(keys[keys.length - 1].value);
  5477. }
  5478. else if ((from > to && ratio <= range) && !loop) {
  5479. returnValue = false;
  5480. highLimitValue = this._animation._getKeyValue(keys[0].value);
  5481. }
  5482. else {
  5483. // Get max value if required
  5484. if (this._correctLoopMode !== _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5485. var keyOffset = to.toString() + from.toString();
  5486. if (!this._offsetsCache[keyOffset]) {
  5487. var fromValue = this._interpolate(from, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5488. var toValue = this._interpolate(to, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5489. switch (this._animation.dataType) {
  5490. // Float
  5491. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5492. this._offsetsCache[keyOffset] = toValue - fromValue;
  5493. break;
  5494. // Quaternion
  5495. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5496. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5497. break;
  5498. // Vector3
  5499. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5500. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5501. // Vector2
  5502. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5503. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5504. // Size
  5505. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5506. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5507. // Color3
  5508. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5509. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5510. default:
  5511. break;
  5512. }
  5513. this._highLimitsCache[keyOffset] = toValue;
  5514. }
  5515. highLimitValue = this._highLimitsCache[keyOffset];
  5516. offsetValue = this._offsetsCache[keyOffset];
  5517. }
  5518. }
  5519. if (offsetValue === undefined) {
  5520. switch (this._animation.dataType) {
  5521. // Float
  5522. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5523. offsetValue = 0;
  5524. break;
  5525. // Quaternion
  5526. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5527. offsetValue = _staticOffsetValueQuaternion;
  5528. break;
  5529. // Vector3
  5530. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5531. offsetValue = _staticOffsetValueVector3;
  5532. break;
  5533. // Vector2
  5534. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5535. offsetValue = _staticOffsetValueVector2;
  5536. break;
  5537. // Size
  5538. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5539. offsetValue = _staticOffsetValueSize;
  5540. break;
  5541. // Color3
  5542. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5543. offsetValue = _staticOffsetValueColor3;
  5544. }
  5545. }
  5546. // Compute value
  5547. var currentFrame = (returnValue && range !== 0) ? from + ratio % range : to;
  5548. // Need to normalize?
  5549. if (this._host && this._host.syncRoot) {
  5550. var syncRoot = this._host.syncRoot;
  5551. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5552. currentFrame = from + (to - from) * hostNormalizedFrame;
  5553. }
  5554. // Reset events if looping
  5555. var events = this._events;
  5556. if (range > 0 && this.currentFrame > currentFrame ||
  5557. range < 0 && this.currentFrame < currentFrame) {
  5558. if (onLoop) {
  5559. onLoop();
  5560. }
  5561. // Need to reset animation events
  5562. for (var index = 0; index < events.length; index++) {
  5563. if (!events[index].onlyOnce) {
  5564. // reset event, the animation is looping
  5565. events[index].isDone = false;
  5566. }
  5567. }
  5568. }
  5569. var repeatCount = range === 0 ? 0 : (ratio / range) >> 0;
  5570. var currentValue = this._interpolate(currentFrame, repeatCount, this._correctLoopMode, offsetValue, highLimitValue);
  5571. // Set value
  5572. this.setValue(currentValue, weight);
  5573. // Check events
  5574. for (var index = 0; index < events.length; index++) {
  5575. // Make sure current frame has passed event frame and that event frame is within the current range
  5576. // Also, handle both forward and reverse animations
  5577. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5578. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5579. var event = events[index];
  5580. if (!event.isDone) {
  5581. // If event should be done only once, remove it.
  5582. if (event.onlyOnce) {
  5583. events.splice(index, 1);
  5584. index--;
  5585. }
  5586. event.isDone = true;
  5587. event.action(currentFrame);
  5588. } // Don't do anything if the event has already be done.
  5589. }
  5590. }
  5591. if (!returnValue) {
  5592. this._stopped = true;
  5593. }
  5594. return returnValue;
  5595. };
  5596. return RuntimeAnimation;
  5597. }());
  5598. /***/ }),
  5599. /***/ "./Audio/analyser.ts":
  5600. /*!***************************!*\
  5601. !*** ./Audio/analyser.ts ***!
  5602. \***************************/
  5603. /*! exports provided: Analyser */
  5604. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5605. "use strict";
  5606. __webpack_require__.r(__webpack_exports__);
  5607. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5608. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5609. /**
  5610. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5612. */
  5613. var Analyser = /** @class */ (function () {
  5614. /**
  5615. * Creates a new analyser
  5616. * @param scene defines hosting scene
  5617. */
  5618. function Analyser(scene) {
  5619. /**
  5620. * Gets or sets the smoothing
  5621. * @ignorenaming
  5622. */
  5623. this.SMOOTHING = 0.75;
  5624. /**
  5625. * Gets or sets the FFT table size
  5626. * @ignorenaming
  5627. */
  5628. this.FFT_SIZE = 512;
  5629. /**
  5630. * Gets or sets the bar graph amplitude
  5631. * @ignorenaming
  5632. */
  5633. this.BARGRAPHAMPLITUDE = 256;
  5634. /**
  5635. * Gets or sets the position of the debug canvas
  5636. * @ignorenaming
  5637. */
  5638. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5639. /**
  5640. * Gets or sets the debug canvas size
  5641. * @ignorenaming
  5642. */
  5643. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5644. this._scene = scene;
  5645. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5646. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5647. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5648. this._webAudioAnalyser.minDecibels = -140;
  5649. this._webAudioAnalyser.maxDecibels = 0;
  5650. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5651. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5652. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5653. }
  5654. }
  5655. /**
  5656. * Get the number of data values you will have to play with for the visualization
  5657. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5658. * @returns a number
  5659. */
  5660. Analyser.prototype.getFrequencyBinCount = function () {
  5661. if (this._audioEngine.canUseWebAudio) {
  5662. return this._webAudioAnalyser.frequencyBinCount;
  5663. }
  5664. else {
  5665. return 0;
  5666. }
  5667. };
  5668. /**
  5669. * Gets the current frequency data as a byte array
  5670. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5671. * @returns a Uint8Array
  5672. */
  5673. Analyser.prototype.getByteFrequencyData = function () {
  5674. if (this._audioEngine.canUseWebAudio) {
  5675. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5676. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5677. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5678. }
  5679. return this._byteFreqs;
  5680. };
  5681. /**
  5682. * Gets the current waveform as a byte array
  5683. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5684. * @returns a Uint8Array
  5685. */
  5686. Analyser.prototype.getByteTimeDomainData = function () {
  5687. if (this._audioEngine.canUseWebAudio) {
  5688. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5689. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5690. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5691. }
  5692. return this._byteTime;
  5693. };
  5694. /**
  5695. * Gets the current frequency data as a float array
  5696. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5697. * @returns a Float32Array
  5698. */
  5699. Analyser.prototype.getFloatFrequencyData = function () {
  5700. if (this._audioEngine.canUseWebAudio) {
  5701. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5702. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5703. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5704. }
  5705. return this._floatFreqs;
  5706. };
  5707. /**
  5708. * Renders the debug canvas
  5709. */
  5710. Analyser.prototype.drawDebugCanvas = function () {
  5711. var _this = this;
  5712. if (this._audioEngine.canUseWebAudio) {
  5713. if (!this._debugCanvas) {
  5714. this._debugCanvas = document.createElement("canvas");
  5715. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5716. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5717. this._debugCanvas.style.position = "absolute";
  5718. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5719. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5720. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5721. document.body.appendChild(this._debugCanvas);
  5722. this._registerFunc = function () {
  5723. _this.drawDebugCanvas();
  5724. };
  5725. this._scene.registerBeforeRender(this._registerFunc);
  5726. }
  5727. if (this._registerFunc && this._debugCanvasContext) {
  5728. var workingArray = this.getByteFrequencyData();
  5729. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5730. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5731. // Draw the frequency domain chart.
  5732. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5733. var value = workingArray[i];
  5734. var percent = value / this.BARGRAPHAMPLITUDE;
  5735. var height = this.DEBUGCANVASSIZE.height * percent;
  5736. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5737. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5738. var hue = i / this.getFrequencyBinCount() * 360;
  5739. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5740. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5741. }
  5742. }
  5743. }
  5744. };
  5745. /**
  5746. * Stops rendering the debug canvas and removes it
  5747. */
  5748. Analyser.prototype.stopDebugCanvas = function () {
  5749. if (this._debugCanvas) {
  5750. if (this._registerFunc) {
  5751. this._scene.unregisterBeforeRender(this._registerFunc);
  5752. this._registerFunc = null;
  5753. }
  5754. document.body.removeChild(this._debugCanvas);
  5755. this._debugCanvas = null;
  5756. this._debugCanvasContext = null;
  5757. }
  5758. };
  5759. /**
  5760. * Connects two audio nodes
  5761. * @param inputAudioNode defines first node to connect
  5762. * @param outputAudioNode defines second node to connect
  5763. */
  5764. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5765. if (this._audioEngine.canUseWebAudio) {
  5766. inputAudioNode.connect(this._webAudioAnalyser);
  5767. this._webAudioAnalyser.connect(outputAudioNode);
  5768. }
  5769. };
  5770. /**
  5771. * Releases all associated resources
  5772. */
  5773. Analyser.prototype.dispose = function () {
  5774. if (this._audioEngine.canUseWebAudio) {
  5775. this._webAudioAnalyser.disconnect();
  5776. }
  5777. };
  5778. return Analyser;
  5779. }());
  5780. /***/ }),
  5781. /***/ "./Audio/audioEngine.ts":
  5782. /*!******************************!*\
  5783. !*** ./Audio/audioEngine.ts ***!
  5784. \******************************/
  5785. /*! exports provided: AudioEngine */
  5786. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5787. "use strict";
  5788. __webpack_require__.r(__webpack_exports__);
  5789. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5790. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5791. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5792. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5793. // Sets the default audio engine to Babylon.js
  5794. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5795. /**
  5796. * This represents the default audio engine used in babylon.
  5797. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5798. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5799. */
  5800. var AudioEngine = /** @class */ (function () {
  5801. /**
  5802. * Instantiates a new audio engine.
  5803. *
  5804. * There should be only one per page as some browsers restrict the number
  5805. * of audio contexts you can create.
  5806. * @param hostElement defines the host element where to display the mute icon if necessary
  5807. */
  5808. function AudioEngine(hostElement) {
  5809. if (hostElement === void 0) { hostElement = null; }
  5810. var _this = this;
  5811. this._audioContext = null;
  5812. this._audioContextInitialized = false;
  5813. this._muteButton = null;
  5814. /**
  5815. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5816. */
  5817. this.canUseWebAudio = false;
  5818. /**
  5819. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5820. * @ignoreNaming
  5821. */
  5822. this.WarnedWebAudioUnsupported = false;
  5823. /**
  5824. * Gets whether or not mp3 are supported by your browser.
  5825. */
  5826. this.isMP3supported = false;
  5827. /**
  5828. * Gets whether or not ogg are supported by your browser.
  5829. */
  5830. this.isOGGsupported = false;
  5831. /**
  5832. * Gets whether audio has been unlocked on the device.
  5833. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5834. * a user interaction has happened.
  5835. */
  5836. this.unlocked = true;
  5837. /**
  5838. * Defines if the audio engine relies on a custom unlocked button.
  5839. * In this case, the embedded button will not be displayed.
  5840. */
  5841. this.useCustomUnlockedButton = false;
  5842. /**
  5843. * Event raised when audio has been unlocked on the browser.
  5844. */
  5845. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5846. /**
  5847. * Event raised when audio has been locked on the browser.
  5848. */
  5849. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5850. this._tryToRun = false;
  5851. this._onResize = function () {
  5852. _this._moveButtonToTopLeft();
  5853. };
  5854. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5855. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5856. this.canUseWebAudio = true;
  5857. }
  5858. var audioElem = document.createElement('audio');
  5859. this._hostElement = hostElement;
  5860. try {
  5861. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5862. this.isMP3supported = true;
  5863. }
  5864. }
  5865. catch (e) {
  5866. // protect error during capability check.
  5867. }
  5868. try {
  5869. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5870. this.isOGGsupported = true;
  5871. }
  5872. }
  5873. catch (e) {
  5874. // protect error during capability check.
  5875. }
  5876. }
  5877. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5878. /**
  5879. * Gets the current AudioContext if available.
  5880. */
  5881. get: function () {
  5882. if (!this._audioContextInitialized) {
  5883. this._initializeAudioContext();
  5884. }
  5885. else {
  5886. if (!this.unlocked && !this._muteButton) {
  5887. this._displayMuteButton();
  5888. }
  5889. }
  5890. return this._audioContext;
  5891. },
  5892. enumerable: true,
  5893. configurable: true
  5894. });
  5895. /**
  5896. * Flags the audio engine in Locked state.
  5897. * This happens due to new browser policies preventing audio to autoplay.
  5898. */
  5899. AudioEngine.prototype.lock = function () {
  5900. this._triggerSuspendedState();
  5901. };
  5902. /**
  5903. * Unlocks the audio engine once a user action has been done on the dom.
  5904. * This is helpful to resume play once browser policies have been satisfied.
  5905. */
  5906. AudioEngine.prototype.unlock = function () {
  5907. this._triggerRunningState();
  5908. };
  5909. AudioEngine.prototype._resumeAudioContext = function () {
  5910. var result;
  5911. if (this._audioContext.resume) {
  5912. result = this._audioContext.resume();
  5913. }
  5914. return result || Promise.resolve();
  5915. };
  5916. AudioEngine.prototype._initializeAudioContext = function () {
  5917. try {
  5918. if (this.canUseWebAudio) {
  5919. this._audioContext = new AudioContext();
  5920. // create a global volume gain node
  5921. this.masterGain = this._audioContext.createGain();
  5922. this.masterGain.gain.value = 1;
  5923. this.masterGain.connect(this._audioContext.destination);
  5924. this._audioContextInitialized = true;
  5925. if (this._audioContext.state === "running") {
  5926. // Do not wait for the promise to unlock.
  5927. this._triggerRunningState();
  5928. }
  5929. }
  5930. }
  5931. catch (e) {
  5932. this.canUseWebAudio = false;
  5933. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  5934. }
  5935. };
  5936. AudioEngine.prototype._triggerRunningState = function () {
  5937. var _this = this;
  5938. if (this._tryToRun) {
  5939. return;
  5940. }
  5941. this._tryToRun = true;
  5942. this._resumeAudioContext()
  5943. .then(function () {
  5944. _this._tryToRun = false;
  5945. if (_this._muteButton) {
  5946. _this._hideMuteButton();
  5947. }
  5948. }).catch(function () {
  5949. _this._tryToRun = false;
  5950. _this.unlocked = false;
  5951. });
  5952. // Notify users that the audio stack is unlocked/unmuted
  5953. this.unlocked = true;
  5954. this.onAudioUnlockedObservable.notifyObservers(this);
  5955. };
  5956. AudioEngine.prototype._triggerSuspendedState = function () {
  5957. this.unlocked = false;
  5958. this.onAudioLockedObservable.notifyObservers(this);
  5959. this._displayMuteButton();
  5960. };
  5961. AudioEngine.prototype._displayMuteButton = function () {
  5962. var _this = this;
  5963. if (this.useCustomUnlockedButton || this._muteButton) {
  5964. return;
  5965. }
  5966. this._muteButton = document.createElement("BUTTON");
  5967. this._muteButton.className = "babylonUnmuteIcon";
  5968. this._muteButton.id = "babylonUnmuteIconBtn";
  5969. this._muteButton.title = "Unmute";
  5970. 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) }";
  5971. var style = document.createElement('style');
  5972. style.appendChild(document.createTextNode(css));
  5973. document.getElementsByTagName('head')[0].appendChild(style);
  5974. document.body.appendChild(this._muteButton);
  5975. this._moveButtonToTopLeft();
  5976. this._muteButton.addEventListener('touchend', function () {
  5977. _this._triggerRunningState();
  5978. }, true);
  5979. this._muteButton.addEventListener('click', function () {
  5980. _this._triggerRunningState();
  5981. }, true);
  5982. window.addEventListener("resize", this._onResize);
  5983. };
  5984. AudioEngine.prototype._moveButtonToTopLeft = function () {
  5985. if (this._hostElement && this._muteButton) {
  5986. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  5987. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  5988. }
  5989. };
  5990. AudioEngine.prototype._hideMuteButton = function () {
  5991. if (this._muteButton) {
  5992. document.body.removeChild(this._muteButton);
  5993. this._muteButton = null;
  5994. }
  5995. };
  5996. /**
  5997. * Destroy and release the resources associated with the audio ccontext.
  5998. */
  5999. AudioEngine.prototype.dispose = function () {
  6000. if (this.canUseWebAudio && this._audioContextInitialized) {
  6001. if (this._connectedAnalyser && this._audioContext) {
  6002. this._connectedAnalyser.stopDebugCanvas();
  6003. this._connectedAnalyser.dispose();
  6004. this.masterGain.disconnect();
  6005. this.masterGain.connect(this._audioContext.destination);
  6006. this._connectedAnalyser = null;
  6007. }
  6008. this.masterGain.gain.value = 1;
  6009. }
  6010. this.WarnedWebAudioUnsupported = false;
  6011. this._hideMuteButton();
  6012. window.removeEventListener("resize", this._onResize);
  6013. this.onAudioUnlockedObservable.clear();
  6014. this.onAudioLockedObservable.clear();
  6015. };
  6016. /**
  6017. * Gets the global volume sets on the master gain.
  6018. * @returns the global volume if set or -1 otherwise
  6019. */
  6020. AudioEngine.prototype.getGlobalVolume = function () {
  6021. if (this.canUseWebAudio && this._audioContextInitialized) {
  6022. return this.masterGain.gain.value;
  6023. }
  6024. else {
  6025. return -1;
  6026. }
  6027. };
  6028. /**
  6029. * Sets the global volume of your experience (sets on the master gain).
  6030. * @param newVolume Defines the new global volume of the application
  6031. */
  6032. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  6033. if (this.canUseWebAudio && this._audioContextInitialized) {
  6034. this.masterGain.gain.value = newVolume;
  6035. }
  6036. };
  6037. /**
  6038. * Connect the audio engine to an audio analyser allowing some amazing
  6039. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  6040. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  6041. * @param analyser The analyser to connect to the engine
  6042. */
  6043. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  6044. if (this._connectedAnalyser) {
  6045. this._connectedAnalyser.stopDebugCanvas();
  6046. }
  6047. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  6048. this._connectedAnalyser = analyser;
  6049. this.masterGain.disconnect();
  6050. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  6051. }
  6052. };
  6053. return AudioEngine;
  6054. }());
  6055. /***/ }),
  6056. /***/ "./Audio/audioSceneComponent.ts":
  6057. /*!**************************************!*\
  6058. !*** ./Audio/audioSceneComponent.ts ***!
  6059. \**************************************/
  6060. /*! exports provided: AudioSceneComponent */
  6061. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6062. "use strict";
  6063. __webpack_require__.r(__webpack_exports__);
  6064. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  6065. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6066. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6067. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6068. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6069. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  6070. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  6071. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  6072. // Adds the parser to the scene parsers.
  6073. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  6074. // TODO: add sound
  6075. var loadedSounds = [];
  6076. var loadedSound;
  6077. container.sounds = container.sounds || [];
  6078. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  6079. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  6080. var parsedSound = parsedData.sounds[index];
  6081. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  6082. if (!parsedSound.url) {
  6083. parsedSound.url = parsedSound.name;
  6084. }
  6085. if (!loadedSounds[parsedSound.url]) {
  6086. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  6087. loadedSounds[parsedSound.url] = loadedSound;
  6088. container.sounds.push(loadedSound);
  6089. }
  6090. else {
  6091. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  6092. }
  6093. }
  6094. else {
  6095. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  6096. }
  6097. }
  6098. }
  6099. loadedSounds = [];
  6100. });
  6101. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  6102. get: function () {
  6103. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6104. if (!compo) {
  6105. compo = new AudioSceneComponent(this);
  6106. this._addComponent(compo);
  6107. }
  6108. if (!this._mainSoundTrack) {
  6109. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  6110. }
  6111. return this._mainSoundTrack;
  6112. },
  6113. enumerable: true,
  6114. configurable: true
  6115. });
  6116. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  6117. var index;
  6118. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  6119. if (this.mainSoundTrack.soundCollection[index].name === name) {
  6120. return this.mainSoundTrack.soundCollection[index];
  6121. }
  6122. }
  6123. if (this.soundTracks) {
  6124. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  6125. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  6126. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  6127. return this.soundTracks[sdIndex].soundCollection[index];
  6128. }
  6129. }
  6130. }
  6131. }
  6132. return null;
  6133. };
  6134. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  6135. get: function () {
  6136. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6137. if (!compo) {
  6138. compo = new AudioSceneComponent(this);
  6139. this._addComponent(compo);
  6140. }
  6141. return compo.audioEnabled;
  6142. },
  6143. set: function (value) {
  6144. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6145. if (!compo) {
  6146. compo = new AudioSceneComponent(this);
  6147. this._addComponent(compo);
  6148. }
  6149. if (value) {
  6150. compo.enableAudio();
  6151. }
  6152. else {
  6153. compo.disableAudio();
  6154. }
  6155. },
  6156. enumerable: true,
  6157. configurable: true
  6158. });
  6159. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  6160. get: function () {
  6161. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6162. if (!compo) {
  6163. compo = new AudioSceneComponent(this);
  6164. this._addComponent(compo);
  6165. }
  6166. return compo.headphone;
  6167. },
  6168. set: function (value) {
  6169. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6170. if (!compo) {
  6171. compo = new AudioSceneComponent(this);
  6172. this._addComponent(compo);
  6173. }
  6174. if (value) {
  6175. compo.switchAudioModeForHeadphones();
  6176. }
  6177. else {
  6178. compo.switchAudioModeForNormalSpeakers();
  6179. }
  6180. },
  6181. enumerable: true,
  6182. configurable: true
  6183. });
  6184. /**
  6185. * Defines the sound scene component responsible to manage any sounds
  6186. * in a given scene.
  6187. */
  6188. var AudioSceneComponent = /** @class */ (function () {
  6189. /**
  6190. * Creates a new instance of the component for the given scene
  6191. * @param scene Defines the scene to register the component in
  6192. */
  6193. function AudioSceneComponent(scene) {
  6194. /**
  6195. * The component name helpfull to identify the component in the list of scene components.
  6196. */
  6197. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  6198. this._audioEnabled = true;
  6199. this._headphone = false;
  6200. this.scene = scene;
  6201. scene.soundTracks = new Array();
  6202. scene.sounds = new Array();
  6203. }
  6204. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  6205. /**
  6206. * Gets whether audio is enabled or not.
  6207. * Please use related enable/disable method to switch state.
  6208. */
  6209. get: function () {
  6210. return this._audioEnabled;
  6211. },
  6212. enumerable: true,
  6213. configurable: true
  6214. });
  6215. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  6216. /**
  6217. * Gets whether audio is outputing to headphone or not.
  6218. * Please use the according Switch methods to change output.
  6219. */
  6220. get: function () {
  6221. return this._headphone;
  6222. },
  6223. enumerable: true,
  6224. configurable: true
  6225. });
  6226. /**
  6227. * Registers the component in a given scene
  6228. */
  6229. AudioSceneComponent.prototype.register = function () {
  6230. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  6231. };
  6232. /**
  6233. * Rebuilds the elements related to this component in case of
  6234. * context lost for instance.
  6235. */
  6236. AudioSceneComponent.prototype.rebuild = function () {
  6237. // Nothing to do here. (Not rendering related)
  6238. };
  6239. /**
  6240. * Serializes the component data to the specified json object
  6241. * @param serializationObject The object to serialize to
  6242. */
  6243. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  6244. serializationObject.sounds = [];
  6245. if (this.scene.soundTracks) {
  6246. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  6247. var soundtrack = this.scene.soundTracks[index];
  6248. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  6249. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  6250. }
  6251. }
  6252. }
  6253. };
  6254. /**
  6255. * Adds all the element from the container to the scene
  6256. * @param container the container holding the elements
  6257. */
  6258. AudioSceneComponent.prototype.addFromContainer = function (container) {
  6259. var _this = this;
  6260. if (!container.sounds) {
  6261. return;
  6262. }
  6263. container.sounds.forEach(function (sound) {
  6264. sound.play();
  6265. sound.autoplay = true;
  6266. _this.scene.mainSoundTrack.AddSound(sound);
  6267. });
  6268. };
  6269. /**
  6270. * Removes all the elements in the container from the scene
  6271. * @param container contains the elements to remove
  6272. * @param dispose if the removed element should be disposed (default: false)
  6273. */
  6274. AudioSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  6275. var _this = this;
  6276. if (dispose === void 0) { dispose = false; }
  6277. if (!container.sounds) {
  6278. return;
  6279. }
  6280. container.sounds.forEach(function (sound) {
  6281. sound.stop();
  6282. sound.autoplay = false;
  6283. _this.scene.mainSoundTrack.RemoveSound(sound);
  6284. if (dispose) {
  6285. sound.dispose();
  6286. }
  6287. });
  6288. };
  6289. /**
  6290. * Disposes the component and the associated ressources.
  6291. */
  6292. AudioSceneComponent.prototype.dispose = function () {
  6293. var scene = this.scene;
  6294. if (scene._mainSoundTrack) {
  6295. scene.mainSoundTrack.dispose();
  6296. }
  6297. if (scene.soundTracks) {
  6298. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  6299. scene.soundTracks[scIndex].dispose();
  6300. }
  6301. }
  6302. };
  6303. /**
  6304. * Disables audio in the associated scene.
  6305. */
  6306. AudioSceneComponent.prototype.disableAudio = function () {
  6307. var scene = this.scene;
  6308. this._audioEnabled = false;
  6309. var i;
  6310. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6311. scene.mainSoundTrack.soundCollection[i].pause();
  6312. }
  6313. if (scene.soundTracks) {
  6314. for (i = 0; i < scene.soundTracks.length; i++) {
  6315. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6316. scene.soundTracks[i].soundCollection[j].pause();
  6317. }
  6318. }
  6319. }
  6320. };
  6321. /**
  6322. * Enables audio in the associated scene.
  6323. */
  6324. AudioSceneComponent.prototype.enableAudio = function () {
  6325. var scene = this.scene;
  6326. this._audioEnabled = true;
  6327. var i;
  6328. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6329. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  6330. scene.mainSoundTrack.soundCollection[i].play();
  6331. }
  6332. }
  6333. if (scene.soundTracks) {
  6334. for (i = 0; i < scene.soundTracks.length; i++) {
  6335. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6336. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  6337. scene.soundTracks[i].soundCollection[j].play();
  6338. }
  6339. }
  6340. }
  6341. }
  6342. };
  6343. /**
  6344. * Switch audio to headphone output.
  6345. */
  6346. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  6347. var scene = this.scene;
  6348. this._headphone = true;
  6349. scene.mainSoundTrack.switchPanningModelToHRTF();
  6350. if (scene.soundTracks) {
  6351. for (var i = 0; i < scene.soundTracks.length; i++) {
  6352. scene.soundTracks[i].switchPanningModelToHRTF();
  6353. }
  6354. }
  6355. };
  6356. /**
  6357. * Switch audio to normal speakers.
  6358. */
  6359. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  6360. var scene = this.scene;
  6361. this._headphone = false;
  6362. scene.mainSoundTrack.switchPanningModelToEqualPower();
  6363. if (scene.soundTracks) {
  6364. for (var i = 0; i < scene.soundTracks.length; i++) {
  6365. scene.soundTracks[i].switchPanningModelToEqualPower();
  6366. }
  6367. }
  6368. };
  6369. AudioSceneComponent.prototype._afterRender = function () {
  6370. var scene = this.scene;
  6371. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6372. return;
  6373. }
  6374. var listeningCamera;
  6375. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6376. if (scene.activeCameras.length > 0) {
  6377. listeningCamera = scene.activeCameras[0];
  6378. }
  6379. else {
  6380. listeningCamera = scene.activeCamera;
  6381. }
  6382. if (listeningCamera && audioEngine.audioContext) {
  6383. audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z);
  6384. // for VR cameras
  6385. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6386. listeningCamera = listeningCamera.rigCameras[0];
  6387. }
  6388. var mat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6389. var cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6390. cameraDirection.normalize();
  6391. // To avoid some errors on GearVR
  6392. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6393. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6394. }
  6395. var i;
  6396. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6397. var sound = scene.mainSoundTrack.soundCollection[i];
  6398. if (sound.useCustomAttenuation) {
  6399. sound.updateDistanceFromListener();
  6400. }
  6401. }
  6402. if (scene.soundTracks) {
  6403. for (i = 0; i < scene.soundTracks.length; i++) {
  6404. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6405. sound = scene.soundTracks[i].soundCollection[j];
  6406. if (sound.useCustomAttenuation) {
  6407. sound.updateDistanceFromListener();
  6408. }
  6409. }
  6410. }
  6411. }
  6412. }
  6413. };
  6414. return AudioSceneComponent;
  6415. }());
  6416. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6417. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6418. if (!compo) {
  6419. compo = new AudioSceneComponent(scene);
  6420. scene._addComponent(compo);
  6421. }
  6422. };
  6423. /***/ }),
  6424. /***/ "./Audio/index.ts":
  6425. /*!************************!*\
  6426. !*** ./Audio/index.ts ***!
  6427. \************************/
  6428. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6429. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6430. "use strict";
  6431. __webpack_require__.r(__webpack_exports__);
  6432. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6434. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6436. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6438. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6440. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6442. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6444. /***/ }),
  6445. /***/ "./Audio/sound.ts":
  6446. /*!************************!*\
  6447. !*** ./Audio/sound.ts ***!
  6448. \************************/
  6449. /*! exports provided: Sound */
  6450. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6451. "use strict";
  6452. __webpack_require__.r(__webpack_exports__);
  6453. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6454. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6455. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6456. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6457. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6458. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6459. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  6460. /**
  6461. * Defines a sound that can be played in the application.
  6462. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6464. */
  6465. var Sound = /** @class */ (function () {
  6466. /**
  6467. * Create a sound and attach it to a scene
  6468. * @param name Name of your sound
  6469. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6470. * @param scene defines the scene the sound belongs to
  6471. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6472. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6473. */
  6474. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6475. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6476. var _this = this;
  6477. /**
  6478. * Does the sound autoplay once loaded.
  6479. */
  6480. this.autoplay = false;
  6481. /**
  6482. * Does the sound loop after it finishes playing once.
  6483. */
  6484. this.loop = false;
  6485. /**
  6486. * Does the sound use a custom attenuation curve to simulate the falloff
  6487. * happening when the source gets further away from the camera.
  6488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6489. */
  6490. this.useCustomAttenuation = false;
  6491. /**
  6492. * Is this sound currently played.
  6493. */
  6494. this.isPlaying = false;
  6495. /**
  6496. * Is this sound currently paused.
  6497. */
  6498. this.isPaused = false;
  6499. /**
  6500. * Does this sound enables spatial sound.
  6501. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6502. */
  6503. this.spatialSound = false;
  6504. /**
  6505. * Define the reference distance the sound should be heard perfectly.
  6506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6507. */
  6508. this.refDistance = 1;
  6509. /**
  6510. * Define the roll off factor of spatial sounds.
  6511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6512. */
  6513. this.rolloffFactor = 1;
  6514. /**
  6515. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6517. */
  6518. this.maxDistance = 100;
  6519. /**
  6520. * Define the distance attenuation model the sound will follow.
  6521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6522. */
  6523. this.distanceModel = "linear";
  6524. /**
  6525. * Observable event when the current playing sound finishes.
  6526. */
  6527. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6528. this._panningModel = "equalpower";
  6529. this._playbackRate = 1;
  6530. this._streaming = false;
  6531. this._startTime = 0;
  6532. this._startOffset = 0;
  6533. this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6534. /** @hidden */
  6535. this._positionInEmitterSpace = false;
  6536. this._localDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6537. this._volume = 1;
  6538. this._isReadyToPlay = false;
  6539. this._isDirectional = false;
  6540. // Used if you'd like to create a directional sound.
  6541. // If not set, the sound will be omnidirectional
  6542. this._coneInnerAngle = 360;
  6543. this._coneOuterAngle = 360;
  6544. this._coneOuterGain = 0;
  6545. this._isOutputConnected = false;
  6546. this._urlType = "Unknown";
  6547. this.name = name;
  6548. this._scene = scene;
  6549. Sound._SceneComponentInitialization(scene);
  6550. this._readyToPlayCallback = readyToPlayCallback;
  6551. // Default custom attenuation function is a linear attenuation
  6552. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6553. if (currentDistance < maxDistance) {
  6554. return currentVolume * (1 - currentDistance / maxDistance);
  6555. }
  6556. else {
  6557. return 0;
  6558. }
  6559. };
  6560. if (options) {
  6561. this.autoplay = options.autoplay || false;
  6562. this.loop = options.loop || false;
  6563. // if volume === 0, we need another way to check this option
  6564. if (options.volume !== undefined) {
  6565. this._volume = options.volume;
  6566. }
  6567. this.spatialSound = options.spatialSound || false;
  6568. this.maxDistance = options.maxDistance || 100;
  6569. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6570. this.rolloffFactor = options.rolloffFactor || 1;
  6571. this.refDistance = options.refDistance || 1;
  6572. this.distanceModel = options.distanceModel || "linear";
  6573. this._playbackRate = options.playbackRate || 1;
  6574. this._streaming = options.streaming || false;
  6575. }
  6576. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6577. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6578. this._soundGain.gain.value = this._volume;
  6579. this._inputAudioNode = this._soundGain;
  6580. this._outputAudioNode = this._soundGain;
  6581. if (this.spatialSound) {
  6582. this._createSpatialParameters();
  6583. }
  6584. this._scene.mainSoundTrack.AddSound(this);
  6585. var validParameter = true;
  6586. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6587. if (urlOrArrayBuffer) {
  6588. try {
  6589. if (typeof (urlOrArrayBuffer) === "string") {
  6590. this._urlType = "String";
  6591. }
  6592. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6593. this._urlType = "ArrayBuffer";
  6594. }
  6595. else if (urlOrArrayBuffer instanceof MediaStream) {
  6596. this._urlType = "MediaStream";
  6597. }
  6598. else if (Array.isArray(urlOrArrayBuffer)) {
  6599. this._urlType = "Array";
  6600. }
  6601. var urls = [];
  6602. var codecSupportedFound = false;
  6603. switch (this._urlType) {
  6604. case "MediaStream":
  6605. this._streaming = true;
  6606. this._isReadyToPlay = true;
  6607. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);
  6608. if (this.autoplay) {
  6609. this.play();
  6610. }
  6611. if (this._readyToPlayCallback) {
  6612. this._readyToPlayCallback();
  6613. }
  6614. break;
  6615. case "ArrayBuffer":
  6616. if (urlOrArrayBuffer.byteLength > 0) {
  6617. codecSupportedFound = true;
  6618. this._soundLoaded(urlOrArrayBuffer);
  6619. }
  6620. break;
  6621. case "String":
  6622. urls.push(urlOrArrayBuffer);
  6623. case "Array":
  6624. if (urls.length === 0) {
  6625. urls = urlOrArrayBuffer;
  6626. }
  6627. // If we found a supported format, we load it immediately and stop the loop
  6628. for (var i = 0; i < urls.length; i++) {
  6629. var url = urls[i];
  6630. if (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) {
  6631. codecSupportedFound = true;
  6632. }
  6633. if (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) {
  6634. codecSupportedFound = true;
  6635. }
  6636. if (url.indexOf(".wav", url.length - 4) !== -1) {
  6637. codecSupportedFound = true;
  6638. }
  6639. if (url.indexOf("blob:") !== -1) {
  6640. codecSupportedFound = true;
  6641. }
  6642. if (codecSupportedFound) {
  6643. // Loading sound using XHR2
  6644. if (!this._streaming) {
  6645. this._scene._loadFile(url, function (data) {
  6646. _this._soundLoaded(data);
  6647. }, undefined, true, true, function (exception) {
  6648. if (exception) {
  6649. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6650. }
  6651. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6652. _this._scene.mainSoundTrack.RemoveSound(_this);
  6653. });
  6654. }
  6655. // Streaming sound using HTML5 Audio tag
  6656. else {
  6657. this._htmlAudioElement = new Audio(url);
  6658. this._htmlAudioElement.controls = false;
  6659. this._htmlAudioElement.loop = this.loop;
  6660. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6661. this._htmlAudioElement.preload = "auto";
  6662. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6663. _this._isReadyToPlay = true;
  6664. if (_this.autoplay) {
  6665. _this.play();
  6666. }
  6667. if (_this._readyToPlayCallback) {
  6668. _this._readyToPlayCallback();
  6669. }
  6670. });
  6671. document.body.appendChild(this._htmlAudioElement);
  6672. this._htmlAudioElement.load();
  6673. }
  6674. break;
  6675. }
  6676. }
  6677. break;
  6678. default:
  6679. validParameter = false;
  6680. break;
  6681. }
  6682. if (!validParameter) {
  6683. _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.");
  6684. }
  6685. else {
  6686. if (!codecSupportedFound) {
  6687. this._isReadyToPlay = true;
  6688. // Simulating a ready to play event to avoid breaking code path
  6689. if (this._readyToPlayCallback) {
  6690. window.setTimeout(function () {
  6691. if (_this._readyToPlayCallback) {
  6692. _this._readyToPlayCallback();
  6693. }
  6694. }, 1000);
  6695. }
  6696. }
  6697. }
  6698. }
  6699. catch (ex) {
  6700. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6701. this._scene.mainSoundTrack.RemoveSound(this);
  6702. }
  6703. }
  6704. }
  6705. else {
  6706. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6707. this._scene.mainSoundTrack.AddSound(this);
  6708. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6709. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6710. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6711. }
  6712. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6713. if (this._readyToPlayCallback) {
  6714. window.setTimeout(function () {
  6715. if (_this._readyToPlayCallback) {
  6716. _this._readyToPlayCallback();
  6717. }
  6718. }, 1000);
  6719. }
  6720. }
  6721. }
  6722. /**
  6723. * Release the sound and its associated resources
  6724. */
  6725. Sound.prototype.dispose = function () {
  6726. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6727. if (this.isPlaying) {
  6728. this.stop();
  6729. }
  6730. this._isReadyToPlay = false;
  6731. if (this.soundTrackId === -1) {
  6732. this._scene.mainSoundTrack.RemoveSound(this);
  6733. }
  6734. else if (this._scene.soundTracks) {
  6735. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6736. }
  6737. if (this._soundGain) {
  6738. this._soundGain.disconnect();
  6739. this._soundGain = null;
  6740. }
  6741. if (this._soundPanner) {
  6742. this._soundPanner.disconnect();
  6743. this._soundPanner = null;
  6744. }
  6745. if (this._soundSource) {
  6746. this._soundSource.disconnect();
  6747. this._soundSource = null;
  6748. }
  6749. this._audioBuffer = null;
  6750. if (this._htmlAudioElement) {
  6751. this._htmlAudioElement.pause();
  6752. this._htmlAudioElement.src = "";
  6753. document.body.removeChild(this._htmlAudioElement);
  6754. }
  6755. if (this._streamingSource) {
  6756. this._streamingSource.disconnect();
  6757. }
  6758. if (this._connectedTransformNode && this._registerFunc) {
  6759. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6760. this._connectedTransformNode = null;
  6761. }
  6762. }
  6763. };
  6764. /**
  6765. * Gets if the sounds is ready to be played or not.
  6766. * @returns true if ready, otherwise false
  6767. */
  6768. Sound.prototype.isReady = function () {
  6769. return this._isReadyToPlay;
  6770. };
  6771. Sound.prototype._soundLoaded = function (audioData) {
  6772. var _this = this;
  6773. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6774. return;
  6775. }
  6776. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6777. _this._audioBuffer = buffer;
  6778. _this._isReadyToPlay = true;
  6779. if (_this.autoplay) {
  6780. _this.play();
  6781. }
  6782. if (_this._readyToPlayCallback) {
  6783. _this._readyToPlayCallback();
  6784. }
  6785. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6786. };
  6787. /**
  6788. * Sets the data of the sound from an audiobuffer
  6789. * @param audioBuffer The audioBuffer containing the data
  6790. */
  6791. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6792. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6793. this._audioBuffer = audioBuffer;
  6794. this._isReadyToPlay = true;
  6795. }
  6796. };
  6797. /**
  6798. * Updates the current sounds options such as maxdistance, loop...
  6799. * @param options A JSON object containing values named as the object properties
  6800. */
  6801. Sound.prototype.updateOptions = function (options) {
  6802. if (options) {
  6803. this.loop = options.loop || this.loop;
  6804. this.maxDistance = options.maxDistance || this.maxDistance;
  6805. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6806. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6807. this.refDistance = options.refDistance || this.refDistance;
  6808. this.distanceModel = options.distanceModel || this.distanceModel;
  6809. this._playbackRate = options.playbackRate || this._playbackRate;
  6810. this._updateSpatialParameters();
  6811. if (this.isPlaying) {
  6812. if (this._streaming && this._htmlAudioElement) {
  6813. this._htmlAudioElement.playbackRate = this._playbackRate;
  6814. }
  6815. else {
  6816. if (this._soundSource) {
  6817. this._soundSource.playbackRate.value = this._playbackRate;
  6818. }
  6819. }
  6820. }
  6821. }
  6822. };
  6823. Sound.prototype._createSpatialParameters = function () {
  6824. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6825. if (this._scene.headphone) {
  6826. this._panningModel = "HRTF";
  6827. }
  6828. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6829. this._updateSpatialParameters();
  6830. this._soundPanner.connect(this._outputAudioNode);
  6831. this._inputAudioNode = this._soundPanner;
  6832. }
  6833. };
  6834. Sound.prototype._updateSpatialParameters = function () {
  6835. if (this.spatialSound && this._soundPanner) {
  6836. if (this.useCustomAttenuation) {
  6837. // Tricks to disable in a way embedded Web Audio attenuation
  6838. this._soundPanner.distanceModel = "linear";
  6839. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6840. this._soundPanner.refDistance = 1;
  6841. this._soundPanner.rolloffFactor = 1;
  6842. this._soundPanner.panningModel = this._panningModel;
  6843. }
  6844. else {
  6845. this._soundPanner.distanceModel = this.distanceModel;
  6846. this._soundPanner.maxDistance = this.maxDistance;
  6847. this._soundPanner.refDistance = this.refDistance;
  6848. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6849. this._soundPanner.panningModel = this._panningModel;
  6850. }
  6851. }
  6852. };
  6853. /**
  6854. * Switch the panning model to HRTF:
  6855. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6857. */
  6858. Sound.prototype.switchPanningModelToHRTF = function () {
  6859. this._panningModel = "HRTF";
  6860. this._switchPanningModel();
  6861. };
  6862. /**
  6863. * Switch the panning model to Equal Power:
  6864. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6865. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6866. */
  6867. Sound.prototype.switchPanningModelToEqualPower = function () {
  6868. this._panningModel = "equalpower";
  6869. this._switchPanningModel();
  6870. };
  6871. Sound.prototype._switchPanningModel = function () {
  6872. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6873. this._soundPanner.panningModel = this._panningModel;
  6874. }
  6875. };
  6876. /**
  6877. * Connect this sound to a sound track audio node like gain...
  6878. * @param soundTrackAudioNode the sound track audio node to connect to
  6879. */
  6880. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6881. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6882. if (this._isOutputConnected) {
  6883. this._outputAudioNode.disconnect();
  6884. }
  6885. this._outputAudioNode.connect(soundTrackAudioNode);
  6886. this._isOutputConnected = true;
  6887. }
  6888. };
  6889. /**
  6890. * Transform this sound into a directional source
  6891. * @param coneInnerAngle Size of the inner cone in degree
  6892. * @param coneOuterAngle Size of the outer cone in degree
  6893. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6894. */
  6895. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6896. if (coneOuterAngle < coneInnerAngle) {
  6897. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6898. return;
  6899. }
  6900. this._coneInnerAngle = coneInnerAngle;
  6901. this._coneOuterAngle = coneOuterAngle;
  6902. this._coneOuterGain = coneOuterGain;
  6903. this._isDirectional = true;
  6904. if (this.isPlaying && this.loop) {
  6905. this.stop();
  6906. this.play();
  6907. }
  6908. };
  6909. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  6910. /**
  6911. * Gets or sets the inner angle for the directional cone.
  6912. */
  6913. get: function () {
  6914. return this._coneInnerAngle;
  6915. },
  6916. /**
  6917. * Gets or sets the inner angle for the directional cone.
  6918. */
  6919. set: function (value) {
  6920. if (value != this._coneInnerAngle) {
  6921. if (this._coneOuterAngle < value) {
  6922. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6923. return;
  6924. }
  6925. this._coneInnerAngle = value;
  6926. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6927. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6928. }
  6929. }
  6930. },
  6931. enumerable: true,
  6932. configurable: true
  6933. });
  6934. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  6935. /**
  6936. * Gets or sets the outer angle for the directional cone.
  6937. */
  6938. get: function () {
  6939. return this._coneOuterAngle;
  6940. },
  6941. /**
  6942. * Gets or sets the outer angle for the directional cone.
  6943. */
  6944. set: function (value) {
  6945. if (value != this._coneOuterAngle) {
  6946. if (value < this._coneInnerAngle) {
  6947. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6948. return;
  6949. }
  6950. this._coneOuterAngle = value;
  6951. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6952. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6953. }
  6954. }
  6955. },
  6956. enumerable: true,
  6957. configurable: true
  6958. });
  6959. /**
  6960. * Sets the position of the emitter if spatial sound is enabled
  6961. * @param newPosition Defines the new posisiton
  6962. */
  6963. Sound.prototype.setPosition = function (newPosition) {
  6964. this._position = newPosition;
  6965. 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)) {
  6966. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6967. }
  6968. };
  6969. /**
  6970. * Sets the local direction of the emitter if spatial sound is enabled
  6971. * @param newLocalDirection Defines the new local direction
  6972. */
  6973. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  6974. this._localDirection = newLocalDirection;
  6975. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  6976. this._updateDirection();
  6977. }
  6978. };
  6979. Sound.prototype._updateDirection = function () {
  6980. if (!this._connectedTransformNode || !this._soundPanner) {
  6981. return;
  6982. }
  6983. var mat = this._connectedTransformNode.getWorldMatrix();
  6984. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  6985. direction.normalize();
  6986. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  6987. };
  6988. /** @hidden */
  6989. Sound.prototype.updateDistanceFromListener = function () {
  6990. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  6991. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  6992. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  6993. }
  6994. };
  6995. /**
  6996. * Sets a new custom attenuation function for the sound.
  6997. * @param callback Defines the function used for the attenuation
  6998. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6999. */
  7000. Sound.prototype.setAttenuationFunction = function (callback) {
  7001. this._customAttenuationFunction = callback;
  7002. };
  7003. /**
  7004. * Play the sound
  7005. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  7006. * @param offset (optional) Start the sound setting it at a specific time
  7007. */
  7008. Sound.prototype.play = function (time, offset) {
  7009. var _this = this;
  7010. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7011. try {
  7012. if (this._startOffset < 0) {
  7013. time = -this._startOffset;
  7014. this._startOffset = 0;
  7015. }
  7016. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7017. if (!this._soundSource || !this._streamingSource) {
  7018. if (this.spatialSound && this._soundPanner) {
  7019. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  7020. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  7021. }
  7022. if (this._isDirectional) {
  7023. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  7024. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  7025. this._soundPanner.coneOuterGain = this._coneOuterGain;
  7026. if (this._connectedTransformNode) {
  7027. this._updateDirection();
  7028. }
  7029. else {
  7030. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  7031. }
  7032. }
  7033. }
  7034. }
  7035. if (this._streaming) {
  7036. if (!this._streamingSource) {
  7037. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  7038. this._htmlAudioElement.onended = function () { _this._onended(); };
  7039. this._htmlAudioElement.playbackRate = this._playbackRate;
  7040. }
  7041. this._streamingSource.disconnect();
  7042. this._streamingSource.connect(this._inputAudioNode);
  7043. if (this._htmlAudioElement) {
  7044. // required to manage properly the new suspended default state of Chrome
  7045. // When the option 'streaming: true' is used, we need first to wait for
  7046. // the audio engine to be unlocked by a user gesture before trying to play
  7047. // an HTML Audio elememt
  7048. var tryToPlay = function () {
  7049. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  7050. var playPromise = _this._htmlAudioElement.play();
  7051. // In browsers that don’t yet support this functionality,
  7052. // playPromise won’t be defined.
  7053. if (playPromise !== undefined) {
  7054. playPromise.catch(function (error) {
  7055. // Automatic playback failed.
  7056. // Waiting for the audio engine to be unlocked by user click on unmute
  7057. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7058. if (_this.loop || _this.autoplay) {
  7059. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7060. }
  7061. });
  7062. }
  7063. }
  7064. else {
  7065. if (_this.loop || _this.autoplay) {
  7066. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7067. }
  7068. }
  7069. };
  7070. tryToPlay();
  7071. }
  7072. }
  7073. else {
  7074. var tryToPlay = function () {
  7075. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7076. _this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  7077. _this._soundSource.buffer = _this._audioBuffer;
  7078. _this._soundSource.connect(_this._inputAudioNode);
  7079. _this._soundSource.loop = _this.loop;
  7080. _this._soundSource.playbackRate.value = _this._playbackRate;
  7081. _this._soundSource.onended = function () { _this._onended(); };
  7082. startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7083. _this._soundSource.start(startTime, _this.isPaused ? _this._startOffset % _this._soundSource.buffer.duration : offset ? offset : 0);
  7084. }
  7085. };
  7086. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7087. // Wait a bit for FF as context seems late to be ready.
  7088. setTimeout(function () {
  7089. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7090. // Automatic playback failed.
  7091. // Waiting for the audio engine to be unlocked by user click on unmute
  7092. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7093. if (_this.loop || _this.autoplay) {
  7094. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7095. }
  7096. }
  7097. else {
  7098. tryToPlay();
  7099. }
  7100. }, 500);
  7101. }
  7102. else {
  7103. tryToPlay();
  7104. }
  7105. }
  7106. this._startTime = startTime;
  7107. this.isPlaying = true;
  7108. this.isPaused = false;
  7109. }
  7110. catch (ex) {
  7111. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  7112. }
  7113. }
  7114. };
  7115. Sound.prototype._onended = function () {
  7116. this.isPlaying = false;
  7117. if (this.onended) {
  7118. this.onended();
  7119. }
  7120. this.onEndedObservable.notifyObservers(this);
  7121. };
  7122. /**
  7123. * Stop the sound
  7124. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  7125. */
  7126. Sound.prototype.stop = function (time) {
  7127. var _this = this;
  7128. if (this.isPlaying) {
  7129. if (this._streaming) {
  7130. if (this._htmlAudioElement) {
  7131. this._htmlAudioElement.pause();
  7132. // Test needed for Firefox or it will generate an Invalid State Error
  7133. if (this._htmlAudioElement.currentTime > 0) {
  7134. this._htmlAudioElement.currentTime = 0;
  7135. }
  7136. }
  7137. else {
  7138. this._streamingSource.disconnect();
  7139. }
  7140. this.isPlaying = false;
  7141. }
  7142. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext && this._soundSource) {
  7143. var stopTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7144. this._soundSource.stop(stopTime);
  7145. this._soundSource.onended = function () { _this.isPlaying = false; };
  7146. if (!this.isPaused) {
  7147. this._startOffset = 0;
  7148. }
  7149. }
  7150. }
  7151. };
  7152. /**
  7153. * Put the sound in pause
  7154. */
  7155. Sound.prototype.pause = function () {
  7156. if (this.isPlaying) {
  7157. this.isPaused = true;
  7158. if (this._streaming) {
  7159. if (this._htmlAudioElement) {
  7160. this._htmlAudioElement.pause();
  7161. }
  7162. else {
  7163. this._streamingSource.disconnect();
  7164. }
  7165. }
  7166. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7167. this.stop(0);
  7168. this._startOffset += _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime - this._startTime;
  7169. }
  7170. }
  7171. };
  7172. /**
  7173. * Sets a dedicated volume for this sounds
  7174. * @param newVolume Define the new volume of the sound
  7175. * @param time Define in how long the sound should be at this value
  7176. */
  7177. Sound.prototype.setVolume = function (newVolume, time) {
  7178. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._soundGain) {
  7179. if (time && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7180. this._soundGain.gain.cancelScheduledValues(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7181. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7182. this._soundGain.gain.linearRampToValueAtTime(newVolume, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time);
  7183. }
  7184. else {
  7185. this._soundGain.gain.value = newVolume;
  7186. }
  7187. }
  7188. this._volume = newVolume;
  7189. };
  7190. /**
  7191. * Set the sound play back rate
  7192. * @param newPlaybackRate Define the playback rate the sound should be played at
  7193. */
  7194. Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
  7195. this._playbackRate = newPlaybackRate;
  7196. if (this.isPlaying) {
  7197. if (this._streaming && this._htmlAudioElement) {
  7198. this._htmlAudioElement.playbackRate = this._playbackRate;
  7199. }
  7200. else if (this._soundSource) {
  7201. this._soundSource.playbackRate.value = this._playbackRate;
  7202. }
  7203. }
  7204. };
  7205. /**
  7206. * Gets the volume of the sound.
  7207. * @returns the volume of the sound
  7208. */
  7209. Sound.prototype.getVolume = function () {
  7210. return this._volume;
  7211. };
  7212. /**
  7213. * Attach the sound to a dedicated mesh
  7214. * @param transformNode The transform node to connect the sound with
  7215. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7216. */
  7217. Sound.prototype.attachToMesh = function (transformNode) {
  7218. var _this = this;
  7219. if (this._connectedTransformNode && this._registerFunc) {
  7220. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7221. this._registerFunc = null;
  7222. }
  7223. this._connectedTransformNode = transformNode;
  7224. if (!this.spatialSound) {
  7225. this.spatialSound = true;
  7226. this._createSpatialParameters();
  7227. if (this.isPlaying && this.loop) {
  7228. this.stop();
  7229. this.play();
  7230. }
  7231. }
  7232. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
  7233. this._registerFunc = function (transformNode) { return _this._onRegisterAfterWorldMatrixUpdate(transformNode); };
  7234. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
  7235. };
  7236. /**
  7237. * Detach the sound from the previously attached mesh
  7238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7239. */
  7240. Sound.prototype.detachFromMesh = function () {
  7241. if (this._connectedTransformNode && this._registerFunc) {
  7242. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7243. this._registerFunc = null;
  7244. this._connectedTransformNode = null;
  7245. }
  7246. };
  7247. Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (node) {
  7248. if (!node.getBoundingInfo) {
  7249. return;
  7250. }
  7251. var mesh = node;
  7252. if (this._positionInEmitterSpace) {
  7253. mesh.worldMatrixFromCache.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0]);
  7254. this.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0].getTranslation());
  7255. }
  7256. else {
  7257. var boundingInfo = mesh.getBoundingInfo();
  7258. this.setPosition(boundingInfo.boundingSphere.centerWorld);
  7259. }
  7260. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
  7261. this._updateDirection();
  7262. }
  7263. };
  7264. /**
  7265. * Clone the current sound in the scene.
  7266. * @returns the new sound clone
  7267. */
  7268. Sound.prototype.clone = function () {
  7269. var _this = this;
  7270. if (!this._streaming) {
  7271. var setBufferAndRun = function () {
  7272. if (_this._isReadyToPlay) {
  7273. clonedSound._audioBuffer = _this.getAudioBuffer();
  7274. clonedSound._isReadyToPlay = true;
  7275. if (clonedSound.autoplay) {
  7276. clonedSound.play();
  7277. }
  7278. }
  7279. else {
  7280. window.setTimeout(setBufferAndRun, 300);
  7281. }
  7282. };
  7283. var currentOptions = {
  7284. autoplay: this.autoplay, loop: this.loop,
  7285. volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance,
  7286. useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor,
  7287. refDistance: this.refDistance, distanceModel: this.distanceModel
  7288. };
  7289. var clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
  7290. if (this.useCustomAttenuation) {
  7291. clonedSound.setAttenuationFunction(this._customAttenuationFunction);
  7292. }
  7293. clonedSound.setPosition(this._position);
  7294. clonedSound.setPlaybackRate(this._playbackRate);
  7295. setBufferAndRun();
  7296. return clonedSound;
  7297. }
  7298. // Can't clone a streaming sound
  7299. else {
  7300. return null;
  7301. }
  7302. };
  7303. /**
  7304. * Gets the current underlying audio buffer containing the data
  7305. * @returns the audio buffer
  7306. */
  7307. Sound.prototype.getAudioBuffer = function () {
  7308. return this._audioBuffer;
  7309. };
  7310. /**
  7311. * Serializes the Sound in a JSON representation
  7312. * @returns the JSON representation of the sound
  7313. */
  7314. Sound.prototype.serialize = function () {
  7315. var serializationObject = {
  7316. name: this.name,
  7317. url: this.name,
  7318. autoplay: this.autoplay,
  7319. loop: this.loop,
  7320. volume: this._volume,
  7321. spatialSound: this.spatialSound,
  7322. maxDistance: this.maxDistance,
  7323. rolloffFactor: this.rolloffFactor,
  7324. refDistance: this.refDistance,
  7325. distanceModel: this.distanceModel,
  7326. playbackRate: this._playbackRate,
  7327. panningModel: this._panningModel,
  7328. soundTrackId: this.soundTrackId
  7329. };
  7330. if (this.spatialSound) {
  7331. if (this._connectedTransformNode) {
  7332. serializationObject.connectedMeshId = this._connectedTransformNode.id;
  7333. }
  7334. serializationObject.position = this._position.asArray();
  7335. serializationObject.refDistance = this.refDistance;
  7336. serializationObject.distanceModel = this.distanceModel;
  7337. serializationObject.isDirectional = this._isDirectional;
  7338. serializationObject.localDirectionToMesh = this._localDirection.asArray();
  7339. serializationObject.coneInnerAngle = this._coneInnerAngle;
  7340. serializationObject.coneOuterAngle = this._coneOuterAngle;
  7341. serializationObject.coneOuterGain = this._coneOuterGain;
  7342. }
  7343. return serializationObject;
  7344. };
  7345. /**
  7346. * Parse a JSON representation of a sound to innstantiate in a given scene
  7347. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  7348. * @param scene Define the scene the new parsed sound should be created in
  7349. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  7350. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  7351. * @returns the newly parsed sound
  7352. */
  7353. Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
  7354. var soundName = parsedSound.name;
  7355. var soundUrl;
  7356. if (parsedSound.url) {
  7357. soundUrl = rootUrl + parsedSound.url;
  7358. }
  7359. else {
  7360. soundUrl = rootUrl + soundName;
  7361. }
  7362. var options = {
  7363. autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
  7364. spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
  7365. rolloffFactor: parsedSound.rolloffFactor,
  7366. refDistance: parsedSound.refDistance,
  7367. distanceModel: parsedSound.distanceModel,
  7368. playbackRate: parsedSound.playbackRate
  7369. };
  7370. var newSound;
  7371. if (!sourceSound) {
  7372. newSound = new Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
  7373. scene._addPendingData(newSound);
  7374. }
  7375. else {
  7376. var setBufferAndRun = function () {
  7377. if (sourceSound._isReadyToPlay) {
  7378. newSound._audioBuffer = sourceSound.getAudioBuffer();
  7379. newSound._isReadyToPlay = true;
  7380. if (newSound.autoplay) {
  7381. newSound.play();
  7382. }
  7383. }
  7384. else {
  7385. window.setTimeout(setBufferAndRun, 300);
  7386. }
  7387. };
  7388. newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
  7389. setBufferAndRun();
  7390. }
  7391. if (parsedSound.position) {
  7392. var soundPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.position);
  7393. newSound.setPosition(soundPosition);
  7394. }
  7395. if (parsedSound.isDirectional) {
  7396. newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
  7397. if (parsedSound.localDirectionToMesh) {
  7398. var localDirectionToMesh = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.localDirectionToMesh);
  7399. newSound.setLocalDirectionToMesh(localDirectionToMesh);
  7400. }
  7401. }
  7402. if (parsedSound.connectedMeshId) {
  7403. var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
  7404. if (connectedMesh) {
  7405. newSound.attachToMesh(connectedMesh);
  7406. }
  7407. }
  7408. return newSound;
  7409. };
  7410. /** @hidden */
  7411. Sound._SceneComponentInitialization = function (_) {
  7412. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AudioSceneComponent");
  7413. };
  7414. return Sound;
  7415. }());
  7416. /***/ }),
  7417. /***/ "./Audio/soundTrack.ts":
  7418. /*!*****************************!*\
  7419. !*** ./Audio/soundTrack.ts ***!
  7420. \*****************************/
  7421. /*! exports provided: SoundTrack */
  7422. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7423. "use strict";
  7424. __webpack_require__.r(__webpack_exports__);
  7425. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return SoundTrack; });
  7426. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  7427. /**
  7428. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  7429. * It will be also used in a future release to apply effects on a specific track.
  7430. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7431. */
  7432. var SoundTrack = /** @class */ (function () {
  7433. /**
  7434. * Creates a new sound track.
  7435. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7436. * @param scene Define the scene the sound track belongs to
  7437. * @param options
  7438. */
  7439. function SoundTrack(scene, options) {
  7440. if (options === void 0) { options = {}; }
  7441. /**
  7442. * The unique identifier of the sound track in the scene.
  7443. */
  7444. this.id = -1;
  7445. this._isMainTrack = false;
  7446. this._isInitialized = false;
  7447. this._scene = scene;
  7448. this.soundCollection = new Array();
  7449. this._options = options;
  7450. if (!this._isMainTrack && this._scene.soundTracks) {
  7451. this._scene.soundTracks.push(this);
  7452. this.id = this._scene.soundTracks.length - 1;
  7453. }
  7454. }
  7455. SoundTrack.prototype._initializeSoundTrackAudioGraph = function () {
  7456. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext) {
  7457. this._outputAudioNode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext.createGain();
  7458. this._outputAudioNode.connect(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7459. if (this._options) {
  7460. if (this._options.volume) {
  7461. this._outputAudioNode.gain.value = this._options.volume;
  7462. }
  7463. if (this._options.mainTrack) {
  7464. this._isMainTrack = this._options.mainTrack;
  7465. }
  7466. }
  7467. this._isInitialized = true;
  7468. }
  7469. };
  7470. /**
  7471. * Release the sound track and its associated resources
  7472. */
  7473. SoundTrack.prototype.dispose = function () {
  7474. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7475. if (this._connectedAnalyser) {
  7476. this._connectedAnalyser.stopDebugCanvas();
  7477. }
  7478. while (this.soundCollection.length) {
  7479. this.soundCollection[0].dispose();
  7480. }
  7481. if (this._outputAudioNode) {
  7482. this._outputAudioNode.disconnect();
  7483. }
  7484. this._outputAudioNode = null;
  7485. }
  7486. };
  7487. /**
  7488. * Adds a sound to this sound track
  7489. * @param sound define the cound to add
  7490. * @ignoreNaming
  7491. */
  7492. SoundTrack.prototype.AddSound = function (sound) {
  7493. if (!this._isInitialized) {
  7494. this._initializeSoundTrackAudioGraph();
  7495. }
  7496. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7497. sound.connectToSoundTrackAudioNode(this._outputAudioNode);
  7498. }
  7499. if (sound.soundTrackId) {
  7500. if (sound.soundTrackId === -1) {
  7501. this._scene.mainSoundTrack.RemoveSound(sound);
  7502. }
  7503. else if (this._scene.soundTracks) {
  7504. this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
  7505. }
  7506. }
  7507. this.soundCollection.push(sound);
  7508. sound.soundTrackId = this.id;
  7509. };
  7510. /**
  7511. * Removes a sound to this sound track
  7512. * @param sound define the cound to remove
  7513. * @ignoreNaming
  7514. */
  7515. SoundTrack.prototype.RemoveSound = function (sound) {
  7516. var index = this.soundCollection.indexOf(sound);
  7517. if (index !== -1) {
  7518. this.soundCollection.splice(index, 1);
  7519. }
  7520. };
  7521. /**
  7522. * Set a global volume for the full sound track.
  7523. * @param newVolume Define the new volume of the sound track
  7524. */
  7525. SoundTrack.prototype.setVolume = function (newVolume) {
  7526. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7527. this._outputAudioNode.gain.value = newVolume;
  7528. }
  7529. };
  7530. /**
  7531. * Switch the panning model to HRTF:
  7532. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  7533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7534. */
  7535. SoundTrack.prototype.switchPanningModelToHRTF = function () {
  7536. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7537. for (var i = 0; i < this.soundCollection.length; i++) {
  7538. this.soundCollection[i].switchPanningModelToHRTF();
  7539. }
  7540. }
  7541. };
  7542. /**
  7543. * Switch the panning model to Equal Power:
  7544. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  7545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7546. */
  7547. SoundTrack.prototype.switchPanningModelToEqualPower = function () {
  7548. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7549. for (var i = 0; i < this.soundCollection.length; i++) {
  7550. this.soundCollection[i].switchPanningModelToEqualPower();
  7551. }
  7552. }
  7553. };
  7554. /**
  7555. * Connect the sound track to an audio analyser allowing some amazing
  7556. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  7557. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  7558. * @param analyser The analyser to connect to the engine
  7559. */
  7560. SoundTrack.prototype.connectToAnalyser = function (analyser) {
  7561. if (this._connectedAnalyser) {
  7562. this._connectedAnalyser.stopDebugCanvas();
  7563. }
  7564. this._connectedAnalyser = analyser;
  7565. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7566. this._outputAudioNode.disconnect();
  7567. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7568. }
  7569. };
  7570. return SoundTrack;
  7571. }());
  7572. /***/ }),
  7573. /***/ "./Audio/weightedsound.ts":
  7574. /*!********************************!*\
  7575. !*** ./Audio/weightedsound.ts ***!
  7576. \********************************/
  7577. /*! exports provided: WeightedSound */
  7578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7579. "use strict";
  7580. __webpack_require__.r(__webpack_exports__);
  7581. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return WeightedSound; });
  7582. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  7583. /**
  7584. * Wraps one or more Sound objects and selects one with random weight for playback.
  7585. */
  7586. var WeightedSound = /** @class */ (function () {
  7587. /**
  7588. * Creates a new WeightedSound from the list of sounds given.
  7589. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  7590. * @param sounds Array of Sounds that will be selected from.
  7591. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  7592. */
  7593. function WeightedSound(loop, sounds, weights) {
  7594. var _this = this;
  7595. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7596. this.loop = false;
  7597. this._coneInnerAngle = 360;
  7598. this._coneOuterAngle = 360;
  7599. this._volume = 1;
  7600. /** A Sound is currently playing. */
  7601. this.isPlaying = false;
  7602. /** A Sound is currently paused. */
  7603. this.isPaused = false;
  7604. this._sounds = [];
  7605. this._weights = [];
  7606. if (sounds.length !== weights.length) {
  7607. throw new Error('Sounds length does not equal weights length');
  7608. }
  7609. this.loop = loop;
  7610. this._weights = weights;
  7611. // Normalize the weights
  7612. var weightSum = 0;
  7613. for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
  7614. var weight = weights_1[_i];
  7615. weightSum += weight;
  7616. }
  7617. var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
  7618. for (var i = 0; i < this._weights.length; i++) {
  7619. this._weights[i] *= invWeightSum;
  7620. }
  7621. this._sounds = sounds;
  7622. for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
  7623. var sound = _b[_a];
  7624. sound.onEndedObservable.add(function () { _this._onended(); });
  7625. }
  7626. }
  7627. Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
  7628. /**
  7629. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  7630. */
  7631. get: function () {
  7632. return this._coneInnerAngle;
  7633. },
  7634. /**
  7635. * The size of cone in degress for a directional sound in which there will be no attenuation.
  7636. */
  7637. set: function (value) {
  7638. if (value !== this._coneInnerAngle) {
  7639. if (this._coneOuterAngle < value) {
  7640. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7641. return;
  7642. }
  7643. this._coneInnerAngle = value;
  7644. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7645. var sound = _a[_i];
  7646. sound.directionalConeInnerAngle = value;
  7647. }
  7648. }
  7649. },
  7650. enumerable: true,
  7651. configurable: true
  7652. });
  7653. Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
  7654. /**
  7655. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7656. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7657. */
  7658. get: function () {
  7659. return this._coneOuterAngle;
  7660. },
  7661. /**
  7662. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7663. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7664. */
  7665. set: function (value) {
  7666. if (value !== this._coneOuterAngle) {
  7667. if (value < this._coneInnerAngle) {
  7668. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7669. return;
  7670. }
  7671. this._coneOuterAngle = value;
  7672. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7673. var sound = _a[_i];
  7674. sound.directionalConeOuterAngle = value;
  7675. }
  7676. }
  7677. },
  7678. enumerable: true,
  7679. configurable: true
  7680. });
  7681. Object.defineProperty(WeightedSound.prototype, "volume", {
  7682. /**
  7683. * Playback volume.
  7684. */
  7685. get: function () {
  7686. return this._volume;
  7687. },
  7688. /**
  7689. * Playback volume.
  7690. */
  7691. set: function (value) {
  7692. if (value !== this._volume) {
  7693. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7694. var sound = _a[_i];
  7695. sound.setVolume(value);
  7696. }
  7697. }
  7698. },
  7699. enumerable: true,
  7700. configurable: true
  7701. });
  7702. WeightedSound.prototype._onended = function () {
  7703. if (this._currentIndex !== undefined) {
  7704. this._sounds[this._currentIndex].autoplay = false;
  7705. }
  7706. if (this.loop && this.isPlaying) {
  7707. this.play();
  7708. }
  7709. else {
  7710. this.isPlaying = false;
  7711. }
  7712. };
  7713. /**
  7714. * Suspend playback
  7715. */
  7716. WeightedSound.prototype.pause = function () {
  7717. this.isPaused = true;
  7718. if (this._currentIndex !== undefined) {
  7719. this._sounds[this._currentIndex].pause();
  7720. }
  7721. };
  7722. /**
  7723. * Stop playback
  7724. */
  7725. WeightedSound.prototype.stop = function () {
  7726. this.isPlaying = false;
  7727. if (this._currentIndex !== undefined) {
  7728. this._sounds[this._currentIndex].stop();
  7729. }
  7730. };
  7731. /**
  7732. * Start playback.
  7733. * @param startOffset Position the clip head at a specific time in seconds.
  7734. */
  7735. WeightedSound.prototype.play = function (startOffset) {
  7736. if (!this.isPaused) {
  7737. this.stop();
  7738. var randomValue = Math.random();
  7739. var total = 0;
  7740. for (var i = 0; i < this._weights.length; i++) {
  7741. total += this._weights[i];
  7742. if (randomValue <= total) {
  7743. this._currentIndex = i;
  7744. break;
  7745. }
  7746. }
  7747. }
  7748. var sound = this._sounds[this._currentIndex];
  7749. if (sound.isReady()) {
  7750. sound.play(0, this.isPaused ? undefined : startOffset);
  7751. }
  7752. else {
  7753. sound.autoplay = true;
  7754. }
  7755. this.isPlaying = true;
  7756. this.isPaused = false;
  7757. };
  7758. return WeightedSound;
  7759. }());
  7760. /***/ }),
  7761. /***/ "./Behaviors/Cameras/autoRotationBehavior.ts":
  7762. /*!***************************************************!*\
  7763. !*** ./Behaviors/Cameras/autoRotationBehavior.ts ***!
  7764. \***************************************************/
  7765. /*! exports provided: AutoRotationBehavior */
  7766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7767. "use strict";
  7768. __webpack_require__.r(__webpack_exports__);
  7769. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return AutoRotationBehavior; });
  7770. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7771. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7772. /**
  7773. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  7774. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7775. */
  7776. var AutoRotationBehavior = /** @class */ (function () {
  7777. function AutoRotationBehavior() {
  7778. this._zoomStopsAnimation = false;
  7779. this._idleRotationSpeed = 0.05;
  7780. this._idleRotationWaitTime = 2000;
  7781. this._idleRotationSpinupTime = 2000;
  7782. this._isPointerDown = false;
  7783. this._lastFrameTime = null;
  7784. this._lastInteractionTime = -Infinity;
  7785. this._cameraRotationSpeed = 0;
  7786. this._lastFrameRadius = 0;
  7787. }
  7788. Object.defineProperty(AutoRotationBehavior.prototype, "name", {
  7789. /**
  7790. * Gets the name of the behavior.
  7791. */
  7792. get: function () {
  7793. return "AutoRotation";
  7794. },
  7795. enumerable: true,
  7796. configurable: true
  7797. });
  7798. Object.defineProperty(AutoRotationBehavior.prototype, "zoomStopsAnimation", {
  7799. /**
  7800. * Gets the flag that indicates if user zooming should stop animation.
  7801. */
  7802. get: function () {
  7803. return this._zoomStopsAnimation;
  7804. },
  7805. /**
  7806. * Sets the flag that indicates if user zooming should stop animation.
  7807. */
  7808. set: function (flag) {
  7809. this._zoomStopsAnimation = flag;
  7810. },
  7811. enumerable: true,
  7812. configurable: true
  7813. });
  7814. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpeed", {
  7815. /**
  7816. * Gets the default speed at which the camera rotates around the model.
  7817. */
  7818. get: function () {
  7819. return this._idleRotationSpeed;
  7820. },
  7821. /**
  7822. * Sets the default speed at which the camera rotates around the model.
  7823. */
  7824. set: function (speed) {
  7825. this._idleRotationSpeed = speed;
  7826. },
  7827. enumerable: true,
  7828. configurable: true
  7829. });
  7830. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationWaitTime", {
  7831. /**
  7832. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  7833. */
  7834. get: function () {
  7835. return this._idleRotationWaitTime;
  7836. },
  7837. /**
  7838. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  7839. */
  7840. set: function (time) {
  7841. this._idleRotationWaitTime = time;
  7842. },
  7843. enumerable: true,
  7844. configurable: true
  7845. });
  7846. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpinupTime", {
  7847. /**
  7848. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7849. */
  7850. get: function () {
  7851. return this._idleRotationSpinupTime;
  7852. },
  7853. /**
  7854. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7855. */
  7856. set: function (time) {
  7857. this._idleRotationSpinupTime = time;
  7858. },
  7859. enumerable: true,
  7860. configurable: true
  7861. });
  7862. Object.defineProperty(AutoRotationBehavior.prototype, "rotationInProgress", {
  7863. /**
  7864. * Gets a value indicating if the camera is currently rotating because of this behavior
  7865. */
  7866. get: function () {
  7867. return Math.abs(this._cameraRotationSpeed) > 0;
  7868. },
  7869. enumerable: true,
  7870. configurable: true
  7871. });
  7872. /**
  7873. * Initializes the behavior.
  7874. */
  7875. AutoRotationBehavior.prototype.init = function () {
  7876. // Do notihng
  7877. };
  7878. /**
  7879. * Attaches the behavior to its arc rotate camera.
  7880. * @param camera Defines the camera to attach the behavior to
  7881. */
  7882. AutoRotationBehavior.prototype.attach = function (camera) {
  7883. var _this = this;
  7884. this._attachedCamera = camera;
  7885. var scene = this._attachedCamera.getScene();
  7886. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7887. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  7888. _this._isPointerDown = true;
  7889. return;
  7890. }
  7891. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  7892. _this._isPointerDown = false;
  7893. }
  7894. });
  7895. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7896. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7897. var dt = 0;
  7898. if (_this._lastFrameTime != null) {
  7899. dt = now - _this._lastFrameTime;
  7900. }
  7901. _this._lastFrameTime = now;
  7902. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7903. _this._applyUserInteraction();
  7904. var timeToRotation = now - _this._lastInteractionTime - _this._idleRotationWaitTime;
  7905. var scale = Math.max(Math.min(timeToRotation / (_this._idleRotationSpinupTime), 1), 0);
  7906. _this._cameraRotationSpeed = _this._idleRotationSpeed * scale;
  7907. // Step camera rotation by rotation speed
  7908. if (_this._attachedCamera) {
  7909. _this._attachedCamera.alpha -= _this._cameraRotationSpeed * (dt / 1000);
  7910. }
  7911. });
  7912. };
  7913. /**
  7914. * Detaches the behavior from its current arc rotate camera.
  7915. */
  7916. AutoRotationBehavior.prototype.detach = function () {
  7917. if (!this._attachedCamera) {
  7918. return;
  7919. }
  7920. var scene = this._attachedCamera.getScene();
  7921. if (this._onPrePointerObservableObserver) {
  7922. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  7923. }
  7924. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7925. this._attachedCamera = null;
  7926. };
  7927. /**
  7928. * Returns true if user is scrolling.
  7929. * @return true if user is scrolling.
  7930. */
  7931. AutoRotationBehavior.prototype._userIsZooming = function () {
  7932. if (!this._attachedCamera) {
  7933. return false;
  7934. }
  7935. return this._attachedCamera.inertialRadiusOffset !== 0;
  7936. };
  7937. AutoRotationBehavior.prototype._shouldAnimationStopForInteraction = function () {
  7938. if (!this._attachedCamera) {
  7939. return false;
  7940. }
  7941. var zoomHasHitLimit = false;
  7942. if (this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0) {
  7943. zoomHasHitLimit = true;
  7944. }
  7945. // Update the record of previous radius - works as an approx. indicator of hitting radius limits
  7946. this._lastFrameRadius = this._attachedCamera.radius;
  7947. return this._zoomStopsAnimation ? zoomHasHitLimit : this._userIsZooming();
  7948. };
  7949. /**
  7950. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  7951. */
  7952. AutoRotationBehavior.prototype._applyUserInteraction = function () {
  7953. if (this._userIsMoving() && !this._shouldAnimationStopForInteraction()) {
  7954. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7955. }
  7956. };
  7957. // Tools
  7958. AutoRotationBehavior.prototype._userIsMoving = function () {
  7959. if (!this._attachedCamera) {
  7960. return false;
  7961. }
  7962. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  7963. this._attachedCamera.inertialBetaOffset !== 0 ||
  7964. this._attachedCamera.inertialRadiusOffset !== 0 ||
  7965. this._attachedCamera.inertialPanningX !== 0 ||
  7966. this._attachedCamera.inertialPanningY !== 0 ||
  7967. this._isPointerDown;
  7968. };
  7969. return AutoRotationBehavior;
  7970. }());
  7971. /***/ }),
  7972. /***/ "./Behaviors/Cameras/bouncingBehavior.ts":
  7973. /*!***********************************************!*\
  7974. !*** ./Behaviors/Cameras/bouncingBehavior.ts ***!
  7975. \***********************************************/
  7976. /*! exports provided: BouncingBehavior */
  7977. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7978. "use strict";
  7979. __webpack_require__.r(__webpack_exports__);
  7980. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return BouncingBehavior; });
  7981. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7982. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7983. /**
  7984. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  7985. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7986. */
  7987. var BouncingBehavior = /** @class */ (function () {
  7988. function BouncingBehavior() {
  7989. /**
  7990. * The duration of the animation, in milliseconds
  7991. */
  7992. this.transitionDuration = 450;
  7993. /**
  7994. * Length of the distance animated by the transition when lower radius is reached
  7995. */
  7996. this.lowerRadiusTransitionRange = 2;
  7997. /**
  7998. * Length of the distance animated by the transition when upper radius is reached
  7999. */
  8000. this.upperRadiusTransitionRange = -2;
  8001. this._autoTransitionRange = false;
  8002. // Animations
  8003. this._radiusIsAnimating = false;
  8004. this._radiusBounceTransition = null;
  8005. this._animatables = new Array();
  8006. }
  8007. Object.defineProperty(BouncingBehavior.prototype, "name", {
  8008. /**
  8009. * Gets the name of the behavior.
  8010. */
  8011. get: function () {
  8012. return "Bouncing";
  8013. },
  8014. enumerable: true,
  8015. configurable: true
  8016. });
  8017. Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
  8018. /**
  8019. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  8020. */
  8021. get: function () {
  8022. return this._autoTransitionRange;
  8023. },
  8024. /**
  8025. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  8026. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  8027. */
  8028. set: function (value) {
  8029. var _this = this;
  8030. if (this._autoTransitionRange === value) {
  8031. return;
  8032. }
  8033. this._autoTransitionRange = value;
  8034. var camera = this._attachedCamera;
  8035. if (!camera) {
  8036. return;
  8037. }
  8038. if (value) {
  8039. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8040. if (!mesh) {
  8041. return;
  8042. }
  8043. mesh.computeWorldMatrix(true);
  8044. var diagonal = mesh.getBoundingInfo().diagonalLength;
  8045. _this.lowerRadiusTransitionRange = diagonal * 0.05;
  8046. _this.upperRadiusTransitionRange = diagonal * 0.05;
  8047. });
  8048. }
  8049. else if (this._onMeshTargetChangedObserver) {
  8050. camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8051. }
  8052. },
  8053. enumerable: true,
  8054. configurable: true
  8055. });
  8056. /**
  8057. * Initializes the behavior.
  8058. */
  8059. BouncingBehavior.prototype.init = function () {
  8060. // Do notihng
  8061. };
  8062. /**
  8063. * Attaches the behavior to its arc rotate camera.
  8064. * @param camera Defines the camera to attach the behavior to
  8065. */
  8066. BouncingBehavior.prototype.attach = function (camera) {
  8067. var _this = this;
  8068. this._attachedCamera = camera;
  8069. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8070. if (!_this._attachedCamera) {
  8071. return;
  8072. }
  8073. // Add the bounce animation to the lower radius limit
  8074. if (_this._isRadiusAtLimit(_this._attachedCamera.lowerRadiusLimit)) {
  8075. _this._applyBoundRadiusAnimation(_this.lowerRadiusTransitionRange);
  8076. }
  8077. // Add the bounce animation to the upper radius limit
  8078. if (_this._isRadiusAtLimit(_this._attachedCamera.upperRadiusLimit)) {
  8079. _this._applyBoundRadiusAnimation(_this.upperRadiusTransitionRange);
  8080. }
  8081. });
  8082. };
  8083. /**
  8084. * Detaches the behavior from its current arc rotate camera.
  8085. */
  8086. BouncingBehavior.prototype.detach = function () {
  8087. if (!this._attachedCamera) {
  8088. return;
  8089. }
  8090. if (this._onAfterCheckInputsObserver) {
  8091. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8092. }
  8093. if (this._onMeshTargetChangedObserver) {
  8094. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8095. }
  8096. this._attachedCamera = null;
  8097. };
  8098. /**
  8099. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  8100. * @param radiusLimit The limit to check against.
  8101. * @return Bool to indicate if at limit.
  8102. */
  8103. BouncingBehavior.prototype._isRadiusAtLimit = function (radiusLimit) {
  8104. if (!this._attachedCamera) {
  8105. return false;
  8106. }
  8107. if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
  8108. return true;
  8109. }
  8110. return false;
  8111. };
  8112. /**
  8113. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  8114. * @param radiusDelta The delta by which to animate to. Can be negative.
  8115. */
  8116. BouncingBehavior.prototype._applyBoundRadiusAnimation = function (radiusDelta) {
  8117. var _this = this;
  8118. if (!this._attachedCamera) {
  8119. return;
  8120. }
  8121. if (!this._radiusBounceTransition) {
  8122. BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
  8123. this._radiusBounceTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
  8124. }
  8125. // Prevent zoom until bounce has completed
  8126. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
  8127. this._attachedCamera.wheelPrecision = Infinity;
  8128. this._attachedCamera.inertialRadiusOffset = 0;
  8129. // Animate to the radius limit
  8130. this.stopAllAnimations();
  8131. this._radiusIsAnimating = true;
  8132. 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(); });
  8133. if (animatable) {
  8134. this._animatables.push(animatable);
  8135. }
  8136. };
  8137. /**
  8138. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  8139. */
  8140. BouncingBehavior.prototype._clearAnimationLocks = function () {
  8141. this._radiusIsAnimating = false;
  8142. if (this._attachedCamera) {
  8143. this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
  8144. }
  8145. };
  8146. /**
  8147. * Stops and removes all animations that have been applied to the camera
  8148. */
  8149. BouncingBehavior.prototype.stopAllAnimations = function () {
  8150. if (this._attachedCamera) {
  8151. this._attachedCamera.animations = [];
  8152. }
  8153. while (this._animatables.length) {
  8154. this._animatables[0].onAnimationEnd = null;
  8155. this._animatables[0].stop();
  8156. this._animatables.shift();
  8157. }
  8158. };
  8159. /**
  8160. * The easing function used by animations
  8161. */
  8162. BouncingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["BackEase"](0.3);
  8163. /**
  8164. * The easing mode used by animations
  8165. */
  8166. BouncingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEOUT;
  8167. return BouncingBehavior;
  8168. }());
  8169. /***/ }),
  8170. /***/ "./Behaviors/Cameras/framingBehavior.ts":
  8171. /*!**********************************************!*\
  8172. !*** ./Behaviors/Cameras/framingBehavior.ts ***!
  8173. \**********************************************/
  8174. /*! exports provided: FramingBehavior */
  8175. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8176. "use strict";
  8177. __webpack_require__.r(__webpack_exports__);
  8178. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return FramingBehavior; });
  8179. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  8180. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  8181. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  8182. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  8183. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8184. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  8185. /**
  8186. * 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.
  8187. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8188. */
  8189. var FramingBehavior = /** @class */ (function () {
  8190. function FramingBehavior() {
  8191. this._mode = FramingBehavior.FitFrustumSidesMode;
  8192. this._radiusScale = 1.0;
  8193. this._positionScale = 0.5;
  8194. this._defaultElevation = 0.3;
  8195. this._elevationReturnTime = 1500;
  8196. this._elevationReturnWaitTime = 1000;
  8197. this._zoomStopsAnimation = false;
  8198. this._framingTime = 1500;
  8199. /**
  8200. * Define if the behavior should automatically change the configured
  8201. * camera limits and sensibilities.
  8202. */
  8203. this.autoCorrectCameraLimitsAndSensibility = true;
  8204. this._isPointerDown = false;
  8205. this._lastInteractionTime = -Infinity;
  8206. // Framing control
  8207. this._animatables = new Array();
  8208. this._betaIsAnimating = false;
  8209. }
  8210. Object.defineProperty(FramingBehavior.prototype, "name", {
  8211. /**
  8212. * Gets the name of the behavior.
  8213. */
  8214. get: function () {
  8215. return "Framing";
  8216. },
  8217. enumerable: true,
  8218. configurable: true
  8219. });
  8220. Object.defineProperty(FramingBehavior.prototype, "mode", {
  8221. /**
  8222. * Gets current mode used by the behavior.
  8223. */
  8224. get: function () {
  8225. return this._mode;
  8226. },
  8227. /**
  8228. * Sets the current mode used by the behavior
  8229. */
  8230. set: function (mode) {
  8231. this._mode = mode;
  8232. },
  8233. enumerable: true,
  8234. configurable: true
  8235. });
  8236. Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
  8237. /**
  8238. * Gets the scale applied to the radius
  8239. */
  8240. get: function () {
  8241. return this._radiusScale;
  8242. },
  8243. /**
  8244. * Sets the scale applied to the radius (1 by default)
  8245. */
  8246. set: function (radius) {
  8247. this._radiusScale = radius;
  8248. },
  8249. enumerable: true,
  8250. configurable: true
  8251. });
  8252. Object.defineProperty(FramingBehavior.prototype, "positionScale", {
  8253. /**
  8254. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8255. */
  8256. get: function () {
  8257. return this._positionScale;
  8258. },
  8259. /**
  8260. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8261. */
  8262. set: function (scale) {
  8263. this._positionScale = scale;
  8264. },
  8265. enumerable: true,
  8266. configurable: true
  8267. });
  8268. Object.defineProperty(FramingBehavior.prototype, "defaultElevation", {
  8269. /**
  8270. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8271. * behaviour is triggered, in radians.
  8272. */
  8273. get: function () {
  8274. return this._defaultElevation;
  8275. },
  8276. /**
  8277. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8278. * behaviour is triggered, in radians.
  8279. */
  8280. set: function (elevation) {
  8281. this._defaultElevation = elevation;
  8282. },
  8283. enumerable: true,
  8284. configurable: true
  8285. });
  8286. Object.defineProperty(FramingBehavior.prototype, "elevationReturnTime", {
  8287. /**
  8288. * Gets the time (in milliseconds) taken to return to the default beta position.
  8289. * Negative value indicates camera should not return to default.
  8290. */
  8291. get: function () {
  8292. return this._elevationReturnTime;
  8293. },
  8294. /**
  8295. * Sets the time (in milliseconds) taken to return to the default beta position.
  8296. * Negative value indicates camera should not return to default.
  8297. */
  8298. set: function (speed) {
  8299. this._elevationReturnTime = speed;
  8300. },
  8301. enumerable: true,
  8302. configurable: true
  8303. });
  8304. Object.defineProperty(FramingBehavior.prototype, "elevationReturnWaitTime", {
  8305. /**
  8306. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8307. */
  8308. get: function () {
  8309. return this._elevationReturnWaitTime;
  8310. },
  8311. /**
  8312. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8313. */
  8314. set: function (time) {
  8315. this._elevationReturnWaitTime = time;
  8316. },
  8317. enumerable: true,
  8318. configurable: true
  8319. });
  8320. Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
  8321. /**
  8322. * Gets the flag that indicates if user zooming should stop animation.
  8323. */
  8324. get: function () {
  8325. return this._zoomStopsAnimation;
  8326. },
  8327. /**
  8328. * Sets the flag that indicates if user zooming should stop animation.
  8329. */
  8330. set: function (flag) {
  8331. this._zoomStopsAnimation = flag;
  8332. },
  8333. enumerable: true,
  8334. configurable: true
  8335. });
  8336. Object.defineProperty(FramingBehavior.prototype, "framingTime", {
  8337. /**
  8338. * Gets the transition time when framing the mesh, in milliseconds
  8339. */
  8340. get: function () {
  8341. return this._framingTime;
  8342. },
  8343. /**
  8344. * Sets the transition time when framing the mesh, in milliseconds
  8345. */
  8346. set: function (time) {
  8347. this._framingTime = time;
  8348. },
  8349. enumerable: true,
  8350. configurable: true
  8351. });
  8352. /**
  8353. * Initializes the behavior.
  8354. */
  8355. FramingBehavior.prototype.init = function () {
  8356. // Do notihng
  8357. };
  8358. /**
  8359. * Attaches the behavior to its arc rotate camera.
  8360. * @param camera Defines the camera to attach the behavior to
  8361. */
  8362. FramingBehavior.prototype.attach = function (camera) {
  8363. var _this = this;
  8364. this._attachedCamera = camera;
  8365. var scene = this._attachedCamera.getScene();
  8366. FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
  8367. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  8368. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  8369. _this._isPointerDown = true;
  8370. return;
  8371. }
  8372. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  8373. _this._isPointerDown = false;
  8374. }
  8375. });
  8376. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8377. if (mesh) {
  8378. _this.zoomOnMesh(mesh);
  8379. }
  8380. });
  8381. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8382. // Stop the animation if there is user interaction and the animation should stop for this interaction
  8383. _this._applyUserInteraction();
  8384. // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
  8385. // back to the default position after a given timeout
  8386. _this._maintainCameraAboveGround();
  8387. });
  8388. };
  8389. /**
  8390. * Detaches the behavior from its current arc rotate camera.
  8391. */
  8392. FramingBehavior.prototype.detach = function () {
  8393. if (!this._attachedCamera) {
  8394. return;
  8395. }
  8396. var scene = this._attachedCamera.getScene();
  8397. if (this._onPrePointerObservableObserver) {
  8398. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8399. }
  8400. if (this._onAfterCheckInputsObserver) {
  8401. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8402. }
  8403. if (this._onMeshTargetChangedObserver) {
  8404. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8405. }
  8406. this._attachedCamera = null;
  8407. };
  8408. /**
  8409. * Targets the given mesh and updates zoom level accordingly.
  8410. * @param mesh The mesh to target.
  8411. * @param radius Optional. If a cached radius position already exists, overrides default.
  8412. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8413. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8414. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8415. */
  8416. FramingBehavior.prototype.zoomOnMesh = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8417. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8418. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8419. mesh.computeWorldMatrix(true);
  8420. var boundingBox = mesh.getBoundingInfo().boundingBox;
  8421. this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
  8422. };
  8423. /**
  8424. * Targets the given mesh with its children and updates zoom level accordingly.
  8425. * @param mesh The mesh to target.
  8426. * @param radius Optional. If a cached radius position already exists, overrides default.
  8427. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8428. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8429. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8430. */
  8431. FramingBehavior.prototype.zoomOnMeshHierarchy = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8432. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8433. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8434. mesh.computeWorldMatrix(true);
  8435. var boundingBox = mesh.getHierarchyBoundingVectors(true);
  8436. this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
  8437. };
  8438. /**
  8439. * Targets the given meshes with their children and updates zoom level accordingly.
  8440. * @param meshes The mesh to target.
  8441. * @param radius Optional. If a cached radius position already exists, overrides default.
  8442. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8443. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8444. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8445. */
  8446. FramingBehavior.prototype.zoomOnMeshesHierarchy = function (meshes, focusOnOriginXZ, onAnimationEnd) {
  8447. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8448. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8449. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  8450. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  8451. for (var i = 0; i < meshes.length; i++) {
  8452. var boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
  8453. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.min, min, max);
  8454. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.max, min, max);
  8455. }
  8456. this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
  8457. };
  8458. /**
  8459. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  8460. * @param minimumWorld Determines the smaller position of the bounding box extend
  8461. * @param maximumWorld Determines the bigger position of the bounding box extend
  8462. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8463. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8464. */
  8465. FramingBehavior.prototype.zoomOnBoundingInfo = function (minimumWorld, maximumWorld, focusOnOriginXZ, onAnimationEnd) {
  8466. var _this = this;
  8467. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8468. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8469. var zoomTarget;
  8470. if (!this._attachedCamera) {
  8471. return;
  8472. }
  8473. // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
  8474. var bottom = minimumWorld.y;
  8475. var top = maximumWorld.y;
  8476. var zoomTargetY = bottom + (top - bottom) * this._positionScale;
  8477. var radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
  8478. if (focusOnOriginXZ) {
  8479. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, zoomTargetY, 0);
  8480. }
  8481. else {
  8482. var centerWorld = minimumWorld.add(radiusWorld);
  8483. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](centerWorld.x, zoomTargetY, centerWorld.z);
  8484. }
  8485. if (!this._vectorTransition) {
  8486. this._vectorTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("target", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
  8487. }
  8488. this._betaIsAnimating = true;
  8489. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  8490. if (animatable) {
  8491. this._animatables.push(animatable);
  8492. }
  8493. // sets the radius and lower radius bounds
  8494. // Small delta ensures camera is not always at lower zoom limit.
  8495. var radius = 0;
  8496. if (this._mode === FramingBehavior.FitFrustumSidesMode) {
  8497. var position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8498. if (this.autoCorrectCameraLimitsAndSensibility) {
  8499. this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
  8500. }
  8501. radius = position;
  8502. }
  8503. else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8504. radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8505. if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {
  8506. this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
  8507. }
  8508. }
  8509. // Set sensibilities
  8510. if (this.autoCorrectCameraLimitsAndSensibility) {
  8511. var extend = maximumWorld.subtract(minimumWorld).length();
  8512. this._attachedCamera.panningSensibility = 5000 / extend;
  8513. this._attachedCamera.wheelPrecision = 100 / radius;
  8514. }
  8515. // transition to new radius
  8516. if (!this._radiusTransition) {
  8517. this._radiusTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8518. }
  8519. animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
  8520. _this.stopAllAnimations();
  8521. if (onAnimationEnd) {
  8522. onAnimationEnd();
  8523. }
  8524. if (_this._attachedCamera && _this._attachedCamera.useInputToRestoreState) {
  8525. _this._attachedCamera.storeState();
  8526. }
  8527. });
  8528. if (animatable) {
  8529. this._animatables.push(animatable);
  8530. }
  8531. };
  8532. /**
  8533. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  8534. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  8535. * frustum width.
  8536. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  8537. * to fully enclose the mesh in the viewing frustum.
  8538. */
  8539. FramingBehavior.prototype._calculateLowerRadiusFromModelBoundingSphere = function (minimumWorld, maximumWorld) {
  8540. var size = maximumWorld.subtract(minimumWorld);
  8541. var boxVectorGlobalDiagonal = size.length();
  8542. var frustumSlope = this._getFrustumSlope();
  8543. // Formula for setting distance
  8544. // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
  8545. var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
  8546. // Horizon distance
  8547. var radius = radiusWithoutFraming * this._radiusScale;
  8548. var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
  8549. var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
  8550. var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
  8551. var camera = this._attachedCamera;
  8552. if (!camera) {
  8553. return 0;
  8554. }
  8555. if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8556. // Don't exceed the requested limit
  8557. distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
  8558. }
  8559. // Don't exceed the upper radius limit
  8560. if (camera.upperRadiusLimit) {
  8561. distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
  8562. }
  8563. return distance;
  8564. };
  8565. /**
  8566. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  8567. * is automatically returned to its default position (expected to be above ground plane).
  8568. */
  8569. FramingBehavior.prototype._maintainCameraAboveGround = function () {
  8570. var _this = this;
  8571. if (this._elevationReturnTime < 0) {
  8572. return;
  8573. }
  8574. var timeSinceInteraction = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now - this._lastInteractionTime;
  8575. var defaultBeta = Math.PI * 0.5 - this._defaultElevation;
  8576. var limitBeta = Math.PI * 0.5;
  8577. // Bring the camera back up if below the ground plane
  8578. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
  8579. this._betaIsAnimating = true;
  8580. //Transition to new position
  8581. this.stopAllAnimations();
  8582. if (!this._betaTransition) {
  8583. this._betaTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("beta", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8584. }
  8585. var animatabe = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function () {
  8586. _this._clearAnimationLocks();
  8587. _this.stopAllAnimations();
  8588. });
  8589. if (animatabe) {
  8590. this._animatables.push(animatabe);
  8591. }
  8592. }
  8593. };
  8594. /**
  8595. * Returns the frustum slope based on the canvas ratio and camera FOV
  8596. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  8597. */
  8598. FramingBehavior.prototype._getFrustumSlope = function () {
  8599. // Calculate the viewport ratio
  8600. // Aspect Ratio is Height/Width.
  8601. var camera = this._attachedCamera;
  8602. if (!camera) {
  8603. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"].Zero();
  8604. }
  8605. var engine = camera.getScene().getEngine();
  8606. var aspectRatio = engine.getAspectRatio(camera);
  8607. // Camera FOV is the vertical field of view (top-bottom) in radians.
  8608. // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
  8609. var frustumSlopeY = Math.tan(camera.fov / 2);
  8610. // Slope of the frustum left/right planes in view space, relative to the forward vector.
  8611. // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
  8612. // along the forward vector.
  8613. var frustumSlopeX = frustumSlopeY * aspectRatio;
  8614. return new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](frustumSlopeX, frustumSlopeY);
  8615. };
  8616. /**
  8617. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  8618. */
  8619. FramingBehavior.prototype._clearAnimationLocks = function () {
  8620. this._betaIsAnimating = false;
  8621. };
  8622. /**
  8623. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8624. */
  8625. FramingBehavior.prototype._applyUserInteraction = function () {
  8626. if (this.isUserIsMoving) {
  8627. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now;
  8628. this.stopAllAnimations();
  8629. this._clearAnimationLocks();
  8630. }
  8631. };
  8632. /**
  8633. * Stops and removes all animations that have been applied to the camera
  8634. */
  8635. FramingBehavior.prototype.stopAllAnimations = function () {
  8636. if (this._attachedCamera) {
  8637. this._attachedCamera.animations = [];
  8638. }
  8639. while (this._animatables.length) {
  8640. if (this._animatables[0]) {
  8641. this._animatables[0].onAnimationEnd = null;
  8642. this._animatables[0].stop();
  8643. }
  8644. this._animatables.shift();
  8645. }
  8646. };
  8647. Object.defineProperty(FramingBehavior.prototype, "isUserIsMoving", {
  8648. /**
  8649. * Gets a value indicating if the user is moving the camera
  8650. */
  8651. get: function () {
  8652. if (!this._attachedCamera) {
  8653. return false;
  8654. }
  8655. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8656. this._attachedCamera.inertialBetaOffset !== 0 ||
  8657. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8658. this._attachedCamera.inertialPanningX !== 0 ||
  8659. this._attachedCamera.inertialPanningY !== 0 ||
  8660. this._isPointerDown;
  8661. },
  8662. enumerable: true,
  8663. configurable: true
  8664. });
  8665. /**
  8666. * The easing function used by animations
  8667. */
  8668. FramingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]();
  8669. /**
  8670. * The easing mode used by animations
  8671. */
  8672. FramingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEINOUT;
  8673. // Statics
  8674. /**
  8675. * The camera can move all the way towards the mesh.
  8676. */
  8677. FramingBehavior.IgnoreBoundsSizeMode = 0;
  8678. /**
  8679. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  8680. */
  8681. FramingBehavior.FitFrustumSidesMode = 1;
  8682. return FramingBehavior;
  8683. }());
  8684. /***/ }),
  8685. /***/ "./Behaviors/Cameras/index.ts":
  8686. /*!************************************!*\
  8687. !*** ./Behaviors/Cameras/index.ts ***!
  8688. \************************************/
  8689. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior */
  8690. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8691. "use strict";
  8692. __webpack_require__.r(__webpack_exports__);
  8693. /* harmony import */ var _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  8694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  8695. /* harmony import */ var _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  8696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__["BouncingBehavior"]; });
  8697. /* harmony import */ var _framingBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  8698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _framingBehavior__WEBPACK_IMPORTED_MODULE_2__["FramingBehavior"]; });
  8699. /***/ }),
  8700. /***/ "./Behaviors/Meshes/attachToBoxBehavior.ts":
  8701. /*!*************************************************!*\
  8702. !*** ./Behaviors/Meshes/attachToBoxBehavior.ts ***!
  8703. \*************************************************/
  8704. /*! exports provided: AttachToBoxBehavior */
  8705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8706. "use strict";
  8707. __webpack_require__.r(__webpack_exports__);
  8708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return AttachToBoxBehavior; });
  8709. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8710. /**
  8711. * @hidden
  8712. */
  8713. var FaceDirectionInfo = /** @class */ (function () {
  8714. function FaceDirectionInfo(direction, rotatedDirection, diff, ignore) {
  8715. if (rotatedDirection === void 0) { rotatedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](); }
  8716. if (diff === void 0) { diff = 0; }
  8717. if (ignore === void 0) { ignore = false; }
  8718. this.direction = direction;
  8719. this.rotatedDirection = rotatedDirection;
  8720. this.diff = diff;
  8721. this.ignore = ignore;
  8722. }
  8723. return FaceDirectionInfo;
  8724. }());
  8725. /**
  8726. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  8727. */
  8728. var AttachToBoxBehavior = /** @class */ (function () {
  8729. /**
  8730. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  8731. * @param ui The transform node that should be attched to the mesh
  8732. */
  8733. function AttachToBoxBehavior(ui) {
  8734. this.ui = ui;
  8735. /**
  8736. * The name of the behavior
  8737. */
  8738. this.name = "AttachToBoxBehavior";
  8739. /**
  8740. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  8741. */
  8742. this.distanceAwayFromFace = 0.15;
  8743. /**
  8744. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  8745. */
  8746. this.distanceAwayFromBottomOfFace = 0.15;
  8747. 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))];
  8748. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8749. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  8750. this._zeroVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  8751. this._lookAtTmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8752. /* Does nothing */
  8753. }
  8754. /**
  8755. * Initializes the behavior
  8756. */
  8757. AttachToBoxBehavior.prototype.init = function () {
  8758. /* Does nothing */
  8759. };
  8760. AttachToBoxBehavior.prototype._closestFace = function (targetDirection) {
  8761. var _this = this;
  8762. // Go over each face and calculate the angle between the face's normal and targetDirection
  8763. this._faceVectors.forEach(function (v) {
  8764. if (!_this._target.rotationQuaternion) {
  8765. _this._target.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this._target.rotation.y, _this._target.rotation.x, _this._target.rotation.z);
  8766. }
  8767. _this._target.rotationQuaternion.toRotationMatrix(_this._tmpMatrix);
  8768. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(v.direction, _this._tmpMatrix, v.rotatedDirection);
  8769. v.diff = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetAngleBetweenVectors(v.rotatedDirection, targetDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v.rotatedDirection, targetDirection));
  8770. });
  8771. // Return the face information of the one with the normal closeset to target direction
  8772. return this._faceVectors.reduce(function (min, p) {
  8773. if (min.ignore) {
  8774. return p;
  8775. }
  8776. else if (p.ignore) {
  8777. return min;
  8778. }
  8779. else {
  8780. return min.diff < p.diff ? min : p;
  8781. }
  8782. }, this._faceVectors[0]);
  8783. };
  8784. AttachToBoxBehavior.prototype._lookAtToRef = function (pos, up, ref) {
  8785. if (up === void 0) { up = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0); }
  8786. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);
  8787. this._lookAtTmpMatrix.invert();
  8788. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);
  8789. };
  8790. /**
  8791. * Attaches the AttachToBoxBehavior to the passed in mesh
  8792. * @param target The mesh that the specified node will be attached to
  8793. */
  8794. AttachToBoxBehavior.prototype.attach = function (target) {
  8795. var _this = this;
  8796. this._target = target;
  8797. this._scene = this._target.getScene();
  8798. // Every frame, update the app bars position
  8799. this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8800. if (!_this._scene.activeCamera) {
  8801. return;
  8802. }
  8803. // Find the face closest to the cameras position
  8804. var cameraPos = _this._scene.activeCamera.position;
  8805. if (_this._scene.activeCamera.devicePosition) {
  8806. cameraPos = _this._scene.activeCamera.devicePosition;
  8807. }
  8808. var facing = _this._closestFace(cameraPos.subtract(target.position));
  8809. if (_this._scene.activeCamera.leftCamera) {
  8810. _this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8811. }
  8812. else {
  8813. _this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8814. }
  8815. // Get camera up direction
  8816. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _this._tmpMatrix, _this._tmpVector);
  8817. // Ignore faces to not select a parrelel face for the up vector of the UI
  8818. _this._faceVectors.forEach(function (v) {
  8819. if (facing.direction.x && v.direction.x) {
  8820. v.ignore = true;
  8821. }
  8822. if (facing.direction.y && v.direction.y) {
  8823. v.ignore = true;
  8824. }
  8825. if (facing.direction.z && v.direction.z) {
  8826. v.ignore = true;
  8827. }
  8828. });
  8829. var facingUp = _this._closestFace(_this._tmpVector);
  8830. // Unignore faces
  8831. _this._faceVectors.forEach(function (v) {
  8832. v.ignore = false;
  8833. });
  8834. // Position the app bar on that face
  8835. _this.ui.position.copyFrom(target.position);
  8836. if (facing.direction.x) {
  8837. facing.rotatedDirection.scaleToRef((target.scaling.x / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8838. _this.ui.position.addInPlace(_this._tmpVector);
  8839. }
  8840. if (facing.direction.y) {
  8841. facing.rotatedDirection.scaleToRef((target.scaling.y / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8842. _this.ui.position.addInPlace(_this._tmpVector);
  8843. }
  8844. if (facing.direction.z) {
  8845. facing.rotatedDirection.scaleToRef((target.scaling.z / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8846. _this.ui.position.addInPlace(_this._tmpVector);
  8847. }
  8848. // Rotate to be oriented properly to the camera
  8849. if (!_this.ui.rotationQuaternion) {
  8850. _this.ui.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this.ui.rotation.y, _this.ui.rotation.x, _this.ui.rotation.z);
  8851. }
  8852. facing.rotatedDirection.scaleToRef(-1, _this._tmpVector);
  8853. _this._lookAtToRef(_this._tmpVector, facingUp.rotatedDirection, _this.ui.rotationQuaternion);
  8854. // Place ui the correct distance from the bottom of the mesh
  8855. if (facingUp.direction.x) {
  8856. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.x / 2, _this._tmpVector);
  8857. }
  8858. if (facingUp.direction.y) {
  8859. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.y / 2, _this._tmpVector);
  8860. }
  8861. if (facingUp.direction.z) {
  8862. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.z / 2, _this._tmpVector);
  8863. }
  8864. _this.ui.position.addInPlace(_this._tmpVector);
  8865. });
  8866. };
  8867. /**
  8868. * Detaches the behavior from the mesh
  8869. */
  8870. AttachToBoxBehavior.prototype.detach = function () {
  8871. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
  8872. };
  8873. return AttachToBoxBehavior;
  8874. }());
  8875. /***/ }),
  8876. /***/ "./Behaviors/Meshes/fadeInOutBehavior.ts":
  8877. /*!***********************************************!*\
  8878. !*** ./Behaviors/Meshes/fadeInOutBehavior.ts ***!
  8879. \***********************************************/
  8880. /*! exports provided: FadeInOutBehavior */
  8881. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8882. "use strict";
  8883. __webpack_require__.r(__webpack_exports__);
  8884. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return FadeInOutBehavior; });
  8885. /**
  8886. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  8887. */
  8888. var FadeInOutBehavior = /** @class */ (function () {
  8889. /**
  8890. * Instatiates the FadeInOutBehavior
  8891. */
  8892. function FadeInOutBehavior() {
  8893. var _this = this;
  8894. /**
  8895. * Time in milliseconds to delay before fading in (Default: 0)
  8896. */
  8897. this.delay = 0;
  8898. /**
  8899. * Time in milliseconds for the mesh to fade in (Default: 300)
  8900. */
  8901. this.fadeInTime = 300;
  8902. this._millisecondsPerFrame = 1000 / 60;
  8903. this._hovered = false;
  8904. this._hoverValue = 0;
  8905. this._ownerNode = null;
  8906. this._update = function () {
  8907. if (_this._ownerNode) {
  8908. _this._hoverValue += _this._hovered ? _this._millisecondsPerFrame : -_this._millisecondsPerFrame;
  8909. _this._setAllVisibility(_this._ownerNode, (_this._hoverValue - _this.delay) / _this.fadeInTime);
  8910. if (_this._ownerNode.visibility > 1) {
  8911. _this._setAllVisibility(_this._ownerNode, 1);
  8912. _this._hoverValue = _this.fadeInTime + _this.delay;
  8913. return;
  8914. }
  8915. else if (_this._ownerNode.visibility < 0) {
  8916. _this._setAllVisibility(_this._ownerNode, 0);
  8917. if (_this._hoverValue < 0) {
  8918. _this._hoverValue = 0;
  8919. return;
  8920. }
  8921. }
  8922. setTimeout(_this._update, _this._millisecondsPerFrame);
  8923. }
  8924. };
  8925. }
  8926. Object.defineProperty(FadeInOutBehavior.prototype, "name", {
  8927. /**
  8928. * The name of the behavior
  8929. */
  8930. get: function () {
  8931. return "FadeInOut";
  8932. },
  8933. enumerable: true,
  8934. configurable: true
  8935. });
  8936. /**
  8937. * Initializes the behavior
  8938. */
  8939. FadeInOutBehavior.prototype.init = function () {
  8940. };
  8941. /**
  8942. * Attaches the fade behavior on the passed in mesh
  8943. * @param ownerNode The mesh that will be faded in/out once attached
  8944. */
  8945. FadeInOutBehavior.prototype.attach = function (ownerNode) {
  8946. this._ownerNode = ownerNode;
  8947. this._setAllVisibility(this._ownerNode, 0);
  8948. };
  8949. /**
  8950. * Detaches the behavior from the mesh
  8951. */
  8952. FadeInOutBehavior.prototype.detach = function () {
  8953. this._ownerNode = null;
  8954. };
  8955. /**
  8956. * Triggers the mesh to begin fading in or out
  8957. * @param value if the object should fade in or out (true to fade in)
  8958. */
  8959. FadeInOutBehavior.prototype.fadeIn = function (value) {
  8960. this._hovered = value;
  8961. this._update();
  8962. };
  8963. FadeInOutBehavior.prototype._setAllVisibility = function (mesh, value) {
  8964. var _this = this;
  8965. mesh.visibility = value;
  8966. mesh.getChildMeshes().forEach(function (c) {
  8967. _this._setAllVisibility(c, value);
  8968. });
  8969. };
  8970. return FadeInOutBehavior;
  8971. }());
  8972. /***/ }),
  8973. /***/ "./Behaviors/Meshes/index.ts":
  8974. /*!***********************************!*\
  8975. !*** ./Behaviors/Meshes/index.ts ***!
  8976. \***********************************/
  8977. /*! exports provided: AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  8978. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8979. "use strict";
  8980. __webpack_require__.r(__webpack_exports__);
  8981. /* harmony import */ var _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attachToBoxBehavior */ "./Behaviors/Meshes/attachToBoxBehavior.ts");
  8982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  8983. /* harmony import */ var _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fadeInOutBehavior */ "./Behaviors/Meshes/fadeInOutBehavior.ts");
  8984. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  8985. /* harmony import */ var _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multiPointerScaleBehavior */ "./Behaviors/Meshes/multiPointerScaleBehavior.ts");
  8986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__["MultiPointerScaleBehavior"]; });
  8987. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__["PointerDragBehavior"]; });
  8989. /* harmony import */ var _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  8990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__["SixDofDragBehavior"]; });
  8991. /***/ }),
  8992. /***/ "./Behaviors/Meshes/multiPointerScaleBehavior.ts":
  8993. /*!*******************************************************!*\
  8994. !*** ./Behaviors/Meshes/multiPointerScaleBehavior.ts ***!
  8995. \*******************************************************/
  8996. /*! exports provided: MultiPointerScaleBehavior */
  8997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8998. "use strict";
  8999. __webpack_require__.r(__webpack_exports__);
  9000. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return MultiPointerScaleBehavior; });
  9001. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  9002. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9003. /**
  9004. * A behavior that when attached to a mesh will allow the mesh to be scaled
  9005. */
  9006. var MultiPointerScaleBehavior = /** @class */ (function () {
  9007. /**
  9008. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  9009. */
  9010. function MultiPointerScaleBehavior() {
  9011. this._startDistance = 0;
  9012. this._initialScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  9013. this._targetScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  9014. this._sceneRenderObserver = null;
  9015. this._dragBehaviorA = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  9016. this._dragBehaviorA.moveAttached = false;
  9017. this._dragBehaviorB = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  9018. this._dragBehaviorB.moveAttached = false;
  9019. }
  9020. Object.defineProperty(MultiPointerScaleBehavior.prototype, "name", {
  9021. /**
  9022. * The name of the behavior
  9023. */
  9024. get: function () {
  9025. return "MultiPointerScale";
  9026. },
  9027. enumerable: true,
  9028. configurable: true
  9029. });
  9030. /**
  9031. * Initializes the behavior
  9032. */
  9033. MultiPointerScaleBehavior.prototype.init = function () { };
  9034. MultiPointerScaleBehavior.prototype._getCurrentDistance = function () {
  9035. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
  9036. };
  9037. /**
  9038. * Attaches the scale behavior the passed in mesh
  9039. * @param ownerNode The mesh that will be scaled around once attached
  9040. */
  9041. MultiPointerScaleBehavior.prototype.attach = function (ownerNode) {
  9042. var _this = this;
  9043. this._ownerNode = ownerNode;
  9044. // Create 2 drag behaviors such that each will only be triggered by a separate pointer
  9045. this._dragBehaviorA.onDragStartObservable.add(function (e) {
  9046. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9047. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9048. _this._dragBehaviorA.releaseDrag();
  9049. }
  9050. else {
  9051. _this._initialScale.copyFrom(ownerNode.scaling);
  9052. _this._startDistance = _this._getCurrentDistance();
  9053. }
  9054. }
  9055. });
  9056. this._dragBehaviorB.onDragStartObservable.add(function (e) {
  9057. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9058. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9059. _this._dragBehaviorB.releaseDrag();
  9060. }
  9061. else {
  9062. _this._initialScale.copyFrom(ownerNode.scaling);
  9063. _this._startDistance = _this._getCurrentDistance();
  9064. }
  9065. }
  9066. });
  9067. // Once both drag behaviors are active scale based on the distance between the two pointers
  9068. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9069. behavior.onDragObservable.add(function () {
  9070. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9071. var ratio = _this._getCurrentDistance() / _this._startDistance;
  9072. _this._initialScale.scaleToRef(ratio, _this._targetScale);
  9073. }
  9074. });
  9075. });
  9076. ownerNode.addBehavior(this._dragBehaviorA);
  9077. ownerNode.addBehavior(this._dragBehaviorB);
  9078. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9079. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9080. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9081. var change = _this._targetScale.subtract(ownerNode.scaling).scaleInPlace(0.1);
  9082. if (change.length() > 0.01) {
  9083. ownerNode.scaling.addInPlace(change);
  9084. }
  9085. }
  9086. });
  9087. };
  9088. /**
  9089. * Detaches the behavior from the mesh
  9090. */
  9091. MultiPointerScaleBehavior.prototype.detach = function () {
  9092. var _this = this;
  9093. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9094. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9095. behavior.onDragStartObservable.clear();
  9096. behavior.onDragObservable.clear();
  9097. _this._ownerNode.removeBehavior(behavior);
  9098. });
  9099. };
  9100. return MultiPointerScaleBehavior;
  9101. }());
  9102. /***/ }),
  9103. /***/ "./Behaviors/Meshes/pointerDragBehavior.ts":
  9104. /*!*************************************************!*\
  9105. !*** ./Behaviors/Meshes/pointerDragBehavior.ts ***!
  9106. \*************************************************/
  9107. /*! exports provided: PointerDragBehavior */
  9108. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9109. "use strict";
  9110. __webpack_require__.r(__webpack_exports__);
  9111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return PointerDragBehavior; });
  9112. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  9113. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9114. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9115. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9116. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9117. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  9118. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9119. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  9120. /**
  9121. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  9122. */
  9123. var PointerDragBehavior = /** @class */ (function () {
  9124. /**
  9125. * Creates a pointer drag behavior that can be attached to a mesh
  9126. * @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)
  9127. */
  9128. function PointerDragBehavior(options) {
  9129. this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1;
  9130. /**
  9131. * 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)
  9132. */
  9133. this.maxDragAngle = 0;
  9134. /**
  9135. * @hidden
  9136. */
  9137. this._useAlternatePickedPointAboveMaxDragAngle = false;
  9138. /**
  9139. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9140. */
  9141. this.currentDraggingPointerID = -1;
  9142. /**
  9143. * If the behavior is currently in a dragging state
  9144. */
  9145. this.dragging = false;
  9146. /**
  9147. * 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)
  9148. */
  9149. this.dragDeltaRatio = 0.2;
  9150. /**
  9151. * If the drag plane orientation should be updated during the dragging (Default: true)
  9152. */
  9153. this.updateDragPlane = true;
  9154. // Debug mode will display drag planes to help visualize behavior
  9155. this._debugMode = false;
  9156. this._moving = false;
  9157. /**
  9158. * Fires each time the attached mesh is dragged with the pointer
  9159. * * delta between last drag position and current drag position in world space
  9160. * * dragDistance along the drag axis
  9161. * * dragPlaneNormal normal of the current drag plane used during the drag
  9162. * * dragPlanePoint in world space where the drag intersects the drag plane
  9163. */
  9164. this.onDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9165. /**
  9166. * Fires each time a drag begins (eg. mouse down on mesh)
  9167. */
  9168. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9169. /**
  9170. * Fires each time a drag ends (eg. mouse release after drag)
  9171. */
  9172. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9173. /**
  9174. * If the attached mesh should be moved when dragged
  9175. */
  9176. this.moveAttached = true;
  9177. /**
  9178. * If the drag behavior will react to drag events (Default: true)
  9179. */
  9180. this.enabled = true;
  9181. /**
  9182. * If camera controls should be detached during the drag
  9183. */
  9184. this.detachCameraControls = true;
  9185. /**
  9186. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  9187. */
  9188. this.useObjectOrienationForDragging = true;
  9189. /**
  9190. * Predicate to determine if it is valid to move the object to a new position when it is moved
  9191. */
  9192. this.validateDrag = function (targetPosition) { return true; };
  9193. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9194. this._alternatePickedPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9195. this._worldDragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9196. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9197. this._attachedElement = null;
  9198. 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"]());
  9199. this._lastPointerRay = {};
  9200. this._dragDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  9201. // Variables to avoid instantiation in the below method
  9202. this._pointA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9203. this._pointB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9204. this._pointC = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9205. this._lineA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9206. this._lineB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9207. this._localAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9208. this._lookAt = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9209. this._options = options ? options : {};
  9210. var optionCount = 0;
  9211. if (this._options.dragAxis) {
  9212. optionCount++;
  9213. }
  9214. if (this._options.dragPlaneNormal) {
  9215. optionCount++;
  9216. }
  9217. if (optionCount > 1) {
  9218. throw "Multiple drag modes specified in dragBehavior options. Only one expected";
  9219. }
  9220. }
  9221. Object.defineProperty(PointerDragBehavior.prototype, "name", {
  9222. /**
  9223. * The name of the behavior
  9224. */
  9225. get: function () {
  9226. return "PointerDrag";
  9227. },
  9228. enumerable: true,
  9229. configurable: true
  9230. });
  9231. /**
  9232. * Initializes the behavior
  9233. */
  9234. PointerDragBehavior.prototype.init = function () { };
  9235. /**
  9236. * Attaches the drag behavior the passed in mesh
  9237. * @param ownerNode The mesh that will be dragged around once attached
  9238. */
  9239. PointerDragBehavior.prototype.attach = function (ownerNode) {
  9240. var _this = this;
  9241. this._scene = ownerNode.getScene();
  9242. this._attachedNode = ownerNode;
  9243. // Initialize drag plane to not interfere with existing scene
  9244. if (!PointerDragBehavior._planeScene) {
  9245. if (this._debugMode) {
  9246. PointerDragBehavior._planeScene = this._scene;
  9247. }
  9248. else {
  9249. PointerDragBehavior._planeScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9250. PointerDragBehavior._planeScene.detachControl();
  9251. this._scene.getEngine().scenes.pop();
  9252. this._scene.onDisposeObservable.addOnce(function () {
  9253. PointerDragBehavior._planeScene.dispose();
  9254. PointerDragBehavior._planeScene = null;
  9255. });
  9256. }
  9257. }
  9258. 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);
  9259. // State of the drag
  9260. this.lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9261. var pickPredicate = function (m) {
  9262. return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
  9263. };
  9264. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9265. if (!_this.enabled) {
  9266. return;
  9267. }
  9268. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN) {
  9269. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9270. _this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
  9271. }
  9272. }
  9273. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP) {
  9274. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9275. _this.releaseDrag();
  9276. }
  9277. }
  9278. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  9279. var pointerId = pointerInfo.event.pointerId;
  9280. // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
  9281. if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
  9282. if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
  9283. _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
  9284. delete _this._lastPointerRay[_this.currentDraggingPointerID];
  9285. }
  9286. _this.currentDraggingPointerID = pointerId;
  9287. }
  9288. // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
  9289. if (!_this._lastPointerRay[pointerId]) {
  9290. _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"]());
  9291. }
  9292. if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
  9293. _this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);
  9294. _this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);
  9295. if (_this.currentDraggingPointerID == pointerId && _this.dragging) {
  9296. _this._moveDrag(pointerInfo.pickInfo.ray);
  9297. }
  9298. }
  9299. }
  9300. });
  9301. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  9302. if (_this._moving && _this.moveAttached) {
  9303. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(_this._attachedNode);
  9304. // Slowly move mesh to avoid jitter
  9305. _this._targetPosition.subtractToRef((_this._attachedNode).absolutePosition, _this._tmpVector);
  9306. _this._tmpVector.scaleInPlace(_this.dragDeltaRatio);
  9307. (_this._attachedNode).getAbsolutePosition().addToRef(_this._tmpVector, _this._tmpVector);
  9308. if (_this.validateDrag(_this._tmpVector)) {
  9309. (_this._attachedNode).setAbsolutePosition(_this._tmpVector);
  9310. }
  9311. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(_this._attachedNode);
  9312. }
  9313. });
  9314. };
  9315. /**
  9316. * Force relase the drag action by code.
  9317. */
  9318. PointerDragBehavior.prototype.releaseDrag = function () {
  9319. this.dragging = false;
  9320. this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
  9321. this.currentDraggingPointerID = -1;
  9322. this._moving = false;
  9323. // Reattach camera controls
  9324. if (this.detachCameraControls && this._attachedElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9325. this._scene.activeCamera.attachControl(this._attachedElement, true);
  9326. }
  9327. };
  9328. /**
  9329. * Simulates the start of a pointer drag event on the behavior
  9330. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  9331. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  9332. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  9333. */
  9334. PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
  9335. if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
  9336. this._startDrag(pointerId, fromRay, startPickedPoint);
  9337. var lastRay = this._lastPointerRay[pointerId];
  9338. if (pointerId === PointerDragBehavior._AnyMouseID) {
  9339. lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
  9340. }
  9341. if (lastRay) {
  9342. // if there was a last pointer ray drag the object there
  9343. this._moveDrag(lastRay);
  9344. }
  9345. };
  9346. PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
  9347. if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
  9348. return;
  9349. }
  9350. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(this._attachedNode);
  9351. // Create start ray from the camera to the object
  9352. if (fromRay) {
  9353. this._startDragRay.direction.copyFrom(fromRay.direction);
  9354. this._startDragRay.origin.copyFrom(fromRay.origin);
  9355. }
  9356. else {
  9357. this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);
  9358. this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);
  9359. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);
  9360. }
  9361. this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);
  9362. var pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);
  9363. if (pickedPoint) {
  9364. this.dragging = true;
  9365. this.currentDraggingPointerID = pointerId;
  9366. this.lastDragPosition.copyFrom(pickedPoint);
  9367. this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerID });
  9368. this._targetPosition.copyFrom((this._attachedNode).absolutePosition);
  9369. // Detatch camera controls
  9370. if (this.detachCameraControls && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9371. if (this._scene.activeCamera.inputs.attachedElement) {
  9372. this._attachedElement = this._scene.activeCamera.inputs.attachedElement;
  9373. this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
  9374. }
  9375. else {
  9376. this._attachedElement = null;
  9377. }
  9378. }
  9379. }
  9380. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(this._attachedNode);
  9381. };
  9382. PointerDragBehavior.prototype._moveDrag = function (ray) {
  9383. this._moving = true;
  9384. var pickedPoint = this._pickWithRayOnDragPlane(ray);
  9385. if (pickedPoint) {
  9386. if (this.updateDragPlane) {
  9387. this._updateDragPlanePosition(ray, pickedPoint);
  9388. }
  9389. var dragLength = 0;
  9390. // depending on the drag mode option drag accordingly
  9391. if (this._options.dragAxis) {
  9392. // Convert local drag axis to world
  9393. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis);
  9394. // Project delta drag from the drag plane onto the drag axis
  9395. pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);
  9396. dragLength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._tmpVector, this._worldDragAxis);
  9397. this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);
  9398. }
  9399. else {
  9400. dragLength = this._dragDelta.length();
  9401. pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);
  9402. }
  9403. this._targetPosition.addInPlace(this._dragDelta);
  9404. this.onDragObservable.notifyObservers({ dragDistance: dragLength, delta: this._dragDelta, dragPlanePoint: pickedPoint, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID });
  9405. this.lastDragPosition.copyFrom(pickedPoint);
  9406. }
  9407. };
  9408. PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
  9409. var _this = this;
  9410. if (!ray) {
  9411. return null;
  9412. }
  9413. // Calculate angle between plane normal and ray
  9414. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, ray.direction));
  9415. // Correct if ray is casted from oposite side
  9416. if (angle > Math.PI / 2) {
  9417. angle = Math.PI - angle;
  9418. }
  9419. // If the angle is too perpendicular to the plane pick another point on the plane where it is looking
  9420. if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {
  9421. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  9422. // Invert ray direction along the towards object axis
  9423. this._tmpVector.copyFrom(ray.direction);
  9424. (this._attachedNode).absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);
  9425. this._alternatePickedPoint.normalize();
  9426. this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._alternatePickedPoint, this._tmpVector));
  9427. this._tmpVector.addInPlace(this._alternatePickedPoint);
  9428. // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point
  9429. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, this._tmpVector);
  9430. this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);
  9431. this._alternatePickedPoint.addInPlace(this._tmpVector);
  9432. this._alternatePickedPoint.addInPlace((this._attachedNode).absolutePosition);
  9433. return this._alternatePickedPoint;
  9434. }
  9435. else {
  9436. return null;
  9437. }
  9438. }
  9439. var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
  9440. if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
  9441. return pickResult.pickedPoint;
  9442. }
  9443. else {
  9444. return null;
  9445. }
  9446. };
  9447. // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
  9448. PointerDragBehavior.prototype._updateDragPlanePosition = function (ray, dragPlanePosition) {
  9449. this._pointA.copyFrom(dragPlanePosition);
  9450. if (this._options.dragAxis) {
  9451. 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);
  9452. // Calculate plane normal in direction of camera but perpendicular to drag axis
  9453. this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
  9454. ray.origin.subtractToRef(this._pointA, this._pointC);
  9455. this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
  9456. // Get perpendicular line from direction to camera and drag axis
  9457. this._pointB.subtractToRef(this._pointA, this._lineA);
  9458. this._pointC.subtractToRef(this._pointA, this._lineB);
  9459. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lineB, this._lookAt);
  9460. // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
  9461. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lookAt, this._lookAt);
  9462. this._lookAt.normalize();
  9463. this._dragPlane.position.copyFrom(this._pointA);
  9464. this._pointA.addToRef(this._lookAt, this._lookAt);
  9465. this._dragPlane.lookAt(this._lookAt);
  9466. }
  9467. else if (this._options.dragPlaneNormal) {
  9468. 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);
  9469. this._dragPlane.position.copyFrom(this._pointA);
  9470. this._pointA.addToRef(this._localAxis, this._lookAt);
  9471. this._dragPlane.lookAt(this._lookAt);
  9472. }
  9473. else {
  9474. this._dragPlane.position.copyFrom(this._pointA);
  9475. this._dragPlane.lookAt(ray.origin);
  9476. }
  9477. // 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)
  9478. this._dragPlane.position.copyFrom(this._attachedNode.absolutePosition);
  9479. this._dragPlane.computeWorldMatrix(true);
  9480. };
  9481. /**
  9482. * Detaches the behavior from the mesh
  9483. */
  9484. PointerDragBehavior.prototype.detach = function () {
  9485. if (this._pointerObserver) {
  9486. this._scene.onPointerObservable.remove(this._pointerObserver);
  9487. }
  9488. if (this._beforeRenderObserver) {
  9489. this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  9490. }
  9491. this.releaseDrag();
  9492. };
  9493. PointerDragBehavior._AnyMouseID = -2;
  9494. return PointerDragBehavior;
  9495. }());
  9496. /***/ }),
  9497. /***/ "./Behaviors/Meshes/sixDofDragBehavior.ts":
  9498. /*!************************************************!*\
  9499. !*** ./Behaviors/Meshes/sixDofDragBehavior.ts ***!
  9500. \************************************************/
  9501. /*! exports provided: SixDofDragBehavior */
  9502. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9503. "use strict";
  9504. __webpack_require__.r(__webpack_exports__);
  9505. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return SixDofDragBehavior; });
  9506. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  9507. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9508. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9509. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9510. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9511. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  9512. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9513. /**
  9514. * 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
  9515. */
  9516. var SixDofDragBehavior = /** @class */ (function () {
  9517. /**
  9518. * 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
  9519. */
  9520. function SixDofDragBehavior() {
  9521. this._sceneRenderObserver = null;
  9522. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9523. this._moving = false;
  9524. this._startingOrientation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9525. /**
  9526. * 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)
  9527. */
  9528. this.zDragFactor = 3;
  9529. /**
  9530. * If the object should rotate to face the drag origin
  9531. */
  9532. this.rotateDraggedObject = true;
  9533. /**
  9534. * If the behavior is currently in a dragging state
  9535. */
  9536. this.dragging = false;
  9537. /**
  9538. * 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)
  9539. */
  9540. this.dragDeltaRatio = 0.2;
  9541. /**
  9542. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9543. */
  9544. this.currentDraggingPointerID = -1;
  9545. /**
  9546. * If camera controls should be detached during the drag
  9547. */
  9548. this.detachCameraControls = true;
  9549. /**
  9550. * Fires each time a drag starts
  9551. */
  9552. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9553. /**
  9554. * Fires each time a drag ends (eg. mouse release after drag)
  9555. */
  9556. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9557. }
  9558. Object.defineProperty(SixDofDragBehavior.prototype, "name", {
  9559. /**
  9560. * The name of the behavior
  9561. */
  9562. get: function () {
  9563. return "SixDofDrag";
  9564. },
  9565. enumerable: true,
  9566. configurable: true
  9567. });
  9568. /**
  9569. * Initializes the behavior
  9570. */
  9571. SixDofDragBehavior.prototype.init = function () { };
  9572. /**
  9573. * Attaches the scale behavior the passed in mesh
  9574. * @param ownerNode The mesh that will be scaled around once attached
  9575. */
  9576. SixDofDragBehavior.prototype.attach = function (ownerNode) {
  9577. var _this = this;
  9578. this._ownerNode = ownerNode;
  9579. this._scene = this._ownerNode.getScene();
  9580. if (!SixDofDragBehavior._virtualScene) {
  9581. SixDofDragBehavior._virtualScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9582. SixDofDragBehavior._virtualScene.detachControl();
  9583. this._scene.getEngine().scenes.pop();
  9584. }
  9585. var pickedMesh = null;
  9586. var lastSixDofOriginPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9587. // Setup virtual meshes to be used for dragging without dirtying the existing scene
  9588. this._virtualOriginMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9589. this._virtualOriginMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9590. this._virtualDragMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9591. this._virtualDragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9592. var pickPredicate = function (m) {
  9593. return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
  9594. };
  9595. var attachedElement = null;
  9596. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9597. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  9598. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9599. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9600. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9601. }
  9602. pickedMesh = _this._ownerNode;
  9603. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9604. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9605. // Set position and orientation of the controller
  9606. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9607. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9608. // Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
  9609. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9610. pickedMesh.computeWorldMatrix();
  9611. _this._virtualDragMesh.position.copyFrom(pickedMesh.absolutePosition);
  9612. if (!pickedMesh.rotationQuaternion) {
  9613. pickedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(pickedMesh.rotation.y, pickedMesh.rotation.x, pickedMesh.rotation.z);
  9614. }
  9615. var oldParent = pickedMesh.parent;
  9616. pickedMesh.setParent(null);
  9617. _this._virtualDragMesh.rotationQuaternion.copyFrom(pickedMesh.rotationQuaternion);
  9618. pickedMesh.setParent(oldParent);
  9619. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9620. // Update state
  9621. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9622. _this.dragging = true;
  9623. _this.currentDraggingPointerID = pointerInfo.event.pointerId;
  9624. // Detatch camera controls
  9625. if (_this.detachCameraControls && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9626. if (_this._scene.activeCamera.inputs.attachedElement) {
  9627. attachedElement = _this._scene.activeCamera.inputs.attachedElement;
  9628. _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
  9629. }
  9630. else {
  9631. attachedElement = null;
  9632. }
  9633. }
  9634. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9635. _this.onDragStartObservable.notifyObservers({});
  9636. }
  9637. }
  9638. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP) {
  9639. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9640. _this.dragging = false;
  9641. _this._moving = false;
  9642. _this.currentDraggingPointerID = -1;
  9643. pickedMesh = null;
  9644. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9645. // Reattach camera controls
  9646. if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9647. _this._scene.activeCamera.attachControl(attachedElement, true);
  9648. }
  9649. _this.onDragEndObservable.notifyObservers({});
  9650. }
  9651. }
  9652. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE) {
  9653. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
  9654. var zDragFactor = _this.zDragFactor;
  9655. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9656. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9657. zDragFactor = 0;
  9658. }
  9659. // Calculate controller drag distance in controller space
  9660. var originDragDifference = pointerInfo.pickInfo.ray.origin.subtract(lastSixDofOriginPosition);
  9661. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9662. var localOriginDragDifference = -_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(originDragDifference, pointerInfo.pickInfo.ray.direction);
  9663. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9664. // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away
  9665. _this._virtualDragMesh.position.z -= _this._virtualDragMesh.position.z < 1 ? localOriginDragDifference * _this.zDragFactor : localOriginDragDifference * zDragFactor * _this._virtualDragMesh.position.z;
  9666. if (_this._virtualDragMesh.position.z < 0) {
  9667. _this._virtualDragMesh.position.z = 0;
  9668. }
  9669. // Update the controller position
  9670. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9671. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9672. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9673. // Move the virtualObjectsPosition into the picked mesh's space if needed
  9674. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9675. if (pickedMesh.parent) {
  9676. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._targetPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(pickedMesh.parent.getWorldMatrix()), _this._targetPosition);
  9677. }
  9678. if (!_this._moving) {
  9679. _this._startingOrientation.copyFrom(_this._virtualDragMesh.rotationQuaternion);
  9680. }
  9681. _this._moving = true;
  9682. }
  9683. }
  9684. });
  9685. var tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9686. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9687. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9688. if (_this.dragging && _this._moving && pickedMesh) {
  9689. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9690. // Slowly move mesh to avoid jitter
  9691. pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
  9692. if (_this.rotateDraggedObject) {
  9693. // Get change in rotation
  9694. tmpQuaternion.copyFrom(_this._startingOrientation);
  9695. tmpQuaternion.x = -tmpQuaternion.x;
  9696. tmpQuaternion.y = -tmpQuaternion.y;
  9697. tmpQuaternion.z = -tmpQuaternion.z;
  9698. _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
  9699. // Convert change in rotation to only y axis rotation
  9700. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
  9701. tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
  9702. // Slowly move mesh to avoid jitter
  9703. var oldParent = pickedMesh.parent;
  9704. // Only rotate the mesh if it's parent has uniform scaling
  9705. if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  9706. pickedMesh.setParent(null);
  9707. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
  9708. pickedMesh.setParent(oldParent);
  9709. }
  9710. }
  9711. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9712. }
  9713. });
  9714. };
  9715. /**
  9716. * Detaches the behavior from the mesh
  9717. */
  9718. SixDofDragBehavior.prototype.detach = function () {
  9719. if (this._scene) {
  9720. this._scene.onPointerObservable.remove(this._pointerObserver);
  9721. }
  9722. if (this._ownerNode) {
  9723. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9724. }
  9725. if (this._virtualOriginMesh) {
  9726. this._virtualOriginMesh.dispose();
  9727. }
  9728. if (this._virtualDragMesh) {
  9729. this._virtualDragMesh.dispose();
  9730. }
  9731. this.onDragEndObservable.clear();
  9732. this.onDragStartObservable.clear();
  9733. };
  9734. return SixDofDragBehavior;
  9735. }());
  9736. /***/ }),
  9737. /***/ "./Behaviors/index.ts":
  9738. /*!****************************!*\
  9739. !*** ./Behaviors/index.ts ***!
  9740. \****************************/
  9741. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  9742. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9743. "use strict";
  9744. __webpack_require__.r(__webpack_exports__);
  9745. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cameras/index */ "./Behaviors/Cameras/index.ts");
  9746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  9747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  9748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  9749. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Meshes/index */ "./Behaviors/Meshes/index.ts");
  9750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  9753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["SixDofDragBehavior"]; });
  9755. /***/ }),
  9756. /***/ "./Bones/bone.ts":
  9757. /*!***********************!*\
  9758. !*** ./Bones/bone.ts ***!
  9759. \***********************/
  9760. /*! exports provided: Bone */
  9761. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9762. "use strict";
  9763. __webpack_require__.r(__webpack_exports__);
  9764. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return Bone; });
  9765. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  9766. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  9767. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  9768. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  9769. /**
  9770. * Class used to store bone information
  9771. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9772. */
  9773. var Bone = /** @class */ (function (_super) {
  9774. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Bone, _super);
  9775. /**
  9776. * Create a new bone
  9777. * @param name defines the bone name
  9778. * @param skeleton defines the parent skeleton
  9779. * @param parentBone defines the parent (can be null if the bone is the root)
  9780. * @param localMatrix defines the local matrix
  9781. * @param restPose defines the rest pose matrix
  9782. * @param baseMatrix defines the base matrix
  9783. * @param index defines index of the bone in the hiearchy
  9784. */
  9785. function Bone(
  9786. /**
  9787. * defines the bone name
  9788. */
  9789. name, skeleton, parentBone, localMatrix, restPose, baseMatrix, index) {
  9790. if (parentBone === void 0) { parentBone = null; }
  9791. if (localMatrix === void 0) { localMatrix = null; }
  9792. if (restPose === void 0) { restPose = null; }
  9793. if (baseMatrix === void 0) { baseMatrix = null; }
  9794. if (index === void 0) { index = null; }
  9795. var _this = _super.call(this, name, skeleton.getScene(), false) || this;
  9796. _this.name = name;
  9797. /**
  9798. * Gets the list of child bones
  9799. */
  9800. _this.children = new Array();
  9801. /** Gets the animations associated with this bone */
  9802. _this.animations = new Array();
  9803. /**
  9804. * @hidden Internal only
  9805. * Set this value to map this bone to a different index in the transform matrices
  9806. * Set this value to -1 to exclude the bone from the transform matrices
  9807. */
  9808. _this._index = null;
  9809. _this._absoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9810. _this._invertedAbsoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9811. _this._scalingDeterminant = 1;
  9812. _this._worldTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9813. _this._needToDecompose = true;
  9814. _this._needToCompose = false;
  9815. /** @hidden */
  9816. _this._linkedTransformNode = null;
  9817. _this._skeleton = skeleton;
  9818. _this._localMatrix = localMatrix ? localMatrix.clone() : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  9819. _this._restPose = restPose ? restPose : _this._localMatrix.clone();
  9820. _this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
  9821. _this._index = index;
  9822. skeleton.bones.push(_this);
  9823. _this.setParent(parentBone, false);
  9824. if (baseMatrix || localMatrix) {
  9825. _this._updateDifferenceMatrix();
  9826. }
  9827. return _this;
  9828. }
  9829. Object.defineProperty(Bone.prototype, "_matrix", {
  9830. /** @hidden */
  9831. get: function () {
  9832. this._compose();
  9833. return this._localMatrix;
  9834. },
  9835. /** @hidden */
  9836. set: function (value) {
  9837. this._localMatrix.copyFrom(value);
  9838. this._needToDecompose = true;
  9839. },
  9840. enumerable: true,
  9841. configurable: true
  9842. });
  9843. /**
  9844. * Gets the current object class name.
  9845. * @return the class name
  9846. */
  9847. Bone.prototype.getClassName = function () {
  9848. return "Bone";
  9849. };
  9850. // Members
  9851. /**
  9852. * Gets the parent skeleton
  9853. * @returns a skeleton
  9854. */
  9855. Bone.prototype.getSkeleton = function () {
  9856. return this._skeleton;
  9857. };
  9858. /**
  9859. * Gets parent bone
  9860. * @returns a bone or null if the bone is the root of the bone hierarchy
  9861. */
  9862. Bone.prototype.getParent = function () {
  9863. return this._parent;
  9864. };
  9865. /**
  9866. * Returns an array containing the root bones
  9867. * @returns an array containing the root bones
  9868. */
  9869. Bone.prototype.getChildren = function () {
  9870. return this.children;
  9871. };
  9872. /**
  9873. * Sets the parent bone
  9874. * @param parent defines the parent (can be null if the bone is the root)
  9875. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9876. */
  9877. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  9878. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9879. if (this._parent === parent) {
  9880. return;
  9881. }
  9882. if (this._parent) {
  9883. var index = this._parent.children.indexOf(this);
  9884. if (index !== -1) {
  9885. this._parent.children.splice(index, 1);
  9886. }
  9887. }
  9888. this._parent = parent;
  9889. if (this._parent) {
  9890. this._parent.children.push(this);
  9891. }
  9892. if (updateDifferenceMatrix) {
  9893. this._updateDifferenceMatrix();
  9894. }
  9895. this.markAsDirty();
  9896. };
  9897. /**
  9898. * Gets the local matrix
  9899. * @returns a matrix
  9900. */
  9901. Bone.prototype.getLocalMatrix = function () {
  9902. this._compose();
  9903. return this._localMatrix;
  9904. };
  9905. /**
  9906. * Gets the base matrix (initial matrix which remains unchanged)
  9907. * @returns a matrix
  9908. */
  9909. Bone.prototype.getBaseMatrix = function () {
  9910. return this._baseMatrix;
  9911. };
  9912. /**
  9913. * Gets the rest pose matrix
  9914. * @returns a matrix
  9915. */
  9916. Bone.prototype.getRestPose = function () {
  9917. return this._restPose;
  9918. };
  9919. /**
  9920. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9921. */
  9922. Bone.prototype.getWorldMatrix = function () {
  9923. return this._worldTransform;
  9924. };
  9925. /**
  9926. * Sets the local matrix to rest pose matrix
  9927. */
  9928. Bone.prototype.returnToRest = function () {
  9929. this.updateMatrix(this._restPose.clone());
  9930. };
  9931. /**
  9932. * Gets the inverse of the absolute transform matrix.
  9933. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9934. * @returns a matrix
  9935. */
  9936. Bone.prototype.getInvertedAbsoluteTransform = function () {
  9937. return this._invertedAbsoluteTransform;
  9938. };
  9939. /**
  9940. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9941. * @returns a matrix
  9942. */
  9943. Bone.prototype.getAbsoluteTransform = function () {
  9944. return this._absoluteTransform;
  9945. };
  9946. /**
  9947. * Links with the given transform node.
  9948. * The local matrix of this bone is copied from the transform node every frame.
  9949. * @param transformNode defines the transform node to link to
  9950. */
  9951. Bone.prototype.linkTransformNode = function (transformNode) {
  9952. if (this._linkedTransformNode) {
  9953. this._skeleton._numBonesWithLinkedTransformNode--;
  9954. }
  9955. this._linkedTransformNode = transformNode;
  9956. if (this._linkedTransformNode) {
  9957. this._skeleton._numBonesWithLinkedTransformNode++;
  9958. }
  9959. };
  9960. Object.defineProperty(Bone.prototype, "position", {
  9961. // Properties (matches AbstractMesh properties)
  9962. /** Gets or sets current position (in local space) */
  9963. get: function () {
  9964. this._decompose();
  9965. return this._localPosition;
  9966. },
  9967. set: function (newPosition) {
  9968. this._decompose();
  9969. this._localPosition.copyFrom(newPosition);
  9970. this._markAsDirtyAndCompose();
  9971. },
  9972. enumerable: true,
  9973. configurable: true
  9974. });
  9975. Object.defineProperty(Bone.prototype, "rotation", {
  9976. /** Gets or sets current rotation (in local space) */
  9977. get: function () {
  9978. return this.getRotation();
  9979. },
  9980. set: function (newRotation) {
  9981. this.setRotation(newRotation);
  9982. },
  9983. enumerable: true,
  9984. configurable: true
  9985. });
  9986. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  9987. /** Gets or sets current rotation quaternion (in local space) */
  9988. get: function () {
  9989. this._decompose();
  9990. return this._localRotation;
  9991. },
  9992. set: function (newRotation) {
  9993. this.setRotationQuaternion(newRotation);
  9994. },
  9995. enumerable: true,
  9996. configurable: true
  9997. });
  9998. Object.defineProperty(Bone.prototype, "scaling", {
  9999. /** Gets or sets current scaling (in local space) */
  10000. get: function () {
  10001. return this.getScale();
  10002. },
  10003. set: function (newScaling) {
  10004. this.setScale(newScaling);
  10005. },
  10006. enumerable: true,
  10007. configurable: true
  10008. });
  10009. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  10010. /**
  10011. * Gets the animation properties override
  10012. */
  10013. get: function () {
  10014. return this._skeleton.animationPropertiesOverride;
  10015. },
  10016. enumerable: true,
  10017. configurable: true
  10018. });
  10019. // Methods
  10020. Bone.prototype._decompose = function () {
  10021. if (!this._needToDecompose) {
  10022. return;
  10023. }
  10024. this._needToDecompose = false;
  10025. if (!this._localScaling) {
  10026. this._localScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10027. this._localRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  10028. this._localPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10029. }
  10030. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  10031. };
  10032. Bone.prototype._compose = function () {
  10033. if (!this._needToCompose) {
  10034. return;
  10035. }
  10036. this._needToCompose = false;
  10037. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  10038. };
  10039. /**
  10040. * Update the base and local matrices
  10041. * @param matrix defines the new base or local matrix
  10042. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  10043. * @param updateLocalMatrix defines if the local matrix should be updated
  10044. */
  10045. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  10046. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  10047. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  10048. this._baseMatrix.copyFrom(matrix);
  10049. if (updateDifferenceMatrix) {
  10050. this._updateDifferenceMatrix();
  10051. }
  10052. if (updateLocalMatrix) {
  10053. this._localMatrix.copyFrom(matrix);
  10054. this._markAsDirtyAndDecompose();
  10055. }
  10056. else {
  10057. this.markAsDirty();
  10058. }
  10059. };
  10060. /** @hidden */
  10061. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  10062. if (updateChildren === void 0) { updateChildren = true; }
  10063. if (!rootMatrix) {
  10064. rootMatrix = this._baseMatrix;
  10065. }
  10066. if (this._parent) {
  10067. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10068. }
  10069. else {
  10070. this._absoluteTransform.copyFrom(rootMatrix);
  10071. }
  10072. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  10073. if (updateChildren) {
  10074. for (var index = 0; index < this.children.length; index++) {
  10075. this.children[index]._updateDifferenceMatrix();
  10076. }
  10077. }
  10078. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  10079. };
  10080. /**
  10081. * Flag the bone as dirty (Forcing it to update everything)
  10082. */
  10083. Bone.prototype.markAsDirty = function () {
  10084. this._currentRenderId++;
  10085. this._childUpdateId++;
  10086. this._skeleton._markAsDirty();
  10087. };
  10088. Bone.prototype._markAsDirtyAndCompose = function () {
  10089. this.markAsDirty();
  10090. this._needToCompose = true;
  10091. };
  10092. Bone.prototype._markAsDirtyAndDecompose = function () {
  10093. this.markAsDirty();
  10094. this._needToDecompose = true;
  10095. };
  10096. /**
  10097. * Translate the bone in local or world space
  10098. * @param vec The amount to translate the bone
  10099. * @param space The space that the translation is in
  10100. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10101. */
  10102. Bone.prototype.translate = function (vec, space, mesh) {
  10103. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10104. var lm = this.getLocalMatrix();
  10105. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10106. lm.addAtIndex(12, vec.x);
  10107. lm.addAtIndex(13, vec.y);
  10108. lm.addAtIndex(14, vec.z);
  10109. }
  10110. else {
  10111. var wm = null;
  10112. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10113. if (mesh) {
  10114. wm = mesh.getWorldMatrix();
  10115. }
  10116. this._skeleton.computeAbsoluteTransforms();
  10117. var tmat = Bone._tmpMats[0];
  10118. var tvec = Bone._tmpVecs[0];
  10119. if (this._parent) {
  10120. if (mesh && wm) {
  10121. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10122. tmat.multiplyToRef(wm, tmat);
  10123. }
  10124. else {
  10125. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10126. }
  10127. }
  10128. tmat.setTranslationFromFloats(0, 0, 0);
  10129. tmat.invert();
  10130. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  10131. lm.addAtIndex(12, tvec.x);
  10132. lm.addAtIndex(13, tvec.y);
  10133. lm.addAtIndex(14, tvec.z);
  10134. }
  10135. this._markAsDirtyAndDecompose();
  10136. };
  10137. /**
  10138. * Set the postion of the bone in local or world space
  10139. * @param position The position to set the bone
  10140. * @param space The space that the position is in
  10141. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10142. */
  10143. Bone.prototype.setPosition = function (position, space, mesh) {
  10144. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10145. var lm = this.getLocalMatrix();
  10146. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10147. lm.setTranslationFromFloats(position.x, position.y, position.z);
  10148. }
  10149. else {
  10150. var wm = null;
  10151. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10152. if (mesh) {
  10153. wm = mesh.getWorldMatrix();
  10154. }
  10155. this._skeleton.computeAbsoluteTransforms();
  10156. var tmat = Bone._tmpMats[0];
  10157. var vec = Bone._tmpVecs[0];
  10158. if (this._parent) {
  10159. if (mesh && wm) {
  10160. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10161. tmat.multiplyToRef(wm, tmat);
  10162. }
  10163. else {
  10164. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10165. }
  10166. }
  10167. tmat.invert();
  10168. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  10169. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  10170. }
  10171. this._markAsDirtyAndDecompose();
  10172. };
  10173. /**
  10174. * Set the absolute position of the bone (world space)
  10175. * @param position The position to set the bone
  10176. * @param mesh The mesh that this bone is attached to
  10177. */
  10178. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  10179. this.setPosition(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh);
  10180. };
  10181. /**
  10182. * Scale the bone on the x, y and z axes (in local space)
  10183. * @param x The amount to scale the bone on the x axis
  10184. * @param y The amount to scale the bone on the y axis
  10185. * @param z The amount to scale the bone on the z axis
  10186. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  10187. */
  10188. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  10189. if (scaleChildren === void 0) { scaleChildren = false; }
  10190. var locMat = this.getLocalMatrix();
  10191. // Apply new scaling on top of current local matrix
  10192. var scaleMat = Bone._tmpMats[0];
  10193. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  10194. scaleMat.multiplyToRef(locMat, locMat);
  10195. // Invert scaling matrix and apply the inverse to all children
  10196. scaleMat.invert();
  10197. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10198. var child = _a[_i];
  10199. var cm = child.getLocalMatrix();
  10200. cm.multiplyToRef(scaleMat, cm);
  10201. cm.multiplyAtIndex(12, x);
  10202. cm.multiplyAtIndex(13, y);
  10203. cm.multiplyAtIndex(14, z);
  10204. child._markAsDirtyAndDecompose();
  10205. }
  10206. this._markAsDirtyAndDecompose();
  10207. if (scaleChildren) {
  10208. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  10209. var child = _c[_b];
  10210. child.scale(x, y, z, scaleChildren);
  10211. }
  10212. }
  10213. };
  10214. /**
  10215. * Set the bone scaling in local space
  10216. * @param scale defines the scaling vector
  10217. */
  10218. Bone.prototype.setScale = function (scale) {
  10219. this._decompose();
  10220. this._localScaling.copyFrom(scale);
  10221. this._markAsDirtyAndCompose();
  10222. };
  10223. /**
  10224. * Gets the current scaling in local space
  10225. * @returns the current scaling vector
  10226. */
  10227. Bone.prototype.getScale = function () {
  10228. this._decompose();
  10229. return this._localScaling;
  10230. };
  10231. /**
  10232. * Gets the current scaling in local space and stores it in a target vector
  10233. * @param result defines the target vector
  10234. */
  10235. Bone.prototype.getScaleToRef = function (result) {
  10236. this._decompose();
  10237. result.copyFrom(this._localScaling);
  10238. };
  10239. /**
  10240. * Set the yaw, pitch, and roll of the bone in local or world space
  10241. * @param yaw The rotation of the bone on the y axis
  10242. * @param pitch The rotation of the bone on the x axis
  10243. * @param roll The rotation of the bone on the z axis
  10244. * @param space The space that the axes of rotation are in
  10245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10246. */
  10247. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  10248. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10249. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10250. var quat = Bone._tmpQuat;
  10251. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  10252. this.setRotationQuaternion(quat, space, mesh);
  10253. return;
  10254. }
  10255. var rotMatInv = Bone._tmpMats[0];
  10256. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10257. return;
  10258. }
  10259. var rotMat = Bone._tmpMats[1];
  10260. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  10261. rotMatInv.multiplyToRef(rotMat, rotMat);
  10262. this._rotateWithMatrix(rotMat, space, mesh);
  10263. };
  10264. /**
  10265. * Add a rotation to the bone on an axis in local or world space
  10266. * @param axis The axis to rotate the bone on
  10267. * @param amount The amount to rotate the bone
  10268. * @param space The space that the axis is in
  10269. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10270. */
  10271. Bone.prototype.rotate = function (axis, amount, space, mesh) {
  10272. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10273. var rmat = Bone._tmpMats[0];
  10274. rmat.setTranslationFromFloats(0, 0, 0);
  10275. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  10276. this._rotateWithMatrix(rmat, space, mesh);
  10277. };
  10278. /**
  10279. * Set the rotation of the bone to a particular axis angle in local or world space
  10280. * @param axis The axis to rotate the bone on
  10281. * @param angle The angle that the bone should be rotated to
  10282. * @param space The space that the axis is in
  10283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10284. */
  10285. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  10286. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10287. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10288. var quat = Bone._tmpQuat;
  10289. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  10290. this.setRotationQuaternion(quat, space, mesh);
  10291. return;
  10292. }
  10293. var rotMatInv = Bone._tmpMats[0];
  10294. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10295. return;
  10296. }
  10297. var rotMat = Bone._tmpMats[1];
  10298. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  10299. rotMatInv.multiplyToRef(rotMat, rotMat);
  10300. this._rotateWithMatrix(rotMat, space, mesh);
  10301. };
  10302. /**
  10303. * Set the euler rotation of the bone in local of world space
  10304. * @param rotation The euler rotation that the bone should be set to
  10305. * @param space The space that the rotation is in
  10306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10307. */
  10308. Bone.prototype.setRotation = function (rotation, space, mesh) {
  10309. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10310. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  10311. };
  10312. /**
  10313. * Set the quaternion rotation of the bone in local of world space
  10314. * @param quat The quaternion rotation that the bone should be set to
  10315. * @param space The space that the rotation is in
  10316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10317. */
  10318. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  10319. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10320. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10321. this._decompose();
  10322. this._localRotation.copyFrom(quat);
  10323. this._markAsDirtyAndCompose();
  10324. return;
  10325. }
  10326. var rotMatInv = Bone._tmpMats[0];
  10327. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10328. return;
  10329. }
  10330. var rotMat = Bone._tmpMats[1];
  10331. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  10332. rotMatInv.multiplyToRef(rotMat, rotMat);
  10333. this._rotateWithMatrix(rotMat, space, mesh);
  10334. };
  10335. /**
  10336. * Set the rotation matrix of the bone in local of world space
  10337. * @param rotMat The rotation matrix that the bone should be set to
  10338. * @param space The space that the rotation is in
  10339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10340. */
  10341. Bone.prototype.setRotationMatrix = function (rotMat, space, mesh) {
  10342. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10343. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10344. var quat = Bone._tmpQuat;
  10345. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(rotMat, quat);
  10346. this.setRotationQuaternion(quat, space, mesh);
  10347. return;
  10348. }
  10349. var rotMatInv = Bone._tmpMats[0];
  10350. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10351. return;
  10352. }
  10353. var rotMat2 = Bone._tmpMats[1];
  10354. rotMat2.copyFrom(rotMat);
  10355. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10356. this._rotateWithMatrix(rotMat2, space, mesh);
  10357. };
  10358. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10359. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10360. var lmat = this.getLocalMatrix();
  10361. var lx = lmat.m[12];
  10362. var ly = lmat.m[13];
  10363. var lz = lmat.m[14];
  10364. var parent = this.getParent();
  10365. var parentScale = Bone._tmpMats[3];
  10366. var parentScaleInv = Bone._tmpMats[4];
  10367. if (parent && space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD) {
  10368. if (mesh) {
  10369. parentScale.copyFrom(mesh.getWorldMatrix());
  10370. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10371. }
  10372. else {
  10373. parentScale.copyFrom(parent.getAbsoluteTransform());
  10374. }
  10375. parentScaleInv.copyFrom(parentScale);
  10376. parentScaleInv.invert();
  10377. lmat.multiplyToRef(parentScale, lmat);
  10378. lmat.multiplyToRef(rmat, lmat);
  10379. lmat.multiplyToRef(parentScaleInv, lmat);
  10380. }
  10381. else {
  10382. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD && mesh) {
  10383. parentScale.copyFrom(mesh.getWorldMatrix());
  10384. parentScaleInv.copyFrom(parentScale);
  10385. parentScaleInv.invert();
  10386. lmat.multiplyToRef(parentScale, lmat);
  10387. lmat.multiplyToRef(rmat, lmat);
  10388. lmat.multiplyToRef(parentScaleInv, lmat);
  10389. }
  10390. else {
  10391. lmat.multiplyToRef(rmat, lmat);
  10392. }
  10393. }
  10394. lmat.setTranslationFromFloats(lx, ly, lz);
  10395. this.computeAbsoluteTransforms();
  10396. this._markAsDirtyAndDecompose();
  10397. };
  10398. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10399. var scaleMatrix = Bone._tmpMats[2];
  10400. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10401. if (mesh) {
  10402. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10403. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10404. }
  10405. rotMatInv.invert();
  10406. if (isNaN(rotMatInv.m[0])) {
  10407. // Matrix failed to invert.
  10408. // This can happen if scale is zero for example.
  10409. return false;
  10410. }
  10411. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10412. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10413. return true;
  10414. };
  10415. /**
  10416. * Get the position of the bone in local or world space
  10417. * @param space The space that the returned position is in
  10418. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10419. * @returns The position of the bone
  10420. */
  10421. Bone.prototype.getPosition = function (space, mesh) {
  10422. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10423. if (mesh === void 0) { mesh = null; }
  10424. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10425. this.getPositionToRef(space, mesh, pos);
  10426. return pos;
  10427. };
  10428. /**
  10429. * Copy the position of the bone to a vector3 in local or world space
  10430. * @param space The space that the returned position is in
  10431. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10432. * @param result The vector3 to copy the position to
  10433. */
  10434. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10435. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10436. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10437. var lm = this.getLocalMatrix();
  10438. result.x = lm.m[12];
  10439. result.y = lm.m[13];
  10440. result.z = lm.m[14];
  10441. }
  10442. else {
  10443. var wm = null;
  10444. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10445. if (mesh) {
  10446. wm = mesh.getWorldMatrix();
  10447. }
  10448. this._skeleton.computeAbsoluteTransforms();
  10449. var tmat = Bone._tmpMats[0];
  10450. if (mesh && wm) {
  10451. tmat.copyFrom(this.getAbsoluteTransform());
  10452. tmat.multiplyToRef(wm, tmat);
  10453. }
  10454. else {
  10455. tmat = this.getAbsoluteTransform();
  10456. }
  10457. result.x = tmat.m[12];
  10458. result.y = tmat.m[13];
  10459. result.z = tmat.m[14];
  10460. }
  10461. };
  10462. /**
  10463. * Get the absolute position of the bone (world space)
  10464. * @param mesh The mesh that this bone is attached to
  10465. * @returns The absolute position of the bone
  10466. */
  10467. Bone.prototype.getAbsolutePosition = function (mesh) {
  10468. if (mesh === void 0) { mesh = null; }
  10469. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10470. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, pos);
  10471. return pos;
  10472. };
  10473. /**
  10474. * Copy the absolute position of the bone (world space) to the result param
  10475. * @param mesh The mesh that this bone is attached to
  10476. * @param result The vector3 to copy the absolute position to
  10477. */
  10478. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10479. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, result);
  10480. };
  10481. /**
  10482. * Compute the absolute transforms of this bone and its children
  10483. */
  10484. Bone.prototype.computeAbsoluteTransforms = function () {
  10485. this._compose();
  10486. if (this._parent) {
  10487. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10488. }
  10489. else {
  10490. this._absoluteTransform.copyFrom(this._localMatrix);
  10491. var poseMatrix = this._skeleton.getPoseMatrix();
  10492. if (poseMatrix) {
  10493. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10494. }
  10495. }
  10496. var children = this.children;
  10497. var len = children.length;
  10498. for (var i = 0; i < len; i++) {
  10499. children[i].computeAbsoluteTransforms();
  10500. }
  10501. };
  10502. /**
  10503. * Get the world direction from an axis that is in the local space of the bone
  10504. * @param localAxis The local direction that is used to compute the world direction
  10505. * @param mesh The mesh that this bone is attached to
  10506. * @returns The world direction
  10507. */
  10508. Bone.prototype.getDirection = function (localAxis, mesh) {
  10509. if (mesh === void 0) { mesh = null; }
  10510. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10511. this.getDirectionToRef(localAxis, mesh, result);
  10512. return result;
  10513. };
  10514. /**
  10515. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10516. * @param localAxis The local direction that is used to compute the world direction
  10517. * @param mesh The mesh that this bone is attached to
  10518. * @param result The vector3 that the world direction will be copied to
  10519. */
  10520. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10521. if (mesh === void 0) { mesh = null; }
  10522. var wm = null;
  10523. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10524. if (mesh) {
  10525. wm = mesh.getWorldMatrix();
  10526. }
  10527. this._skeleton.computeAbsoluteTransforms();
  10528. var mat = Bone._tmpMats[0];
  10529. mat.copyFrom(this.getAbsoluteTransform());
  10530. if (mesh && wm) {
  10531. mat.multiplyToRef(wm, mat);
  10532. }
  10533. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10534. result.normalize();
  10535. };
  10536. /**
  10537. * Get the euler rotation of the bone in local or world space
  10538. * @param space The space that the rotation should be in
  10539. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10540. * @returns The euler rotation
  10541. */
  10542. Bone.prototype.getRotation = function (space, mesh) {
  10543. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10544. if (mesh === void 0) { mesh = null; }
  10545. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10546. this.getRotationToRef(space, mesh, result);
  10547. return result;
  10548. };
  10549. /**
  10550. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10551. * @param space The space that the rotation should be in
  10552. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10553. * @param result The vector3 that the rotation should be copied to
  10554. */
  10555. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10556. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10557. if (mesh === void 0) { mesh = null; }
  10558. var quat = Bone._tmpQuat;
  10559. this.getRotationQuaternionToRef(space, mesh, quat);
  10560. quat.toEulerAnglesToRef(result);
  10561. };
  10562. /**
  10563. * Get the quaternion rotation of the bone in either local or world space
  10564. * @param space The space that the rotation should be in
  10565. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10566. * @returns The quaternion rotation
  10567. */
  10568. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10569. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10570. if (mesh === void 0) { mesh = null; }
  10571. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10572. this.getRotationQuaternionToRef(space, mesh, result);
  10573. return result;
  10574. };
  10575. /**
  10576. * Copy the quaternion rotation of the bone to a quaternion. 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.getRotationQuaternionToRef = function (space, mesh, result) {
  10582. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10583. if (mesh === void 0) { mesh = null; }
  10584. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10585. this._decompose();
  10586. result.copyFrom(this._localRotation);
  10587. }
  10588. else {
  10589. var mat = Bone._tmpMats[0];
  10590. var amat = this.getAbsoluteTransform();
  10591. if (mesh) {
  10592. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10593. }
  10594. else {
  10595. mat.copyFrom(amat);
  10596. }
  10597. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10598. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10599. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10600. mat.decompose(undefined, result, undefined);
  10601. }
  10602. };
  10603. /**
  10604. * Get the rotation matrix of the bone in local or world space
  10605. * @param space The space that the rotation should be in
  10606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10607. * @returns The rotation matrix
  10608. */
  10609. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10610. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10611. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10612. this.getRotationMatrixToRef(space, mesh, result);
  10613. return result;
  10614. };
  10615. /**
  10616. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10617. * @param space The space that the rotation should be in
  10618. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10619. * @param result The quaternion that the rotation should be copied to
  10620. */
  10621. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10622. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10623. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10624. this.getLocalMatrix().getRotationMatrixToRef(result);
  10625. }
  10626. else {
  10627. var mat = Bone._tmpMats[0];
  10628. var amat = this.getAbsoluteTransform();
  10629. if (mesh) {
  10630. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10631. }
  10632. else {
  10633. mat.copyFrom(amat);
  10634. }
  10635. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10636. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10637. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10638. mat.getRotationMatrixToRef(result);
  10639. }
  10640. };
  10641. /**
  10642. * Get the world position of a point that is in the local space of the bone
  10643. * @param position The local position
  10644. * @param mesh The mesh that this bone is attached to
  10645. * @returns The world position
  10646. */
  10647. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10648. if (mesh === void 0) { mesh = null; }
  10649. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10650. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10651. return result;
  10652. };
  10653. /**
  10654. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10655. * @param position The local position
  10656. * @param mesh The mesh that this bone is attached to
  10657. * @param result The vector3 that the world position should be copied to
  10658. */
  10659. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10660. if (mesh === void 0) { mesh = null; }
  10661. var wm = null;
  10662. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10663. if (mesh) {
  10664. wm = mesh.getWorldMatrix();
  10665. }
  10666. this._skeleton.computeAbsoluteTransforms();
  10667. var tmat = Bone._tmpMats[0];
  10668. if (mesh && wm) {
  10669. tmat.copyFrom(this.getAbsoluteTransform());
  10670. tmat.multiplyToRef(wm, tmat);
  10671. }
  10672. else {
  10673. tmat = this.getAbsoluteTransform();
  10674. }
  10675. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10676. };
  10677. /**
  10678. * Get the local position of a point that is in world space
  10679. * @param position The world position
  10680. * @param mesh The mesh that this bone is attached to
  10681. * @returns The local position
  10682. */
  10683. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10684. if (mesh === void 0) { mesh = null; }
  10685. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10686. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10687. return result;
  10688. };
  10689. /**
  10690. * Get the local position of a point that is in world space and copy it to the result param
  10691. * @param position The world position
  10692. * @param mesh The mesh that this bone is attached to
  10693. * @param result The vector3 that the local position should be copied to
  10694. */
  10695. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10696. if (mesh === void 0) { mesh = null; }
  10697. var wm = null;
  10698. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10699. if (mesh) {
  10700. wm = mesh.getWorldMatrix();
  10701. }
  10702. this._skeleton.computeAbsoluteTransforms();
  10703. var tmat = Bone._tmpMats[0];
  10704. tmat.copyFrom(this.getAbsoluteTransform());
  10705. if (mesh && wm) {
  10706. tmat.multiplyToRef(wm, tmat);
  10707. }
  10708. tmat.invert();
  10709. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10710. };
  10711. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10712. Bone._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10713. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10714. return Bone;
  10715. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  10716. /***/ }),
  10717. /***/ "./Bones/boneIKController.ts":
  10718. /*!***********************************!*\
  10719. !*** ./Bones/boneIKController.ts ***!
  10720. \***********************************/
  10721. /*! exports provided: BoneIKController */
  10722. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10723. "use strict";
  10724. __webpack_require__.r(__webpack_exports__);
  10725. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10726. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10727. /**
  10728. * Class used to apply inverse kinematics to bones
  10729. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10730. */
  10731. var BoneIKController = /** @class */ (function () {
  10732. /**
  10733. * Creates a new BoneIKController
  10734. * @param mesh defines the mesh to control
  10735. * @param bone defines the bone to control
  10736. * @param options defines options to set up the controller
  10737. */
  10738. function BoneIKController(mesh, bone, options) {
  10739. /**
  10740. * Gets or sets the target position
  10741. */
  10742. this.targetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10743. /**
  10744. * Gets or sets the pole target position
  10745. */
  10746. this.poleTargetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10747. /**
  10748. * Gets or sets the pole target local offset
  10749. */
  10750. this.poleTargetLocalOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10751. /**
  10752. * Gets or sets the pole angle
  10753. */
  10754. this.poleAngle = 0;
  10755. /**
  10756. * 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)
  10757. */
  10758. this.slerpAmount = 1;
  10759. this._bone1Quat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10760. this._bone1Mat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10761. this._bone2Ang = Math.PI;
  10762. this._maxAngle = Math.PI;
  10763. this._rightHandedSystem = false;
  10764. this._bendAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10765. this._slerping = false;
  10766. this._adjustRoll = 0;
  10767. this._bone2 = bone;
  10768. this._bone1 = bone.getParent();
  10769. if (!this._bone1) {
  10770. return;
  10771. }
  10772. this.mesh = mesh;
  10773. var bonePos = bone.getPosition();
  10774. if (bone.getAbsoluteTransform().determinant() > 0) {
  10775. this._rightHandedSystem = true;
  10776. this._bendAxis.x = 0;
  10777. this._bendAxis.y = 0;
  10778. this._bendAxis.z = -1;
  10779. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10780. this._adjustRoll = Math.PI * .5;
  10781. this._bendAxis.z = 1;
  10782. }
  10783. }
  10784. if (this._bone1.length) {
  10785. var boneScale1 = this._bone1.getScale();
  10786. var boneScale2 = this._bone2.getScale();
  10787. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10788. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10789. }
  10790. else if (this._bone1.children[0]) {
  10791. mesh.computeWorldMatrix(true);
  10792. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10793. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10794. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10795. this._bone1Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10796. this._bone2Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10797. }
  10798. this._bone1.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, mesh, this._bone1Mat);
  10799. this.maxAngle = Math.PI;
  10800. if (options) {
  10801. if (options.targetMesh) {
  10802. this.targetMesh = options.targetMesh;
  10803. this.targetMesh.computeWorldMatrix(true);
  10804. }
  10805. if (options.poleTargetMesh) {
  10806. this.poleTargetMesh = options.poleTargetMesh;
  10807. this.poleTargetMesh.computeWorldMatrix(true);
  10808. }
  10809. else if (options.poleTargetBone) {
  10810. this.poleTargetBone = options.poleTargetBone;
  10811. }
  10812. else if (this._bone1.getParent()) {
  10813. this.poleTargetBone = this._bone1.getParent();
  10814. }
  10815. if (options.poleTargetLocalOffset) {
  10816. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10817. }
  10818. if (options.poleAngle) {
  10819. this.poleAngle = options.poleAngle;
  10820. }
  10821. if (options.bendAxis) {
  10822. this._bendAxis.copyFrom(options.bendAxis);
  10823. }
  10824. if (options.maxAngle) {
  10825. this.maxAngle = options.maxAngle;
  10826. }
  10827. if (options.slerpAmount) {
  10828. this.slerpAmount = options.slerpAmount;
  10829. }
  10830. }
  10831. }
  10832. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10833. /**
  10834. * Gets or sets maximum allowed angle
  10835. */
  10836. get: function () {
  10837. return this._maxAngle;
  10838. },
  10839. set: function (value) {
  10840. this._setMaxAngle(value);
  10841. },
  10842. enumerable: true,
  10843. configurable: true
  10844. });
  10845. BoneIKController.prototype._setMaxAngle = function (ang) {
  10846. if (ang < 0) {
  10847. ang = 0;
  10848. }
  10849. if (ang > Math.PI || ang == undefined) {
  10850. ang = Math.PI;
  10851. }
  10852. this._maxAngle = ang;
  10853. var a = this._bone1Length;
  10854. var b = this._bone2Length;
  10855. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10856. };
  10857. /**
  10858. * Force the controller to update the bones
  10859. */
  10860. BoneIKController.prototype.update = function () {
  10861. var bone1 = this._bone1;
  10862. if (!bone1) {
  10863. return;
  10864. }
  10865. var target = this.targetPosition;
  10866. var poleTarget = this.poleTargetPosition;
  10867. var mat1 = BoneIKController._tmpMats[0];
  10868. var mat2 = BoneIKController._tmpMats[1];
  10869. if (this.targetMesh) {
  10870. target.copyFrom(this.targetMesh.getAbsolutePosition());
  10871. }
  10872. if (this.poleTargetBone) {
  10873. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  10874. }
  10875. else if (this.poleTargetMesh) {
  10876. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  10877. }
  10878. var bonePos = BoneIKController._tmpVecs[0];
  10879. var zaxis = BoneIKController._tmpVecs[1];
  10880. var xaxis = BoneIKController._tmpVecs[2];
  10881. var yaxis = BoneIKController._tmpVecs[3];
  10882. var upAxis = BoneIKController._tmpVecs[4];
  10883. var _tmpQuat = BoneIKController._tmpQuat;
  10884. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  10885. poleTarget.subtractToRef(bonePos, upAxis);
  10886. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  10887. upAxis.y = 1;
  10888. }
  10889. else {
  10890. upAxis.normalize();
  10891. }
  10892. target.subtractToRef(bonePos, yaxis);
  10893. yaxis.normalize();
  10894. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  10895. zaxis.normalize();
  10896. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  10897. xaxis.normalize();
  10898. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  10899. var a = this._bone1Length;
  10900. var b = this._bone2Length;
  10901. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  10902. if (this._maxReach > 0) {
  10903. c = Math.min(this._maxReach, c);
  10904. }
  10905. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  10906. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  10907. if (acosa > 1) {
  10908. acosa = 1;
  10909. }
  10910. if (acosb > 1) {
  10911. acosb = 1;
  10912. }
  10913. if (acosa < -1) {
  10914. acosa = -1;
  10915. }
  10916. if (acosb < -1) {
  10917. acosb = -1;
  10918. }
  10919. var angA = Math.acos(acosa);
  10920. var angB = Math.acos(acosb);
  10921. var angC = -angA - angB;
  10922. if (this._rightHandedSystem) {
  10923. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  10924. mat2.multiplyToRef(mat1, mat1);
  10925. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  10926. mat2.multiplyToRef(mat1, mat1);
  10927. }
  10928. else {
  10929. var _tmpVec = BoneIKController._tmpVecs[5];
  10930. _tmpVec.copyFrom(this._bendAxis);
  10931. _tmpVec.x *= -1;
  10932. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  10933. mat2.multiplyToRef(mat1, mat1);
  10934. }
  10935. if (this.poleAngle) {
  10936. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  10937. mat1.multiplyToRef(mat2, mat1);
  10938. }
  10939. if (this._bone1) {
  10940. if (this.slerpAmount < 1) {
  10941. if (!this._slerping) {
  10942. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  10943. }
  10944. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  10945. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  10946. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  10947. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10948. this._slerping = true;
  10949. }
  10950. else {
  10951. this._bone1.setRotationMatrix(mat1, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10952. this._bone1Mat.copyFrom(mat1);
  10953. this._slerping = false;
  10954. }
  10955. }
  10956. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].LOCAL);
  10957. this._bone2Ang = angC;
  10958. };
  10959. 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()];
  10960. BoneIKController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10961. BoneIKController._tmpMats = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  10962. return BoneIKController;
  10963. }());
  10964. /***/ }),
  10965. /***/ "./Bones/boneLookController.ts":
  10966. /*!*************************************!*\
  10967. !*** ./Bones/boneLookController.ts ***!
  10968. \*************************************/
  10969. /*! exports provided: BoneLookController */
  10970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10971. "use strict";
  10972. __webpack_require__.r(__webpack_exports__);
  10973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  10974. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  10975. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10976. /**
  10977. * Class used to make a bone look toward a point in space
  10978. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  10979. */
  10980. var BoneLookController = /** @class */ (function () {
  10981. /**
  10982. * Create a BoneLookController
  10983. * @param mesh the mesh that the bone belongs to
  10984. * @param bone the bone that will be looking to the target
  10985. * @param target the target Vector3 to look at
  10986. * @param options optional settings:
  10987. * * maxYaw: the maximum angle the bone will yaw to
  10988. * * minYaw: the minimum angle the bone will yaw to
  10989. * * maxPitch: the maximum angle the bone will pitch to
  10990. * * minPitch: the minimum angle the bone will yaw to
  10991. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  10992. * * upAxis: the up axis of the coordinate system
  10993. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  10994. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  10995. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  10996. * * adjustYaw: used to make an adjustment to the yaw of the bone
  10997. * * adjustPitch: used to make an adjustment to the pitch of the bone
  10998. * * adjustRoll: used to make an adjustment to the roll of the bone
  10999. **/
  11000. function BoneLookController(mesh, bone, target, options) {
  11001. /**
  11002. * The up axis of the coordinate system that is used when the bone is rotated
  11003. */
  11004. this.upAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  11005. /**
  11006. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  11007. */
  11008. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11009. /**
  11010. * Used to make an adjustment to the yaw of the bone
  11011. */
  11012. this.adjustYaw = 0;
  11013. /**
  11014. * Used to make an adjustment to the pitch of the bone
  11015. */
  11016. this.adjustPitch = 0;
  11017. /**
  11018. * Used to make an adjustment to the roll of the bone
  11019. */
  11020. this.adjustRoll = 0;
  11021. /**
  11022. * 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)
  11023. */
  11024. this.slerpAmount = 1;
  11025. this._boneQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11026. this._slerping = false;
  11027. this._firstFrameSkipped = false;
  11028. this._fowardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  11029. this.mesh = mesh;
  11030. this.bone = bone;
  11031. this.target = target;
  11032. if (options) {
  11033. if (options.adjustYaw) {
  11034. this.adjustYaw = options.adjustYaw;
  11035. }
  11036. if (options.adjustPitch) {
  11037. this.adjustPitch = options.adjustPitch;
  11038. }
  11039. if (options.adjustRoll) {
  11040. this.adjustRoll = options.adjustRoll;
  11041. }
  11042. if (options.maxYaw != null) {
  11043. this.maxYaw = options.maxYaw;
  11044. }
  11045. else {
  11046. this.maxYaw = Math.PI;
  11047. }
  11048. if (options.minYaw != null) {
  11049. this.minYaw = options.minYaw;
  11050. }
  11051. else {
  11052. this.minYaw = -Math.PI;
  11053. }
  11054. if (options.maxPitch != null) {
  11055. this.maxPitch = options.maxPitch;
  11056. }
  11057. else {
  11058. this.maxPitch = Math.PI;
  11059. }
  11060. if (options.minPitch != null) {
  11061. this.minPitch = options.minPitch;
  11062. }
  11063. else {
  11064. this.minPitch = -Math.PI;
  11065. }
  11066. if (options.slerpAmount != null) {
  11067. this.slerpAmount = options.slerpAmount;
  11068. }
  11069. if (options.upAxis != null) {
  11070. this.upAxis = options.upAxis;
  11071. }
  11072. if (options.upAxisSpace != null) {
  11073. this.upAxisSpace = options.upAxisSpace;
  11074. }
  11075. if (options.yawAxis != null || options.pitchAxis != null) {
  11076. var newYawAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y;
  11077. var newPitchAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].X;
  11078. if (options.yawAxis != null) {
  11079. newYawAxis = options.yawAxis.clone();
  11080. newYawAxis.normalize();
  11081. }
  11082. if (options.pitchAxis != null) {
  11083. newPitchAxis = options.pitchAxis.clone();
  11084. newPitchAxis.normalize();
  11085. }
  11086. var newRollAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  11087. this._transformYawPitch = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  11088. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  11089. this._transformYawPitchInv = this._transformYawPitch.clone();
  11090. this._transformYawPitch.invert();
  11091. }
  11092. }
  11093. if (!bone.getParent() && this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE) {
  11094. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11095. }
  11096. }
  11097. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  11098. /**
  11099. * Gets or sets the minimum yaw angle that the bone can look to
  11100. */
  11101. get: function () {
  11102. return this._minYaw;
  11103. },
  11104. set: function (value) {
  11105. this._minYaw = value;
  11106. this._minYawSin = Math.sin(value);
  11107. this._minYawCos = Math.cos(value);
  11108. if (this._maxYaw != null) {
  11109. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11110. this._yawRange = this._maxYaw - this._minYaw;
  11111. }
  11112. },
  11113. enumerable: true,
  11114. configurable: true
  11115. });
  11116. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  11117. /**
  11118. * Gets or sets the maximum yaw angle that the bone can look to
  11119. */
  11120. get: function () {
  11121. return this._maxYaw;
  11122. },
  11123. set: function (value) {
  11124. this._maxYaw = value;
  11125. this._maxYawSin = Math.sin(value);
  11126. this._maxYawCos = Math.cos(value);
  11127. if (this._minYaw != null) {
  11128. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11129. this._yawRange = this._maxYaw - this._minYaw;
  11130. }
  11131. },
  11132. enumerable: true,
  11133. configurable: true
  11134. });
  11135. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  11136. /**
  11137. * Gets or sets the minimum pitch angle that the bone can look to
  11138. */
  11139. get: function () {
  11140. return this._minPitch;
  11141. },
  11142. set: function (value) {
  11143. this._minPitch = value;
  11144. this._minPitchTan = Math.tan(value);
  11145. },
  11146. enumerable: true,
  11147. configurable: true
  11148. });
  11149. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  11150. /**
  11151. * Gets or sets the maximum pitch angle that the bone can look to
  11152. */
  11153. get: function () {
  11154. return this._maxPitch;
  11155. },
  11156. set: function (value) {
  11157. this._maxPitch = value;
  11158. this._maxPitchTan = Math.tan(value);
  11159. },
  11160. enumerable: true,
  11161. configurable: true
  11162. });
  11163. /**
  11164. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  11165. */
  11166. BoneLookController.prototype.update = function () {
  11167. //skip the first frame when slerping so that the mesh rotation is correct
  11168. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  11169. this._firstFrameSkipped = true;
  11170. return;
  11171. }
  11172. var bone = this.bone;
  11173. var bonePos = BoneLookController._tmpVecs[0];
  11174. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  11175. var target = this.target;
  11176. var _tmpMat1 = BoneLookController._tmpMats[0];
  11177. var _tmpMat2 = BoneLookController._tmpMats[1];
  11178. var mesh = this.mesh;
  11179. var parentBone = bone.getParent();
  11180. var upAxis = BoneLookController._tmpVecs[1];
  11181. upAxis.copyFrom(this.upAxis);
  11182. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && parentBone) {
  11183. if (this._transformYawPitch) {
  11184. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  11185. }
  11186. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  11187. }
  11188. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  11189. mesh.getDirectionToRef(upAxis, upAxis);
  11190. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  11191. upAxis.normalize();
  11192. }
  11193. }
  11194. var checkYaw = false;
  11195. var checkPitch = false;
  11196. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  11197. checkYaw = true;
  11198. }
  11199. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  11200. checkPitch = true;
  11201. }
  11202. if (checkYaw || checkPitch) {
  11203. var spaceMat = BoneLookController._tmpMats[2];
  11204. var spaceMatInv = BoneLookController._tmpMats[3];
  11205. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && upAxis.y == 1 && parentBone) {
  11206. parentBone.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, spaceMat);
  11207. }
  11208. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  11209. spaceMat.copyFrom(mesh.getWorldMatrix());
  11210. }
  11211. else {
  11212. var forwardAxis = BoneLookController._tmpVecs[2];
  11213. forwardAxis.copyFrom(this._fowardAxis);
  11214. if (this._transformYawPitch) {
  11215. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  11216. }
  11217. if (parentBone) {
  11218. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  11219. }
  11220. else {
  11221. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  11222. }
  11223. var rightAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  11224. rightAxis.normalize();
  11225. var forwardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  11226. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  11227. }
  11228. spaceMat.invertToRef(spaceMatInv);
  11229. var xzlen = null;
  11230. if (checkPitch) {
  11231. var localTarget = BoneLookController._tmpVecs[3];
  11232. target.subtractToRef(bonePos, localTarget);
  11233. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11234. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11235. var pitch = Math.atan2(localTarget.y, xzlen);
  11236. var newPitch = pitch;
  11237. if (pitch > this._maxPitch) {
  11238. localTarget.y = this._maxPitchTan * xzlen;
  11239. newPitch = this._maxPitch;
  11240. }
  11241. else if (pitch < this._minPitch) {
  11242. localTarget.y = this._minPitchTan * xzlen;
  11243. newPitch = this._minPitch;
  11244. }
  11245. if (pitch != newPitch) {
  11246. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11247. localTarget.addInPlace(bonePos);
  11248. target = localTarget;
  11249. }
  11250. }
  11251. if (checkYaw) {
  11252. var localTarget = BoneLookController._tmpVecs[4];
  11253. target.subtractToRef(bonePos, localTarget);
  11254. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11255. var yaw = Math.atan2(localTarget.x, localTarget.z);
  11256. var newYaw = yaw;
  11257. if (yaw > this._maxYaw || yaw < this._minYaw) {
  11258. if (xzlen == null) {
  11259. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11260. }
  11261. if (this._yawRange > Math.PI) {
  11262. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  11263. localTarget.z = this._maxYawCos * xzlen;
  11264. localTarget.x = this._maxYawSin * xzlen;
  11265. newYaw = this._maxYaw;
  11266. }
  11267. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  11268. localTarget.z = this._minYawCos * xzlen;
  11269. localTarget.x = this._minYawSin * xzlen;
  11270. newYaw = this._minYaw;
  11271. }
  11272. }
  11273. else {
  11274. if (yaw > this._maxYaw) {
  11275. localTarget.z = this._maxYawCos * xzlen;
  11276. localTarget.x = this._maxYawSin * xzlen;
  11277. newYaw = this._maxYaw;
  11278. }
  11279. else if (yaw < this._minYaw) {
  11280. localTarget.z = this._minYawCos * xzlen;
  11281. localTarget.x = this._minYawSin * xzlen;
  11282. newYaw = this._minYaw;
  11283. }
  11284. }
  11285. }
  11286. if (this._slerping && this._yawRange > Math.PI) {
  11287. //are we going to be crossing into the min/max region?
  11288. var boneFwd = BoneLookController._tmpVecs[8];
  11289. boneFwd.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Z);
  11290. if (this._transformYawPitch) {
  11291. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  11292. }
  11293. var boneRotMat = BoneLookController._tmpMats[4];
  11294. this._boneQuat.toRotationMatrix(boneRotMat);
  11295. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  11296. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  11297. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  11298. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  11299. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  11300. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  11301. if (angBtwTar > angBtwMidYaw) {
  11302. if (xzlen == null) {
  11303. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11304. }
  11305. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  11306. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  11307. if (angBtwMin < angBtwMax) {
  11308. newYaw = boneYaw + Math.PI * .75;
  11309. localTarget.z = Math.cos(newYaw) * xzlen;
  11310. localTarget.x = Math.sin(newYaw) * xzlen;
  11311. }
  11312. else {
  11313. newYaw = boneYaw - Math.PI * .75;
  11314. localTarget.z = Math.cos(newYaw) * xzlen;
  11315. localTarget.x = Math.sin(newYaw) * xzlen;
  11316. }
  11317. }
  11318. }
  11319. if (yaw != newYaw) {
  11320. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11321. localTarget.addInPlace(bonePos);
  11322. target = localTarget;
  11323. }
  11324. }
  11325. }
  11326. var zaxis = BoneLookController._tmpVecs[5];
  11327. var xaxis = BoneLookController._tmpVecs[6];
  11328. var yaxis = BoneLookController._tmpVecs[7];
  11329. var _tmpQuat = BoneLookController._tmpQuat;
  11330. target.subtractToRef(bonePos, zaxis);
  11331. zaxis.normalize();
  11332. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  11333. xaxis.normalize();
  11334. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  11335. yaxis.normalize();
  11336. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  11337. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  11338. return;
  11339. }
  11340. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  11341. return;
  11342. }
  11343. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  11344. return;
  11345. }
  11346. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  11347. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11348. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11349. }
  11350. if (this.slerpAmount < 1) {
  11351. if (!this._slerping) {
  11352. this.bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, this._boneQuat);
  11353. }
  11354. if (this._transformYawPitch) {
  11355. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11356. }
  11357. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11358. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11359. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11360. this._slerping = true;
  11361. }
  11362. else {
  11363. if (this._transformYawPitch) {
  11364. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11365. }
  11366. this.bone.setRotationMatrix(_tmpMat1, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11367. this._slerping = false;
  11368. }
  11369. };
  11370. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11371. var angDiff = ang2 - ang1;
  11372. angDiff %= Math.PI * 2;
  11373. if (angDiff > Math.PI) {
  11374. angDiff -= Math.PI * 2;
  11375. }
  11376. else if (angDiff < -Math.PI) {
  11377. angDiff += Math.PI * 2;
  11378. }
  11379. return angDiff;
  11380. };
  11381. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11382. ang1 %= (2 * Math.PI);
  11383. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11384. ang2 %= (2 * Math.PI);
  11385. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11386. var ab = 0;
  11387. if (ang1 < ang2) {
  11388. ab = ang2 - ang1;
  11389. }
  11390. else {
  11391. ab = ang1 - ang2;
  11392. }
  11393. if (ab > Math.PI) {
  11394. ab = Math.PI * 2 - ab;
  11395. }
  11396. return ab;
  11397. };
  11398. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11399. ang %= (2 * Math.PI);
  11400. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11401. ang1 %= (2 * Math.PI);
  11402. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11403. ang2 %= (2 * Math.PI);
  11404. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11405. if (ang1 < ang2) {
  11406. if (ang > ang1 && ang < ang2) {
  11407. return true;
  11408. }
  11409. }
  11410. else {
  11411. if (ang > ang2 && ang < ang1) {
  11412. return true;
  11413. }
  11414. }
  11415. return false;
  11416. };
  11417. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11418. BoneLookController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11419. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11420. return BoneLookController;
  11421. }());
  11422. /***/ }),
  11423. /***/ "./Bones/index.ts":
  11424. /*!************************!*\
  11425. !*** ./Bones/index.ts ***!
  11426. \************************/
  11427. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11428. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11429. "use strict";
  11430. __webpack_require__.r(__webpack_exports__);
  11431. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11433. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11435. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11437. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11439. /***/ }),
  11440. /***/ "./Bones/skeleton.ts":
  11441. /*!***************************!*\
  11442. !*** ./Bones/skeleton.ts ***!
  11443. \***************************/
  11444. /*! exports provided: Skeleton */
  11445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11446. "use strict";
  11447. __webpack_require__.r(__webpack_exports__);
  11448. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11449. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11450. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11451. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11452. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11453. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11454. /* harmony import */ var _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animationRange */ "./Animations/animationRange.ts");
  11455. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11456. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11457. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11458. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11459. /**
  11460. * Class used to handle skinning animations
  11461. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11462. */
  11463. var Skeleton = /** @class */ (function () {
  11464. /**
  11465. * Creates a new skeleton
  11466. * @param name defines the skeleton name
  11467. * @param id defines the skeleton Id
  11468. * @param scene defines the hosting scene
  11469. */
  11470. function Skeleton(
  11471. /** defines the skeleton name */
  11472. name,
  11473. /** defines the skeleton Id */
  11474. id, scene) {
  11475. this.name = name;
  11476. this.id = id;
  11477. /**
  11478. * Defines the list of child bones
  11479. */
  11480. this.bones = new Array();
  11481. /**
  11482. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11483. */
  11484. this.needInitialSkinMatrix = false;
  11485. /**
  11486. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11487. */
  11488. this.overrideMesh = null;
  11489. this._isDirty = true;
  11490. this._meshesWithPoseMatrix = new Array();
  11491. this._identity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11492. this._ranges = {};
  11493. this._lastAbsoluteTransformsUpdateId = -1;
  11494. this._canUseTextureForBones = false;
  11495. this._uniqueId = 0;
  11496. /** @hidden */
  11497. this._numBonesWithLinkedTransformNode = 0;
  11498. /**
  11499. * Specifies if the skeleton should be serialized
  11500. */
  11501. this.doNotSerialize = false;
  11502. this._useTextureToStoreBoneMatrices = true;
  11503. this._animationPropertiesOverride = null;
  11504. // Events
  11505. /**
  11506. * An observable triggered before computing the skeleton's matrices
  11507. */
  11508. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11509. this.bones = [];
  11510. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  11511. this._uniqueId = this._scene.getUniqueId();
  11512. this._scene.addSkeleton(this);
  11513. //make sure it will recalculate the matrix next time prepare is called.
  11514. this._isDirty = true;
  11515. var engineCaps = this._scene.getEngine().getCaps();
  11516. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11517. }
  11518. Object.defineProperty(Skeleton.prototype, "useTextureToStoreBoneMatrices", {
  11519. /**
  11520. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11521. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  11522. */
  11523. get: function () {
  11524. return this._useTextureToStoreBoneMatrices;
  11525. },
  11526. set: function (value) {
  11527. this._useTextureToStoreBoneMatrices = value;
  11528. this._markAsDirty();
  11529. },
  11530. enumerable: true,
  11531. configurable: true
  11532. });
  11533. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11534. /**
  11535. * Gets or sets the animation properties override
  11536. */
  11537. get: function () {
  11538. if (!this._animationPropertiesOverride) {
  11539. return this._scene.animationPropertiesOverride;
  11540. }
  11541. return this._animationPropertiesOverride;
  11542. },
  11543. set: function (value) {
  11544. this._animationPropertiesOverride = value;
  11545. },
  11546. enumerable: true,
  11547. configurable: true
  11548. });
  11549. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11550. /**
  11551. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11552. */
  11553. get: function () {
  11554. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
  11555. },
  11556. enumerable: true,
  11557. configurable: true
  11558. });
  11559. Object.defineProperty(Skeleton.prototype, "uniqueId", {
  11560. /**
  11561. * Gets the unique ID of this skeleton
  11562. */
  11563. get: function () {
  11564. return this._uniqueId;
  11565. },
  11566. enumerable: true,
  11567. configurable: true
  11568. });
  11569. /**
  11570. * Gets the current object class name.
  11571. * @return the class name
  11572. */
  11573. Skeleton.prototype.getClassName = function () {
  11574. return "Skeleton";
  11575. };
  11576. /**
  11577. * Returns an array containing the root bones
  11578. * @returns an array containing the root bones
  11579. */
  11580. Skeleton.prototype.getChildren = function () {
  11581. return this.bones.filter(function (b) { return !b.getParent(); });
  11582. };
  11583. // Members
  11584. /**
  11585. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11586. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11587. * @returns a Float32Array containing matrices data
  11588. */
  11589. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11590. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11591. return mesh._bonesTransformMatrices;
  11592. }
  11593. if (!this._transformMatrices) {
  11594. this.prepare();
  11595. }
  11596. return this._transformMatrices;
  11597. };
  11598. /**
  11599. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11600. * @returns a raw texture containing the data
  11601. */
  11602. Skeleton.prototype.getTransformMatrixTexture = function () {
  11603. return this._transformMatrixTexture;
  11604. };
  11605. /**
  11606. * Gets the current hosting scene
  11607. * @returns a scene object
  11608. */
  11609. Skeleton.prototype.getScene = function () {
  11610. return this._scene;
  11611. };
  11612. // Methods
  11613. /**
  11614. * Gets a string representing the current skeleton data
  11615. * @param fullDetails defines a boolean indicating if we want a verbose version
  11616. * @returns a string representing the current skeleton data
  11617. */
  11618. Skeleton.prototype.toString = function (fullDetails) {
  11619. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11620. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11621. if (fullDetails) {
  11622. ret += ", Ranges: {";
  11623. var first = true;
  11624. for (var name_1 in this._ranges) {
  11625. if (first) {
  11626. ret += ", ";
  11627. first = false;
  11628. }
  11629. ret += name_1;
  11630. }
  11631. ret += "}";
  11632. }
  11633. return ret;
  11634. };
  11635. /**
  11636. * Get bone's index searching by name
  11637. * @param name defines bone's name to search for
  11638. * @return the indice of the bone. Returns -1 if not found
  11639. */
  11640. Skeleton.prototype.getBoneIndexByName = function (name) {
  11641. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11642. if (this.bones[boneIndex].name === name) {
  11643. return boneIndex;
  11644. }
  11645. }
  11646. return -1;
  11647. };
  11648. /**
  11649. * Creater a new animation range
  11650. * @param name defines the name of the range
  11651. * @param from defines the start key
  11652. * @param to defines the end key
  11653. */
  11654. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11655. // check name not already in use
  11656. if (!this._ranges[name]) {
  11657. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  11658. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11659. if (this.bones[i].animations[0]) {
  11660. this.bones[i].animations[0].createRange(name, from, to);
  11661. }
  11662. }
  11663. }
  11664. };
  11665. /**
  11666. * Delete a specific animation range
  11667. * @param name defines the name of the range
  11668. * @param deleteFrames defines if frames must be removed as well
  11669. */
  11670. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11671. if (deleteFrames === void 0) { deleteFrames = true; }
  11672. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11673. if (this.bones[i].animations[0]) {
  11674. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11675. }
  11676. }
  11677. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11678. };
  11679. /**
  11680. * Gets a specific animation range
  11681. * @param name defines the name of the range to look for
  11682. * @returns the requested animation range or null if not found
  11683. */
  11684. Skeleton.prototype.getAnimationRange = function (name) {
  11685. return this._ranges[name];
  11686. };
  11687. /**
  11688. * Gets the list of all animation ranges defined on this skeleton
  11689. * @returns an array
  11690. */
  11691. Skeleton.prototype.getAnimationRanges = function () {
  11692. var animationRanges = [];
  11693. var name;
  11694. for (name in this._ranges) {
  11695. animationRanges.push(this._ranges[name]);
  11696. }
  11697. return animationRanges;
  11698. };
  11699. /**
  11700. * Copy animation range from a source skeleton.
  11701. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11702. * @param source defines the source skeleton
  11703. * @param name defines the name of the range to copy
  11704. * @param rescaleAsRequired defines if rescaling must be applied if required
  11705. * @returns true if operation was successful
  11706. */
  11707. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11708. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11709. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11710. return false;
  11711. }
  11712. var ret = true;
  11713. var frameOffset = this._getHighestAnimationFrame() + 1;
  11714. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11715. var boneDict = {};
  11716. var sourceBones = source.bones;
  11717. var nBones;
  11718. var i;
  11719. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11720. boneDict[sourceBones[i].name] = sourceBones[i];
  11721. }
  11722. if (this.bones.length !== sourceBones.length) {
  11723. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11724. ret = false;
  11725. }
  11726. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11727. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11728. var boneName = this.bones[i].name;
  11729. var sourceBone = boneDict[boneName];
  11730. if (sourceBone) {
  11731. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11732. }
  11733. else {
  11734. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11735. ret = false;
  11736. }
  11737. }
  11738. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11739. var range = source.getAnimationRange(name);
  11740. if (range) {
  11741. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11742. }
  11743. return ret;
  11744. };
  11745. /**
  11746. * Forces the skeleton to go to rest pose
  11747. */
  11748. Skeleton.prototype.returnToRest = function () {
  11749. for (var index = 0; index < this.bones.length; index++) {
  11750. this.bones[index].returnToRest();
  11751. }
  11752. };
  11753. Skeleton.prototype._getHighestAnimationFrame = function () {
  11754. var ret = 0;
  11755. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11756. if (this.bones[i].animations[0]) {
  11757. var highest = this.bones[i].animations[0].getHighestFrame();
  11758. if (ret < highest) {
  11759. ret = highest;
  11760. }
  11761. }
  11762. }
  11763. return ret;
  11764. };
  11765. /**
  11766. * Begin a specific animation range
  11767. * @param name defines the name of the range to start
  11768. * @param loop defines if looping must be turned on (false by default)
  11769. * @param speedRatio defines the speed ratio to apply (1 by default)
  11770. * @param onAnimationEnd defines a callback which will be called when animation will end
  11771. * @returns a new animatable
  11772. */
  11773. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11774. var range = this.getAnimationRange(name);
  11775. if (!range) {
  11776. return null;
  11777. }
  11778. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11779. };
  11780. /** @hidden */
  11781. Skeleton.prototype._markAsDirty = function () {
  11782. this._isDirty = true;
  11783. };
  11784. /** @hidden */
  11785. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11786. this._meshesWithPoseMatrix.push(mesh);
  11787. };
  11788. /** @hidden */
  11789. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11790. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11791. if (index > -1) {
  11792. this._meshesWithPoseMatrix.splice(index, 1);
  11793. }
  11794. };
  11795. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11796. this.onBeforeComputeObservable.notifyObservers(this);
  11797. for (var index = 0; index < this.bones.length; index++) {
  11798. var bone = this.bones[index];
  11799. var parentBone = bone.getParent();
  11800. if (parentBone) {
  11801. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11802. }
  11803. else {
  11804. if (initialSkinMatrix) {
  11805. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11806. }
  11807. else {
  11808. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11809. }
  11810. }
  11811. if (bone._index !== -1) {
  11812. var mappedIndex = bone._index === null ? index : bone._index;
  11813. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11814. }
  11815. }
  11816. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11817. };
  11818. /**
  11819. * Build all resources required to render a skeleton
  11820. */
  11821. Skeleton.prototype.prepare = function () {
  11822. // Update the local matrix of bones with linked transform nodes.
  11823. if (this._numBonesWithLinkedTransformNode > 0) {
  11824. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11825. var bone_1 = _a[_i];
  11826. if (bone_1._linkedTransformNode) {
  11827. // Computing the world matrix also computes the local matrix.
  11828. bone_1._linkedTransformNode.computeWorldMatrix();
  11829. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11830. bone_1.markAsDirty();
  11831. }
  11832. }
  11833. }
  11834. if (!this._isDirty) {
  11835. return;
  11836. }
  11837. if (this.needInitialSkinMatrix) {
  11838. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11839. var mesh = this._meshesWithPoseMatrix[index];
  11840. var poseMatrix = mesh.getPoseMatrix();
  11841. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11842. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11843. }
  11844. if (this._synchronizedWithMesh !== mesh) {
  11845. this._synchronizedWithMesh = mesh;
  11846. // Prepare bones
  11847. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11848. var bone = this.bones[boneIndex];
  11849. if (!bone.getParent()) {
  11850. var matrix = bone.getBaseMatrix();
  11851. matrix.multiplyToRef(poseMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11852. bone._updateDifferenceMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11853. }
  11854. }
  11855. }
  11856. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  11857. }
  11858. }
  11859. else {
  11860. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  11861. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11862. if (this.isUsingTextureForMatrices) {
  11863. if (this._transformMatrixTexture) {
  11864. this._transformMatrixTexture.dispose();
  11865. }
  11866. 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);
  11867. }
  11868. }
  11869. this._computeTransformMatrices(this._transformMatrices, null);
  11870. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  11871. this._transformMatrixTexture.update(this._transformMatrices);
  11872. }
  11873. }
  11874. this._isDirty = false;
  11875. this._scene._activeBones.addCount(this.bones.length, false);
  11876. };
  11877. /**
  11878. * Gets the list of animatables currently running for this skeleton
  11879. * @returns an array of animatables
  11880. */
  11881. Skeleton.prototype.getAnimatables = function () {
  11882. if (!this._animatables || this._animatables.length !== this.bones.length) {
  11883. this._animatables = [];
  11884. for (var index = 0; index < this.bones.length; index++) {
  11885. this._animatables.push(this.bones[index]);
  11886. }
  11887. }
  11888. return this._animatables;
  11889. };
  11890. /**
  11891. * Clone the current skeleton
  11892. * @param name defines the name of the new skeleton
  11893. * @param id defines the id of the enw skeleton
  11894. * @returns the new skeleton
  11895. */
  11896. Skeleton.prototype.clone = function (name, id) {
  11897. var result = new Skeleton(name, id || name, this._scene);
  11898. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11899. for (var index = 0; index < this.bones.length; index++) {
  11900. var source = this.bones[index];
  11901. var parentBone = null;
  11902. var parent_1 = source.getParent();
  11903. if (parent_1) {
  11904. var parentIndex = this.bones.indexOf(parent_1);
  11905. parentBone = result.bones[parentIndex];
  11906. }
  11907. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  11908. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  11909. }
  11910. if (this._ranges) {
  11911. result._ranges = {};
  11912. for (var rangeName in this._ranges) {
  11913. var range = this._ranges[rangeName];
  11914. if (range) {
  11915. result._ranges[rangeName] = range.clone();
  11916. }
  11917. }
  11918. }
  11919. this._isDirty = true;
  11920. return result;
  11921. };
  11922. /**
  11923. * Enable animation blending for this skeleton
  11924. * @param blendingSpeed defines the blending speed to apply
  11925. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  11926. */
  11927. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  11928. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  11929. this.bones.forEach(function (bone) {
  11930. bone.animations.forEach(function (animation) {
  11931. animation.enableBlending = true;
  11932. animation.blendingSpeed = blendingSpeed;
  11933. });
  11934. });
  11935. };
  11936. /**
  11937. * Releases all resources associated with the current skeleton
  11938. */
  11939. Skeleton.prototype.dispose = function () {
  11940. this._meshesWithPoseMatrix = [];
  11941. // Animations
  11942. this.getScene().stopAnimation(this);
  11943. // Remove from scene
  11944. this.getScene().removeSkeleton(this);
  11945. if (this._transformMatrixTexture) {
  11946. this._transformMatrixTexture.dispose();
  11947. this._transformMatrixTexture = null;
  11948. }
  11949. };
  11950. /**
  11951. * Serialize the skeleton in a JSON object
  11952. * @returns a JSON object
  11953. */
  11954. Skeleton.prototype.serialize = function () {
  11955. var serializationObject = {};
  11956. serializationObject.name = this.name;
  11957. serializationObject.id = this.id;
  11958. if (this.dimensionsAtRest) {
  11959. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  11960. }
  11961. serializationObject.bones = [];
  11962. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11963. for (var index = 0; index < this.bones.length; index++) {
  11964. var bone = this.bones[index];
  11965. var parent_2 = bone.getParent();
  11966. var serializedBone = {
  11967. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  11968. name: bone.name,
  11969. matrix: bone.getBaseMatrix().toArray(),
  11970. rest: bone.getRestPose().toArray()
  11971. };
  11972. serializationObject.bones.push(serializedBone);
  11973. if (bone.length) {
  11974. serializedBone.length = bone.length;
  11975. }
  11976. if (bone.metadata) {
  11977. serializedBone.metadata = bone.metadata;
  11978. }
  11979. if (bone.animations && bone.animations.length > 0) {
  11980. serializedBone.animation = bone.animations[0].serialize();
  11981. }
  11982. serializationObject.ranges = [];
  11983. for (var name in this._ranges) {
  11984. var source = this._ranges[name];
  11985. if (!source) {
  11986. continue;
  11987. }
  11988. var range = {};
  11989. range.name = name;
  11990. range.from = source.from;
  11991. range.to = source.to;
  11992. serializationObject.ranges.push(range);
  11993. }
  11994. }
  11995. return serializationObject;
  11996. };
  11997. /**
  11998. * Creates a new skeleton from serialized data
  11999. * @param parsedSkeleton defines the serialized data
  12000. * @param scene defines the hosting scene
  12001. * @returns a new skeleton
  12002. */
  12003. Skeleton.Parse = function (parsedSkeleton, scene) {
  12004. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  12005. if (parsedSkeleton.dimensionsAtRest) {
  12006. skeleton.dimensionsAtRest = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  12007. }
  12008. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  12009. var index;
  12010. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  12011. var parsedBone = parsedSkeleton.bones[index];
  12012. var parentBone = null;
  12013. if (parsedBone.parentBoneIndex > -1) {
  12014. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  12015. }
  12016. var rest = parsedBone.rest ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  12017. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  12018. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  12019. bone.id = parsedBone.id;
  12020. }
  12021. if (parsedBone.length) {
  12022. bone.length = parsedBone.length;
  12023. }
  12024. if (parsedBone.metadata) {
  12025. bone.metadata = parsedBone.metadata;
  12026. }
  12027. if (parsedBone.animation) {
  12028. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  12029. }
  12030. }
  12031. // placed after bones, so createAnimationRange can cascade down
  12032. if (parsedSkeleton.ranges) {
  12033. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  12034. var data = parsedSkeleton.ranges[index];
  12035. skeleton.createAnimationRange(data.name, data.from, data.to);
  12036. }
  12037. }
  12038. return skeleton;
  12039. };
  12040. /**
  12041. * Compute all node absolute transforms
  12042. * @param forceUpdate defines if computation must be done even if cache is up to date
  12043. */
  12044. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  12045. if (forceUpdate === void 0) { forceUpdate = false; }
  12046. var renderId = this._scene.getRenderId();
  12047. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  12048. this.bones[0].computeAbsoluteTransforms();
  12049. this._lastAbsoluteTransformsUpdateId = renderId;
  12050. }
  12051. };
  12052. /**
  12053. * Gets the root pose matrix
  12054. * @returns a matrix
  12055. */
  12056. Skeleton.prototype.getPoseMatrix = function () {
  12057. var poseMatrix = null;
  12058. if (this._meshesWithPoseMatrix.length > 0) {
  12059. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  12060. }
  12061. return poseMatrix;
  12062. };
  12063. /**
  12064. * Sorts bones per internal index
  12065. */
  12066. Skeleton.prototype.sortBones = function () {
  12067. var bones = new Array();
  12068. var visited = new Array(this.bones.length);
  12069. for (var index = 0; index < this.bones.length; index++) {
  12070. this._sortBones(index, bones, visited);
  12071. }
  12072. this.bones = bones;
  12073. };
  12074. Skeleton.prototype._sortBones = function (index, bones, visited) {
  12075. if (visited[index]) {
  12076. return;
  12077. }
  12078. visited[index] = true;
  12079. var bone = this.bones[index];
  12080. if (bone._index === undefined) {
  12081. bone._index = index;
  12082. }
  12083. var parentBone = bone.getParent();
  12084. if (parentBone) {
  12085. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  12086. }
  12087. bones.push(bone);
  12088. };
  12089. return Skeleton;
  12090. }());
  12091. /***/ }),
  12092. /***/ "./Cameras/Inputs/BaseCameraPointersInput.ts":
  12093. /*!***************************************************!*\
  12094. !*** ./Cameras/Inputs/BaseCameraPointersInput.ts ***!
  12095. \***************************************************/
  12096. /*! exports provided: BaseCameraPointersInput */
  12097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12098. "use strict";
  12099. __webpack_require__.r(__webpack_exports__);
  12100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseCameraPointersInput", function() { return BaseCameraPointersInput; });
  12101. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12102. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12103. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12104. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12105. /**
  12106. * Base class for Camera Pointer Inputs.
  12107. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  12108. * for example usage.
  12109. */
  12110. var BaseCameraPointersInput = /** @class */ (function () {
  12111. function BaseCameraPointersInput() {
  12112. /**
  12113. * Defines the buttons associated with the input to handle camera move.
  12114. */
  12115. this.buttons = [0, 1, 2];
  12116. }
  12117. /**
  12118. * Attach the input controls to a specific dom element to get the input from.
  12119. * @param element Defines the element the controls should be listened from
  12120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12121. */
  12122. BaseCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12123. var _this = this;
  12124. var engine = this.camera.getEngine();
  12125. var previousPinchSquaredDistance = 0;
  12126. var previousMultiTouchPanPosition = null;
  12127. this.pointA = null;
  12128. this.pointB = null;
  12129. this._altKey = false;
  12130. this._ctrlKey = false;
  12131. this._metaKey = false;
  12132. this._shiftKey = false;
  12133. this._buttonsPressed = 0;
  12134. this._pointerInput = function (p, s) {
  12135. var evt = p.event;
  12136. var isTouch = evt.pointerType === "touch";
  12137. if (engine.isInVRExclusivePointerMode) {
  12138. return;
  12139. }
  12140. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE &&
  12141. _this.buttons.indexOf(evt.button) === -1) {
  12142. return;
  12143. }
  12144. var srcElement = (evt.srcElement || evt.target);
  12145. _this._altKey = evt.altKey;
  12146. _this._ctrlKey = evt.ctrlKey;
  12147. _this._metaKey = evt.metaKey;
  12148. _this._shiftKey = evt.shiftKey;
  12149. _this._buttonsPressed = evt.buttons;
  12150. if (engine.isPointerLock) {
  12151. var offsetX = evt.movementX ||
  12152. evt.mozMovementX ||
  12153. evt.webkitMovementX ||
  12154. evt.msMovementX ||
  12155. 0;
  12156. var offsetY = evt.movementY ||
  12157. evt.mozMovementY ||
  12158. evt.webkitMovementY ||
  12159. evt.msMovementY ||
  12160. 0;
  12161. _this.onTouch(null, offsetX, offsetY);
  12162. _this.pointA = null;
  12163. _this.pointB = null;
  12164. }
  12165. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12166. try {
  12167. srcElement.setPointerCapture(evt.pointerId);
  12168. }
  12169. catch (e) {
  12170. //Nothing to do with the error. Execution will continue.
  12171. }
  12172. if (_this.pointA === null) {
  12173. _this.pointA = { x: evt.clientX,
  12174. y: evt.clientY,
  12175. pointerId: evt.pointerId,
  12176. type: evt.pointerType };
  12177. }
  12178. else if (_this.pointB === null) {
  12179. _this.pointB = { x: evt.clientX,
  12180. y: evt.clientY,
  12181. pointerId: evt.pointerId,
  12182. type: evt.pointerType };
  12183. }
  12184. _this.onButtonDown(evt);
  12185. if (!noPreventDefault) {
  12186. evt.preventDefault();
  12187. element.focus();
  12188. }
  12189. }
  12190. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOUBLETAP) {
  12191. _this.onDoubleTap(evt.pointerType);
  12192. }
  12193. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  12194. try {
  12195. srcElement.releasePointerCapture(evt.pointerId);
  12196. }
  12197. catch (e) {
  12198. //Nothing to do with the error.
  12199. }
  12200. if (!isTouch) {
  12201. _this.pointB = null; // Mouse and pen are mono pointer
  12202. }
  12203. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12204. //but emptying completely pointers collection is required to fix a bug on iPhone :
  12205. //when changing orientation while pinching camera,
  12206. //one pointer stay pressed forever if we don't release all pointers
  12207. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12208. if (engine._badOS) {
  12209. _this.pointA = _this.pointB = null;
  12210. }
  12211. else {
  12212. //only remove the impacted pointer in case of multitouch allowing on most
  12213. //platforms switching from rotate to zoom and pan seamlessly.
  12214. if (_this.pointB && _this.pointA && _this.pointA.pointerId == evt.pointerId) {
  12215. _this.pointA = _this.pointB;
  12216. _this.pointB = null;
  12217. }
  12218. else if (_this.pointA && _this.pointB &&
  12219. _this.pointB.pointerId == evt.pointerId) {
  12220. _this.pointB = null;
  12221. }
  12222. else {
  12223. _this.pointA = _this.pointB = null;
  12224. }
  12225. }
  12226. if (previousPinchSquaredDistance !== 0 || previousMultiTouchPanPosition) {
  12227. // Previous pinch data is populated but a button has been lifted
  12228. // so pinch has ended.
  12229. _this.onMultiTouch(_this.pointA, _this.pointB, previousPinchSquaredDistance, 0, // pinchSquaredDistance
  12230. previousMultiTouchPanPosition, null // multiTouchPanPosition
  12231. );
  12232. previousPinchSquaredDistance = 0;
  12233. previousMultiTouchPanPosition = null;
  12234. }
  12235. _this.onButtonUp(evt);
  12236. if (!noPreventDefault) {
  12237. evt.preventDefault();
  12238. }
  12239. }
  12240. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  12241. if (!noPreventDefault) {
  12242. evt.preventDefault();
  12243. }
  12244. // One button down
  12245. if (_this.pointA && _this.pointB === null) {
  12246. var offsetX = evt.clientX - _this.pointA.x;
  12247. var offsetY = evt.clientY - _this.pointA.y;
  12248. _this.onTouch(_this.pointA, offsetX, offsetY);
  12249. _this.pointA.x = evt.clientX;
  12250. _this.pointA.y = evt.clientY;
  12251. }
  12252. // Two buttons down: pinch
  12253. else if (_this.pointA && _this.pointB) {
  12254. var ed = (_this.pointA.pointerId === evt.pointerId) ?
  12255. _this.pointA : _this.pointB;
  12256. ed.x = evt.clientX;
  12257. ed.y = evt.clientY;
  12258. var distX = _this.pointA.x - _this.pointB.x;
  12259. var distY = _this.pointA.y - _this.pointB.y;
  12260. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12261. var multiTouchPanPosition = { x: (_this.pointA.x + _this.pointB.x) / 2,
  12262. y: (_this.pointA.y + _this.pointB.y) / 2,
  12263. pointerId: evt.pointerId,
  12264. type: p.type };
  12265. _this.onMultiTouch(_this.pointA, _this.pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition);
  12266. previousMultiTouchPanPosition = multiTouchPanPosition;
  12267. previousPinchSquaredDistance = pinchSquaredDistance;
  12268. }
  12269. }
  12270. };
  12271. 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 |
  12272. _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  12273. this._onLostFocus = function () {
  12274. _this.pointA = _this.pointB = null;
  12275. previousPinchSquaredDistance = 0;
  12276. previousMultiTouchPanPosition = null;
  12277. _this.onLostFocus();
  12278. };
  12279. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  12280. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12281. { name: "blur", handler: this._onLostFocus }
  12282. ]);
  12283. };
  12284. /**
  12285. * Detach the current controls from the specified dom element.
  12286. * @param element Defines the element to stop listening the inputs from
  12287. */
  12288. BaseCameraPointersInput.prototype.detachControl = function (element) {
  12289. if (this._onLostFocus) {
  12290. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12291. { name: "blur", handler: this._onLostFocus }
  12292. ]);
  12293. }
  12294. if (element && this._observer) {
  12295. this.camera.getScene().onPointerObservable.remove(this._observer);
  12296. this._observer = null;
  12297. if (this.onContextMenu) {
  12298. element.removeEventListener("contextmenu", this.onContextMenu);
  12299. }
  12300. this._onLostFocus = null;
  12301. }
  12302. this._altKey = false;
  12303. this._ctrlKey = false;
  12304. this._metaKey = false;
  12305. this._shiftKey = false;
  12306. this._buttonsPressed = 0;
  12307. };
  12308. /**
  12309. * Gets the class name of the current input.
  12310. * @returns the class name
  12311. */
  12312. BaseCameraPointersInput.prototype.getClassName = function () {
  12313. return "BaseCameraPointersInput";
  12314. };
  12315. /**
  12316. * Get the friendly name associated with the input class.
  12317. * @returns the input friendly name
  12318. */
  12319. BaseCameraPointersInput.prototype.getSimpleName = function () {
  12320. return "pointers";
  12321. };
  12322. /**
  12323. * Called on pointer POINTERDOUBLETAP event.
  12324. * Override this method to provide functionality on POINTERDOUBLETAP event.
  12325. */
  12326. BaseCameraPointersInput.prototype.onDoubleTap = function (type) {
  12327. };
  12328. /**
  12329. * Called on pointer POINTERMOVE event if only a single touch is active.
  12330. * Override this method to provide functionality.
  12331. */
  12332. BaseCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12333. };
  12334. /**
  12335. * Called on pointer POINTERMOVE event if multiple touches are active.
  12336. * Override this method to provide functionality.
  12337. */
  12338. BaseCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  12339. };
  12340. /**
  12341. * Called on JS contextmenu event.
  12342. * Override this method to provide functionality.
  12343. */
  12344. BaseCameraPointersInput.prototype.onContextMenu = function (evt) {
  12345. evt.preventDefault();
  12346. };
  12347. /**
  12348. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  12349. * press.
  12350. * Override this method to provide functionality.
  12351. */
  12352. BaseCameraPointersInput.prototype.onButtonDown = function (evt) {
  12353. };
  12354. /**
  12355. * Called each time a new POINTERUP event occurs. Ie, for each button
  12356. * release.
  12357. * Override this method to provide functionality.
  12358. */
  12359. BaseCameraPointersInput.prototype.onButtonUp = function (evt) {
  12360. };
  12361. /**
  12362. * Called when window becomes inactive.
  12363. * Override this method to provide functionality.
  12364. */
  12365. BaseCameraPointersInput.prototype.onLostFocus = function () {
  12366. };
  12367. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12368. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12369. ], BaseCameraPointersInput.prototype, "buttons", void 0);
  12370. return BaseCameraPointersInput;
  12371. }());
  12372. /***/ }),
  12373. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  12374. /*!*******************************************************!*\
  12375. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  12376. \*******************************************************/
  12377. /*! exports provided: ArcRotateCameraGamepadInput */
  12378. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12379. "use strict";
  12380. __webpack_require__.r(__webpack_exports__);
  12381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  12382. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12383. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12384. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12385. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  12386. /**
  12387. * Manage the gamepad inputs to control an arc rotate camera.
  12388. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12389. */
  12390. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  12391. function ArcRotateCameraGamepadInput() {
  12392. /**
  12393. * Defines the gamepad rotation sensiblity.
  12394. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  12395. */
  12396. this.gamepadRotationSensibility = 80;
  12397. /**
  12398. * Defines the gamepad move sensiblity.
  12399. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  12400. */
  12401. this.gamepadMoveSensibility = 40;
  12402. }
  12403. /**
  12404. * Attach the input controls to a specific dom element to get the input from.
  12405. * @param element Defines the element the controls should be listened from
  12406. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12407. */
  12408. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  12409. var _this = this;
  12410. var manager = this.camera.getScene().gamepadManager;
  12411. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  12412. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  12413. // prioritize XBOX gamepads.
  12414. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  12415. _this.gamepad = gamepad;
  12416. }
  12417. }
  12418. });
  12419. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  12420. if (_this.gamepad === gamepad) {
  12421. _this.gamepad = null;
  12422. }
  12423. });
  12424. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  12425. };
  12426. /**
  12427. * Detach the current controls from the specified dom element.
  12428. * @param element Defines the element to stop listening the inputs from
  12429. */
  12430. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  12431. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  12432. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  12433. this.gamepad = null;
  12434. };
  12435. /**
  12436. * Update the current camera state depending on the inputs that have been used this frame.
  12437. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12438. */
  12439. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  12440. if (this.gamepad) {
  12441. var camera = this.camera;
  12442. var RSValues = this.gamepad.rightStick;
  12443. if (RSValues) {
  12444. if (RSValues.x != 0) {
  12445. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  12446. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  12447. camera.inertialAlphaOffset += normalizedRX;
  12448. }
  12449. }
  12450. if (RSValues.y != 0) {
  12451. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  12452. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  12453. camera.inertialBetaOffset += normalizedRY;
  12454. }
  12455. }
  12456. }
  12457. var LSValues = this.gamepad.leftStick;
  12458. if (LSValues && LSValues.y != 0) {
  12459. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  12460. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  12461. this.camera.inertialRadiusOffset -= normalizedLY;
  12462. }
  12463. }
  12464. }
  12465. };
  12466. /**
  12467. * Gets the class name of the current intput.
  12468. * @returns the class name
  12469. */
  12470. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  12471. return "ArcRotateCameraGamepadInput";
  12472. };
  12473. /**
  12474. * Get the friendly name associated with the input class.
  12475. * @returns the input friendly name
  12476. */
  12477. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  12478. return "gamepad";
  12479. };
  12480. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12481. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12482. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  12483. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12484. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12485. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  12486. return ArcRotateCameraGamepadInput;
  12487. }());
  12488. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  12489. /***/ }),
  12490. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  12491. /*!************************************************************!*\
  12492. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  12493. \************************************************************/
  12494. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  12495. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12496. "use strict";
  12497. __webpack_require__.r(__webpack_exports__);
  12498. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  12499. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12500. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12501. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12502. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12503. /**
  12504. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  12505. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12506. */
  12507. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  12508. function ArcRotateCameraKeyboardMoveInput() {
  12509. /**
  12510. * Defines the list of key codes associated with the up action (increase alpha)
  12511. */
  12512. this.keysUp = [38];
  12513. /**
  12514. * Defines the list of key codes associated with the down action (decrease alpha)
  12515. */
  12516. this.keysDown = [40];
  12517. /**
  12518. * Defines the list of key codes associated with the left action (increase beta)
  12519. */
  12520. this.keysLeft = [37];
  12521. /**
  12522. * Defines the list of key codes associated with the right action (decrease beta)
  12523. */
  12524. this.keysRight = [39];
  12525. /**
  12526. * Defines the list of key codes associated with the reset action.
  12527. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  12528. */
  12529. this.keysReset = [220];
  12530. /**
  12531. * Defines the panning sensibility of the inputs.
  12532. * (How fast is the camera paning)
  12533. */
  12534. this.panningSensibility = 50.0;
  12535. /**
  12536. * Defines the zooming sensibility of the inputs.
  12537. * (How fast is the camera zooming)
  12538. */
  12539. this.zoomingSensibility = 25.0;
  12540. /**
  12541. * Defines wether maintaining the alt key down switch the movement mode from
  12542. * orientation to zoom.
  12543. */
  12544. this.useAltToZoom = true;
  12545. /**
  12546. * Rotation speed of the camera
  12547. */
  12548. this.angularSpeed = 0.01;
  12549. this._keys = new Array();
  12550. }
  12551. /**
  12552. * Attach the input controls to a specific dom element to get the input from.
  12553. * @param element Defines the element the controls should be listened from
  12554. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12555. */
  12556. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  12557. var _this = this;
  12558. if (this._onCanvasBlurObserver) {
  12559. return;
  12560. }
  12561. this._scene = this.camera.getScene();
  12562. this._engine = this._scene.getEngine();
  12563. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12564. _this._keys = [];
  12565. });
  12566. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12567. var evt = info.event;
  12568. if (!evt.metaKey) {
  12569. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12570. _this._ctrlPressed = evt.ctrlKey;
  12571. _this._altPressed = evt.altKey;
  12572. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12573. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12574. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12575. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12576. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12577. var index = _this._keys.indexOf(evt.keyCode);
  12578. if (index === -1) {
  12579. _this._keys.push(evt.keyCode);
  12580. }
  12581. if (evt.preventDefault) {
  12582. if (!noPreventDefault) {
  12583. evt.preventDefault();
  12584. }
  12585. }
  12586. }
  12587. }
  12588. else {
  12589. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12590. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12591. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12592. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12593. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12594. var index = _this._keys.indexOf(evt.keyCode);
  12595. if (index >= 0) {
  12596. _this._keys.splice(index, 1);
  12597. }
  12598. if (evt.preventDefault) {
  12599. if (!noPreventDefault) {
  12600. evt.preventDefault();
  12601. }
  12602. }
  12603. }
  12604. }
  12605. }
  12606. });
  12607. };
  12608. /**
  12609. * Detach the current controls from the specified dom element.
  12610. * @param element Defines the element to stop listening the inputs from
  12611. */
  12612. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  12613. if (this._scene) {
  12614. if (this._onKeyboardObserver) {
  12615. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12616. }
  12617. if (this._onCanvasBlurObserver) {
  12618. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12619. }
  12620. this._onKeyboardObserver = null;
  12621. this._onCanvasBlurObserver = null;
  12622. }
  12623. this._keys = [];
  12624. };
  12625. /**
  12626. * Update the current camera state depending on the inputs that have been used this frame.
  12627. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12628. */
  12629. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  12630. if (this._onKeyboardObserver) {
  12631. var camera = this.camera;
  12632. for (var index = 0; index < this._keys.length; index++) {
  12633. var keyCode = this._keys[index];
  12634. if (this.keysLeft.indexOf(keyCode) !== -1) {
  12635. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12636. camera.inertialPanningX -= 1 / this.panningSensibility;
  12637. }
  12638. else {
  12639. camera.inertialAlphaOffset -= this.angularSpeed;
  12640. }
  12641. }
  12642. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12643. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12644. camera.inertialPanningY += 1 / this.panningSensibility;
  12645. }
  12646. else if (this._altPressed && this.useAltToZoom) {
  12647. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  12648. }
  12649. else {
  12650. camera.inertialBetaOffset -= this.angularSpeed;
  12651. }
  12652. }
  12653. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12654. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12655. camera.inertialPanningX += 1 / this.panningSensibility;
  12656. }
  12657. else {
  12658. camera.inertialAlphaOffset += this.angularSpeed;
  12659. }
  12660. }
  12661. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12662. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12663. camera.inertialPanningY -= 1 / this.panningSensibility;
  12664. }
  12665. else if (this._altPressed && this.useAltToZoom) {
  12666. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12667. }
  12668. else {
  12669. camera.inertialBetaOffset += this.angularSpeed;
  12670. }
  12671. }
  12672. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12673. if (camera.useInputToRestoreState) {
  12674. camera.restoreState();
  12675. }
  12676. }
  12677. }
  12678. }
  12679. };
  12680. /**
  12681. * Gets the class name of the current intput.
  12682. * @returns the class name
  12683. */
  12684. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12685. return "ArcRotateCameraKeyboardMoveInput";
  12686. };
  12687. /**
  12688. * Get the friendly name associated with the input class.
  12689. * @returns the input friendly name
  12690. */
  12691. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12692. return "keyboard";
  12693. };
  12694. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12695. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12696. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12697. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12698. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12699. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12700. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12701. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12702. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12703. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12704. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12705. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12706. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12707. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12708. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12709. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12710. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12711. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12712. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12713. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12714. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12715. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12716. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12717. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12718. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12719. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12720. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12721. return ArcRotateCameraKeyboardMoveInput;
  12722. }());
  12723. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12724. /***/ }),
  12725. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12726. /*!**********************************************************!*\
  12727. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12728. \**********************************************************/
  12729. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12730. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12731. "use strict";
  12732. __webpack_require__.r(__webpack_exports__);
  12733. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12734. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12735. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12736. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12737. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12738. /**
  12739. * Manage the mouse wheel inputs to control an arc rotate camera.
  12740. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12741. */
  12742. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12743. function ArcRotateCameraMouseWheelInput() {
  12744. /**
  12745. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12746. */
  12747. this.wheelPrecision = 3.0;
  12748. /**
  12749. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12750. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12751. */
  12752. this.wheelDeltaPercentage = 0;
  12753. }
  12754. /**
  12755. * Attach the input controls to a specific dom element to get the input from.
  12756. * @param element Defines the element the controls should be listened from
  12757. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12758. */
  12759. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12760. var _this = this;
  12761. this._wheel = function (p, s) {
  12762. //sanity check - this should be a PointerWheel event.
  12763. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12764. return;
  12765. }
  12766. var event = p.event;
  12767. var delta = 0;
  12768. var mouseWheelLegacyEvent = event;
  12769. if (mouseWheelLegacyEvent.wheelDelta) {
  12770. if (_this.wheelDeltaPercentage) {
  12771. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * _this.wheelDeltaPercentage) * _this.camera.radius;
  12772. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12773. delta = wheelDelta / (1.0 + _this.wheelDeltaPercentage);
  12774. }
  12775. else {
  12776. delta = wheelDelta * (1.0 + _this.wheelDeltaPercentage);
  12777. }
  12778. }
  12779. else {
  12780. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12781. }
  12782. }
  12783. else {
  12784. var deltaValue = event.deltaY || event.detail;
  12785. delta = -deltaValue / _this.wheelPrecision;
  12786. }
  12787. if (delta) {
  12788. _this.camera.inertialRadiusOffset += delta;
  12789. }
  12790. if (event.preventDefault) {
  12791. if (!noPreventDefault) {
  12792. event.preventDefault();
  12793. }
  12794. }
  12795. };
  12796. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  12797. };
  12798. /**
  12799. * Detach the current controls from the specified dom element.
  12800. * @param element Defines the element to stop listening the inputs from
  12801. */
  12802. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12803. if (this._observer && element) {
  12804. this.camera.getScene().onPointerObservable.remove(this._observer);
  12805. this._observer = null;
  12806. this._wheel = null;
  12807. }
  12808. };
  12809. /**
  12810. * Gets the class name of the current intput.
  12811. * @returns the class name
  12812. */
  12813. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12814. return "ArcRotateCameraMouseWheelInput";
  12815. };
  12816. /**
  12817. * Get the friendly name associated with the input class.
  12818. * @returns the input friendly name
  12819. */
  12820. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  12821. return "mousewheel";
  12822. };
  12823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12825. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  12826. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12827. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12828. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  12829. return ArcRotateCameraMouseWheelInput;
  12830. }());
  12831. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  12832. /***/ }),
  12833. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  12834. /*!********************************************************!*\
  12835. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  12836. \********************************************************/
  12837. /*! exports provided: ArcRotateCameraPointersInput */
  12838. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12839. "use strict";
  12840. __webpack_require__.r(__webpack_exports__);
  12841. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  12842. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12843. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12844. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12845. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  12846. /**
  12847. * Manage the pointers inputs to control an arc rotate camera.
  12848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12849. */
  12850. var ArcRotateCameraPointersInput = /** @class */ (function (_super) {
  12851. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraPointersInput, _super);
  12852. function ArcRotateCameraPointersInput() {
  12853. var _this = _super !== null && _super.apply(this, arguments) || this;
  12854. /**
  12855. * Defines the buttons associated with the input to handle camera move.
  12856. */
  12857. _this.buttons = [0, 1, 2];
  12858. /**
  12859. * Defines the pointer angular sensibility along the X axis or how fast is
  12860. * the camera rotating.
  12861. */
  12862. _this.angularSensibilityX = 1000.0;
  12863. /**
  12864. * Defines the pointer angular sensibility along the Y axis or how fast is
  12865. * the camera rotating.
  12866. */
  12867. _this.angularSensibilityY = 1000.0;
  12868. /**
  12869. * Defines the pointer pinch precision or how fast is the camera zooming.
  12870. */
  12871. _this.pinchPrecision = 12.0;
  12872. /**
  12873. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  12874. * from 0.
  12875. * It defines the percentage of current camera.radius to use as delta when
  12876. * pinch zoom is used.
  12877. */
  12878. _this.pinchDeltaPercentage = 0;
  12879. /**
  12880. * Defines the pointer panning sensibility or how fast is the camera moving.
  12881. */
  12882. _this.panningSensibility = 1000.0;
  12883. /**
  12884. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  12885. */
  12886. _this.multiTouchPanning = true;
  12887. /**
  12888. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  12889. * zoom (pinch) through multitouch.
  12890. */
  12891. _this.multiTouchPanAndZoom = true;
  12892. /**
  12893. * Revers pinch action direction.
  12894. */
  12895. _this.pinchInwards = true;
  12896. _this._isPanClick = false;
  12897. _this._twoFingerActivityCount = 0;
  12898. _this._isPinching = false;
  12899. return _this;
  12900. }
  12901. /**
  12902. * Gets the class name of the current input.
  12903. * @returns the class name
  12904. */
  12905. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  12906. return "ArcRotateCameraPointersInput";
  12907. };
  12908. /**
  12909. * Called on pointer POINTERMOVE event if only a single touch is active.
  12910. */
  12911. ArcRotateCameraPointersInput.prototype.onTouch = function (point, offsetX, offsetY) {
  12912. if (this.panningSensibility !== 0 &&
  12913. ((this._ctrlKey && this.camera._useCtrlForPanning) || this._isPanClick)) {
  12914. this.camera.inertialPanningX += -offsetX / this.panningSensibility;
  12915. this.camera.inertialPanningY += offsetY / this.panningSensibility;
  12916. }
  12917. else {
  12918. this.camera.inertialAlphaOffset -= offsetX / this.angularSensibilityX;
  12919. this.camera.inertialBetaOffset -= offsetY / this.angularSensibilityY;
  12920. }
  12921. };
  12922. /**
  12923. * Called on pointer POINTERDOUBLETAP event.
  12924. */
  12925. ArcRotateCameraPointersInput.prototype.onDoubleTap = function (type) {
  12926. if (this.camera.useInputToRestoreState) {
  12927. this.camera.restoreState();
  12928. }
  12929. };
  12930. /**
  12931. * Called on pointer POINTERMOVE event if multiple touches are active.
  12932. */
  12933. ArcRotateCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  12934. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  12935. // First time this method is called for new pinch.
  12936. // Next time this is called there will be a
  12937. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  12938. return;
  12939. }
  12940. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  12941. // Last time this method is called at the end of a pinch.
  12942. return;
  12943. }
  12944. var direction = this.pinchInwards ? 1 : -1;
  12945. if (this.multiTouchPanAndZoom) {
  12946. if (this.pinchDeltaPercentage) {
  12947. this.camera.inertialRadiusOffset +=
  12948. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  12949. this.camera.radius * this.pinchDeltaPercentage;
  12950. }
  12951. else {
  12952. this.camera.inertialRadiusOffset +=
  12953. (pinchSquaredDistance - previousPinchSquaredDistance) /
  12954. (this.pinchPrecision * direction *
  12955. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  12956. }
  12957. if (this.panningSensibility !== 0 &&
  12958. previousMultiTouchPanPosition && multiTouchPanPosition) {
  12959. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  12960. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  12961. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  12962. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  12963. }
  12964. }
  12965. else {
  12966. this._twoFingerActivityCount++;
  12967. var previousPinchDistance = Math.sqrt(previousPinchSquaredDistance);
  12968. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  12969. if (this._isPinching ||
  12970. (this._twoFingerActivityCount < 20 &&
  12971. Math.abs(pinchDistance - previousPinchDistance) >
  12972. this.camera.pinchToPanMaxDistance)) {
  12973. // Since pinch has not been active long, assume we intend to zoom.
  12974. if (this.pinchDeltaPercentage) {
  12975. this.camera.inertialRadiusOffset +=
  12976. (pinchSquaredDistance - previousPinchSquaredDistance) * 0.001 *
  12977. this.camera.radius * this.pinchDeltaPercentage;
  12978. }
  12979. else {
  12980. this.camera.inertialRadiusOffset +=
  12981. (pinchSquaredDistance - previousPinchSquaredDistance) /
  12982. (this.pinchPrecision * direction *
  12983. (this.angularSensibilityX + this.angularSensibilityY) / 2);
  12984. }
  12985. // Since we are pinching, remain pinching on next iteration.
  12986. this._isPinching = true;
  12987. }
  12988. else {
  12989. // Pause between pinch starting and moving implies not a zoom event.
  12990. // Pan instead.
  12991. if (this.panningSensibility !== 0 && this.multiTouchPanning &&
  12992. multiTouchPanPosition && previousMultiTouchPanPosition) {
  12993. var moveDeltaX = multiTouchPanPosition.x - previousMultiTouchPanPosition.x;
  12994. var moveDeltaY = multiTouchPanPosition.y - previousMultiTouchPanPosition.y;
  12995. this.camera.inertialPanningX += -moveDeltaX / this.panningSensibility;
  12996. this.camera.inertialPanningY += moveDeltaY / this.panningSensibility;
  12997. }
  12998. }
  12999. }
  13000. };
  13001. /**
  13002. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  13003. * press.
  13004. */
  13005. ArcRotateCameraPointersInput.prototype.onButtonDown = function (evt) {
  13006. this._isPanClick = evt.button === this.camera._panningMouseButton;
  13007. };
  13008. /**
  13009. * Called each time a new POINTERUP event occurs. Ie, for each button
  13010. * release.
  13011. */
  13012. ArcRotateCameraPointersInput.prototype.onButtonUp = function (evt) {
  13013. this._twoFingerActivityCount = 0;
  13014. this._isPinching = false;
  13015. };
  13016. /**
  13017. * Called when window becomes inactive.
  13018. */
  13019. ArcRotateCameraPointersInput.prototype.onLostFocus = function () {
  13020. this._isPanClick = false;
  13021. this._twoFingerActivityCount = 0;
  13022. this._isPinching = false;
  13023. };
  13024. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13025. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13026. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  13027. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13028. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13029. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  13030. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13032. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  13033. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13034. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13035. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  13036. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13037. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13038. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  13039. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13041. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  13042. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13044. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  13045. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13047. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  13048. return ArcRotateCameraPointersInput;
  13049. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  13050. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraPointersInput"] =
  13051. ArcRotateCameraPointersInput;
  13052. /***/ }),
  13053. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  13054. /*!*******************************************************************!*\
  13055. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  13056. \*******************************************************************/
  13057. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  13058. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13059. "use strict";
  13060. __webpack_require__.r(__webpack_exports__);
  13061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  13062. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13063. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  13064. /**
  13065. * Add orientation input support to the input manager.
  13066. * @returns the current input manager
  13067. */
  13068. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraInputsManager"].prototype.addVRDeviceOrientation = function () {
  13069. this.add(new ArcRotateCameraVRDeviceOrientationInput());
  13070. return this;
  13071. };
  13072. /**
  13073. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  13074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13075. */
  13076. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  13077. /**
  13078. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  13079. */
  13080. function ArcRotateCameraVRDeviceOrientationInput() {
  13081. /**
  13082. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  13083. */
  13084. this.alphaCorrection = 1;
  13085. /**
  13086. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  13087. */
  13088. this.gammaCorrection = 1;
  13089. this._alpha = 0;
  13090. this._gamma = 0;
  13091. this._dirty = false;
  13092. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  13093. }
  13094. /**
  13095. * Attach the input controls to a specific dom element to get the input from.
  13096. * @param element Defines the element the controls should be listened from
  13097. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13098. */
  13099. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13100. this.camera.attachControl(element, noPreventDefault);
  13101. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  13102. };
  13103. /** @hidden */
  13104. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  13105. if (evt.alpha !== null) {
  13106. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  13107. }
  13108. if (evt.gamma !== null) {
  13109. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  13110. }
  13111. this._dirty = true;
  13112. };
  13113. /**
  13114. * Update the current camera state depending on the inputs that have been used this frame.
  13115. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13116. */
  13117. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  13118. if (this._dirty) {
  13119. this._dirty = false;
  13120. if (this._gamma < 0) {
  13121. this._gamma = 180 + this._gamma;
  13122. }
  13123. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  13124. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  13125. }
  13126. };
  13127. /**
  13128. * Detach the current controls from the specified dom element.
  13129. * @param element Defines the element to stop listening the inputs from
  13130. */
  13131. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  13132. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  13133. };
  13134. /**
  13135. * Gets the class name of the current intput.
  13136. * @returns the class name
  13137. */
  13138. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  13139. return "ArcRotateCameraVRDeviceOrientationInput";
  13140. };
  13141. /**
  13142. * Get the friendly name associated with the input class.
  13143. * @returns the input friendly name
  13144. */
  13145. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  13146. return "VRDeviceOrientation";
  13147. };
  13148. return ArcRotateCameraVRDeviceOrientationInput;
  13149. }());
  13150. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  13151. /***/ }),
  13152. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  13153. /*!**************************************************!*\
  13154. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  13155. \**************************************************/
  13156. /*! exports provided: FlyCameraKeyboardInput */
  13157. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13158. "use strict";
  13159. __webpack_require__.r(__webpack_exports__);
  13160. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  13161. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13162. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13163. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13164. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13165. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13166. /**
  13167. * Listen to keyboard events to control the camera.
  13168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13169. */
  13170. var FlyCameraKeyboardInput = /** @class */ (function () {
  13171. function FlyCameraKeyboardInput() {
  13172. /**
  13173. * The list of keyboard keys used to control the forward move of the camera.
  13174. */
  13175. this.keysForward = [87];
  13176. /**
  13177. * The list of keyboard keys used to control the backward move of the camera.
  13178. */
  13179. this.keysBackward = [83];
  13180. /**
  13181. * The list of keyboard keys used to control the forward move of the camera.
  13182. */
  13183. this.keysUp = [69];
  13184. /**
  13185. * The list of keyboard keys used to control the backward move of the camera.
  13186. */
  13187. this.keysDown = [81];
  13188. /**
  13189. * The list of keyboard keys used to control the right strafe move of the camera.
  13190. */
  13191. this.keysRight = [68];
  13192. /**
  13193. * The list of keyboard keys used to control the left strafe move of the camera.
  13194. */
  13195. this.keysLeft = [65];
  13196. this._keys = new Array();
  13197. }
  13198. /**
  13199. * Attach the input controls to a specific dom element to get the input from.
  13200. * @param element Defines the element the controls should be listened from
  13201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13202. */
  13203. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  13204. var _this = this;
  13205. if (this._onCanvasBlurObserver) {
  13206. return;
  13207. }
  13208. this._scene = this.camera.getScene();
  13209. this._engine = this._scene.getEngine();
  13210. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13211. _this._keys = [];
  13212. });
  13213. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13214. var evt = info.event;
  13215. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13216. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13217. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13218. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13219. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13220. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13221. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13222. var index = _this._keys.indexOf(evt.keyCode);
  13223. if (index === -1) {
  13224. _this._keys.push(evt.keyCode);
  13225. }
  13226. if (!noPreventDefault) {
  13227. evt.preventDefault();
  13228. }
  13229. }
  13230. }
  13231. else {
  13232. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13233. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13234. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13235. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13236. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13237. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13238. var index = _this._keys.indexOf(evt.keyCode);
  13239. if (index >= 0) {
  13240. _this._keys.splice(index, 1);
  13241. }
  13242. if (!noPreventDefault) {
  13243. evt.preventDefault();
  13244. }
  13245. }
  13246. }
  13247. });
  13248. };
  13249. /**
  13250. * Detach the current controls from the specified dom element.
  13251. * @param element Defines the element to stop listening the inputs from
  13252. */
  13253. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  13254. if (this._scene) {
  13255. if (this._onKeyboardObserver) {
  13256. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13257. }
  13258. if (this._onCanvasBlurObserver) {
  13259. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13260. }
  13261. this._onKeyboardObserver = null;
  13262. this._onCanvasBlurObserver = null;
  13263. }
  13264. this._keys = [];
  13265. };
  13266. /**
  13267. * Gets the class name of the current intput.
  13268. * @returns the class name
  13269. */
  13270. FlyCameraKeyboardInput.prototype.getClassName = function () {
  13271. return "FlyCameraKeyboardInput";
  13272. };
  13273. /** @hidden */
  13274. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  13275. this._keys = [];
  13276. };
  13277. /**
  13278. * Get the friendly name associated with the input class.
  13279. * @returns the input friendly name
  13280. */
  13281. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  13282. return "keyboard";
  13283. };
  13284. /**
  13285. * Update the current camera state depending on the inputs that have been used this frame.
  13286. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13287. */
  13288. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  13289. if (this._onKeyboardObserver) {
  13290. var camera = this.camera;
  13291. // Keyboard
  13292. for (var index = 0; index < this._keys.length; index++) {
  13293. var keyCode = this._keys[index];
  13294. var speed = camera._computeLocalCameraSpeed();
  13295. if (this.keysForward.indexOf(keyCode) !== -1) {
  13296. camera._localDirection.copyFromFloats(0, 0, speed);
  13297. }
  13298. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  13299. camera._localDirection.copyFromFloats(0, 0, -speed);
  13300. }
  13301. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13302. camera._localDirection.copyFromFloats(0, speed, 0);
  13303. }
  13304. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13305. camera._localDirection.copyFromFloats(0, -speed, 0);
  13306. }
  13307. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13308. camera._localDirection.copyFromFloats(speed, 0, 0);
  13309. }
  13310. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  13311. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13312. }
  13313. if (camera.getScene().useRightHandedSystem) {
  13314. camera._localDirection.z *= -1;
  13315. }
  13316. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13317. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13318. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13319. }
  13320. }
  13321. };
  13322. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13323. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13324. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  13325. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13327. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  13328. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13329. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13330. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  13331. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13332. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13333. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  13334. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13335. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13336. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  13337. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13338. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13339. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  13340. return FlyCameraKeyboardInput;
  13341. }());
  13342. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  13343. /***/ }),
  13344. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  13345. /*!***********************************************!*\
  13346. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  13347. \***********************************************/
  13348. /*! exports provided: FlyCameraMouseInput */
  13349. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13350. "use strict";
  13351. __webpack_require__.r(__webpack_exports__);
  13352. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  13353. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13354. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13355. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13356. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13357. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13358. /**
  13359. * Listen to mouse events to control the camera.
  13360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13361. */
  13362. var FlyCameraMouseInput = /** @class */ (function () {
  13363. /**
  13364. * Listen to mouse events to control the camera.
  13365. * @param touchEnabled Define if touch is enabled. (Default is true.)
  13366. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13367. */
  13368. function FlyCameraMouseInput(touchEnabled) {
  13369. if (touchEnabled === void 0) { touchEnabled = true; }
  13370. /**
  13371. * Defines the buttons associated with the input to handle camera rotation.
  13372. */
  13373. this.buttons = [0, 1, 2];
  13374. /**
  13375. * Assign buttons for Yaw control.
  13376. */
  13377. this.buttonsYaw = [-1, 0, 1];
  13378. /**
  13379. * Assign buttons for Pitch control.
  13380. */
  13381. this.buttonsPitch = [-1, 0, 1];
  13382. /**
  13383. * Assign buttons for Roll control.
  13384. */
  13385. this.buttonsRoll = [2];
  13386. /**
  13387. * Detect if any button is being pressed while mouse is moved.
  13388. * -1 = Mouse locked.
  13389. * 0 = Left button.
  13390. * 1 = Middle Button.
  13391. * 2 = Right Button.
  13392. */
  13393. this.activeButton = -1;
  13394. /**
  13395. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  13396. * Higher values reduce its sensitivity.
  13397. */
  13398. this.angularSensibility = 1000.0;
  13399. this.previousPosition = null;
  13400. }
  13401. /**
  13402. * Attach the mouse control to the HTML DOM element.
  13403. * @param element Defines the element that listens to the input events.
  13404. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  13405. */
  13406. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13407. var _this = this;
  13408. this.element = element;
  13409. this.noPreventDefault = noPreventDefault;
  13410. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  13411. _this._pointerInput(p, s);
  13412. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  13413. // Correct Roll by rate, if enabled.
  13414. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  13415. if (_this.camera.rollCorrect) {
  13416. _this.camera.restoreRoll(_this.camera.rollCorrect);
  13417. }
  13418. });
  13419. // Helper function to keep 'this'.
  13420. this._mousemoveCallback = function (e) {
  13421. _this._onMouseMove(e);
  13422. };
  13423. element.addEventListener("mousemove", this._mousemoveCallback, false);
  13424. };
  13425. /**
  13426. * Detach the current controls from the specified dom element.
  13427. * @param element Defines the element to stop listening the inputs from
  13428. */
  13429. FlyCameraMouseInput.prototype.detachControl = function (element) {
  13430. if (this._observer && element) {
  13431. this.camera.getScene().onPointerObservable.remove(this._observer);
  13432. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  13433. if (this._mousemoveCallback) {
  13434. element.removeEventListener("mousemove", this._mousemoveCallback);
  13435. }
  13436. this._observer = null;
  13437. this._rollObserver = null;
  13438. this.previousPosition = null;
  13439. this.noPreventDefault = undefined;
  13440. }
  13441. };
  13442. /**
  13443. * Gets the class name of the current input.
  13444. * @returns the class name.
  13445. */
  13446. FlyCameraMouseInput.prototype.getClassName = function () {
  13447. return "FlyCameraMouseInput";
  13448. };
  13449. /**
  13450. * Get the friendly name associated with the input class.
  13451. * @returns the input's friendly name.
  13452. */
  13453. FlyCameraMouseInput.prototype.getSimpleName = function () {
  13454. return "mouse";
  13455. };
  13456. // Track mouse movement, when the pointer is not locked.
  13457. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  13458. var e = p.event;
  13459. var camera = this.camera;
  13460. var engine = camera.getEngine();
  13461. if (engine.isInVRExclusivePointerMode) {
  13462. return;
  13463. }
  13464. if (!this.touchEnabled && e.pointerType === "touch") {
  13465. return;
  13466. }
  13467. // Mouse is moved but an unknown mouse button is pressed.
  13468. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  13469. return;
  13470. }
  13471. var srcElement = (e.srcElement || e.target);
  13472. // Mouse down.
  13473. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13474. try {
  13475. srcElement.setPointerCapture(e.pointerId);
  13476. }
  13477. catch (e) {
  13478. // Nothing to do with the error. Execution continues.
  13479. }
  13480. this.previousPosition = {
  13481. x: e.clientX,
  13482. y: e.clientY
  13483. };
  13484. this.activeButton = e.button;
  13485. if (!this.noPreventDefault) {
  13486. e.preventDefault();
  13487. this.element.focus();
  13488. }
  13489. }
  13490. else
  13491. // Mouse up.
  13492. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13493. try {
  13494. srcElement.releasePointerCapture(e.pointerId);
  13495. }
  13496. catch (e) {
  13497. // Nothing to do with the error. Execution continues.
  13498. }
  13499. this.activeButton = -1;
  13500. this.previousPosition = null;
  13501. if (!this.noPreventDefault) {
  13502. e.preventDefault();
  13503. }
  13504. }
  13505. else
  13506. // Mouse move.
  13507. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13508. if (!this.previousPosition || engine.isPointerLock) {
  13509. return;
  13510. }
  13511. var offsetX = e.clientX - this.previousPosition.x;
  13512. var offsetY = e.clientY - this.previousPosition.y;
  13513. this.rotateCamera(offsetX, offsetY);
  13514. this.previousPosition = {
  13515. x: e.clientX,
  13516. y: e.clientY
  13517. };
  13518. if (!this.noPreventDefault) {
  13519. e.preventDefault();
  13520. }
  13521. }
  13522. };
  13523. // Track mouse movement, when pointer is locked.
  13524. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13525. var camera = this.camera;
  13526. var engine = camera.getEngine();
  13527. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13528. return;
  13529. }
  13530. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13531. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13532. this.rotateCamera(offsetX, offsetY);
  13533. this.previousPosition = null;
  13534. if (!this.noPreventDefault) {
  13535. e.preventDefault();
  13536. }
  13537. };
  13538. /**
  13539. * Rotate camera by mouse offset.
  13540. */
  13541. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13542. var _this = this;
  13543. var camera = this.camera;
  13544. var scene = this.camera.getScene();
  13545. if (scene.useRightHandedSystem) {
  13546. offsetX *= -1;
  13547. }
  13548. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13549. offsetX *= -1;
  13550. }
  13551. var x = offsetX / this.angularSensibility;
  13552. var y = offsetY / this.angularSensibility;
  13553. // Initialize to current rotation.
  13554. var currentRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13555. var rotationChange;
  13556. // Pitch.
  13557. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13558. // Apply change in Radians to vector Angle.
  13559. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].X, y);
  13560. // Apply Pitch to quaternion.
  13561. currentRotation.multiplyInPlace(rotationChange);
  13562. }
  13563. // Yaw.
  13564. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13565. // Apply change in Radians to vector Angle.
  13566. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y, x);
  13567. // Apply Yaw to quaternion.
  13568. currentRotation.multiplyInPlace(rotationChange);
  13569. // Add Roll, if banked turning is enabled, within Roll limit.
  13570. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13571. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13572. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13573. // Apply change in Radians to vector Angle.
  13574. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, bankingDelta);
  13575. // Apply Yaw to quaternion.
  13576. currentRotation.multiplyInPlace(rotationChange);
  13577. }
  13578. }
  13579. // Roll.
  13580. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13581. // Apply change in Radians to vector Angle.
  13582. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, -x);
  13583. // Track Rolling.
  13584. camera._trackRoll -= x;
  13585. // Apply Pitch to quaternion.
  13586. currentRotation.multiplyInPlace(rotationChange);
  13587. }
  13588. // Apply rotationQuaternion to Euler camera.rotation.
  13589. currentRotation.toEulerAnglesToRef(camera.rotation);
  13590. };
  13591. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13592. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13593. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13594. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13595. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13596. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13597. return FlyCameraMouseInput;
  13598. }());
  13599. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13600. /***/ }),
  13601. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13602. /*!*********************************************************!*\
  13603. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13604. \*********************************************************/
  13605. /*! exports provided: FollowCameraKeyboardMoveInput */
  13606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13607. "use strict";
  13608. __webpack_require__.r(__webpack_exports__);
  13609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13610. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13611. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13612. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13613. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13614. /**
  13615. * Manage the keyboard inputs to control the movement of a follow camera.
  13616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13617. */
  13618. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13619. function FollowCameraKeyboardMoveInput() {
  13620. /**
  13621. * Defines the list of key codes associated with the up action (increase heightOffset)
  13622. */
  13623. this.keysHeightOffsetIncr = [38];
  13624. /**
  13625. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13626. */
  13627. this.keysHeightOffsetDecr = [40];
  13628. /**
  13629. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  13630. */
  13631. this.keysHeightOffsetModifierAlt = false;
  13632. /**
  13633. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  13634. */
  13635. this.keysHeightOffsetModifierCtrl = false;
  13636. /**
  13637. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  13638. */
  13639. this.keysHeightOffsetModifierShift = false;
  13640. /**
  13641. * Defines the list of key codes associated with the left action (increase rotationOffset)
  13642. */
  13643. this.keysRotationOffsetIncr = [37];
  13644. /**
  13645. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  13646. */
  13647. this.keysRotationOffsetDecr = [39];
  13648. /**
  13649. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  13650. */
  13651. this.keysRotationOffsetModifierAlt = false;
  13652. /**
  13653. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  13654. */
  13655. this.keysRotationOffsetModifierCtrl = false;
  13656. /**
  13657. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  13658. */
  13659. this.keysRotationOffsetModifierShift = false;
  13660. /**
  13661. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  13662. */
  13663. this.keysRadiusIncr = [40];
  13664. /**
  13665. * Defines the list of key codes associated with the zoom-out action (increase radius)
  13666. */
  13667. this.keysRadiusDecr = [38];
  13668. /**
  13669. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  13670. */
  13671. this.keysRadiusModifierAlt = true;
  13672. /**
  13673. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  13674. */
  13675. this.keysRadiusModifierCtrl = false;
  13676. /**
  13677. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  13678. */
  13679. this.keysRadiusModifierShift = false;
  13680. /**
  13681. * Defines the rate of change of heightOffset.
  13682. */
  13683. this.heightSensibility = 1;
  13684. /**
  13685. * Defines the rate of change of rotationOffset.
  13686. */
  13687. this.rotationSensibility = 1;
  13688. /**
  13689. * Defines the rate of change of radius.
  13690. */
  13691. this.radiusSensibility = 1;
  13692. this._keys = new Array();
  13693. }
  13694. /**
  13695. * Attach the input controls to a specific dom element to get the input from.
  13696. * @param element Defines the element the controls should be listened from
  13697. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13698. */
  13699. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13700. var _this = this;
  13701. if (this._onCanvasBlurObserver) {
  13702. return;
  13703. }
  13704. this._scene = this.camera.getScene();
  13705. this._engine = this._scene.getEngine();
  13706. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13707. _this._keys = [];
  13708. });
  13709. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13710. var evt = info.event;
  13711. if (!evt.metaKey) {
  13712. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13713. _this._ctrlPressed = evt.ctrlKey;
  13714. _this._altPressed = evt.altKey;
  13715. _this._shiftPressed = evt.shiftKey;
  13716. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13717. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13718. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13719. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13720. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13721. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13722. var index = _this._keys.indexOf(evt.keyCode);
  13723. if (index === -1) {
  13724. _this._keys.push(evt.keyCode);
  13725. }
  13726. if (evt.preventDefault) {
  13727. if (!noPreventDefault) {
  13728. evt.preventDefault();
  13729. }
  13730. }
  13731. }
  13732. }
  13733. else {
  13734. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13735. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13736. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13737. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13738. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13739. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13740. var index = _this._keys.indexOf(evt.keyCode);
  13741. if (index >= 0) {
  13742. _this._keys.splice(index, 1);
  13743. }
  13744. if (evt.preventDefault) {
  13745. if (!noPreventDefault) {
  13746. evt.preventDefault();
  13747. }
  13748. }
  13749. }
  13750. }
  13751. }
  13752. });
  13753. };
  13754. /**
  13755. * Detach the current controls from the specified dom element.
  13756. * @param element Defines the element to stop listening the inputs from
  13757. */
  13758. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13759. if (this._scene) {
  13760. if (this._onKeyboardObserver) {
  13761. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13762. }
  13763. if (this._onCanvasBlurObserver) {
  13764. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13765. }
  13766. this._onKeyboardObserver = null;
  13767. this._onCanvasBlurObserver = null;
  13768. }
  13769. this._keys = [];
  13770. };
  13771. /**
  13772. * Update the current camera state depending on the inputs that have been used this frame.
  13773. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13774. */
  13775. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13776. var _this = this;
  13777. if (this._onKeyboardObserver) {
  13778. this._keys.forEach(function (keyCode) {
  13779. if (_this.keysHeightOffsetIncr.indexOf(keyCode) !== -1 &&
  13780. _this._modifierHeightOffset()) {
  13781. _this.camera.heightOffset += _this.heightSensibility;
  13782. }
  13783. else if (_this.keysHeightOffsetDecr.indexOf(keyCode) !== -1 &&
  13784. _this._modifierHeightOffset()) {
  13785. _this.camera.heightOffset -= _this.heightSensibility;
  13786. }
  13787. else if (_this.keysRotationOffsetIncr.indexOf(keyCode) !== -1 &&
  13788. _this._modifierRotationOffset()) {
  13789. _this.camera.rotationOffset += _this.rotationSensibility;
  13790. _this.camera.rotationOffset %= 360;
  13791. }
  13792. else if (_this.keysRotationOffsetDecr.indexOf(keyCode) !== -1 &&
  13793. _this._modifierRotationOffset()) {
  13794. _this.camera.rotationOffset -= _this.rotationSensibility;
  13795. _this.camera.rotationOffset %= 360;
  13796. }
  13797. else if (_this.keysRadiusIncr.indexOf(keyCode) !== -1 &&
  13798. _this._modifierRadius()) {
  13799. _this.camera.radius += _this.radiusSensibility;
  13800. }
  13801. else if (_this.keysRadiusDecr.indexOf(keyCode) !== -1 &&
  13802. _this._modifierRadius()) {
  13803. _this.camera.radius -= _this.radiusSensibility;
  13804. }
  13805. });
  13806. }
  13807. };
  13808. /**
  13809. * Gets the class name of the current input.
  13810. * @returns the class name
  13811. */
  13812. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13813. return "FollowCameraKeyboardMoveInput";
  13814. };
  13815. /**
  13816. * Get the friendly name associated with the input class.
  13817. * @returns the input friendly name
  13818. */
  13819. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13820. return "keyboard";
  13821. };
  13822. /**
  13823. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13824. * allow modification of the heightOffset value.
  13825. */
  13826. FollowCameraKeyboardMoveInput.prototype._modifierHeightOffset = function () {
  13827. return (this.keysHeightOffsetModifierAlt === this._altPressed &&
  13828. this.keysHeightOffsetModifierCtrl === this._ctrlPressed &&
  13829. this.keysHeightOffsetModifierShift === this._shiftPressed);
  13830. };
  13831. /**
  13832. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13833. * allow modification of the rotationOffset value.
  13834. */
  13835. FollowCameraKeyboardMoveInput.prototype._modifierRotationOffset = function () {
  13836. return (this.keysRotationOffsetModifierAlt === this._altPressed &&
  13837. this.keysRotationOffsetModifierCtrl === this._ctrlPressed &&
  13838. this.keysRotationOffsetModifierShift === this._shiftPressed);
  13839. };
  13840. /**
  13841. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13842. * allow modification of the radius value.
  13843. */
  13844. FollowCameraKeyboardMoveInput.prototype._modifierRadius = function () {
  13845. return (this.keysRadiusModifierAlt === this._altPressed &&
  13846. this.keysRadiusModifierCtrl === this._ctrlPressed &&
  13847. this.keysRadiusModifierShift === this._shiftPressed);
  13848. };
  13849. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13850. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13851. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetIncr", void 0);
  13852. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13853. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13854. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetDecr", void 0);
  13855. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13856. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13857. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierAlt", void 0);
  13858. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13859. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13860. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierCtrl", void 0);
  13861. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13862. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13863. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierShift", void 0);
  13864. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13865. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13866. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetIncr", void 0);
  13867. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13868. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13869. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetDecr", void 0);
  13870. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13871. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13872. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierAlt", void 0);
  13873. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13874. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13875. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierCtrl", void 0);
  13876. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13877. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13878. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierShift", void 0);
  13879. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13880. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13881. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusIncr", void 0);
  13882. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13883. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13884. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusDecr", void 0);
  13885. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13886. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13887. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierAlt", void 0);
  13888. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13889. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13890. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierCtrl", void 0);
  13891. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13892. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13893. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierShift", void 0);
  13894. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13895. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13896. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  13897. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13898. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13899. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  13900. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13901. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13902. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  13903. return FollowCameraKeyboardMoveInput;
  13904. }());
  13905. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  13906. /***/ }),
  13907. /***/ "./Cameras/Inputs/followCameraMouseWheelInput.ts":
  13908. /*!*******************************************************!*\
  13909. !*** ./Cameras/Inputs/followCameraMouseWheelInput.ts ***!
  13910. \*******************************************************/
  13911. /*! exports provided: FollowCameraMouseWheelInput */
  13912. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13913. "use strict";
  13914. __webpack_require__.r(__webpack_exports__);
  13915. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return FollowCameraMouseWheelInput; });
  13916. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13917. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13918. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13919. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13920. /**
  13921. * Manage the mouse wheel inputs to control a follow camera.
  13922. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13923. */
  13924. var FollowCameraMouseWheelInput = /** @class */ (function () {
  13925. function FollowCameraMouseWheelInput() {
  13926. /**
  13927. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  13928. */
  13929. this.axisControlRadius = true;
  13930. /**
  13931. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  13932. */
  13933. this.axisControlHeight = false;
  13934. /**
  13935. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  13936. */
  13937. this.axisControlRotation = false;
  13938. /**
  13939. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  13940. * relation to mouseWheel events.
  13941. */
  13942. this.wheelPrecision = 3.0;
  13943. /**
  13944. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  13945. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  13946. */
  13947. this.wheelDeltaPercentage = 0;
  13948. }
  13949. /**
  13950. * Attach the input controls to a specific dom element to get the input from.
  13951. * @param element Defines the element the controls should be listened from
  13952. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13953. */
  13954. FollowCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  13955. var _this = this;
  13956. this._wheel = function (p, s) {
  13957. // sanity check - this should be a PointerWheel event.
  13958. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  13959. return;
  13960. }
  13961. var event = p.event;
  13962. var delta = 0;
  13963. // Chrome, Safari: event.deltaY
  13964. // IE: event.wheelDelta
  13965. // Firefox: event.detail (inverted)
  13966. var wheelDelta = Math.max(-1, Math.min(1, (event.deltaY || event.wheelDelta || -event.detail)));
  13967. if (_this.wheelDeltaPercentage) {
  13968. console.assert((_this.axisControlRadius +
  13969. _this.axisControlHeight +
  13970. _this.axisControlRotation) <= 1, "wheelDeltaPercentage only usable when mouse wheel " +
  13971. "controlls ONE axis. " +
  13972. "Currently enabled: " +
  13973. "axisControlRadius: " + _this.axisControlRadius +
  13974. ", axisControlHeightOffset: " + _this.axisControlHeight +
  13975. ", axisControlRotationOffset: " + _this.axisControlRotation);
  13976. if (_this.axisControlRadius) {
  13977. delta =
  13978. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13979. _this.camera.radius;
  13980. }
  13981. else if (_this.axisControlHeight) {
  13982. delta =
  13983. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13984. _this.camera.heightOffset;
  13985. }
  13986. else if (_this.axisControlRotation) {
  13987. delta =
  13988. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13989. _this.camera.rotationOffset;
  13990. }
  13991. }
  13992. else {
  13993. delta = wheelDelta * _this.wheelPrecision;
  13994. }
  13995. if (delta) {
  13996. if (_this.axisControlRadius) {
  13997. _this.camera.radius += delta;
  13998. }
  13999. else if (_this.axisControlHeight) {
  14000. _this.camera.heightOffset -= delta;
  14001. }
  14002. else if (_this.axisControlRotation) {
  14003. _this.camera.rotationOffset -= delta;
  14004. }
  14005. }
  14006. if (event.preventDefault) {
  14007. if (!noPreventDefault) {
  14008. event.preventDefault();
  14009. }
  14010. }
  14011. };
  14012. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  14013. };
  14014. /**
  14015. * Detach the current controls from the specified dom element.
  14016. * @param element Defines the element to stop listening the inputs from
  14017. */
  14018. FollowCameraMouseWheelInput.prototype.detachControl = function (element) {
  14019. if (this._observer && element) {
  14020. this.camera.getScene().onPointerObservable.remove(this._observer);
  14021. this._observer = null;
  14022. this._wheel = null;
  14023. }
  14024. };
  14025. /**
  14026. * Gets the class name of the current intput.
  14027. * @returns the class name
  14028. */
  14029. FollowCameraMouseWheelInput.prototype.getClassName = function () {
  14030. return "ArcRotateCameraMouseWheelInput";
  14031. };
  14032. /**
  14033. * Get the friendly name associated with the input class.
  14034. * @returns the input friendly name
  14035. */
  14036. FollowCameraMouseWheelInput.prototype.getSimpleName = function () {
  14037. return "mousewheel";
  14038. };
  14039. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14041. ], FollowCameraMouseWheelInput.prototype, "axisControlRadius", void 0);
  14042. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14044. ], FollowCameraMouseWheelInput.prototype, "axisControlHeight", void 0);
  14045. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14047. ], FollowCameraMouseWheelInput.prototype, "axisControlRotation", void 0);
  14048. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14049. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14050. ], FollowCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  14051. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14052. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14053. ], FollowCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  14054. return FollowCameraMouseWheelInput;
  14055. }());
  14056. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraMouseWheelInput"] = FollowCameraMouseWheelInput;
  14057. /***/ }),
  14058. /***/ "./Cameras/Inputs/followCameraPointersInput.ts":
  14059. /*!*****************************************************!*\
  14060. !*** ./Cameras/Inputs/followCameraPointersInput.ts ***!
  14061. \*****************************************************/
  14062. /*! exports provided: FollowCameraPointersInput */
  14063. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14064. "use strict";
  14065. __webpack_require__.r(__webpack_exports__);
  14066. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return FollowCameraPointersInput; });
  14067. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14068. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14069. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14070. /* harmony import */ var _Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/Inputs/BaseCameraPointersInput */ "./Cameras/Inputs/BaseCameraPointersInput.ts");
  14071. /**
  14072. * Manage the pointers inputs to control an follow camera.
  14073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14074. */
  14075. var FollowCameraPointersInput = /** @class */ (function (_super) {
  14076. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraPointersInput, _super);
  14077. function FollowCameraPointersInput() {
  14078. var _this = _super !== null && _super.apply(this, arguments) || this;
  14079. /**
  14080. * Defines the pointer angular sensibility along the X axis or how fast is
  14081. * the camera rotating.
  14082. * A negative number will reverse the axis direction.
  14083. */
  14084. _this.angularSensibilityX = 1;
  14085. /**
  14086. * Defines the pointer angular sensibility along the Y axis or how fast is
  14087. * the camera rotating.
  14088. * A negative number will reverse the axis direction.
  14089. */
  14090. _this.angularSensibilityY = 1;
  14091. /**
  14092. * Defines the pointer pinch precision or how fast is the camera zooming.
  14093. * A negative number will reverse the axis direction.
  14094. */
  14095. _this.pinchPrecision = 10000.0;
  14096. /**
  14097. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  14098. * from 0.
  14099. * It defines the percentage of current camera.radius to use as delta when
  14100. * pinch zoom is used.
  14101. */
  14102. _this.pinchDeltaPercentage = 0;
  14103. /**
  14104. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  14105. */
  14106. _this.axisXControlRadius = false;
  14107. /**
  14108. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  14109. */
  14110. _this.axisXControlHeight = false;
  14111. /**
  14112. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  14113. */
  14114. _this.axisXControlRotation = true;
  14115. /**
  14116. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  14117. */
  14118. _this.axisYControlRadius = false;
  14119. /**
  14120. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  14121. */
  14122. _this.axisYControlHeight = true;
  14123. /**
  14124. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  14125. */
  14126. _this.axisYControlRotation = false;
  14127. /**
  14128. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  14129. */
  14130. _this.axisPinchControlRadius = true;
  14131. /**
  14132. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  14133. */
  14134. _this.axisPinchControlHeight = false;
  14135. /**
  14136. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  14137. */
  14138. _this.axisPinchControlRotation = false;
  14139. /**
  14140. * Log error messages if basic misconfiguration has occurred.
  14141. */
  14142. _this.warningEnable = true;
  14143. /* Check for obvious misconfiguration. */
  14144. _this._warningCounter = 0;
  14145. return _this;
  14146. }
  14147. /**
  14148. * Gets the class name of the current input.
  14149. * @returns the class name
  14150. */
  14151. FollowCameraPointersInput.prototype.getClassName = function () {
  14152. return "FollowCameraPointersInput";
  14153. };
  14154. FollowCameraPointersInput.prototype.onTouch = function (pointA, offsetX, offsetY) {
  14155. this._warning();
  14156. if (this.axisXControlRotation) {
  14157. this.camera.rotationOffset += offsetX / this.angularSensibilityX;
  14158. }
  14159. else if (this.axisYControlRotation) {
  14160. this.camera.rotationOffset += offsetY / this.angularSensibilityX;
  14161. }
  14162. if (this.axisXControlHeight) {
  14163. this.camera.heightOffset += offsetX / this.angularSensibilityY;
  14164. }
  14165. else if (this.axisYControlHeight) {
  14166. this.camera.heightOffset += offsetY / this.angularSensibilityY;
  14167. }
  14168. if (this.axisXControlRadius) {
  14169. this.camera.radius -= offsetX / this.angularSensibilityY;
  14170. }
  14171. else if (this.axisYControlRadius) {
  14172. this.camera.radius -= offsetY / this.angularSensibilityY;
  14173. }
  14174. };
  14175. FollowCameraPointersInput.prototype.onMultiTouch = function (pointA, pointB, previousPinchSquaredDistance, pinchSquaredDistance, previousMultiTouchPanPosition, multiTouchPanPosition) {
  14176. if (previousPinchSquaredDistance === 0 && previousMultiTouchPanPosition === null) {
  14177. // First time this method is called for new pinch.
  14178. // Next time this is called there will be a
  14179. // previousPinchSquaredDistance and pinchSquaredDistance to compare.
  14180. return;
  14181. }
  14182. if (pinchSquaredDistance === 0 && multiTouchPanPosition === null) {
  14183. // Last time this method is called at the end of a pinch.
  14184. return;
  14185. }
  14186. var pinchDelta = (pinchSquaredDistance - previousPinchSquaredDistance) /
  14187. (this.pinchPrecision * (this.angularSensibilityX + this.angularSensibilityY) / 2);
  14188. if (this.pinchDeltaPercentage) {
  14189. pinchDelta *= 0.01 * this.pinchDeltaPercentage;
  14190. if (this.axisPinchControlRotation) {
  14191. this.camera.rotationOffset += pinchDelta * this.camera.rotationOffset;
  14192. }
  14193. if (this.axisPinchControlHeight) {
  14194. this.camera.heightOffset += pinchDelta * this.camera.heightOffset;
  14195. }
  14196. if (this.axisPinchControlRadius) {
  14197. this.camera.radius -= pinchDelta * this.camera.radius;
  14198. }
  14199. }
  14200. else {
  14201. if (this.axisPinchControlRotation) {
  14202. this.camera.rotationOffset += pinchDelta;
  14203. }
  14204. if (this.axisPinchControlHeight) {
  14205. this.camera.heightOffset += pinchDelta;
  14206. }
  14207. if (this.axisPinchControlRadius) {
  14208. this.camera.radius -= pinchDelta;
  14209. }
  14210. }
  14211. };
  14212. FollowCameraPointersInput.prototype._warning = function () {
  14213. if (!this.warningEnable || this._warningCounter++ % 100 !== 0) {
  14214. return;
  14215. }
  14216. var warn = "It probably only makes sense to control ONE camera " +
  14217. "property with each pointer axis. Set 'warningEnable = false' " +
  14218. "if you are sure. Currently enabled: ";
  14219. console.assert((this.axisXControlRotation +
  14220. this.axisXControlHeight +
  14221. this.axisXControlRadius) <= 1, warn +
  14222. "axisXControlRotation: " + this.axisXControlRotation +
  14223. ", axisXControlHeight: " + this.axisXControlHeight +
  14224. ", axisXControlRadius: " + this.axisXControlRadius);
  14225. console.assert((this.axisYControlRotation +
  14226. this.axisYControlHeight +
  14227. this.axisYControlRadius) <= 1, warn +
  14228. "axisYControlRotation: " + this.axisYControlRotation +
  14229. ", axisYControlHeight: " + this.axisYControlHeight +
  14230. ", axisYControlRadius: " + this.axisYControlRadius);
  14231. console.assert((this.axisPinchControlRotation +
  14232. this.axisPinchControlHeight +
  14233. this.axisPinchControlRadius) <= 1, warn +
  14234. "axisPinchControlRotation: " + this.axisPinchControlRotation +
  14235. ", axisPinchControlHeight: " + this.axisPinchControlHeight +
  14236. ", axisPinchControlRadius: " + this.axisPinchControlRadius);
  14237. };
  14238. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14239. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14240. ], FollowCameraPointersInput.prototype, "angularSensibilityX", void 0);
  14241. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14242. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14243. ], FollowCameraPointersInput.prototype, "angularSensibilityY", void 0);
  14244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14246. ], FollowCameraPointersInput.prototype, "pinchPrecision", void 0);
  14247. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14248. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14249. ], FollowCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  14250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14252. ], FollowCameraPointersInput.prototype, "axisXControlRadius", void 0);
  14253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14255. ], FollowCameraPointersInput.prototype, "axisXControlHeight", void 0);
  14256. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14258. ], FollowCameraPointersInput.prototype, "axisXControlRotation", void 0);
  14259. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14260. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14261. ], FollowCameraPointersInput.prototype, "axisYControlRadius", void 0);
  14262. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14263. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14264. ], FollowCameraPointersInput.prototype, "axisYControlHeight", void 0);
  14265. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14267. ], FollowCameraPointersInput.prototype, "axisYControlRotation", void 0);
  14268. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14270. ], FollowCameraPointersInput.prototype, "axisPinchControlRadius", void 0);
  14271. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14272. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14273. ], FollowCameraPointersInput.prototype, "axisPinchControlHeight", void 0);
  14274. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14275. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14276. ], FollowCameraPointersInput.prototype, "axisPinchControlRotation", void 0);
  14277. return FollowCameraPointersInput;
  14278. }(_Cameras_Inputs_BaseCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["BaseCameraPointersInput"]));
  14279. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraPointersInput"] = FollowCameraPointersInput;
  14280. /***/ }),
  14281. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  14282. /*!************************************************************!*\
  14283. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  14284. \************************************************************/
  14285. /*! exports provided: FreeCameraDeviceOrientationInput */
  14286. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14287. "use strict";
  14288. __webpack_require__.r(__webpack_exports__);
  14289. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  14290. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14291. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14292. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  14293. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14294. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  14295. /**
  14296. * Add orientation input support to the input manager.
  14297. * @returns the current input manager
  14298. */
  14299. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addDeviceOrientation = function () {
  14300. if (!this._deviceOrientationInput) {
  14301. this._deviceOrientationInput = new FreeCameraDeviceOrientationInput();
  14302. this.add(this._deviceOrientationInput);
  14303. }
  14304. return this;
  14305. };
  14306. /**
  14307. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  14308. * Screen rotation is taken into account.
  14309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14310. */
  14311. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  14312. /**
  14313. * Instantiates a new input
  14314. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14315. */
  14316. function FreeCameraDeviceOrientationInput() {
  14317. var _this = this;
  14318. this._screenOrientationAngle = 0;
  14319. this._screenQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14320. this._alpha = 0;
  14321. this._beta = 0;
  14322. this._gamma = 0;
  14323. /**
  14324. * @hidden
  14325. */
  14326. this._onDeviceOrientationChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  14327. this._orientationChanged = function () {
  14328. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  14329. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  14330. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  14331. };
  14332. this._deviceOrientation = function (evt) {
  14333. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  14334. _this._beta = evt.beta !== null ? evt.beta : 0;
  14335. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  14336. if (evt.alpha !== null) {
  14337. _this._onDeviceOrientationChangedObservable.notifyObservers();
  14338. }
  14339. };
  14340. this._constantTranform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  14341. this._orientationChanged();
  14342. }
  14343. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  14344. /**
  14345. * Define the camera controlled by the input.
  14346. */
  14347. get: function () {
  14348. return this._camera;
  14349. },
  14350. set: function (camera) {
  14351. var _this = this;
  14352. this._camera = camera;
  14353. if (this._camera != null && !this._camera.rotationQuaternion) {
  14354. this._camera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  14355. }
  14356. if (this._camera) {
  14357. this._camera.onDisposeObservable.add(function () {
  14358. _this._onDeviceOrientationChangedObservable.clear();
  14359. });
  14360. }
  14361. },
  14362. enumerable: true,
  14363. configurable: true
  14364. });
  14365. /**
  14366. * Attach the input controls to a specific dom element to get the input from.
  14367. * @param element Defines the element the controls should be listened from
  14368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14369. */
  14370. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  14371. window.addEventListener("orientationchange", this._orientationChanged);
  14372. window.addEventListener("deviceorientation", this._deviceOrientation);
  14373. //In certain cases, the attach control is called AFTER orientation was changed,
  14374. //So this is needed.
  14375. this._orientationChanged();
  14376. };
  14377. /**
  14378. * Detach the current controls from the specified dom element.
  14379. * @param element Defines the element to stop listening the inputs from
  14380. */
  14381. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  14382. window.removeEventListener("orientationchange", this._orientationChanged);
  14383. window.removeEventListener("deviceorientation", this._deviceOrientation);
  14384. this._alpha = 0;
  14385. };
  14386. /**
  14387. * Update the current camera state depending on the inputs that have been used this frame.
  14388. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14389. */
  14390. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  14391. //if no device orientation provided, don't update the rotation.
  14392. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  14393. if (!this._alpha) {
  14394. return;
  14395. }
  14396. _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);
  14397. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  14398. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  14399. //Mirror on XY Plane
  14400. this._camera.rotationQuaternion.z *= -1;
  14401. this._camera.rotationQuaternion.w *= -1;
  14402. };
  14403. /**
  14404. * Gets the class name of the current intput.
  14405. * @returns the class name
  14406. */
  14407. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  14408. return "FreeCameraDeviceOrientationInput";
  14409. };
  14410. /**
  14411. * Get the friendly name associated with the input class.
  14412. * @returns the input friendly name
  14413. */
  14414. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  14415. return "deviceOrientation";
  14416. };
  14417. return FreeCameraDeviceOrientationInput;
  14418. }());
  14419. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  14420. /***/ }),
  14421. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  14422. /*!**************************************************!*\
  14423. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  14424. \**************************************************/
  14425. /*! exports provided: FreeCameraGamepadInput */
  14426. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14427. "use strict";
  14428. __webpack_require__.r(__webpack_exports__);
  14429. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  14430. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14431. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14432. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14433. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14434. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  14435. /**
  14436. * Manage the gamepad inputs to control a free camera.
  14437. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14438. */
  14439. var FreeCameraGamepadInput = /** @class */ (function () {
  14440. function FreeCameraGamepadInput() {
  14441. /**
  14442. * Defines the gamepad rotation sensiblity.
  14443. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  14444. */
  14445. this.gamepadAngularSensibility = 200;
  14446. /**
  14447. * Defines the gamepad move sensiblity.
  14448. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  14449. */
  14450. this.gamepadMoveSensibility = 40;
  14451. this._cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  14452. this._deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14453. this._vector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14454. this._vector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  14455. }
  14456. /**
  14457. * Attach the input controls to a specific dom element to get the input from.
  14458. * @param element Defines the element the controls should be listened from
  14459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14460. */
  14461. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  14462. var _this = this;
  14463. var manager = this.camera.getScene().gamepadManager;
  14464. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  14465. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  14466. // prioritize XBOX gamepads.
  14467. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  14468. _this.gamepad = gamepad;
  14469. }
  14470. }
  14471. });
  14472. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  14473. if (_this.gamepad === gamepad) {
  14474. _this.gamepad = null;
  14475. }
  14476. });
  14477. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  14478. };
  14479. /**
  14480. * Detach the current controls from the specified dom element.
  14481. * @param element Defines the element to stop listening the inputs from
  14482. */
  14483. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  14484. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  14485. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  14486. this.gamepad = null;
  14487. };
  14488. /**
  14489. * Update the current camera state depending on the inputs that have been used this frame.
  14490. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14491. */
  14492. FreeCameraGamepadInput.prototype.checkInputs = function () {
  14493. if (this.gamepad && this.gamepad.leftStick) {
  14494. var camera = this.camera;
  14495. var LSValues = this.gamepad.leftStick;
  14496. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  14497. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  14498. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  14499. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  14500. var RSValues = this.gamepad.rightStick;
  14501. if (RSValues) {
  14502. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  14503. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  14504. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  14505. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  14506. }
  14507. else {
  14508. RSValues = { x: 0, y: 0 };
  14509. }
  14510. if (!camera.rotationQuaternion) {
  14511. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  14512. }
  14513. else {
  14514. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  14515. }
  14516. var speed = camera._computeLocalCameraSpeed() * 50.0;
  14517. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  14518. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  14519. camera.cameraDirection.addInPlace(this._deltaTransform);
  14520. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  14521. camera.cameraRotation.addInPlace(this._vector2);
  14522. }
  14523. };
  14524. /**
  14525. * Gets the class name of the current intput.
  14526. * @returns the class name
  14527. */
  14528. FreeCameraGamepadInput.prototype.getClassName = function () {
  14529. return "FreeCameraGamepadInput";
  14530. };
  14531. /**
  14532. * Get the friendly name associated with the input class.
  14533. * @returns the input friendly name
  14534. */
  14535. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  14536. return "gamepad";
  14537. };
  14538. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14539. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14540. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  14541. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14542. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14543. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  14544. return FreeCameraGamepadInput;
  14545. }());
  14546. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  14547. /***/ }),
  14548. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  14549. /*!*******************************************************!*\
  14550. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  14551. \*******************************************************/
  14552. /*! exports provided: FreeCameraKeyboardMoveInput */
  14553. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14554. "use strict";
  14555. __webpack_require__.r(__webpack_exports__);
  14556. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  14557. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14558. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14559. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14560. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  14561. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14562. /**
  14563. * Manage the keyboard inputs to control the movement of a free camera.
  14564. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14565. */
  14566. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  14567. function FreeCameraKeyboardMoveInput() {
  14568. /**
  14569. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  14570. */
  14571. this.keysUp = [38];
  14572. /**
  14573. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  14574. */
  14575. this.keysDown = [40];
  14576. /**
  14577. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  14578. */
  14579. this.keysLeft = [37];
  14580. /**
  14581. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  14582. */
  14583. this.keysRight = [39];
  14584. this._keys = new Array();
  14585. }
  14586. /**
  14587. * Attach the input controls to a specific dom element to get the input from.
  14588. * @param element Defines the element the controls should be listened from
  14589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14590. */
  14591. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  14592. var _this = this;
  14593. if (this._onCanvasBlurObserver) {
  14594. return;
  14595. }
  14596. this._scene = this.camera.getScene();
  14597. this._engine = this._scene.getEngine();
  14598. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  14599. _this._keys = [];
  14600. });
  14601. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  14602. var evt = info.event;
  14603. if (!evt.metaKey) {
  14604. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  14605. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14606. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14607. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14608. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14609. var index = _this._keys.indexOf(evt.keyCode);
  14610. if (index === -1) {
  14611. _this._keys.push(evt.keyCode);
  14612. }
  14613. if (!noPreventDefault) {
  14614. evt.preventDefault();
  14615. }
  14616. }
  14617. }
  14618. else {
  14619. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14620. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14621. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14622. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14623. var index = _this._keys.indexOf(evt.keyCode);
  14624. if (index >= 0) {
  14625. _this._keys.splice(index, 1);
  14626. }
  14627. if (!noPreventDefault) {
  14628. evt.preventDefault();
  14629. }
  14630. }
  14631. }
  14632. }
  14633. });
  14634. };
  14635. /**
  14636. * Detach the current controls from the specified dom element.
  14637. * @param element Defines the element to stop listening the inputs from
  14638. */
  14639. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  14640. if (this._scene) {
  14641. if (this._onKeyboardObserver) {
  14642. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  14643. }
  14644. if (this._onCanvasBlurObserver) {
  14645. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  14646. }
  14647. this._onKeyboardObserver = null;
  14648. this._onCanvasBlurObserver = null;
  14649. }
  14650. this._keys = [];
  14651. };
  14652. /**
  14653. * Update the current camera state depending on the inputs that have been used this frame.
  14654. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14655. */
  14656. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  14657. if (this._onKeyboardObserver) {
  14658. var camera = this.camera;
  14659. // Keyboard
  14660. for (var index = 0; index < this._keys.length; index++) {
  14661. var keyCode = this._keys[index];
  14662. var speed = camera._computeLocalCameraSpeed();
  14663. if (this.keysLeft.indexOf(keyCode) !== -1) {
  14664. camera._localDirection.copyFromFloats(-speed, 0, 0);
  14665. }
  14666. else if (this.keysUp.indexOf(keyCode) !== -1) {
  14667. camera._localDirection.copyFromFloats(0, 0, speed);
  14668. }
  14669. else if (this.keysRight.indexOf(keyCode) !== -1) {
  14670. camera._localDirection.copyFromFloats(speed, 0, 0);
  14671. }
  14672. else if (this.keysDown.indexOf(keyCode) !== -1) {
  14673. camera._localDirection.copyFromFloats(0, 0, -speed);
  14674. }
  14675. if (camera.getScene().useRightHandedSystem) {
  14676. camera._localDirection.z *= -1;
  14677. }
  14678. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  14679. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  14680. camera.cameraDirection.addInPlace(camera._transformedDirection);
  14681. }
  14682. }
  14683. };
  14684. /**
  14685. * Gets the class name of the current intput.
  14686. * @returns the class name
  14687. */
  14688. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  14689. return "FreeCameraKeyboardMoveInput";
  14690. };
  14691. /** @hidden */
  14692. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  14693. this._keys = [];
  14694. };
  14695. /**
  14696. * Get the friendly name associated with the input class.
  14697. * @returns the input friendly name
  14698. */
  14699. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  14700. return "keyboard";
  14701. };
  14702. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14703. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14704. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  14705. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14706. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14707. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  14708. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14709. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14710. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  14711. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14712. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14713. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  14714. return FreeCameraKeyboardMoveInput;
  14715. }());
  14716. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  14717. /***/ }),
  14718. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  14719. /*!************************************************!*\
  14720. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  14721. \************************************************/
  14722. /*! exports provided: FreeCameraMouseInput */
  14723. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14724. "use strict";
  14725. __webpack_require__.r(__webpack_exports__);
  14726. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  14727. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14728. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  14729. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14730. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14731. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14732. /**
  14733. * Manage the mouse inputs to control the movement of a free camera.
  14734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14735. */
  14736. var FreeCameraMouseInput = /** @class */ (function () {
  14737. /**
  14738. * Manage the mouse inputs to control the movement of a free camera.
  14739. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14740. * @param touchEnabled Defines if touch is enabled or not
  14741. */
  14742. function FreeCameraMouseInput(
  14743. /**
  14744. * Define if touch is enabled in the mouse input
  14745. */
  14746. touchEnabled) {
  14747. if (touchEnabled === void 0) { touchEnabled = true; }
  14748. this.touchEnabled = touchEnabled;
  14749. /**
  14750. * Defines the buttons associated with the input to handle camera move.
  14751. */
  14752. this.buttons = [0, 1, 2];
  14753. /**
  14754. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  14755. */
  14756. this.angularSensibility = 2000.0;
  14757. this.previousPosition = null;
  14758. /**
  14759. * Observable for when a pointer move event occurs containing the move offset
  14760. */
  14761. this.onPointerMovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  14762. /**
  14763. * @hidden
  14764. * If the camera should be rotated automatically based on pointer movement
  14765. */
  14766. this._allowCameraRotation = true;
  14767. }
  14768. /**
  14769. * Attach the input controls to a specific dom element to get the input from.
  14770. * @param element Defines the element the controls should be listened from
  14771. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14772. */
  14773. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  14774. var _this = this;
  14775. var engine = this.camera.getEngine();
  14776. if (!this._pointerInput) {
  14777. this._pointerInput = function (p) {
  14778. var evt = p.event;
  14779. if (engine.isInVRExclusivePointerMode) {
  14780. return;
  14781. }
  14782. if (!_this.touchEnabled && evt.pointerType === "touch") {
  14783. return;
  14784. }
  14785. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  14786. return;
  14787. }
  14788. var srcElement = (evt.srcElement || evt.target);
  14789. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN && srcElement) {
  14790. try {
  14791. srcElement.setPointerCapture(evt.pointerId);
  14792. }
  14793. catch (e) {
  14794. //Nothing to do with the error. Execution will continue.
  14795. }
  14796. _this.previousPosition = {
  14797. x: evt.clientX,
  14798. y: evt.clientY
  14799. };
  14800. if (!noPreventDefault) {
  14801. evt.preventDefault();
  14802. element.focus();
  14803. }
  14804. }
  14805. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP && srcElement) {
  14806. try {
  14807. srcElement.releasePointerCapture(evt.pointerId);
  14808. }
  14809. catch (e) {
  14810. //Nothing to do with the error.
  14811. }
  14812. _this.previousPosition = null;
  14813. if (!noPreventDefault) {
  14814. evt.preventDefault();
  14815. }
  14816. }
  14817. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  14818. if (!_this.previousPosition || engine.isPointerLock) {
  14819. return;
  14820. }
  14821. var offsetX = evt.clientX - _this.previousPosition.x;
  14822. var offsetY = evt.clientY - _this.previousPosition.y;
  14823. if (_this.camera.getScene().useRightHandedSystem) {
  14824. offsetX *= -1;
  14825. }
  14826. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14827. offsetX *= -1;
  14828. }
  14829. if (_this._allowCameraRotation) {
  14830. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14831. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14832. }
  14833. _this.onPointerMovedObservable.notifyObservers({ offsetX: offsetX, offsetY: offsetY });
  14834. _this.previousPosition = {
  14835. x: evt.clientX,
  14836. y: evt.clientY
  14837. };
  14838. if (!noPreventDefault) {
  14839. evt.preventDefault();
  14840. }
  14841. }
  14842. };
  14843. }
  14844. this._onMouseMove = function (evt) {
  14845. if (!engine.isPointerLock) {
  14846. return;
  14847. }
  14848. if (engine.isInVRExclusivePointerMode) {
  14849. return;
  14850. }
  14851. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  14852. if (_this.camera.getScene().useRightHandedSystem) {
  14853. offsetX *= -1;
  14854. }
  14855. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14856. offsetX *= -1;
  14857. }
  14858. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14859. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  14860. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14861. _this.previousPosition = null;
  14862. if (!noPreventDefault) {
  14863. evt.preventDefault();
  14864. }
  14865. };
  14866. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE);
  14867. element.addEventListener("mousemove", this._onMouseMove, false);
  14868. element.addEventListener("contextmenu", this.onContextMenu.bind(this), false);
  14869. };
  14870. /**
  14871. * Called on JS contextmenu event.
  14872. * Override this method to provide functionality.
  14873. */
  14874. FreeCameraMouseInput.prototype.onContextMenu = function (evt) {
  14875. evt.preventDefault();
  14876. };
  14877. /**
  14878. * Detach the current controls from the specified dom element.
  14879. * @param element Defines the element to stop listening the inputs from
  14880. */
  14881. FreeCameraMouseInput.prototype.detachControl = function (element) {
  14882. if (this._observer && element) {
  14883. this.camera.getScene().onPointerObservable.remove(this._observer);
  14884. if (this._onMouseMove) {
  14885. element.removeEventListener("mousemove", this._onMouseMove);
  14886. }
  14887. if (this.onContextMenu) {
  14888. element.removeEventListener("contextmenu", this.onContextMenu);
  14889. }
  14890. if (this.onPointerMovedObservable) {
  14891. this.onPointerMovedObservable.clear();
  14892. }
  14893. this._observer = null;
  14894. this._onMouseMove = null;
  14895. this.previousPosition = null;
  14896. }
  14897. };
  14898. /**
  14899. * Gets the class name of the current intput.
  14900. * @returns the class name
  14901. */
  14902. FreeCameraMouseInput.prototype.getClassName = function () {
  14903. return "FreeCameraMouseInput";
  14904. };
  14905. /**
  14906. * Get the friendly name associated with the input class.
  14907. * @returns the input friendly name
  14908. */
  14909. FreeCameraMouseInput.prototype.getSimpleName = function () {
  14910. return "mouse";
  14911. };
  14912. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14913. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14914. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  14915. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14916. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  14917. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  14918. return FreeCameraMouseInput;
  14919. }());
  14920. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  14921. /***/ }),
  14922. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  14923. /*!************************************************!*\
  14924. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  14925. \************************************************/
  14926. /*! exports provided: FreeCameraTouchInput */
  14927. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14928. "use strict";
  14929. __webpack_require__.r(__webpack_exports__);
  14930. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  14931. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14932. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14933. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14934. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14935. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14936. /**
  14937. * Manage the touch inputs to control the movement of a free camera.
  14938. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14939. */
  14940. var FreeCameraTouchInput = /** @class */ (function () {
  14941. function FreeCameraTouchInput() {
  14942. /**
  14943. * Defines the touch sensibility for rotation.
  14944. * The higher the faster.
  14945. */
  14946. this.touchAngularSensibility = 200000.0;
  14947. /**
  14948. * Defines the touch sensibility for move.
  14949. * The higher the faster.
  14950. */
  14951. this.touchMoveSensibility = 250.0;
  14952. this._offsetX = null;
  14953. this._offsetY = null;
  14954. this._pointerPressed = new Array();
  14955. }
  14956. /**
  14957. * Attach the input controls to a specific dom element to get the input from.
  14958. * @param element Defines the element the controls should be listened from
  14959. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14960. */
  14961. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  14962. var _this = this;
  14963. var previousPosition = null;
  14964. if (this._pointerInput === undefined) {
  14965. this._onLostFocus = function () {
  14966. _this._offsetX = null;
  14967. _this._offsetY = null;
  14968. };
  14969. this._pointerInput = function (p) {
  14970. var evt = p.event;
  14971. if (evt.pointerType === "mouse") {
  14972. return;
  14973. }
  14974. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  14975. if (!noPreventDefault) {
  14976. evt.preventDefault();
  14977. }
  14978. _this._pointerPressed.push(evt.pointerId);
  14979. if (_this._pointerPressed.length !== 1) {
  14980. return;
  14981. }
  14982. previousPosition = {
  14983. x: evt.clientX,
  14984. y: evt.clientY
  14985. };
  14986. }
  14987. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  14988. if (!noPreventDefault) {
  14989. evt.preventDefault();
  14990. }
  14991. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14992. if (index === -1) {
  14993. return;
  14994. }
  14995. _this._pointerPressed.splice(index, 1);
  14996. if (index != 0) {
  14997. return;
  14998. }
  14999. previousPosition = null;
  15000. _this._offsetX = null;
  15001. _this._offsetY = null;
  15002. }
  15003. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  15004. if (!noPreventDefault) {
  15005. evt.preventDefault();
  15006. }
  15007. if (!previousPosition) {
  15008. return;
  15009. }
  15010. var index = _this._pointerPressed.indexOf(evt.pointerId);
  15011. if (index != 0) {
  15012. return;
  15013. }
  15014. _this._offsetX = evt.clientX - previousPosition.x;
  15015. _this._offsetY = -(evt.clientY - previousPosition.y);
  15016. }
  15017. };
  15018. }
  15019. 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);
  15020. if (this._onLostFocus) {
  15021. element.addEventListener("blur", this._onLostFocus);
  15022. }
  15023. };
  15024. /**
  15025. * Detach the current controls from the specified dom element.
  15026. * @param element Defines the element to stop listening the inputs from
  15027. */
  15028. FreeCameraTouchInput.prototype.detachControl = function (element) {
  15029. if (this._pointerInput && element) {
  15030. if (this._observer) {
  15031. this.camera.getScene().onPointerObservable.remove(this._observer);
  15032. this._observer = null;
  15033. }
  15034. if (this._onLostFocus) {
  15035. element.removeEventListener("blur", this._onLostFocus);
  15036. this._onLostFocus = null;
  15037. }
  15038. this._pointerPressed = [];
  15039. this._offsetX = null;
  15040. this._offsetY = null;
  15041. }
  15042. };
  15043. /**
  15044. * Update the current camera state depending on the inputs that have been used this frame.
  15045. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  15046. */
  15047. FreeCameraTouchInput.prototype.checkInputs = function () {
  15048. if (this._offsetX && this._offsetY) {
  15049. var camera = this.camera;
  15050. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  15051. if (this._pointerPressed.length > 1) {
  15052. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  15053. }
  15054. else {
  15055. var speed = camera._computeLocalCameraSpeed();
  15056. var direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  15057. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  15058. camera.cameraDirection.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  15059. }
  15060. }
  15061. };
  15062. /**
  15063. * Gets the class name of the current intput.
  15064. * @returns the class name
  15065. */
  15066. FreeCameraTouchInput.prototype.getClassName = function () {
  15067. return "FreeCameraTouchInput";
  15068. };
  15069. /**
  15070. * Get the friendly name associated with the input class.
  15071. * @returns the input friendly name
  15072. */
  15073. FreeCameraTouchInput.prototype.getSimpleName = function () {
  15074. return "touch";
  15075. };
  15076. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15077. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15078. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  15079. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  15080. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15081. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  15082. return FreeCameraTouchInput;
  15083. }());
  15084. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  15085. /***/ }),
  15086. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  15087. /*!**********************************************************!*\
  15088. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  15089. \**********************************************************/
  15090. /*! exports provided: FreeCameraVirtualJoystickInput */
  15091. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15092. "use strict";
  15093. __webpack_require__.r(__webpack_exports__);
  15094. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  15095. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  15096. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  15097. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15098. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  15099. /**
  15100. * Add virtual joystick input support to the input manager.
  15101. * @returns the current input manager
  15102. */
  15103. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addVirtualJoystick = function () {
  15104. this.add(new FreeCameraVirtualJoystickInput());
  15105. return this;
  15106. };
  15107. /**
  15108. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  15109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  15110. */
  15111. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  15112. function FreeCameraVirtualJoystickInput() {
  15113. }
  15114. /**
  15115. * Gets the left stick of the virtual joystick.
  15116. * @returns The virtual Joystick
  15117. */
  15118. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  15119. return this._leftjoystick;
  15120. };
  15121. /**
  15122. * Gets the right stick of the virtual joystick.
  15123. * @returns The virtual Joystick
  15124. */
  15125. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  15126. return this._rightjoystick;
  15127. };
  15128. /**
  15129. * Update the current camera state depending on the inputs that have been used this frame.
  15130. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  15131. */
  15132. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  15133. if (this._leftjoystick) {
  15134. var camera = this.camera;
  15135. var speed = camera._computeLocalCameraSpeed() * 50;
  15136. var cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  15137. 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);
  15138. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  15139. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  15140. if (!this._leftjoystick.pressed) {
  15141. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  15142. }
  15143. if (!this._rightjoystick.pressed) {
  15144. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  15145. }
  15146. }
  15147. };
  15148. /**
  15149. * Attach the input controls to a specific dom element to get the input from.
  15150. * @param element Defines the element the controls should be listened from
  15151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  15152. */
  15153. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  15154. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  15155. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  15156. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15157. this._leftjoystick.setJoystickSensibility(0.15);
  15158. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  15159. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  15160. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  15161. this._rightjoystick.reverseUpDown = true;
  15162. this._rightjoystick.setJoystickSensibility(0.05);
  15163. this._rightjoystick.setJoystickColor("yellow");
  15164. };
  15165. /**
  15166. * Detach the current controls from the specified dom element.
  15167. * @param element Defines the element to stop listening the inputs from
  15168. */
  15169. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  15170. this._leftjoystick.releaseCanvas();
  15171. this._rightjoystick.releaseCanvas();
  15172. };
  15173. /**
  15174. * Gets the class name of the current intput.
  15175. * @returns the class name
  15176. */
  15177. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  15178. return "FreeCameraVirtualJoystickInput";
  15179. };
  15180. /**
  15181. * Get the friendly name associated with the input class.
  15182. * @returns the input friendly name
  15183. */
  15184. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  15185. return "virtualJoystick";
  15186. };
  15187. return FreeCameraVirtualJoystickInput;
  15188. }());
  15189. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  15190. /***/ }),
  15191. /***/ "./Cameras/Inputs/index.ts":
  15192. /*!*********************************!*\
  15193. !*** ./Cameras/Inputs/index.ts ***!
  15194. \*********************************/
  15195. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FollowCameraKeyboardMoveInput, FollowCameraMouseWheelInput, FollowCameraPointersInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  15196. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15197. "use strict";
  15198. __webpack_require__.r(__webpack_exports__);
  15199. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  15200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  15201. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  15202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  15203. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  15204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  15205. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  15206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  15207. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  15209. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  15210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  15211. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  15212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  15213. /* harmony import */ var _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  15214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  15215. /* harmony import */ var _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  15216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_8__["FollowCameraMouseWheelInput"]; });
  15217. /* harmony import */ var _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  15218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _followCameraPointersInput__WEBPACK_IMPORTED_MODULE_9__["FollowCameraPointersInput"]; });
  15219. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  15220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraDeviceOrientationInput"]; });
  15221. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  15222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraGamepadInput"]; });
  15223. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  15224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraKeyboardMoveInput"]; });
  15225. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  15226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_13__["FreeCameraMouseInput"]; });
  15227. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  15228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_14__["FreeCameraTouchInput"]; });
  15229. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  15230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_15__["FreeCameraVirtualJoystickInput"]; });
  15231. /***/ }),
  15232. /***/ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts":
  15233. /*!*********************************************************!*\
  15234. !*** ./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts ***!
  15235. \*********************************************************/
  15236. /*! no exports provided */
  15237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15238. "use strict";
  15239. __webpack_require__.r(__webpack_exports__);
  15240. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15241. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15242. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  15243. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicAnaglyphRigMode = function (camera) {
  15244. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15245. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__["AnaglyphPostProcess"](camera.name + "_anaglyph", 1.0, camera._rigCameras);
  15246. };
  15247. /***/ }),
  15248. /***/ "./Cameras/RigModes/stereoscopicRigMode.ts":
  15249. /*!*************************************************!*\
  15250. !*** ./Cameras/RigModes/stereoscopicRigMode.ts ***!
  15251. \*************************************************/
  15252. /*! no exports provided */
  15253. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15254. "use strict";
  15255. __webpack_require__.r(__webpack_exports__);
  15256. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15257. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  15258. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  15259. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicRigMode = function (camera) {
  15260. 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;
  15261. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  15262. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__["StereoscopicInterlacePostProcess"](camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
  15263. };
  15264. /***/ }),
  15265. /***/ "./Cameras/RigModes/vrRigMode.ts":
  15266. /*!***************************************!*\
  15267. !*** ./Cameras/RigModes/vrRigMode.ts ***!
  15268. \***************************************/
  15269. /*! no exports provided */
  15270. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15271. "use strict";
  15272. __webpack_require__.r(__webpack_exports__);
  15273. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15274. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15275. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  15276. /* harmony import */ var _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../PostProcesses/vrMultiviewToSingleviewPostProcess */ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts");
  15277. /* harmony import */ var _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15278. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  15279. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setVRRigMode = function (camera, rigParams) {
  15280. var metrics = rigParams.vrCameraMetrics || _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_4__["VRCameraMetrics"].GetDefault();
  15281. camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  15282. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  15283. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15284. camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  15285. camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  15286. camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
  15287. camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  15288. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  15289. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15290. camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  15291. camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  15292. camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
  15293. // For multiview on a webVR camera
  15294. // First multiview will be rendered to camera._multiviewTexture
  15295. // Then this postprocess will run on each eye to copy the right texture to each eye
  15296. if (metrics.multiviewEnabled) {
  15297. if (!camera.getScene().getEngine().getCaps().multiview) {
  15298. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("Multiview is not supported, falling back to standard rendering");
  15299. metrics.multiviewEnabled = false;
  15300. }
  15301. else {
  15302. camera._useMultiviewToSingleView = true;
  15303. camera._rigPostProcess = new _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_3__["VRMultiviewToSingleviewPostProcess"]("VRMultiviewToSingleview", camera, metrics.postProcessScaleFactor);
  15304. }
  15305. }
  15306. if (metrics.compensateDistortion) {
  15307. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
  15308. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
  15309. }
  15310. };
  15311. /***/ }),
  15312. /***/ "./Cameras/RigModes/webVRRigMode.ts":
  15313. /*!******************************************!*\
  15314. !*** ./Cameras/RigModes/webVRRigMode.ts ***!
  15315. \******************************************/
  15316. /*! no exports provided */
  15317. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15318. "use strict";
  15319. __webpack_require__.r(__webpack_exports__);
  15320. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  15321. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15322. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setWebVRRigMode = function (camera, rigParams) {
  15323. if (rigParams.vrDisplay) {
  15324. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  15325. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  15326. //Left eye
  15327. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  15328. camera._rigCameras[0].setCameraRigParameter("left", true);
  15329. //leaving this for future reference
  15330. camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  15331. camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  15332. camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  15333. camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15334. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15335. camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15336. camera._rigCameras[0].parent = camera;
  15337. camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
  15338. //Right eye
  15339. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  15340. camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  15341. camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  15342. camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  15343. camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  15344. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  15345. camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  15346. camera._rigCameras[1].parent = camera;
  15347. camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
  15348. }
  15349. };
  15350. /***/ }),
  15351. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  15352. /*!*********************************************************!*\
  15353. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  15354. \*********************************************************/
  15355. /*! exports provided: AnaglyphArcRotateCamera */
  15356. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15357. "use strict";
  15358. __webpack_require__.r(__webpack_exports__);
  15359. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  15360. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15361. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15362. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15363. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15364. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15365. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15366. // Side effect import to define the stereoscopic mode.
  15367. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  15368. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15369. });
  15370. /**
  15371. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  15372. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15373. */
  15374. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  15375. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  15376. /**
  15377. * Creates a new AnaglyphArcRotateCamera
  15378. * @param name defines camera name
  15379. * @param alpha defines alpha angle (in radians)
  15380. * @param beta defines beta angle (in radians)
  15381. * @param radius defines radius
  15382. * @param target defines camera target
  15383. * @param interaxialDistance defines distance between each color axis
  15384. * @param scene defines the hosting scene
  15385. */
  15386. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  15387. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15388. _this.interaxialDistance = interaxialDistance;
  15389. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15390. return _this;
  15391. }
  15392. /**
  15393. * Gets camera class name
  15394. * @returns AnaglyphArcRotateCamera
  15395. */
  15396. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  15397. return "AnaglyphArcRotateCamera";
  15398. };
  15399. return AnaglyphArcRotateCamera;
  15400. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15401. /***/ }),
  15402. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  15403. /*!****************************************************!*\
  15404. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  15405. \****************************************************/
  15406. /*! exports provided: AnaglyphFreeCamera */
  15407. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15408. "use strict";
  15409. __webpack_require__.r(__webpack_exports__);
  15410. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  15411. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15412. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15413. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15414. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15415. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15416. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15417. // Side effect import to define the stereoscopic mode.
  15418. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphFreeCamera", function (name, scene, options) {
  15419. return function () { return new AnaglyphFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15420. });
  15421. /**
  15422. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  15423. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15424. */
  15425. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  15426. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  15427. /**
  15428. * Creates a new AnaglyphFreeCamera
  15429. * @param name defines camera name
  15430. * @param position defines initial position
  15431. * @param interaxialDistance defines distance between each color axis
  15432. * @param scene defines the hosting scene
  15433. */
  15434. function AnaglyphFreeCamera(name, position, interaxialDistance, scene) {
  15435. var _this = _super.call(this, name, position, scene) || this;
  15436. _this.interaxialDistance = interaxialDistance;
  15437. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15438. return _this;
  15439. }
  15440. /**
  15441. * Gets camera class name
  15442. * @returns AnaglyphFreeCamera
  15443. */
  15444. AnaglyphFreeCamera.prototype.getClassName = function () {
  15445. return "AnaglyphFreeCamera";
  15446. };
  15447. return AnaglyphFreeCamera;
  15448. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15449. /***/ }),
  15450. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  15451. /*!*******************************************************!*\
  15452. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  15453. \*******************************************************/
  15454. /*! exports provided: AnaglyphGamepadCamera */
  15455. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15456. "use strict";
  15457. __webpack_require__.r(__webpack_exports__);
  15458. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  15459. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15460. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15461. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15462. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15463. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15464. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15465. // Side effect import to define the stereoscopic mode.
  15466. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphGamepadCamera", function (name, scene, options) {
  15467. return function () { return new AnaglyphGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15468. });
  15469. /**
  15470. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  15471. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15472. */
  15473. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  15474. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  15475. /**
  15476. * Creates a new AnaglyphGamepadCamera
  15477. * @param name defines camera name
  15478. * @param position defines initial position
  15479. * @param interaxialDistance defines distance between each color axis
  15480. * @param scene defines the hosting scene
  15481. */
  15482. function AnaglyphGamepadCamera(name, position, interaxialDistance, scene) {
  15483. var _this = _super.call(this, name, position, scene) || this;
  15484. _this.interaxialDistance = interaxialDistance;
  15485. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15486. return _this;
  15487. }
  15488. /**
  15489. * Gets camera class name
  15490. * @returns AnaglyphGamepadCamera
  15491. */
  15492. AnaglyphGamepadCamera.prototype.getClassName = function () {
  15493. return "AnaglyphGamepadCamera";
  15494. };
  15495. return AnaglyphGamepadCamera;
  15496. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15497. /***/ }),
  15498. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  15499. /*!*********************************************************!*\
  15500. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  15501. \*********************************************************/
  15502. /*! exports provided: AnaglyphUniversalCamera */
  15503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15504. "use strict";
  15505. __webpack_require__.r(__webpack_exports__);
  15506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  15507. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15508. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15509. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15510. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15511. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15512. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15513. // Side effect import to define the stereoscopic mode.
  15514. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  15515. return function () { return new AnaglyphUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15516. });
  15517. /**
  15518. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  15519. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15520. */
  15521. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  15522. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  15523. /**
  15524. * Creates a new AnaglyphUniversalCamera
  15525. * @param name defines camera name
  15526. * @param position defines initial position
  15527. * @param interaxialDistance defines distance between each color axis
  15528. * @param scene defines the hosting scene
  15529. */
  15530. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  15531. var _this = _super.call(this, name, position, scene) || this;
  15532. _this.interaxialDistance = interaxialDistance;
  15533. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15534. return _this;
  15535. }
  15536. /**
  15537. * Gets camera class name
  15538. * @returns AnaglyphUniversalCamera
  15539. */
  15540. AnaglyphUniversalCamera.prototype.getClassName = function () {
  15541. return "AnaglyphUniversalCamera";
  15542. };
  15543. return AnaglyphUniversalCamera;
  15544. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15545. /***/ }),
  15546. /***/ "./Cameras/Stereoscopic/index.ts":
  15547. /*!***************************************!*\
  15548. !*** ./Cameras/Stereoscopic/index.ts ***!
  15549. \***************************************/
  15550. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  15551. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15552. "use strict";
  15553. __webpack_require__.r(__webpack_exports__);
  15554. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  15555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  15556. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  15557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  15558. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  15559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  15560. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  15561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  15562. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  15563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  15564. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  15565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  15566. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  15567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  15568. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  15569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  15570. /***/ }),
  15571. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  15572. /*!*************************************************************!*\
  15573. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  15574. \*************************************************************/
  15575. /*! exports provided: StereoscopicArcRotateCamera */
  15576. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15577. "use strict";
  15578. __webpack_require__.r(__webpack_exports__);
  15579. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  15580. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15581. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15582. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15583. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15584. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15585. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15586. // Side effect import to define the stereoscopic mode.
  15587. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  15588. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15589. });
  15590. /**
  15591. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  15592. * @see http://doc.babylonjs.com/features/cameras
  15593. */
  15594. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  15595. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  15596. /**
  15597. * Creates a new StereoscopicArcRotateCamera
  15598. * @param name defines camera name
  15599. * @param alpha defines alpha angle (in radians)
  15600. * @param beta defines beta angle (in radians)
  15601. * @param radius defines radius
  15602. * @param target defines camera target
  15603. * @param interaxialDistance defines distance between each color axis
  15604. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15605. * @param scene defines the hosting scene
  15606. */
  15607. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  15608. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15609. _this.interaxialDistance = interaxialDistance;
  15610. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15611. _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 });
  15612. return _this;
  15613. }
  15614. /**
  15615. * Gets camera class name
  15616. * @returns StereoscopicArcRotateCamera
  15617. */
  15618. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  15619. return "StereoscopicArcRotateCamera";
  15620. };
  15621. return StereoscopicArcRotateCamera;
  15622. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15623. /***/ }),
  15624. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  15625. /*!********************************************************!*\
  15626. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  15627. \********************************************************/
  15628. /*! exports provided: StereoscopicFreeCamera */
  15629. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15630. "use strict";
  15631. __webpack_require__.r(__webpack_exports__);
  15632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  15633. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15634. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15635. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15636. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15637. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15638. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15639. // Side effect import to define the stereoscopic mode.
  15640. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15641. return function () { return new StereoscopicFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15642. });
  15643. /**
  15644. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  15645. * @see http://doc.babylonjs.com/features/cameras
  15646. */
  15647. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  15648. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  15649. /**
  15650. * Creates a new StereoscopicFreeCamera
  15651. * @param name defines camera name
  15652. * @param position defines initial position
  15653. * @param interaxialDistance defines distance between each color axis
  15654. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15655. * @param scene defines the hosting scene
  15656. */
  15657. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15658. var _this = _super.call(this, name, position, scene) || this;
  15659. _this.interaxialDistance = interaxialDistance;
  15660. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15661. _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 });
  15662. return _this;
  15663. }
  15664. /**
  15665. * Gets camera class name
  15666. * @returns StereoscopicFreeCamera
  15667. */
  15668. StereoscopicFreeCamera.prototype.getClassName = function () {
  15669. return "StereoscopicFreeCamera";
  15670. };
  15671. return StereoscopicFreeCamera;
  15672. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15673. /***/ }),
  15674. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  15675. /*!***********************************************************!*\
  15676. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  15677. \***********************************************************/
  15678. /*! exports provided: StereoscopicGamepadCamera */
  15679. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15680. "use strict";
  15681. __webpack_require__.r(__webpack_exports__);
  15682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  15683. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15684. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15685. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15686. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15687. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15688. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15689. // Side effect import to define the stereoscopic mode.
  15690. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  15691. return function () { return new StereoscopicGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15692. });
  15693. /**
  15694. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  15695. * @see http://doc.babylonjs.com/features/cameras
  15696. */
  15697. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  15698. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  15699. /**
  15700. * Creates a new StereoscopicGamepadCamera
  15701. * @param name defines camera name
  15702. * @param position defines initial position
  15703. * @param interaxialDistance defines distance between each color axis
  15704. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15705. * @param scene defines the hosting scene
  15706. */
  15707. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15708. var _this = _super.call(this, name, position, scene) || this;
  15709. _this.interaxialDistance = interaxialDistance;
  15710. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15711. _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 });
  15712. return _this;
  15713. }
  15714. /**
  15715. * Gets camera class name
  15716. * @returns StereoscopicGamepadCamera
  15717. */
  15718. StereoscopicGamepadCamera.prototype.getClassName = function () {
  15719. return "StereoscopicGamepadCamera";
  15720. };
  15721. return StereoscopicGamepadCamera;
  15722. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15723. /***/ }),
  15724. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  15725. /*!*************************************************************!*\
  15726. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  15727. \*************************************************************/
  15728. /*! exports provided: StereoscopicUniversalCamera */
  15729. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15730. "use strict";
  15731. __webpack_require__.r(__webpack_exports__);
  15732. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  15733. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15734. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15735. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15736. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15737. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15738. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15739. // Side effect import to define the stereoscopic mode.
  15740. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15741. return function () { return new StereoscopicUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15742. });
  15743. /**
  15744. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  15745. * @see http://doc.babylonjs.com/features/cameras
  15746. */
  15747. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  15748. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  15749. /**
  15750. * Creates a new StereoscopicUniversalCamera
  15751. * @param name defines camera name
  15752. * @param position defines initial position
  15753. * @param interaxialDistance defines distance between each color axis
  15754. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15755. * @param scene defines the hosting scene
  15756. */
  15757. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15758. var _this = _super.call(this, name, position, scene) || this;
  15759. _this.interaxialDistance = interaxialDistance;
  15760. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15761. _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 });
  15762. return _this;
  15763. }
  15764. /**
  15765. * Gets camera class name
  15766. * @returns StereoscopicUniversalCamera
  15767. */
  15768. StereoscopicUniversalCamera.prototype.getClassName = function () {
  15769. return "StereoscopicUniversalCamera";
  15770. };
  15771. return StereoscopicUniversalCamera;
  15772. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15773. /***/ }),
  15774. /***/ "./Cameras/VR/index.ts":
  15775. /*!*****************************!*\
  15776. !*** ./Cameras/VR/index.ts ***!
  15777. \*****************************/
  15778. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, OnAfterEnteringVRObservableEvent, VRExperienceHelper, WebVRFreeCamera */
  15779. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15780. "use strict";
  15781. __webpack_require__.r(__webpack_exports__);
  15782. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  15784. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  15785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  15786. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  15788. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  15789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  15790. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  15791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["OnAfterEnteringVRObservableEvent"]; });
  15792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  15793. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  15795. /***/ }),
  15796. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  15797. /*!***************************************!*\
  15798. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  15799. \***************************************/
  15800. /*! exports provided: VRCameraMetrics */
  15801. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15802. "use strict";
  15803. __webpack_require__.r(__webpack_exports__);
  15804. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  15805. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15806. /**
  15807. * This represents all the required metrics to create a VR camera.
  15808. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  15809. */
  15810. var VRCameraMetrics = /** @class */ (function () {
  15811. function VRCameraMetrics() {
  15812. /**
  15813. * Define if the current vr camera should compensate the distortion of the lense or not.
  15814. */
  15815. this.compensateDistortion = true;
  15816. /**
  15817. * Defines if multiview should be enabled when rendering (Default: false)
  15818. */
  15819. this.multiviewEnabled = false;
  15820. }
  15821. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  15822. /**
  15823. * Gets the rendering aspect ratio based on the provided resolutions.
  15824. */
  15825. get: function () {
  15826. return this.hResolution / (2 * this.vResolution);
  15827. },
  15828. enumerable: true,
  15829. configurable: true
  15830. });
  15831. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  15832. /**
  15833. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  15834. */
  15835. get: function () {
  15836. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  15837. },
  15838. enumerable: true,
  15839. configurable: true
  15840. });
  15841. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  15842. /**
  15843. * @hidden
  15844. */
  15845. get: function () {
  15846. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15847. var h = (4 * meters) / this.hScreenSize;
  15848. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  15849. },
  15850. enumerable: true,
  15851. configurable: true
  15852. });
  15853. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  15854. /**
  15855. * @hidden
  15856. */
  15857. get: function () {
  15858. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15859. var h = (4 * meters) / this.hScreenSize;
  15860. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  15861. },
  15862. enumerable: true,
  15863. configurable: true
  15864. });
  15865. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  15866. /**
  15867. * @hidden
  15868. */
  15869. get: function () {
  15870. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  15871. },
  15872. enumerable: true,
  15873. configurable: true
  15874. });
  15875. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  15876. /**
  15877. * @hidden
  15878. */
  15879. get: function () {
  15880. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  15881. },
  15882. enumerable: true,
  15883. configurable: true
  15884. });
  15885. /**
  15886. * Get the default VRMetrics based on the most generic setup.
  15887. * @returns the default vr metrics
  15888. */
  15889. VRCameraMetrics.GetDefault = function () {
  15890. var result = new VRCameraMetrics();
  15891. result.hResolution = 1280;
  15892. result.vResolution = 800;
  15893. result.hScreenSize = 0.149759993;
  15894. result.vScreenSize = 0.0935999975;
  15895. result.vScreenCenter = 0.0467999987;
  15896. result.eyeToScreenDistance = 0.0410000011;
  15897. result.lensSeparationDistance = 0.0635000020;
  15898. result.interpupillaryDistance = 0.0640000030;
  15899. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  15900. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  15901. result.postProcessScaleFactor = 1.714605507808412;
  15902. result.lensCenterOffset = 0.151976421;
  15903. return result;
  15904. };
  15905. return VRCameraMetrics;
  15906. }());
  15907. /***/ }),
  15908. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  15909. /*!**********************************************************!*\
  15910. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  15911. \**********************************************************/
  15912. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  15913. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15914. "use strict";
  15915. __webpack_require__.r(__webpack_exports__);
  15916. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  15917. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15918. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15919. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15920. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15921. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15922. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15923. /* harmony import */ var _Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15924. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15925. // Side effect import to define the stereoscopic mode.
  15926. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15927. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15928. });
  15929. /**
  15930. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  15931. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15932. */
  15933. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  15934. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  15935. /**
  15936. * Creates a new VRDeviceOrientationArcRotateCamera
  15937. * @param name defines camera name
  15938. * @param alpha defines the camera rotation along the logitudinal axis
  15939. * @param beta defines the camera rotation along the latitudinal axis
  15940. * @param radius defines the camera distance from its target
  15941. * @param target defines the camera target
  15942. * @param scene defines the scene the camera belongs to
  15943. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15944. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15945. */
  15946. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  15947. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15948. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15949. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15950. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15951. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15952. _this.inputs.addVRDeviceOrientation();
  15953. return _this;
  15954. }
  15955. /**
  15956. * Gets camera class name
  15957. * @returns VRDeviceOrientationArcRotateCamera
  15958. */
  15959. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  15960. return "VRDeviceOrientationArcRotateCamera";
  15961. };
  15962. return VRDeviceOrientationArcRotateCamera;
  15963. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15964. /***/ }),
  15965. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  15966. /*!*****************************************************!*\
  15967. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  15968. \*****************************************************/
  15969. /*! exports provided: VRDeviceOrientationFreeCamera */
  15970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15971. "use strict";
  15972. __webpack_require__.r(__webpack_exports__);
  15973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  15974. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15975. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15976. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15977. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15978. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15979. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15980. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15981. // Side effect import to define the stereoscopic mode.
  15982. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15983. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15984. });
  15985. /**
  15986. * Camera used to simulate VR rendering (based on FreeCamera)
  15987. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15988. */
  15989. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  15990. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  15991. /**
  15992. * Creates a new VRDeviceOrientationFreeCamera
  15993. * @param name defines camera name
  15994. * @param position defines the start position of the camera
  15995. * @param scene defines the scene the camera belongs to
  15996. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15997. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15998. */
  15999. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  16000. if (compensateDistortion === void 0) { compensateDistortion = true; }
  16001. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  16002. var _this = _super.call(this, name, position, scene) || this;
  16003. vrCameraMetrics.compensateDistortion = compensateDistortion;
  16004. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  16005. return _this;
  16006. }
  16007. /**
  16008. * Gets camera class name
  16009. * @returns VRDeviceOrientationFreeCamera
  16010. */
  16011. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  16012. return "VRDeviceOrientationFreeCamera";
  16013. };
  16014. return VRDeviceOrientationFreeCamera;
  16015. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  16016. /***/ }),
  16017. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  16018. /*!********************************************************!*\
  16019. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  16020. \********************************************************/
  16021. /*! exports provided: VRDeviceOrientationGamepadCamera */
  16022. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16023. "use strict";
  16024. __webpack_require__.r(__webpack_exports__);
  16025. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  16026. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  16027. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  16028. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  16029. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  16030. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  16031. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  16032. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  16033. });
  16034. /**
  16035. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  16036. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  16037. */
  16038. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  16039. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  16040. /**
  16041. * Creates a new VRDeviceOrientationGamepadCamera
  16042. * @param name defines camera name
  16043. * @param position defines the start position of the camera
  16044. * @param scene defines the scene the camera belongs to
  16045. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  16046. * @param vrCameraMetrics defines the vr metrics associated to the camera
  16047. */
  16048. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  16049. if (compensateDistortion === void 0) { compensateDistortion = true; }
  16050. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  16051. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  16052. _this.inputs.addGamepad();
  16053. return _this;
  16054. }
  16055. /**
  16056. * Gets camera class name
  16057. * @returns VRDeviceOrientationGamepadCamera
  16058. */
  16059. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  16060. return "VRDeviceOrientationGamepadCamera";
  16061. };
  16062. return VRDeviceOrientationGamepadCamera;
  16063. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  16064. /***/ }),
  16065. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  16066. /*!******************************************!*\
  16067. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  16068. \******************************************/
  16069. /*! exports provided: OnAfterEnteringVRObservableEvent, VRExperienceHelper */
  16070. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16071. "use strict";
  16072. __webpack_require__.r(__webpack_exports__);
  16073. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return OnAfterEnteringVRObservableEvent; });
  16074. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  16075. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  16076. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  16077. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  16078. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  16079. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  16080. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  16081. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  16082. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  16083. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  16084. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  16085. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  16086. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  16087. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  16088. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  16089. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  16090. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  16091. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  16092. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  16093. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  16094. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  16095. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  16096. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  16097. /* harmony import */ var _Cameras_VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Cameras/VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  16098. /* harmony import */ var _Meshes_Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Meshes/Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  16099. /* harmony import */ var _Meshes_Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Meshes/Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  16100. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  16101. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  16102. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ../../Animations/animatable */ "./Animations/animatable.ts");
  16103. var VRExperienceHelperGazer = /** @class */ (function () {
  16104. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  16105. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  16106. this.scene = scene;
  16107. /** @hidden */
  16108. this._pointerDownOnMeshAsked = false;
  16109. /** @hidden */
  16110. this._isActionableMesh = false;
  16111. /** @hidden */
  16112. this._teleportationRequestInitiated = false;
  16113. /** @hidden */
  16114. this._teleportationBackRequestInitiated = false;
  16115. /** @hidden */
  16116. this._rotationRightAsked = false;
  16117. /** @hidden */
  16118. this._rotationLeftAsked = false;
  16119. /** @hidden */
  16120. this._dpadPressed = true;
  16121. /** @hidden */
  16122. this._activePointer = false;
  16123. this._id = VRExperienceHelperGazer._idCounter++;
  16124. // Gaze tracker
  16125. if (!gazeTrackerToClone) {
  16126. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  16127. this._gazeTracker.bakeCurrentTransformIntoVertices();
  16128. this._gazeTracker.isPickable = false;
  16129. this._gazeTracker.isVisible = false;
  16130. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("targetMat", scene);
  16131. targetMat.specularColor = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"].Black();
  16132. targetMat.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  16133. targetMat.backFaceCulling = false;
  16134. this._gazeTracker.material = targetMat;
  16135. }
  16136. else {
  16137. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  16138. }
  16139. }
  16140. /** @hidden */
  16141. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  16142. 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));
  16143. };
  16144. /** @hidden */
  16145. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  16146. this._pointerDownOnMeshAsked = true;
  16147. if (this._currentHit) {
  16148. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  16149. }
  16150. };
  16151. /** @hidden */
  16152. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  16153. if (this._currentHit) {
  16154. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  16155. }
  16156. this._pointerDownOnMeshAsked = false;
  16157. };
  16158. /** @hidden */
  16159. VRExperienceHelperGazer.prototype._activatePointer = function () {
  16160. this._activePointer = true;
  16161. };
  16162. /** @hidden */
  16163. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  16164. this._activePointer = false;
  16165. };
  16166. /** @hidden */
  16167. VRExperienceHelperGazer.prototype._updatePointerDistance = function (distance) {
  16168. if (distance === void 0) { distance = 100; }
  16169. };
  16170. VRExperienceHelperGazer.prototype.dispose = function () {
  16171. this._interactionsEnabled = false;
  16172. this._teleportationEnabled = false;
  16173. if (this._gazeTracker) {
  16174. this._gazeTracker.dispose();
  16175. }
  16176. };
  16177. VRExperienceHelperGazer._idCounter = 0;
  16178. return VRExperienceHelperGazer;
  16179. }());
  16180. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  16181. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  16182. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  16183. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  16184. _this.webVRController = webVRController;
  16185. // Laser pointer
  16186. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  16187. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("laserPointerMat", scene);
  16188. laserPointerMaterial.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  16189. laserPointerMaterial.alpha = 0.6;
  16190. _this._laserPointer.material = laserPointerMaterial;
  16191. _this._laserPointer.rotation.x = Math.PI / 2;
  16192. _this._laserPointer.position.z = -0.5;
  16193. _this._laserPointer.isVisible = false;
  16194. _this._laserPointer.isPickable = false;
  16195. if (!webVRController.mesh) {
  16196. // Create an empty mesh that is used prior to loading the high quality model
  16197. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"]("preloadControllerMesh", scene);
  16198. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE, scene);
  16199. preloadPointerPose.rotation.x = -0.7;
  16200. preloadMesh.addChild(preloadPointerPose);
  16201. webVRController.attachToMesh(preloadMesh);
  16202. }
  16203. _this._setLaserPointerParent(webVRController.mesh);
  16204. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  16205. _this._setLaserPointerParent(mesh);
  16206. });
  16207. return _this;
  16208. }
  16209. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  16210. return this.webVRController.getForwardRay(length);
  16211. };
  16212. /** @hidden */
  16213. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  16214. _super.prototype._activatePointer.call(this);
  16215. this._laserPointer.isVisible = true;
  16216. };
  16217. /** @hidden */
  16218. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  16219. _super.prototype._deactivatePointer.call(this);
  16220. this._laserPointer.isVisible = false;
  16221. };
  16222. /** @hidden */
  16223. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  16224. this._laserPointer.material.emissiveColor = color;
  16225. };
  16226. /** @hidden */
  16227. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  16228. var makeNotPick = function (root) {
  16229. root.isPickable = false;
  16230. root.getChildMeshes().forEach(function (c) {
  16231. makeNotPick(c);
  16232. });
  16233. };
  16234. makeNotPick(mesh);
  16235. var meshChildren = mesh.getChildren(undefined, false);
  16236. var laserParent = mesh;
  16237. this.webVRController._pointingPoseNode = null;
  16238. for (var i = 0; i < meshChildren.length; i++) {
  16239. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE) >= 0) {
  16240. laserParent = meshChildren[i];
  16241. this.webVRController._pointingPoseNode = laserParent;
  16242. break;
  16243. }
  16244. }
  16245. this._laserPointer.parent = laserParent;
  16246. };
  16247. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  16248. if (distance === void 0) { distance = 100; }
  16249. this._laserPointer.scaling.y = distance;
  16250. this._laserPointer.position.z = -distance / 2;
  16251. };
  16252. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  16253. _super.prototype.dispose.call(this);
  16254. this._laserPointer.dispose();
  16255. if (this._meshAttachedObserver) {
  16256. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  16257. }
  16258. };
  16259. return VRExperienceHelperControllerGazer;
  16260. }(VRExperienceHelperGazer));
  16261. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  16262. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  16263. function VRExperienceHelperCameraGazer(getCamera, scene) {
  16264. var _this = _super.call(this, scene) || this;
  16265. _this.getCamera = getCamera;
  16266. return _this;
  16267. }
  16268. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  16269. var camera = this.getCamera();
  16270. if (camera) {
  16271. return camera.getForwardRay(length);
  16272. }
  16273. else {
  16274. 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());
  16275. }
  16276. };
  16277. return VRExperienceHelperCameraGazer;
  16278. }(VRExperienceHelperGazer));
  16279. /**
  16280. * Event containing information after VR has been entered
  16281. */
  16282. var OnAfterEnteringVRObservableEvent = /** @class */ (function () {
  16283. function OnAfterEnteringVRObservableEvent() {
  16284. }
  16285. return OnAfterEnteringVRObservableEvent;
  16286. }());
  16287. /**
  16288. * Helps to quickly add VR support to an existing scene.
  16289. * See http://doc.babylonjs.com/how_to/webvr_helper
  16290. */
  16291. var VRExperienceHelper = /** @class */ (function () {
  16292. /**
  16293. * Instantiates a VRExperienceHelper.
  16294. * Helps to quickly add VR support to an existing scene.
  16295. * @param scene The scene the VRExperienceHelper belongs to.
  16296. * @param webVROptions Options to modify the vr experience helper's behavior.
  16297. */
  16298. function VRExperienceHelper(scene,
  16299. /** Options to modify the vr experience helper's behavior. */
  16300. webVROptions) {
  16301. if (webVROptions === void 0) { webVROptions = {}; }
  16302. var _this = this;
  16303. this.webVROptions = webVROptions;
  16304. // Can the system support WebVR, even if a headset isn't plugged in?
  16305. this._webVRsupported = false;
  16306. // If WebVR is supported, is a headset plugged in and are we ready to present?
  16307. this._webVRready = false;
  16308. // Are we waiting for the requestPresent callback to complete?
  16309. this._webVRrequesting = false;
  16310. // Are we presenting to the headset right now? (this is the vrDevice state)
  16311. this._webVRpresenting = false;
  16312. // Are we presenting in the fullscreen fallback?
  16313. this._fullscreenVRpresenting = false;
  16314. /**
  16315. * Observable raised right before entering VR.
  16316. */
  16317. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16318. /**
  16319. * Observable raised when entering VR has completed.
  16320. */
  16321. this.onAfterEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16322. /**
  16323. * Observable raised when exiting VR.
  16324. */
  16325. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16326. /**
  16327. * Observable raised when controller mesh is loaded.
  16328. */
  16329. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16330. this._useCustomVRButton = false;
  16331. this._teleportationRequested = false;
  16332. this._teleportActive = false;
  16333. this._floorMeshesCollection = [];
  16334. this._rotationAllowed = true;
  16335. this._teleportBackwardsVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  16336. this._isDefaultTeleportationTarget = true;
  16337. this._teleportationFillColor = "#444444";
  16338. this._teleportationBorderColor = "#FFFFFF";
  16339. this._rotationAngle = 0;
  16340. this._haloCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  16341. this._padSensibilityUp = 0.65;
  16342. this._padSensibilityDown = 0.35;
  16343. this._leftController = null;
  16344. this._rightController = null;
  16345. /**
  16346. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  16347. */
  16348. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16349. /**
  16350. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  16351. */
  16352. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16353. /**
  16354. * Observable raised before camera teleportation
  16355. */
  16356. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16357. /**
  16358. * Observable raised after camera teleportation
  16359. */
  16360. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16361. /**
  16362. * Observable raised when current selected mesh gets unselected
  16363. */
  16364. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  16365. /**
  16366. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  16367. */
  16368. this.teleportationEnabled = true;
  16369. this._teleportationInitialized = false;
  16370. this._interactionsEnabled = false;
  16371. this._interactionsRequested = false;
  16372. this._displayGaze = true;
  16373. this._displayLaserPointer = true;
  16374. /**
  16375. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  16376. */
  16377. this.updateGazeTrackerScale = true;
  16378. /**
  16379. * If the gaze trackers color should be updated when selecting meshes
  16380. */
  16381. this.updateGazeTrackerColor = true;
  16382. /**
  16383. * Defines wether or not Pointer lock should be requested when switching to
  16384. * full screen.
  16385. */
  16386. this.requestPointerLockOnFullScreen = true;
  16387. this._onResize = function () {
  16388. _this.moveButtonToBottomRight();
  16389. if (_this._fullscreenVRpresenting && _this._webVRready) {
  16390. _this.exitVR();
  16391. }
  16392. };
  16393. this._onFullscreenChange = function () {
  16394. var anyDoc = document;
  16395. if (anyDoc.fullscreen !== undefined) {
  16396. _this._fullscreenVRpresenting = document.fullscreen;
  16397. }
  16398. else if (anyDoc.mozFullScreen !== undefined) {
  16399. _this._fullscreenVRpresenting = anyDoc.mozFullScreen;
  16400. }
  16401. else if (anyDoc.webkitIsFullScreen !== undefined) {
  16402. _this._fullscreenVRpresenting = anyDoc.webkitIsFullScreen;
  16403. }
  16404. else if (anyDoc.msIsFullScreen !== undefined) {
  16405. _this._fullscreenVRpresenting = anyDoc.msIsFullScreen;
  16406. }
  16407. else if (document.msFullscreenElement !== undefined) {
  16408. _this._fullscreenVRpresenting = document.msFullscreenElement;
  16409. }
  16410. if (!_this._fullscreenVRpresenting && _this._canvas) {
  16411. _this.exitVR();
  16412. if (!_this._useCustomVRButton) {
  16413. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  16414. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  16415. }
  16416. }
  16417. };
  16418. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  16419. this.beforeRender = function () {
  16420. if (_this._leftController && _this._leftController._activePointer) {
  16421. _this._castRayAndSelectObject(_this._leftController);
  16422. }
  16423. if (_this._rightController && _this._rightController._activePointer) {
  16424. _this._castRayAndSelectObject(_this._rightController);
  16425. }
  16426. if (_this._noControllerIsActive) {
  16427. _this._castRayAndSelectObject(_this._cameraGazer);
  16428. }
  16429. else {
  16430. _this._cameraGazer._gazeTracker.isVisible = false;
  16431. }
  16432. };
  16433. this._onNewGamepadConnected = function (gamepad) {
  16434. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].POSE_ENABLED) {
  16435. if (gamepad.leftStick) {
  16436. gamepad.onleftstickchanged(function (stickValues) {
  16437. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  16438. // Listening to classic/xbox gamepad only if no VR controller is active
  16439. if ((!_this._leftController && !_this._rightController) ||
  16440. ((_this._leftController && !_this._leftController._activePointer) &&
  16441. (_this._rightController && !_this._rightController._activePointer))) {
  16442. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  16443. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  16444. }
  16445. }
  16446. });
  16447. }
  16448. if (gamepad.rightStick) {
  16449. gamepad.onrightstickchanged(function (stickValues) {
  16450. if (_this._teleportationInitialized) {
  16451. _this._checkRotate(stickValues, _this._cameraGazer);
  16452. }
  16453. });
  16454. }
  16455. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].XBOX) {
  16456. gamepad.onbuttondown(function (buttonPressed) {
  16457. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  16458. _this._cameraGazer._selectionPointerDown();
  16459. }
  16460. });
  16461. gamepad.onbuttonup(function (buttonPressed) {
  16462. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  16463. _this._cameraGazer._selectionPointerUp();
  16464. }
  16465. });
  16466. }
  16467. }
  16468. else {
  16469. var webVRController = gamepad;
  16470. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  16471. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  16472. _this._rightController = controller;
  16473. }
  16474. else {
  16475. _this._leftController = controller;
  16476. }
  16477. _this._tryEnableInteractionOnController(controller);
  16478. }
  16479. };
  16480. // 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
  16481. this._tryEnableInteractionOnController = function (controller) {
  16482. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  16483. _this._enableInteractionOnController(controller);
  16484. }
  16485. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  16486. _this._enableTeleportationOnController(controller);
  16487. }
  16488. };
  16489. this._onNewGamepadDisconnected = function (gamepad) {
  16490. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__["WebVRController"]) {
  16491. if (gamepad.hand === "left" && _this._leftController != null) {
  16492. _this._leftController.dispose();
  16493. _this._leftController = null;
  16494. }
  16495. if (gamepad.hand === "right" && _this._rightController != null) {
  16496. _this._rightController.dispose();
  16497. _this._rightController = null;
  16498. }
  16499. }
  16500. };
  16501. this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  16502. this._workingQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  16503. this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  16504. this._scene = scene;
  16505. this._canvas = scene.getEngine().getRenderingCanvas();
  16506. // Parse options
  16507. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  16508. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  16509. }
  16510. if (webVROptions.createDeviceOrientationCamera === undefined) {
  16511. webVROptions.createDeviceOrientationCamera = true;
  16512. }
  16513. if (webVROptions.laserToggle === undefined) {
  16514. webVROptions.laserToggle = true;
  16515. }
  16516. if (webVROptions.defaultHeight === undefined) {
  16517. webVROptions.defaultHeight = 1.7;
  16518. }
  16519. if (webVROptions.useCustomVRButton) {
  16520. this._useCustomVRButton = true;
  16521. if (webVROptions.customVRButton) {
  16522. this._btnVR = webVROptions.customVRButton;
  16523. }
  16524. }
  16525. if (webVROptions.rayLength) {
  16526. this._rayLength = webVROptions.rayLength;
  16527. }
  16528. this._defaultHeight = webVROptions.defaultHeight;
  16529. if (webVROptions.positionScale) {
  16530. this._rayLength *= webVROptions.positionScale;
  16531. this._defaultHeight *= webVROptions.positionScale;
  16532. }
  16533. this._hasEnteredVR = false;
  16534. // Set position
  16535. if (this._scene.activeCamera) {
  16536. this._position = this._scene.activeCamera.position.clone();
  16537. }
  16538. else {
  16539. this._position = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  16540. }
  16541. // Set non-vr camera
  16542. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  16543. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  16544. // Copy data from existing camera
  16545. if (this._scene.activeCamera) {
  16546. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16547. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  16548. // Set rotation from previous camera
  16549. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  16550. var targetCamera = this._scene.activeCamera;
  16551. if (targetCamera.rotationQuaternion) {
  16552. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  16553. }
  16554. else {
  16555. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  16556. }
  16557. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  16558. }
  16559. }
  16560. this._scene.activeCamera = this._deviceOrientationCamera;
  16561. if (this._canvas) {
  16562. this._scene.activeCamera.attachControl(this._canvas);
  16563. }
  16564. }
  16565. else {
  16566. this._existingCamera = this._scene.activeCamera;
  16567. }
  16568. // Create VR cameras
  16569. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16570. if (webVROptions.useMultiview) {
  16571. if (!webVROptions.vrDeviceOrientationCameraMetrics) {
  16572. webVROptions.vrDeviceOrientationCameraMetrics = _Cameras_VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_22__["VRCameraMetrics"].GetDefault();
  16573. }
  16574. webVROptions.vrDeviceOrientationCameraMetrics.multiviewEnabled = true;
  16575. }
  16576. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene, true, webVROptions.vrDeviceOrientationCameraMetrics);
  16577. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16578. }
  16579. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  16580. this._webVRCamera.useStandingMatrix();
  16581. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  16582. // Create default button
  16583. if (!this._useCustomVRButton) {
  16584. this._btnVR = document.createElement("BUTTON");
  16585. this._btnVR.className = "babylonVRicon";
  16586. this._btnVR.id = "babylonVRiconbtn";
  16587. this._btnVR.title = "Click to switch to VR";
  16588. 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) }";
  16589. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  16590. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  16591. // css += ".babylonVRicon.vrdisplaysupported { }";
  16592. // css += ".babylonVRicon.vrdisplayready { }";
  16593. // css += ".babylonVRicon.vrdisplayrequesting { }";
  16594. var style = document.createElement('style');
  16595. style.appendChild(document.createTextNode(css));
  16596. document.getElementsByTagName('head')[0].appendChild(style);
  16597. this.moveButtonToBottomRight();
  16598. }
  16599. // VR button click event
  16600. if (this._btnVR) {
  16601. this._btnVR.addEventListener("click", function () {
  16602. if (!_this.isInVRMode) {
  16603. _this.enterVR();
  16604. }
  16605. else {
  16606. _this.exitVR();
  16607. }
  16608. });
  16609. }
  16610. // Window events
  16611. window.addEventListener("resize", this._onResize);
  16612. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  16613. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  16614. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  16615. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  16616. document.onmsfullscreenchange = this._onFullscreenChange;
  16617. // Display vr button when headset is connected
  16618. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16619. this.displayVRButton();
  16620. }
  16621. else {
  16622. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  16623. if (e.vrDisplay) {
  16624. _this.displayVRButton();
  16625. }
  16626. });
  16627. }
  16628. // Exiting VR mode using 'ESC' key on desktop
  16629. this._onKeyDown = function (event) {
  16630. if (event.keyCode === 27 && _this.isInVRMode) {
  16631. _this.exitVR();
  16632. }
  16633. };
  16634. document.addEventListener("keydown", this._onKeyDown);
  16635. // Exiting VR mode double tapping the touch screen
  16636. this._scene.onPrePointerObservable.add(function () {
  16637. if (_this.isInVRMode) {
  16638. _this.exitVR();
  16639. if (_this._fullscreenVRpresenting) {
  16640. _this._scene.getEngine().exitFullscreen();
  16641. }
  16642. }
  16643. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  16644. // Listen for WebVR display changes
  16645. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  16646. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  16647. this._onVRRequestPresentStart = function () {
  16648. _this._webVRrequesting = true;
  16649. _this.updateButtonVisibility();
  16650. };
  16651. this._onVRRequestPresentComplete = function () {
  16652. _this._webVRrequesting = false;
  16653. _this.updateButtonVisibility();
  16654. };
  16655. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  16656. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  16657. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  16658. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16659. scene.onDisposeObservable.add(function () {
  16660. _this.dispose();
  16661. });
  16662. // Gamepad connection events
  16663. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  16664. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  16665. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  16666. this.updateButtonVisibility();
  16667. //create easing functions
  16668. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["CircleEase"]();
  16669. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16670. if (this.webVROptions.floorMeshes) {
  16671. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  16672. }
  16673. }
  16674. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  16675. /** Return this.onEnteringVRObservable
  16676. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  16677. */
  16678. get: function () {
  16679. return this.onEnteringVRObservable;
  16680. },
  16681. enumerable: true,
  16682. configurable: true
  16683. });
  16684. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  16685. /** Return this.onExitingVRObservable
  16686. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  16687. */
  16688. get: function () {
  16689. return this.onExitingVRObservable;
  16690. },
  16691. enumerable: true,
  16692. configurable: true
  16693. });
  16694. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  16695. /** Return this.onControllerMeshLoadedObservable
  16696. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  16697. */
  16698. get: function () {
  16699. return this.onControllerMeshLoadedObservable;
  16700. },
  16701. enumerable: true,
  16702. configurable: true
  16703. });
  16704. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  16705. /**
  16706. * The mesh used to display where the user is going to teleport.
  16707. */
  16708. get: function () {
  16709. return this._teleportationTarget;
  16710. },
  16711. /**
  16712. * Sets the mesh to be used to display where the user is going to teleport.
  16713. */
  16714. set: function (value) {
  16715. if (value) {
  16716. value.name = "teleportationTarget";
  16717. this._isDefaultTeleportationTarget = false;
  16718. this._teleportationTarget = value;
  16719. }
  16720. },
  16721. enumerable: true,
  16722. configurable: true
  16723. });
  16724. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  16725. /**
  16726. * 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
  16727. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  16728. * See http://doc.babylonjs.com/resources/baking_transformations
  16729. */
  16730. get: function () {
  16731. return this._cameraGazer._gazeTracker;
  16732. },
  16733. set: function (value) {
  16734. if (value) {
  16735. // Dispose of existing meshes
  16736. if (this._cameraGazer._gazeTracker) {
  16737. this._cameraGazer._gazeTracker.dispose();
  16738. }
  16739. if (this._leftController && this._leftController._gazeTracker) {
  16740. this._leftController._gazeTracker.dispose();
  16741. }
  16742. if (this._rightController && this._rightController._gazeTracker) {
  16743. this._rightController._gazeTracker.dispose();
  16744. }
  16745. // Set and create gaze trackers on head and controllers
  16746. this._cameraGazer._gazeTracker = value;
  16747. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  16748. this._cameraGazer._gazeTracker.isPickable = false;
  16749. this._cameraGazer._gazeTracker.isVisible = false;
  16750. this._cameraGazer._gazeTracker.name = "gazeTracker";
  16751. if (this._leftController) {
  16752. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16753. }
  16754. if (this._rightController) {
  16755. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16756. }
  16757. }
  16758. },
  16759. enumerable: true,
  16760. configurable: true
  16761. });
  16762. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  16763. /**
  16764. * The gaze tracking mesh corresponding to the left controller
  16765. */
  16766. get: function () {
  16767. if (this._leftController) {
  16768. return this._leftController._gazeTracker;
  16769. }
  16770. return null;
  16771. },
  16772. enumerable: true,
  16773. configurable: true
  16774. });
  16775. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  16776. /**
  16777. * The gaze tracking mesh corresponding to the right controller
  16778. */
  16779. get: function () {
  16780. if (this._rightController) {
  16781. return this._rightController._gazeTracker;
  16782. }
  16783. return null;
  16784. },
  16785. enumerable: true,
  16786. configurable: true
  16787. });
  16788. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  16789. /**
  16790. * If the ray of the gaze should be displayed.
  16791. */
  16792. get: function () {
  16793. return this._displayGaze;
  16794. },
  16795. /**
  16796. * Sets if the ray of the gaze should be displayed.
  16797. */
  16798. set: function (value) {
  16799. this._displayGaze = value;
  16800. if (!value) {
  16801. this._cameraGazer._gazeTracker.isVisible = false;
  16802. if (this._leftController) {
  16803. this._leftController._gazeTracker.isVisible = false;
  16804. }
  16805. if (this._rightController) {
  16806. this._rightController._gazeTracker.isVisible = false;
  16807. }
  16808. }
  16809. },
  16810. enumerable: true,
  16811. configurable: true
  16812. });
  16813. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  16814. /**
  16815. * If the ray of the LaserPointer should be displayed.
  16816. */
  16817. get: function () {
  16818. return this._displayLaserPointer;
  16819. },
  16820. /**
  16821. * Sets if the ray of the LaserPointer should be displayed.
  16822. */
  16823. set: function (value) {
  16824. this._displayLaserPointer = value;
  16825. if (!value) {
  16826. if (this._rightController) {
  16827. this._rightController._deactivatePointer();
  16828. this._rightController._gazeTracker.isVisible = false;
  16829. }
  16830. if (this._leftController) {
  16831. this._leftController._deactivatePointer();
  16832. this._leftController._gazeTracker.isVisible = false;
  16833. }
  16834. }
  16835. else {
  16836. if (this._rightController) {
  16837. this._rightController._activatePointer();
  16838. }
  16839. if (this._leftController) {
  16840. this._leftController._activatePointer();
  16841. }
  16842. }
  16843. },
  16844. enumerable: true,
  16845. configurable: true
  16846. });
  16847. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  16848. /**
  16849. * The deviceOrientationCamera used as the camera when not in VR.
  16850. */
  16851. get: function () {
  16852. return this._deviceOrientationCamera;
  16853. },
  16854. enumerable: true,
  16855. configurable: true
  16856. });
  16857. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  16858. /**
  16859. * Based on the current WebVR support, returns the current VR camera used.
  16860. */
  16861. get: function () {
  16862. if (this._webVRready) {
  16863. return this._webVRCamera;
  16864. }
  16865. else {
  16866. return this._scene.activeCamera;
  16867. }
  16868. },
  16869. enumerable: true,
  16870. configurable: true
  16871. });
  16872. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  16873. /**
  16874. * The webVRCamera which is used when in VR.
  16875. */
  16876. get: function () {
  16877. return this._webVRCamera;
  16878. },
  16879. enumerable: true,
  16880. configurable: true
  16881. });
  16882. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  16883. /**
  16884. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  16885. */
  16886. get: function () {
  16887. return this._vrDeviceOrientationCamera;
  16888. },
  16889. enumerable: true,
  16890. configurable: true
  16891. });
  16892. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  16893. get: function () {
  16894. var result = this._cameraGazer._teleportationRequestInitiated
  16895. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  16896. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  16897. return result;
  16898. },
  16899. enumerable: true,
  16900. configurable: true
  16901. });
  16902. // Raised when one of the controller has loaded successfully its associated default mesh
  16903. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  16904. if (this._leftController && this._leftController.webVRController == webVRController) {
  16905. if (webVRController.mesh) {
  16906. this._leftController._setLaserPointerParent(webVRController.mesh);
  16907. }
  16908. }
  16909. if (this._rightController && this._rightController.webVRController == webVRController) {
  16910. if (webVRController.mesh) {
  16911. this._rightController._setLaserPointerParent(webVRController.mesh);
  16912. }
  16913. }
  16914. try {
  16915. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  16916. }
  16917. catch (err) {
  16918. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  16919. }
  16920. };
  16921. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  16922. /**
  16923. * Gets a value indicating if we are currently in VR mode.
  16924. */
  16925. get: function () {
  16926. return this._webVRpresenting || this._fullscreenVRpresenting;
  16927. },
  16928. enumerable: true,
  16929. configurable: true
  16930. });
  16931. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  16932. var vrDisplay = this._scene.getEngine().getVRDevice();
  16933. if (vrDisplay) {
  16934. var wasPresenting = this._webVRpresenting;
  16935. this._webVRpresenting = vrDisplay.isPresenting;
  16936. if (wasPresenting && !this._webVRpresenting) {
  16937. this.exitVR();
  16938. }
  16939. }
  16940. else {
  16941. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  16942. }
  16943. this.updateButtonVisibility();
  16944. };
  16945. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  16946. this._webVRsupported = eventArgs.vrSupported;
  16947. this._webVRready = !!eventArgs.vrDisplay;
  16948. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  16949. this.updateButtonVisibility();
  16950. };
  16951. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  16952. if (this._canvas && !this._useCustomVRButton) {
  16953. this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
  16954. this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
  16955. }
  16956. };
  16957. VRExperienceHelper.prototype.displayVRButton = function () {
  16958. if (!this._useCustomVRButton && !this._btnVRDisplayed) {
  16959. document.body.appendChild(this._btnVR);
  16960. this._btnVRDisplayed = true;
  16961. }
  16962. };
  16963. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  16964. if (!this._btnVR || this._useCustomVRButton) {
  16965. return;
  16966. }
  16967. this._btnVR.className = "babylonVRicon";
  16968. if (this.isInVRMode) {
  16969. this._btnVR.className += " vrdisplaypresenting";
  16970. }
  16971. else {
  16972. if (this._webVRready) {
  16973. this._btnVR.className += " vrdisplayready";
  16974. }
  16975. if (this._webVRsupported) {
  16976. this._btnVR.className += " vrdisplaysupported";
  16977. }
  16978. if (this._webVRrequesting) {
  16979. this._btnVR.className += " vrdisplayrequesting";
  16980. }
  16981. }
  16982. };
  16983. /**
  16984. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  16985. * Otherwise, will use the fullscreen API.
  16986. */
  16987. VRExperienceHelper.prototype.enterVR = function () {
  16988. var _this = this;
  16989. if (this.onEnteringVRObservable) {
  16990. try {
  16991. this.onEnteringVRObservable.notifyObservers(this);
  16992. }
  16993. catch (err) {
  16994. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  16995. }
  16996. }
  16997. if (this._scene.activeCamera) {
  16998. this._position = this._scene.activeCamera.position.clone();
  16999. if (this.vrDeviceOrientationCamera) {
  17000. this.vrDeviceOrientationCamera.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  17001. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  17002. }
  17003. if (this.webVRCamera) {
  17004. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  17005. var desiredYRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  17006. var delta = desiredYRotation - currentYRotation;
  17007. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  17008. this.webVRCamera.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  17009. }
  17010. // make sure that we return to the last active camera
  17011. this._existingCamera = this._scene.activeCamera;
  17012. // Remove and cache angular sensability to avoid camera rotation when in VR
  17013. if (this._existingCamera.angularSensibilityX) {
  17014. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  17015. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  17016. }
  17017. if (this._existingCamera.angularSensibilityY) {
  17018. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  17019. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  17020. }
  17021. if (this._existingCamera.angularSensibility) {
  17022. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  17023. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  17024. }
  17025. }
  17026. if (this._webVRrequesting) {
  17027. return;
  17028. }
  17029. // If WebVR is supported and a headset is connected
  17030. if (this._webVRready) {
  17031. if (!this._webVRpresenting) {
  17032. this._scene.getEngine().onVRRequestPresentComplete.addOnce(function (result) {
  17033. _this.onAfterEnteringVRObservable.notifyObservers({ success: result });
  17034. });
  17035. this._webVRCamera.position = this._position;
  17036. this._scene.activeCamera = this._webVRCamera;
  17037. }
  17038. }
  17039. else if (this._vrDeviceOrientationCamera) {
  17040. this._vrDeviceOrientationCamera.position = this._position;
  17041. if (this._scene.activeCamera) {
  17042. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  17043. }
  17044. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  17045. this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen);
  17046. this.updateButtonVisibility();
  17047. this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce(function () {
  17048. _this.onAfterEnteringVRObservable.notifyObservers({ success: true });
  17049. });
  17050. }
  17051. if (this._scene.activeCamera && this._canvas) {
  17052. this._scene.activeCamera.attachControl(this._canvas);
  17053. }
  17054. if (this._interactionsEnabled) {
  17055. this._scene.registerBeforeRender(this.beforeRender);
  17056. }
  17057. if (this._displayLaserPointer) {
  17058. [this._leftController, this._rightController].forEach(function (controller) {
  17059. if (controller) {
  17060. controller._activatePointer();
  17061. }
  17062. });
  17063. }
  17064. this._hasEnteredVR = true;
  17065. };
  17066. /**
  17067. * Attempt to exit VR, or fullscreen.
  17068. */
  17069. VRExperienceHelper.prototype.exitVR = function () {
  17070. if (this._hasEnteredVR) {
  17071. if (this.onExitingVRObservable) {
  17072. try {
  17073. this.onExitingVRObservable.notifyObservers(this);
  17074. }
  17075. catch (err) {
  17076. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  17077. }
  17078. }
  17079. if (this._webVRpresenting) {
  17080. this._scene.getEngine().disableVR();
  17081. }
  17082. if (this._scene.activeCamera) {
  17083. this._position = this._scene.activeCamera.position.clone();
  17084. }
  17085. if (this.vrDeviceOrientationCamera) {
  17086. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  17087. }
  17088. if (this._deviceOrientationCamera) {
  17089. this._deviceOrientationCamera.position = this._position;
  17090. this._scene.activeCamera = this._deviceOrientationCamera;
  17091. if (this._canvas) {
  17092. this._scene.activeCamera.attachControl(this._canvas);
  17093. }
  17094. // Restore angular sensibility
  17095. if (this._cachedAngularSensibility.angularSensibilityX) {
  17096. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  17097. this._cachedAngularSensibility.angularSensibilityX = null;
  17098. }
  17099. if (this._cachedAngularSensibility.angularSensibilityY) {
  17100. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  17101. this._cachedAngularSensibility.angularSensibilityY = null;
  17102. }
  17103. if (this._cachedAngularSensibility.angularSensibility) {
  17104. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  17105. this._cachedAngularSensibility.angularSensibility = null;
  17106. }
  17107. }
  17108. else if (this._existingCamera) {
  17109. this._existingCamera.position = this._position;
  17110. this._scene.activeCamera = this._existingCamera;
  17111. // Restore angular sensibility
  17112. if (this._cachedAngularSensibility.angularSensibilityX) {
  17113. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  17114. this._cachedAngularSensibility.angularSensibilityX = null;
  17115. }
  17116. if (this._cachedAngularSensibility.angularSensibilityY) {
  17117. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  17118. this._cachedAngularSensibility.angularSensibilityY = null;
  17119. }
  17120. if (this._cachedAngularSensibility.angularSensibility) {
  17121. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  17122. this._cachedAngularSensibility.angularSensibility = null;
  17123. }
  17124. }
  17125. this.updateButtonVisibility();
  17126. if (this._interactionsEnabled) {
  17127. this._scene.unregisterBeforeRender(this.beforeRender);
  17128. this._cameraGazer._gazeTracker.isVisible = false;
  17129. if (this._leftController) {
  17130. this._leftController._gazeTracker.isVisible = false;
  17131. }
  17132. if (this._rightController) {
  17133. this._rightController._gazeTracker.isVisible = false;
  17134. }
  17135. }
  17136. // resize to update width and height when exiting vr exits fullscreen
  17137. this._scene.getEngine().resize();
  17138. [this._leftController, this._rightController].forEach(function (controller) {
  17139. if (controller) {
  17140. controller._deactivatePointer();
  17141. }
  17142. });
  17143. this._hasEnteredVR = false;
  17144. }
  17145. };
  17146. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  17147. /**
  17148. * The position of the vr experience helper.
  17149. */
  17150. get: function () {
  17151. return this._position;
  17152. },
  17153. /**
  17154. * Sets the position of the vr experience helper.
  17155. */
  17156. set: function (value) {
  17157. this._position = value;
  17158. if (this._scene.activeCamera) {
  17159. this._scene.activeCamera.position = value;
  17160. }
  17161. },
  17162. enumerable: true,
  17163. configurable: true
  17164. });
  17165. /**
  17166. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  17167. */
  17168. VRExperienceHelper.prototype.enableInteractions = function () {
  17169. var _this = this;
  17170. if (!this._interactionsEnabled) {
  17171. this._interactionsRequested = true;
  17172. if (this._leftController) {
  17173. this._enableInteractionOnController(this._leftController);
  17174. }
  17175. if (this._rightController) {
  17176. this._enableInteractionOnController(this._rightController);
  17177. }
  17178. this.raySelectionPredicate = function (mesh) {
  17179. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  17180. };
  17181. this.meshSelectionPredicate = function () {
  17182. return true;
  17183. };
  17184. this._raySelectionPredicate = function (mesh) {
  17185. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  17186. && mesh.name.indexOf("teleportationTarget") === -1
  17187. && mesh.name.indexOf("torusTeleportation") === -1)) {
  17188. return _this.raySelectionPredicate(mesh);
  17189. }
  17190. return false;
  17191. };
  17192. this._interactionsEnabled = true;
  17193. }
  17194. };
  17195. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  17196. get: function () {
  17197. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  17198. },
  17199. enumerable: true,
  17200. configurable: true
  17201. });
  17202. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  17203. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  17204. if (this._floorMeshesCollection[i].id === mesh.id) {
  17205. return true;
  17206. }
  17207. }
  17208. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  17209. return true;
  17210. }
  17211. return false;
  17212. };
  17213. /**
  17214. * Adds a floor mesh to be used for teleportation.
  17215. * @param floorMesh the mesh to be used for teleportation.
  17216. */
  17217. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  17218. if (!this._floorMeshesCollection) {
  17219. return;
  17220. }
  17221. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  17222. return;
  17223. }
  17224. this._floorMeshesCollection.push(floorMesh);
  17225. };
  17226. /**
  17227. * Removes a floor mesh from being used for teleportation.
  17228. * @param floorMesh the mesh to be removed.
  17229. */
  17230. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  17231. if (!this._floorMeshesCollection) {
  17232. return;
  17233. }
  17234. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  17235. if (meshIndex !== -1) {
  17236. this._floorMeshesCollection.splice(meshIndex, 1);
  17237. }
  17238. };
  17239. /**
  17240. * Enables interactions and teleportation using the VR controllers and gaze.
  17241. * @param vrTeleportationOptions options to modify teleportation behavior.
  17242. */
  17243. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  17244. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  17245. if (!this._teleportationInitialized) {
  17246. this._teleportationRequested = true;
  17247. this.enableInteractions();
  17248. if (vrTeleportationOptions.floorMeshName) {
  17249. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  17250. }
  17251. if (vrTeleportationOptions.floorMeshes) {
  17252. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  17253. }
  17254. if (this._leftController != null) {
  17255. this._enableTeleportationOnController(this._leftController);
  17256. }
  17257. if (this._rightController != null) {
  17258. this._enableTeleportationOnController(this._rightController);
  17259. }
  17260. // Creates an image processing post process for the vignette not relying
  17261. // on the main scene configuration for image processing to reduce setup and spaces
  17262. // (gamma/linear) conflicts.
  17263. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingConfiguration"]();
  17264. imageProcessingConfiguration.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color4"](0, 0, 0, 0);
  17265. imageProcessingConfiguration.vignetteEnabled = true;
  17266. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  17267. this._webVRCamera.detachPostProcess(this._postProcessMove);
  17268. this._teleportationInitialized = true;
  17269. if (this._isDefaultTeleportationTarget) {
  17270. this._createTeleportationCircles();
  17271. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  17272. }
  17273. }
  17274. };
  17275. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  17276. var _this = this;
  17277. var controllerMesh = controller.webVRController.mesh;
  17278. if (controllerMesh) {
  17279. controller._interactionsEnabled = true;
  17280. if (this.isInVRMode && this._displayLaserPointer) {
  17281. controller._activatePointer();
  17282. }
  17283. if (this.webVROptions.laserToggle) {
  17284. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  17285. // Enabling / disabling laserPointer
  17286. if (_this._displayLaserPointer && stateObject.value === 1) {
  17287. if (controller._activePointer) {
  17288. controller._deactivatePointer();
  17289. }
  17290. else {
  17291. controller._activatePointer();
  17292. }
  17293. if (_this.displayGaze) {
  17294. controller._gazeTracker.isVisible = controller._activePointer;
  17295. }
  17296. }
  17297. });
  17298. }
  17299. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  17300. var gazer = controller;
  17301. if (_this._noControllerIsActive) {
  17302. gazer = _this._cameraGazer;
  17303. }
  17304. if (!gazer._pointerDownOnMeshAsked) {
  17305. if (stateObject.value > _this._padSensibilityUp) {
  17306. gazer._selectionPointerDown();
  17307. }
  17308. }
  17309. else if (stateObject.value < _this._padSensibilityDown) {
  17310. gazer._selectionPointerUp();
  17311. }
  17312. });
  17313. }
  17314. };
  17315. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  17316. // Dont teleport if another gaze already requested teleportation
  17317. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  17318. return;
  17319. }
  17320. if (!gazer._teleportationRequestInitiated) {
  17321. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  17322. gazer._activatePointer();
  17323. gazer._teleportationRequestInitiated = true;
  17324. }
  17325. }
  17326. else {
  17327. // Listening to the proper controller values changes to confirm teleportation
  17328. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  17329. if (this._teleportActive) {
  17330. this.teleportCamera(this._haloCenter);
  17331. }
  17332. gazer._teleportationRequestInitiated = false;
  17333. }
  17334. }
  17335. };
  17336. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  17337. // Only rotate when user is not currently selecting a teleportation location
  17338. if (gazer._teleportationRequestInitiated) {
  17339. return;
  17340. }
  17341. if (!gazer._rotationLeftAsked) {
  17342. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  17343. gazer._rotationLeftAsked = true;
  17344. if (this._rotationAllowed) {
  17345. this._rotateCamera(false);
  17346. }
  17347. }
  17348. }
  17349. else {
  17350. if (stateObject.x > -this._padSensibilityDown) {
  17351. gazer._rotationLeftAsked = false;
  17352. }
  17353. }
  17354. if (!gazer._rotationRightAsked) {
  17355. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  17356. gazer._rotationRightAsked = true;
  17357. if (this._rotationAllowed) {
  17358. this._rotateCamera(true);
  17359. }
  17360. }
  17361. }
  17362. else {
  17363. if (stateObject.x < this._padSensibilityDown) {
  17364. gazer._rotationRightAsked = false;
  17365. }
  17366. }
  17367. };
  17368. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  17369. // Only teleport backwards when user is not currently selecting a teleportation location
  17370. if (gazer._teleportationRequestInitiated) {
  17371. return;
  17372. }
  17373. // Teleport backwards
  17374. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  17375. if (!gazer._teleportationBackRequestInitiated) {
  17376. if (!this.currentVRCamera) {
  17377. return;
  17378. }
  17379. // Get rotation and position of the current camera
  17380. var rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  17381. var position = this.currentVRCamera.position;
  17382. // If the camera has device position, use that instead
  17383. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  17384. rotation = this.currentVRCamera.deviceRotationQuaternion;
  17385. position = this.currentVRCamera.devicePosition;
  17386. }
  17387. // Get matrix with only the y rotation of the device rotation
  17388. rotation.toEulerAnglesToRef(this._workingVector);
  17389. this._workingVector.z = 0;
  17390. this._workingVector.x = 0;
  17391. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  17392. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  17393. // Rotate backwards ray by device rotation to cast at the ground behind the user
  17394. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  17395. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  17396. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](position, this._workingVector);
  17397. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17398. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  17399. this.teleportCamera(hit.pickedPoint);
  17400. }
  17401. gazer._teleportationBackRequestInitiated = true;
  17402. }
  17403. }
  17404. else {
  17405. gazer._teleportationBackRequestInitiated = false;
  17406. }
  17407. };
  17408. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  17409. var _this = this;
  17410. var controllerMesh = controller.webVRController.mesh;
  17411. if (controllerMesh) {
  17412. if (!controller._interactionsEnabled) {
  17413. this._enableInteractionOnController(controller);
  17414. }
  17415. controller._interactionsEnabled = true;
  17416. controller._teleportationEnabled = true;
  17417. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledControllerType"].VIVE) {
  17418. controller._dpadPressed = false;
  17419. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  17420. controller._dpadPressed = stateObject.pressed;
  17421. if (!controller._dpadPressed) {
  17422. controller._rotationLeftAsked = false;
  17423. controller._rotationRightAsked = false;
  17424. controller._teleportationBackRequestInitiated = false;
  17425. }
  17426. });
  17427. }
  17428. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  17429. if (_this.teleportationEnabled) {
  17430. _this._checkTeleportBackwards(stateObject, controller);
  17431. _this._checkTeleportWithRay(stateObject, controller);
  17432. }
  17433. _this._checkRotate(stateObject, controller);
  17434. });
  17435. }
  17436. };
  17437. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  17438. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  17439. this._teleportationTarget.isPickable = false;
  17440. var length = 512;
  17441. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  17442. dynamicTexture.hasAlpha = true;
  17443. var context = dynamicTexture.getContext();
  17444. var centerX = length / 2;
  17445. var centerY = length / 2;
  17446. var radius = 200;
  17447. context.beginPath();
  17448. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  17449. context.fillStyle = this._teleportationFillColor;
  17450. context.fill();
  17451. context.lineWidth = 10;
  17452. context.strokeStyle = this._teleportationBorderColor;
  17453. context.stroke();
  17454. context.closePath();
  17455. dynamicTexture.update();
  17456. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  17457. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  17458. this._teleportationTarget.material = teleportationCircleMaterial;
  17459. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  17460. torus.isPickable = false;
  17461. torus.parent = this._teleportationTarget;
  17462. 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);
  17463. var keys = [];
  17464. keys.push({
  17465. frame: 0,
  17466. value: 0
  17467. });
  17468. keys.push({
  17469. frame: 30,
  17470. value: 0.4
  17471. });
  17472. keys.push({
  17473. frame: 60,
  17474. value: 0
  17475. });
  17476. animationInnerCircle.setKeys(keys);
  17477. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["SineEase"]();
  17478. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  17479. animationInnerCircle.setEasingFunction(easingFunction);
  17480. torus.animations = [];
  17481. torus.animations.push(animationInnerCircle);
  17482. this._scene.beginAnimation(torus, 0, 60, true);
  17483. this._hideTeleportationTarget();
  17484. };
  17485. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  17486. this._teleportActive = true;
  17487. if (this._teleportationInitialized) {
  17488. this._teleportationTarget.isVisible = true;
  17489. if (this._isDefaultTeleportationTarget) {
  17490. this._teleportationTarget.getChildren()[0].isVisible = true;
  17491. }
  17492. }
  17493. };
  17494. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  17495. this._teleportActive = false;
  17496. if (this._teleportationInitialized) {
  17497. this._teleportationTarget.isVisible = false;
  17498. if (this._isDefaultTeleportationTarget) {
  17499. this._teleportationTarget.getChildren()[0].isVisible = false;
  17500. }
  17501. }
  17502. };
  17503. VRExperienceHelper.prototype._rotateCamera = function (right) {
  17504. var _this = this;
  17505. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17506. return;
  17507. }
  17508. if (right) {
  17509. this._rotationAngle++;
  17510. }
  17511. else {
  17512. this._rotationAngle--;
  17513. }
  17514. this.currentVRCamera.animations = [];
  17515. var target = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  17516. 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);
  17517. var animationRotationKeys = [];
  17518. animationRotationKeys.push({
  17519. frame: 0,
  17520. value: this.currentVRCamera.rotationQuaternion
  17521. });
  17522. animationRotationKeys.push({
  17523. frame: 6,
  17524. value: target
  17525. });
  17526. animationRotation.setKeys(animationRotationKeys);
  17527. animationRotation.setEasingFunction(this._circleEase);
  17528. this.currentVRCamera.animations.push(animationRotation);
  17529. this._postProcessMove.animations = [];
  17530. 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);
  17531. var vignetteWeightKeys = [];
  17532. vignetteWeightKeys.push({
  17533. frame: 0,
  17534. value: 0
  17535. });
  17536. vignetteWeightKeys.push({
  17537. frame: 3,
  17538. value: 4
  17539. });
  17540. vignetteWeightKeys.push({
  17541. frame: 6,
  17542. value: 0
  17543. });
  17544. animationPP.setKeys(vignetteWeightKeys);
  17545. animationPP.setEasingFunction(this._circleEase);
  17546. this._postProcessMove.animations.push(animationPP);
  17547. 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);
  17548. var vignetteStretchKeys = [];
  17549. vignetteStretchKeys.push({
  17550. frame: 0,
  17551. value: 0
  17552. });
  17553. vignetteStretchKeys.push({
  17554. frame: 3,
  17555. value: 10
  17556. });
  17557. vignetteStretchKeys.push({
  17558. frame: 6,
  17559. value: 0
  17560. });
  17561. animationPP2.setKeys(vignetteStretchKeys);
  17562. animationPP2.setEasingFunction(this._circleEase);
  17563. this._postProcessMove.animations.push(animationPP2);
  17564. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17565. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17566. this._postProcessMove.samples = 4;
  17567. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17568. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  17569. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17570. });
  17571. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  17572. };
  17573. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  17574. if (hit.pickedPoint) {
  17575. if (gazer._teleportationRequestInitiated) {
  17576. this._displayTeleportationTarget();
  17577. this._haloCenter.copyFrom(hit.pickedPoint);
  17578. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  17579. }
  17580. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  17581. if (pickNormal) {
  17582. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17583. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17584. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  17585. }
  17586. this._teleportationTarget.position.y += 0.1;
  17587. }
  17588. };
  17589. /**
  17590. * Teleports the users feet to the desired location
  17591. * @param location The location where the user's feet should be placed
  17592. */
  17593. VRExperienceHelper.prototype.teleportCamera = function (location) {
  17594. var _this = this;
  17595. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17596. return;
  17597. }
  17598. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  17599. // offset of the headset from the anchor.
  17600. if (this.webVRCamera.leftCamera) {
  17601. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  17602. this._workingVector.subtractInPlace(this.webVRCamera.position);
  17603. location.subtractToRef(this._workingVector, this._workingVector);
  17604. }
  17605. else {
  17606. this._workingVector.copyFrom(location);
  17607. }
  17608. // Add height to account for user's height offset
  17609. if (this.isInVRMode) {
  17610. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  17611. }
  17612. else {
  17613. this._workingVector.y += this._defaultHeight;
  17614. }
  17615. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  17616. // Create animation from the camera's position to the new location
  17617. this.currentVRCamera.animations = [];
  17618. 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);
  17619. var animationCameraTeleportationKeys = [{
  17620. frame: 0,
  17621. value: this.currentVRCamera.position
  17622. },
  17623. {
  17624. frame: 11,
  17625. value: this._workingVector
  17626. }
  17627. ];
  17628. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  17629. animationCameraTeleportation.setEasingFunction(this._circleEase);
  17630. this.currentVRCamera.animations.push(animationCameraTeleportation);
  17631. this._postProcessMove.animations = [];
  17632. 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);
  17633. var vignetteWeightKeys = [];
  17634. vignetteWeightKeys.push({
  17635. frame: 0,
  17636. value: 0
  17637. });
  17638. vignetteWeightKeys.push({
  17639. frame: 5,
  17640. value: 8
  17641. });
  17642. vignetteWeightKeys.push({
  17643. frame: 11,
  17644. value: 0
  17645. });
  17646. animationPP.setKeys(vignetteWeightKeys);
  17647. this._postProcessMove.animations.push(animationPP);
  17648. 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);
  17649. var vignetteStretchKeys = [];
  17650. vignetteStretchKeys.push({
  17651. frame: 0,
  17652. value: 0
  17653. });
  17654. vignetteStretchKeys.push({
  17655. frame: 5,
  17656. value: 10
  17657. });
  17658. vignetteStretchKeys.push({
  17659. frame: 11,
  17660. value: 0
  17661. });
  17662. animationPP2.setKeys(vignetteStretchKeys);
  17663. this._postProcessMove.animations.push(animationPP2);
  17664. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17665. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17666. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17667. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  17668. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17669. });
  17670. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  17671. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  17672. });
  17673. this._hideTeleportationTarget();
  17674. };
  17675. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  17676. if (normal) {
  17677. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  17678. if (angle < Math.PI / 2) {
  17679. normal.scaleInPlace(-1);
  17680. }
  17681. }
  17682. return normal;
  17683. };
  17684. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  17685. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17686. return;
  17687. }
  17688. var ray = gazer._getForwardRay(this._rayLength);
  17689. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17690. if (hit) {
  17691. // Populate the contrllers mesh that can be used for drag/drop
  17692. if (gazer._laserPointer) {
  17693. hit.originMesh = gazer._laserPointer.parent;
  17694. }
  17695. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  17696. }
  17697. gazer._currentHit = hit;
  17698. // Moving the gazeTracker on the mesh face targetted
  17699. if (hit && hit.pickedPoint) {
  17700. if (this._displayGaze) {
  17701. var multiplier = 1;
  17702. gazer._gazeTracker.isVisible = true;
  17703. if (gazer._isActionableMesh) {
  17704. multiplier = 3;
  17705. }
  17706. if (this.updateGazeTrackerScale) {
  17707. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  17708. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  17709. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  17710. }
  17711. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  17712. // To avoid z-fighting
  17713. var deltaFighting = 0.002;
  17714. if (pickNormal) {
  17715. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17716. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17717. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  17718. }
  17719. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  17720. if (gazer._gazeTracker.position.x < 0) {
  17721. gazer._gazeTracker.position.x += deltaFighting;
  17722. }
  17723. else {
  17724. gazer._gazeTracker.position.x -= deltaFighting;
  17725. }
  17726. if (gazer._gazeTracker.position.y < 0) {
  17727. gazer._gazeTracker.position.y += deltaFighting;
  17728. }
  17729. else {
  17730. gazer._gazeTracker.position.y -= deltaFighting;
  17731. }
  17732. if (gazer._gazeTracker.position.z < 0) {
  17733. gazer._gazeTracker.position.z += deltaFighting;
  17734. }
  17735. else {
  17736. gazer._gazeTracker.position.z -= deltaFighting;
  17737. }
  17738. }
  17739. // Changing the size of the laser pointer based on the distance from the targetted point
  17740. gazer._updatePointerDistance(hit.distance);
  17741. }
  17742. else {
  17743. gazer._updatePointerDistance();
  17744. gazer._gazeTracker.isVisible = false;
  17745. }
  17746. if (hit && hit.pickedMesh) {
  17747. // The object selected is the floor, we're in a teleportation scenario
  17748. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  17749. // Moving the teleportation area to this targetted point
  17750. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  17751. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  17752. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17753. }
  17754. gazer._currentMeshSelected = null;
  17755. if (gazer._teleportationRequestInitiated) {
  17756. this._moveTeleportationSelectorTo(hit, gazer, ray);
  17757. }
  17758. return;
  17759. }
  17760. // If not, we're in a selection scenario
  17761. //this._teleportationAllowed = false;
  17762. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  17763. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  17764. this.onNewMeshPicked.notifyObservers(hit);
  17765. gazer._currentMeshSelected = hit.pickedMesh;
  17766. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  17767. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0, 0, 1));
  17768. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.2, 0.2, 1));
  17769. gazer._isActionableMesh = true;
  17770. }
  17771. else {
  17772. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17773. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17774. gazer._isActionableMesh = false;
  17775. }
  17776. try {
  17777. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  17778. }
  17779. catch (err) {
  17780. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  17781. }
  17782. }
  17783. else {
  17784. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17785. gazer._currentMeshSelected = null;
  17786. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17787. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17788. }
  17789. }
  17790. }
  17791. else {
  17792. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17793. gazer._currentMeshSelected = null;
  17794. //this._teleportationAllowed = false;
  17795. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17796. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17797. }
  17798. };
  17799. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  17800. if (mesh) {
  17801. this.onSelectedMeshUnselected.notifyObservers(mesh);
  17802. }
  17803. };
  17804. /**
  17805. * Sets the color of the laser ray from the vr controllers.
  17806. * @param color new color for the ray.
  17807. */
  17808. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  17809. if (this._leftController) {
  17810. this._leftController._setLaserPointerColor(color);
  17811. }
  17812. if (this._rightController) {
  17813. this._rightController._setLaserPointerColor(color);
  17814. }
  17815. };
  17816. /**
  17817. * Sets the color of the ray from the vr headsets gaze.
  17818. * @param color new color for the ray.
  17819. */
  17820. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  17821. if (!this.updateGazeTrackerColor) {
  17822. return;
  17823. }
  17824. if (!this._cameraGazer._gazeTracker.material) {
  17825. return;
  17826. }
  17827. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  17828. if (this._leftController) {
  17829. this._leftController._gazeTracker.material.emissiveColor = color;
  17830. }
  17831. if (this._rightController) {
  17832. this._rightController._gazeTracker.material.emissiveColor = color;
  17833. }
  17834. };
  17835. /**
  17836. * Exits VR and disposes of the vr experience helper
  17837. */
  17838. VRExperienceHelper.prototype.dispose = function () {
  17839. if (this.isInVRMode) {
  17840. this.exitVR();
  17841. }
  17842. if (this._postProcessMove) {
  17843. this._postProcessMove.dispose();
  17844. }
  17845. if (this._webVRCamera) {
  17846. this._webVRCamera.dispose();
  17847. }
  17848. if (this._vrDeviceOrientationCamera) {
  17849. this._vrDeviceOrientationCamera.dispose();
  17850. }
  17851. if (!this._useCustomVRButton && this._btnVR.parentNode) {
  17852. document.body.removeChild(this._btnVR);
  17853. }
  17854. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  17855. this._deviceOrientationCamera.dispose();
  17856. }
  17857. if (this._cameraGazer) {
  17858. this._cameraGazer.dispose();
  17859. }
  17860. if (this._leftController) {
  17861. this._leftController.dispose();
  17862. }
  17863. if (this._rightController) {
  17864. this._rightController.dispose();
  17865. }
  17866. if (this._teleportationTarget) {
  17867. this._teleportationTarget.dispose();
  17868. }
  17869. this._floorMeshesCollection = [];
  17870. document.removeEventListener("keydown", this._onKeyDown);
  17871. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17872. window.removeEventListener("resize", this._onResize);
  17873. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  17874. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  17875. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  17876. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  17877. document.onmsfullscreenchange = null;
  17878. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  17879. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  17880. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  17881. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17882. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  17883. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  17884. this._scene.unregisterBeforeRender(this.beforeRender);
  17885. };
  17886. /**
  17887. * Gets the name of the VRExperienceHelper class
  17888. * @returns "VRExperienceHelper"
  17889. */
  17890. VRExperienceHelper.prototype.getClassName = function () {
  17891. return "VRExperienceHelper";
  17892. };
  17893. return VRExperienceHelper;
  17894. }());
  17895. /***/ }),
  17896. /***/ "./Cameras/VR/webVRCamera.ts":
  17897. /*!***********************************!*\
  17898. !*** ./Cameras/VR/webVRCamera.ts ***!
  17899. \***********************************/
  17900. /*! exports provided: WebVRFreeCamera */
  17901. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17902. "use strict";
  17903. __webpack_require__.r(__webpack_exports__);
  17904. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  17905. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17906. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17907. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  17908. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  17909. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17910. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  17911. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  17912. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  17913. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  17914. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  17915. /* harmony import */ var _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../PostProcesses/vrMultiviewToSingleviewPostProcess */ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts");
  17916. /* harmony import */ var _RigModes_webVRRigMode__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../RigModes/webVRRigMode */ "./Cameras/RigModes/webVRRigMode.ts");
  17917. // Side effect import to define the stereoscopic mode.
  17918. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  17919. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17920. });
  17921. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  17922. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17923. });
  17924. /**
  17925. * This represents a WebVR camera.
  17926. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17927. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17928. */
  17929. var WebVRFreeCamera = /** @class */ (function (_super) {
  17930. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  17931. /**
  17932. * Instantiates a WebVRFreeCamera.
  17933. * @param name The name of the WebVRFreeCamera
  17934. * @param position The starting anchor position for the camera
  17935. * @param scene The scene the camera belongs to
  17936. * @param webVROptions a set of customizable options for the webVRCamera
  17937. */
  17938. function WebVRFreeCamera(name, position, scene, webVROptions) {
  17939. if (webVROptions === void 0) { webVROptions = {}; }
  17940. var _this = _super.call(this, name, position, scene) || this;
  17941. _this.webVROptions = webVROptions;
  17942. /**
  17943. * @hidden
  17944. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17945. */
  17946. _this._vrDevice = null;
  17947. /**
  17948. * The rawPose of the vrDevice.
  17949. */
  17950. _this.rawPose = null;
  17951. _this._specsVersion = "1.1";
  17952. _this._attached = false;
  17953. _this._descendants = [];
  17954. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  17955. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17956. /** @hidden */
  17957. _this._deviceRoomRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17958. _this._standingMatrix = null;
  17959. /**
  17960. * Represents device position in babylon space.
  17961. */
  17962. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17963. /**
  17964. * Represents device rotation in babylon space.
  17965. */
  17966. _this.deviceRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17967. /**
  17968. * The scale of the device to be used when translating from device space to babylon space.
  17969. */
  17970. _this.deviceScaleFactor = 1;
  17971. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17972. _this._worldToDevice = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17973. /**
  17974. * References to the webVR controllers for the vrDevice.
  17975. */
  17976. _this.controllers = [];
  17977. /**
  17978. * Emits an event when a controller is attached.
  17979. */
  17980. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17981. /**
  17982. * Emits an event when a controller's mesh has been loaded;
  17983. */
  17984. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17985. /**
  17986. * Emits an event when the HMD's pose has been updated.
  17987. */
  17988. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17989. _this._poseSet = false;
  17990. /**
  17991. * If the rig cameras be used as parent instead of this camera.
  17992. */
  17993. _this.rigParenting = true;
  17994. _this._defaultHeight = undefined;
  17995. _this._htmlElementAttached = null;
  17996. _this._detachIfAttached = function () {
  17997. var vrDisplay = _this.getEngine().getVRDevice();
  17998. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  17999. _this.detachControl(_this._htmlElementAttached);
  18000. }
  18001. };
  18002. _this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  18003. _this._oneVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  18004. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18005. _this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  18006. _this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  18007. if (webVROptions.defaultHeight) {
  18008. _this._defaultHeight = webVROptions.defaultHeight;
  18009. _this.position.y = _this._defaultHeight;
  18010. }
  18011. _this.minZ = 0.1;
  18012. //legacy support - the compensation boolean was removed.
  18013. if (arguments.length === 5) {
  18014. _this.webVROptions = arguments[4];
  18015. }
  18016. // default webVR options
  18017. if (_this.webVROptions.trackPosition == undefined) {
  18018. _this.webVROptions.trackPosition = true;
  18019. }
  18020. if (_this.webVROptions.controllerMeshes == undefined) {
  18021. _this.webVROptions.controllerMeshes = true;
  18022. }
  18023. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  18024. _this.webVROptions.defaultLightingOnControllers = true;
  18025. }
  18026. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  18027. if (_this.webVROptions && _this.webVROptions.positionScale) {
  18028. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  18029. }
  18030. //enable VR
  18031. var engine = _this.getEngine();
  18032. _this._onVREnabled = function (success) { if (success) {
  18033. _this.initControllers();
  18034. } };
  18035. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  18036. engine.initWebVR().add(function (event) {
  18037. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  18038. return;
  18039. }
  18040. _this._vrDevice = event.vrDisplay;
  18041. //reset the rig parameters.
  18042. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  18043. if (_this._attached) {
  18044. _this.getEngine().enableVR();
  18045. }
  18046. });
  18047. if (typeof (VRFrameData) !== "undefined") {
  18048. _this._frameData = new VRFrameData();
  18049. }
  18050. if (webVROptions.useMultiview) {
  18051. if (!_this.getScene().getEngine().getCaps().multiview) {
  18052. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn("Multiview is not supported, falling back to standard rendering");
  18053. _this._useMultiviewToSingleView = false;
  18054. }
  18055. else {
  18056. _this._useMultiviewToSingleView = true;
  18057. _this._rigPostProcess = new _PostProcesses_vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_10__["VRMultiviewToSingleviewPostProcess"]("VRMultiviewToSingleview", _this, 1.0);
  18058. }
  18059. }
  18060. /**
  18061. * The idea behind the following lines:
  18062. * objects that have the camera as parent should actually have the rig cameras as a parent.
  18063. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  18064. * the second will not show it correctly.
  18065. *
  18066. * To solve this - each object that has the camera as parent will be added to a protected array.
  18067. * When the rig camera renders, it will take this array and set all of those to be its children.
  18068. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  18069. * Amazing!
  18070. */
  18071. scene.onBeforeCameraRenderObservable.add(function (camera) {
  18072. if (camera.parent === _this && _this.rigParenting) {
  18073. _this._descendants = _this.getDescendants(true, function (n) {
  18074. // don't take the cameras or the controllers!
  18075. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  18076. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  18077. return !isController && !isRigCamera;
  18078. });
  18079. _this._descendants.forEach(function (node) {
  18080. node.parent = camera;
  18081. });
  18082. }
  18083. });
  18084. scene.onAfterCameraRenderObservable.add(function (camera) {
  18085. if (camera.parent === _this && _this.rigParenting) {
  18086. _this._descendants.forEach(function (node) {
  18087. node.parent = _this;
  18088. });
  18089. }
  18090. });
  18091. return _this;
  18092. }
  18093. /**
  18094. * Gets the device distance from the ground in meters.
  18095. * @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.
  18096. */
  18097. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  18098. if (this._standingMatrix) {
  18099. // Add standing matrix offset to get real offset from ground in room
  18100. this._standingMatrix.getTranslationToRef(this._workingVector);
  18101. return this._deviceRoomPosition.y + this._workingVector.y;
  18102. }
  18103. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  18104. return this._defaultHeight || 0;
  18105. };
  18106. /**
  18107. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18108. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18109. */
  18110. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  18111. var _this = this;
  18112. if (callback === void 0) { callback = function (bool) { }; }
  18113. // Use standing matrix if available
  18114. this.getEngine().initWebVRAsync().then(function (result) {
  18115. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  18116. callback(false);
  18117. }
  18118. else {
  18119. _this._standingMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  18120. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  18121. if (!_this.getScene().useRightHandedSystem) {
  18122. if (_this._standingMatrix) {
  18123. _this._standingMatrix.toggleModelMatrixHandInPlace();
  18124. }
  18125. }
  18126. callback(true);
  18127. }
  18128. });
  18129. };
  18130. /**
  18131. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18132. * @returns A promise with a boolean set to if the standing matrix is supported.
  18133. */
  18134. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  18135. var _this = this;
  18136. return new Promise(function (res) {
  18137. _this.useStandingMatrix(function (supported) {
  18138. res(supported);
  18139. });
  18140. });
  18141. };
  18142. /**
  18143. * Disposes the camera
  18144. */
  18145. WebVRFreeCamera.prototype.dispose = function () {
  18146. this._detachIfAttached();
  18147. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  18148. if (this._updateCacheWhenTrackingDisabledObserver) {
  18149. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  18150. }
  18151. _super.prototype.dispose.call(this);
  18152. };
  18153. /**
  18154. * Gets a vrController by name.
  18155. * @param name The name of the controller to retreive
  18156. * @returns the controller matching the name specified or null if not found
  18157. */
  18158. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  18159. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  18160. var gp = _a[_i];
  18161. if (gp.hand === name) {
  18162. return gp;
  18163. }
  18164. }
  18165. return null;
  18166. };
  18167. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  18168. /**
  18169. * The controller corrisponding to the users left hand.
  18170. */
  18171. get: function () {
  18172. if (!this._leftController) {
  18173. this._leftController = this.getControllerByName("left");
  18174. }
  18175. return this._leftController;
  18176. },
  18177. enumerable: true,
  18178. configurable: true
  18179. });
  18180. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  18181. /**
  18182. * The controller corrisponding to the users right hand.
  18183. */
  18184. get: function () {
  18185. if (!this._rightController) {
  18186. this._rightController = this.getControllerByName("right");
  18187. }
  18188. return this._rightController;
  18189. },
  18190. enumerable: true,
  18191. configurable: true
  18192. });
  18193. /**
  18194. * Casts a ray forward from the vrCamera's gaze.
  18195. * @param length Length of the ray (default: 100)
  18196. * @returns the ray corrisponding to the gaze
  18197. */
  18198. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  18199. if (length === void 0) { length = 100; }
  18200. if (this.leftCamera) {
  18201. // Use left eye to avoid computation to compute center on every call
  18202. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  18203. }
  18204. else {
  18205. return _super.prototype.getForwardRay.call(this, length);
  18206. }
  18207. };
  18208. /**
  18209. * @hidden
  18210. * Updates the camera based on device's frame data
  18211. */
  18212. WebVRFreeCamera.prototype._checkInputs = function () {
  18213. if (this._vrDevice && this._vrDevice.isPresenting) {
  18214. this._vrDevice.getFrameData(this._frameData);
  18215. this.updateFromDevice(this._frameData.pose);
  18216. }
  18217. _super.prototype._checkInputs.call(this);
  18218. };
  18219. /**
  18220. * Updates the poseControlled values based on the input device pose.
  18221. * @param poseData Pose coming from the device
  18222. */
  18223. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  18224. if (poseData && poseData.orientation) {
  18225. this.rawPose = poseData;
  18226. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  18227. if (this.getScene().useRightHandedSystem) {
  18228. this._deviceRoomRotationQuaternion.z *= -1;
  18229. this._deviceRoomRotationQuaternion.w *= -1;
  18230. }
  18231. if (this.webVROptions.trackPosition && this.rawPose.position) {
  18232. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  18233. if (this.getScene().useRightHandedSystem) {
  18234. this._deviceRoomPosition.z *= -1;
  18235. }
  18236. }
  18237. this._poseSet = true;
  18238. }
  18239. };
  18240. /**
  18241. * WebVR's attach control will start broadcasting frames to the device.
  18242. * Note that in certain browsers (chrome for example) this function must be called
  18243. * within a user-interaction callback. Example:
  18244. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18245. *
  18246. * @param element html element to attach the vrDevice to
  18247. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18248. */
  18249. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  18250. _super.prototype.attachControl.call(this, element, noPreventDefault);
  18251. this._attached = true;
  18252. this._htmlElementAttached = element;
  18253. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  18254. if (this._vrDevice) {
  18255. this.getEngine().enableVR();
  18256. }
  18257. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18258. };
  18259. /**
  18260. * Detaches the camera from the html element and disables VR
  18261. *
  18262. * @param element html element to detach from
  18263. */
  18264. WebVRFreeCamera.prototype.detachControl = function (element) {
  18265. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  18266. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  18267. _super.prototype.detachControl.call(this, element);
  18268. this._attached = false;
  18269. this.getEngine().disableVR();
  18270. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  18271. };
  18272. /**
  18273. * @returns the name of this class
  18274. */
  18275. WebVRFreeCamera.prototype.getClassName = function () {
  18276. return "WebVRFreeCamera";
  18277. };
  18278. /**
  18279. * Calls resetPose on the vrDisplay
  18280. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18281. */
  18282. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  18283. //uses the vrDisplay's "resetPose()".
  18284. //pitch and roll won't be affected.
  18285. this._vrDevice.resetPose();
  18286. };
  18287. /**
  18288. * @hidden
  18289. * Updates the rig cameras (left and right eye)
  18290. */
  18291. WebVRFreeCamera.prototype._updateRigCameras = function () {
  18292. var camLeft = this._rigCameras[0];
  18293. var camRight = this._rigCameras[1];
  18294. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18295. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  18296. camLeft.position.copyFrom(this._deviceRoomPosition);
  18297. camRight.position.copyFrom(this._deviceRoomPosition);
  18298. };
  18299. // Remove translation from 6dof headset if trackposition is set to false
  18300. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  18301. if (isViewMatrix === void 0) { isViewMatrix = false; }
  18302. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  18303. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  18304. if (!isViewMatrix) {
  18305. this._tmpMatrix.invert();
  18306. }
  18307. this._tmpMatrix.multiplyToRef(matrix, matrix);
  18308. }
  18309. };
  18310. /**
  18311. * @hidden
  18312. * Updates the cached values of the camera
  18313. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18314. */
  18315. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  18316. var _this = this;
  18317. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  18318. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  18319. if (!this.updateCacheCalled) {
  18320. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  18321. this.updateCacheCalled = true;
  18322. this.update();
  18323. }
  18324. // Set working vector to the device position in room space rotated by the new rotation
  18325. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  18326. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  18327. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  18328. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  18329. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  18330. // Add translation from anchor position
  18331. this._deviceToWorld.getTranslationToRef(this._workingVector);
  18332. this._workingVector.addInPlace(this.position);
  18333. this._workingVector.subtractInPlace(this._cache.position);
  18334. this._deviceToWorld.setTranslation(this._workingVector);
  18335. // Set an inverted matrix to be used when updating the camera
  18336. this._deviceToWorld.invertToRef(this._worldToDevice);
  18337. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  18338. this.controllers.forEach(function (controller) {
  18339. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  18340. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  18341. controller.update();
  18342. });
  18343. }
  18344. if (!ignoreParentClass) {
  18345. _super.prototype._updateCache.call(this);
  18346. }
  18347. this.updateCacheCalled = false;
  18348. };
  18349. /**
  18350. * @hidden
  18351. * Get current device position in babylon world
  18352. */
  18353. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  18354. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  18355. };
  18356. /**
  18357. * Updates the current device position and rotation in the babylon world
  18358. */
  18359. WebVRFreeCamera.prototype.update = function () {
  18360. this._computeDevicePosition();
  18361. // Get current device rotation in babylon world
  18362. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  18363. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  18364. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  18365. if (this._poseSet) {
  18366. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  18367. }
  18368. _super.prototype.update.call(this);
  18369. };
  18370. /**
  18371. * @hidden
  18372. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18373. * @returns an identity matrix
  18374. */
  18375. WebVRFreeCamera.prototype._getViewMatrix = function () {
  18376. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18377. };
  18378. /**
  18379. * This function is called by the two RIG cameras.
  18380. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18381. * @hidden
  18382. */
  18383. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  18384. // Update the parent camera prior to using a child camera to avoid desynchronization
  18385. var parentCamera = this._cameraRigParams["parentCamera"];
  18386. parentCamera._updateCache();
  18387. //WebVR 1.1
  18388. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  18389. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  18390. if (!this.getScene().useRightHandedSystem) {
  18391. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  18392. }
  18393. // update the camera rotation matrix
  18394. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  18395. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  18396. // Computing target and final matrix
  18397. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  18398. // should the view matrix be updated with scale and position offset?
  18399. if (parentCamera.deviceScaleFactor !== 1) {
  18400. this._webvrViewMatrix.invert();
  18401. // scale the position, if set
  18402. if (parentCamera.deviceScaleFactor) {
  18403. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  18404. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  18405. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  18406. }
  18407. this._webvrViewMatrix.invert();
  18408. }
  18409. // Remove translation from 6dof headset if trackposition is set to false
  18410. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  18411. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  18412. // Compute global position
  18413. this._workingMatrix = this._workingMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  18414. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  18415. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  18416. this._workingMatrix.getTranslationToRef(this._globalPosition);
  18417. this._markSyncedWithParent();
  18418. return this._webvrViewMatrix;
  18419. };
  18420. /** @hidden */
  18421. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  18422. var parentCamera = this.parent;
  18423. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  18424. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  18425. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  18426. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  18427. //babylon compatible matrix
  18428. if (!this.getScene().useRightHandedSystem) {
  18429. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18430. }
  18431. return this._projectionMatrix;
  18432. };
  18433. /**
  18434. * Initializes the controllers and their meshes
  18435. */
  18436. WebVRFreeCamera.prototype.initControllers = function () {
  18437. var _this = this;
  18438. this.controllers = [];
  18439. var manager = this.getScene().gamepadManager;
  18440. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  18441. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18442. var webVrController = gamepad;
  18443. if (webVrController.defaultModel) {
  18444. webVrController.defaultModel.setEnabled(false);
  18445. }
  18446. if (webVrController.hand === "right") {
  18447. _this._rightController = null;
  18448. }
  18449. if (webVrController.hand === "left") {
  18450. _this._leftController = null;
  18451. }
  18452. var controllerIndex = _this.controllers.indexOf(webVrController);
  18453. if (controllerIndex !== -1) {
  18454. _this.controllers.splice(controllerIndex, 1);
  18455. }
  18456. }
  18457. });
  18458. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  18459. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  18460. var webVrController_1 = gamepad;
  18461. if (!_this.webVROptions.trackPosition) {
  18462. webVrController_1._disableTrackPosition(new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  18463. // Cache must be updated before rendering controllers to avoid them being one frame behind
  18464. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  18465. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  18466. _this._updateCache();
  18467. });
  18468. }
  18469. }
  18470. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  18471. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  18472. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  18473. if (_this.webVROptions.controllerMeshes) {
  18474. if (webVrController_1.defaultModel) {
  18475. webVrController_1.defaultModel.setEnabled(true);
  18476. }
  18477. else {
  18478. // Load the meshes
  18479. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  18480. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  18481. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  18482. if (_this.webVROptions.defaultLightingOnControllers) {
  18483. if (!_this._lightOnControllers) {
  18484. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  18485. }
  18486. var activateLightOnSubMeshes_1 = function (mesh, light) {
  18487. var children = mesh.getChildren();
  18488. if (children && children.length !== 0) {
  18489. children.forEach(function (mesh) {
  18490. light.includedOnlyMeshes.push(mesh);
  18491. activateLightOnSubMeshes_1(mesh, light);
  18492. });
  18493. }
  18494. };
  18495. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  18496. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  18497. }
  18498. });
  18499. }
  18500. }
  18501. webVrController_1.attachToPoseControlledCamera(_this);
  18502. // since this is async - sanity check. Is the controller already stored?
  18503. if (_this.controllers.indexOf(webVrController_1) === -1) {
  18504. //add to the controllers array
  18505. _this.controllers.push(webVrController_1);
  18506. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  18507. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  18508. // So we're overriding setting left & right manually to be sure
  18509. var firstViveWandDetected = false;
  18510. for (var i = 0; i < _this.controllers.length; i++) {
  18511. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  18512. if (!firstViveWandDetected) {
  18513. firstViveWandDetected = true;
  18514. _this.controllers[i].hand = "left";
  18515. }
  18516. else {
  18517. _this.controllers[i].hand = "right";
  18518. }
  18519. }
  18520. }
  18521. //did we find enough controllers? Great! let the developer know.
  18522. if (_this.controllers.length >= 2) {
  18523. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  18524. }
  18525. }
  18526. }
  18527. });
  18528. };
  18529. return WebVRFreeCamera;
  18530. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  18531. /***/ }),
  18532. /***/ "./Cameras/XR/index.ts":
  18533. /*!*****************************!*\
  18534. !*** ./Cameras/XR/index.ts ***!
  18535. \*****************************/
  18536. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  18537. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18538. "use strict";
  18539. __webpack_require__.r(__webpack_exports__);
  18540. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  18542. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  18543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  18544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  18545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  18546. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  18548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  18549. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  18550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRController"]; });
  18551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  18552. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  18553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__["WebXRManagedOutputCanvas"]; });
  18554. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__["WebXRSessionManager"]; });
  18556. /***/ }),
  18557. /***/ "./Cameras/XR/webXRCamera.ts":
  18558. /*!***********************************!*\
  18559. !*** ./Cameras/XR/webXRCamera.ts ***!
  18560. \***********************************/
  18561. /*! exports provided: WebXRCamera */
  18562. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18563. "use strict";
  18564. __webpack_require__.r(__webpack_exports__);
  18565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  18566. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18567. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18568. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  18569. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  18570. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  18571. /**
  18572. * WebXR Camera which holds the views for the xrSession
  18573. * @see https://doc.babylonjs.com/how_to/webxr
  18574. */
  18575. var WebXRCamera = /** @class */ (function (_super) {
  18576. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  18577. /**
  18578. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  18579. * @param name the name of the camera
  18580. * @param scene the scene to add the camera to
  18581. */
  18582. function WebXRCamera(name, scene) {
  18583. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  18584. // Initial camera configuration
  18585. _this.minZ = 0;
  18586. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18587. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  18588. _this.updateUpVectorFromRotation = true;
  18589. _this._updateNumberOfRigCameras(1);
  18590. return _this;
  18591. }
  18592. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  18593. if (viewCount === void 0) { viewCount = 1; }
  18594. while (this.rigCameras.length < viewCount) {
  18595. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  18596. newCamera.minZ = 0;
  18597. newCamera.parent = this;
  18598. newCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18599. newCamera.updateUpVectorFromRotation = true;
  18600. this.rigCameras.push(newCamera);
  18601. }
  18602. while (this.rigCameras.length > viewCount) {
  18603. var removedCamera = this.rigCameras.pop();
  18604. if (removedCamera) {
  18605. removedCamera.dispose();
  18606. }
  18607. }
  18608. };
  18609. /** @hidden */
  18610. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  18611. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  18612. // Create initial camera rigs
  18613. this._updateNumberOfRigCameras(2);
  18614. this.rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  18615. this.rigCameras[0].position.x = -pupilDistance / 2;
  18616. this.rigCameras[0].outputRenderTarget = null;
  18617. this.rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  18618. this.rigCameras[1].position.x = pupilDistance / 2;
  18619. this.rigCameras[1].outputRenderTarget = null;
  18620. };
  18621. /**
  18622. * Updates the cameras position from the current pose information of the XR session
  18623. * @param xrSessionManager the session containing pose information
  18624. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  18625. */
  18626. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  18627. var _this = this;
  18628. // Ensure all frame data is available
  18629. if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
  18630. return false;
  18631. }
  18632. var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
  18633. if (!pose || !pose.poseModelMatrix) {
  18634. return false;
  18635. }
  18636. // Update the parent cameras matrix
  18637. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
  18638. if (!this._scene.useRightHandedSystem) {
  18639. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  18640. }
  18641. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  18642. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  18643. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  18644. this.computeWorldMatrix();
  18645. // Update camera rigs
  18646. this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
  18647. xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
  18648. // Update view/projection matrix
  18649. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
  18650. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  18651. if (!_this._scene.useRightHandedSystem) {
  18652. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  18653. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18654. }
  18655. // Update viewport
  18656. var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
  18657. var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
  18658. var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
  18659. _this.rigCameras[i].viewport.width = viewport.width / width;
  18660. _this.rigCameras[i].viewport.height = viewport.height / height;
  18661. _this.rigCameras[i].viewport.x = viewport.x / width;
  18662. _this.rigCameras[i].viewport.y = viewport.y / height;
  18663. // Set cameras to render to the session's render target
  18664. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  18665. });
  18666. return true;
  18667. };
  18668. WebXRCamera._TmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  18669. return WebXRCamera;
  18670. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  18671. /***/ }),
  18672. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  18673. /*!****************************************!*\
  18674. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  18675. \****************************************/
  18676. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  18677. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18678. "use strict";
  18679. __webpack_require__.r(__webpack_exports__);
  18680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  18681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  18682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  18683. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18684. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18685. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18686. /**
  18687. * Button which can be used to enter a different mode of XR
  18688. */
  18689. var WebXREnterExitUIButton = /** @class */ (function () {
  18690. /**
  18691. * Creates a WebXREnterExitUIButton
  18692. * @param element button element
  18693. * @param initializationOptions XR initialization options for the button
  18694. */
  18695. function WebXREnterExitUIButton(
  18696. /** button element */
  18697. element,
  18698. /** XR initialization options for the button */
  18699. initializationOptions) {
  18700. this.element = element;
  18701. this.initializationOptions = initializationOptions;
  18702. }
  18703. /**
  18704. * Overwritable function which can be used to update the button's visuals when the state changes
  18705. * @param activeButton the current active button in the UI
  18706. */
  18707. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  18708. };
  18709. return WebXREnterExitUIButton;
  18710. }());
  18711. /**
  18712. * Options to create the webXR UI
  18713. */
  18714. var WebXREnterExitUIOptions = /** @class */ (function () {
  18715. function WebXREnterExitUIOptions() {
  18716. }
  18717. return WebXREnterExitUIOptions;
  18718. }());
  18719. /**
  18720. * UI to allow the user to enter/exit XR mode
  18721. */
  18722. var WebXREnterExitUI = /** @class */ (function () {
  18723. function WebXREnterExitUI(scene, options) {
  18724. var _this = this;
  18725. this.scene = scene;
  18726. this._buttons = [];
  18727. this._activeButton = null;
  18728. /**
  18729. * Fired every time the active button is changed.
  18730. *
  18731. * When xr is entered via a button that launches xr that button will be the callback parameter
  18732. *
  18733. * When exiting xr the callback parameter will be null)
  18734. */
  18735. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18736. this._overlay = document.createElement("div");
  18737. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  18738. if (options.customButtons) {
  18739. this._buttons = options.customButtons;
  18740. }
  18741. else {
  18742. var hmdBtn = document.createElement("button");
  18743. 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;";
  18744. hmdBtn.innerText = "HMD";
  18745. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
  18746. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18747. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18748. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  18749. };
  18750. var windowBtn = document.createElement("button");
  18751. windowBtn.style.cssText = hmdBtn.style.cssText;
  18752. windowBtn.innerText = "Window";
  18753. this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
  18754. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18755. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18756. this.element.innerText = activeButton === this ? "EXIT" : "Window";
  18757. };
  18758. this._updateButtons(null);
  18759. }
  18760. var renderCanvas = scene.getEngine().getRenderingCanvas();
  18761. if (renderCanvas && renderCanvas.parentNode) {
  18762. renderCanvas.parentNode.appendChild(this._overlay);
  18763. scene.onDisposeObservable.addOnce(function () {
  18764. _this.dispose();
  18765. });
  18766. }
  18767. }
  18768. /**
  18769. * Creates UI to allow the user to enter/exit XR mode
  18770. * @param scene the scene to add the ui to
  18771. * @param helper the xr experience helper to enter/exit xr with
  18772. * @param options options to configure the UI
  18773. * @returns the created ui
  18774. */
  18775. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  18776. var _this = this;
  18777. var ui = new WebXREnterExitUI(scene, options);
  18778. var supportedPromises = ui._buttons.map(function (btn) {
  18779. return helper.supportsSessionAsync(btn.initializationOptions);
  18780. });
  18781. helper.onStateChangedObservable.add(function (state) {
  18782. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  18783. ui._updateButtons(null);
  18784. }
  18785. });
  18786. return Promise.all(supportedPromises).then(function (results) {
  18787. results.forEach(function (supported, i) {
  18788. if (supported) {
  18789. ui._overlay.appendChild(ui._buttons[i].element);
  18790. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  18791. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  18792. switch (_a.label) {
  18793. case 0:
  18794. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  18795. ui._updateButtons(null);
  18796. return [4 /*yield*/, helper.exitXRAsync()];
  18797. case 1:
  18798. _a.sent();
  18799. return [2 /*return*/];
  18800. case 2:
  18801. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  18802. ui._updateButtons(ui._buttons[i]);
  18803. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
  18804. case 3:
  18805. _a.sent();
  18806. _a.label = 4;
  18807. case 4: return [2 /*return*/];
  18808. }
  18809. });
  18810. }); };
  18811. }
  18812. });
  18813. return ui;
  18814. });
  18815. };
  18816. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  18817. var _this = this;
  18818. this._activeButton = activeButton;
  18819. this._buttons.forEach(function (b) {
  18820. b.update(_this._activeButton);
  18821. });
  18822. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  18823. };
  18824. /**
  18825. * Disposes of the object
  18826. */
  18827. WebXREnterExitUI.prototype.dispose = function () {
  18828. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  18829. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  18830. renderCanvas.parentNode.removeChild(this._overlay);
  18831. }
  18832. this.activeButtonChangedObservable.clear();
  18833. };
  18834. return WebXREnterExitUI;
  18835. }());
  18836. /***/ }),
  18837. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  18838. /*!*********************************************!*\
  18839. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  18840. \*********************************************/
  18841. /*! exports provided: WebXRState, WebXRExperienceHelper */
  18842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18843. "use strict";
  18844. __webpack_require__.r(__webpack_exports__);
  18845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  18846. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  18847. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18848. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18849. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18850. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18851. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18852. /**
  18853. * States of the webXR experience
  18854. */
  18855. var WebXRState;
  18856. (function (WebXRState) {
  18857. /**
  18858. * Transitioning to being in XR mode
  18859. */
  18860. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  18861. /**
  18862. * Transitioning to non XR mode
  18863. */
  18864. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  18865. /**
  18866. * In XR mode and presenting
  18867. */
  18868. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  18869. /**
  18870. * Not entered XR mode
  18871. */
  18872. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  18873. })(WebXRState || (WebXRState = {}));
  18874. /**
  18875. * Helper class used to enable XR
  18876. * @see https://doc.babylonjs.com/how_to/webxr
  18877. */
  18878. var WebXRExperienceHelper = /** @class */ (function () {
  18879. /**
  18880. * Creates a WebXRExperienceHelper
  18881. * @param scene The scene the helper should be created in
  18882. */
  18883. function WebXRExperienceHelper(scene) {
  18884. this.scene = scene;
  18885. /**
  18886. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  18887. */
  18888. this.state = WebXRState.NOT_IN_XR;
  18889. /**
  18890. * Fires when the state of the experience helper has changed
  18891. */
  18892. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  18893. this._nonVRCamera = null;
  18894. this._originalSceneAutoClear = true;
  18895. this._supported = false;
  18896. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  18897. this._sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  18898. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", scene);
  18899. this.camera.parent = this.container;
  18900. }
  18901. WebXRExperienceHelper.prototype._setState = function (val) {
  18902. this.state = val;
  18903. this.onStateChangedObservable.notifyObservers(this.state);
  18904. };
  18905. /**
  18906. * Creates the experience helper
  18907. * @param scene the scene to attach the experience helper to
  18908. * @returns a promise for the experience helper
  18909. */
  18910. WebXRExperienceHelper.CreateAsync = function (scene) {
  18911. var helper = new WebXRExperienceHelper(scene);
  18912. return helper._sessionManager.initializeAsync().then(function () {
  18913. helper._supported = true;
  18914. return helper;
  18915. }).catch(function () {
  18916. return helper;
  18917. });
  18918. };
  18919. /**
  18920. * Exits XR mode and returns the scene to its original state
  18921. * @returns promise that resolves after xr mode has exited
  18922. */
  18923. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  18924. this._setState(WebXRState.EXITING_XR);
  18925. return this._sessionManager.exitXRAsync();
  18926. };
  18927. /**
  18928. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  18929. * @param sessionCreationOptions options for the XR session
  18930. * @param frameOfReference frame of reference of the XR session
  18931. * @returns promise that resolves after xr mode has entered
  18932. */
  18933. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
  18934. var _this = this;
  18935. if (!this._supported) {
  18936. throw "XR session not supported by this browser";
  18937. }
  18938. this._setState(WebXRState.ENTERING_XR);
  18939. return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
  18940. // Cache pre xr scene settings
  18941. _this._originalSceneAutoClear = _this.scene.autoClear;
  18942. _this._nonVRCamera = _this.scene.activeCamera;
  18943. // Overwrite current scene settings
  18944. _this.scene.autoClear = false;
  18945. _this.scene.activeCamera = _this.camera;
  18946. _this._sessionManager.onXRFrameObservable.add(function () {
  18947. _this.camera.updateFromXRSessionManager(_this._sessionManager);
  18948. });
  18949. _this._sessionManager.onXRSessionEnded.addOnce(function () {
  18950. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  18951. _this.camera.rigCameras.forEach(function (c) {
  18952. c.outputRenderTarget = null;
  18953. });
  18954. // Restore scene settings
  18955. _this.scene.autoClear = _this._originalSceneAutoClear;
  18956. _this.scene.activeCamera = _this._nonVRCamera;
  18957. _this._sessionManager.onXRFrameObservable.clear();
  18958. _this._setState(WebXRState.NOT_IN_XR);
  18959. });
  18960. _this._setState(WebXRState.IN_XR);
  18961. });
  18962. };
  18963. /**
  18964. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18965. * @param ray ray to cast into the environment
  18966. * @returns Promise which resolves with a collision point in the environment if it exists
  18967. */
  18968. WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
  18969. return this._sessionManager.environmentPointHitTestAsync(ray);
  18970. };
  18971. /**
  18972. * Updates the global position of the camera by moving the camera's container
  18973. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  18974. * @param position The desired global position of the camera
  18975. */
  18976. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  18977. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  18978. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  18979. };
  18980. /**
  18981. * Rotates the xr camera by rotating the camera's container around the camera's position
  18982. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  18983. * @param rotation the desired quaternion rotation to apply to the camera
  18984. */
  18985. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  18986. if (!this.container.rotationQuaternion) {
  18987. this.container.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  18988. }
  18989. this.container.rotationQuaternion.multiplyInPlace(rotation);
  18990. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  18991. };
  18992. /**
  18993. * Checks if the creation options are supported by the xr session
  18994. * @param options creation options
  18995. * @returns true if supported
  18996. */
  18997. WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
  18998. if (!this._supported) {
  18999. return Promise.resolve(false);
  19000. }
  19001. return this._sessionManager.supportsSessionAsync(options);
  19002. };
  19003. /**
  19004. * Disposes of the experience helper
  19005. */
  19006. WebXRExperienceHelper.prototype.dispose = function () {
  19007. this.camera.dispose();
  19008. this.container.dispose();
  19009. this.onStateChangedObservable.clear();
  19010. this._sessionManager.dispose();
  19011. };
  19012. WebXRExperienceHelper._TmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  19013. return WebXRExperienceHelper;
  19014. }());
  19015. /***/ }),
  19016. /***/ "./Cameras/XR/webXRInput.ts":
  19017. /*!**********************************!*\
  19018. !*** ./Cameras/XR/webXRInput.ts ***!
  19019. \**********************************/
  19020. /*! exports provided: WebXRController, WebXRInput */
  19021. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19022. "use strict";
  19023. __webpack_require__.r(__webpack_exports__);
  19024. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return WebXRController; });
  19025. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  19026. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  19027. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  19028. /**
  19029. * Represents an XR input
  19030. */
  19031. var WebXRController = /** @class */ (function () {
  19032. /**
  19033. * Creates the controller
  19034. * @see https://doc.babylonjs.com/how_to/webxr
  19035. * @param scene the scene which the controller should be associated to
  19036. */
  19037. function WebXRController(scene) {
  19038. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  19039. }
  19040. /**
  19041. * Disposes of the object
  19042. */
  19043. WebXRController.prototype.dispose = function () {
  19044. if (this.grip) {
  19045. this.grip.dispose();
  19046. }
  19047. this.pointer.dispose();
  19048. };
  19049. return WebXRController;
  19050. }());
  19051. /**
  19052. * XR input used to track XR inputs such as controllers/rays
  19053. */
  19054. var WebXRInput = /** @class */ (function () {
  19055. /**
  19056. * Initializes the WebXRInput
  19057. * @param helper experience helper which the input should be created for
  19058. */
  19059. function WebXRInput(helper) {
  19060. var _this = this;
  19061. this.helper = helper;
  19062. /**
  19063. * XR controllers being tracked
  19064. */
  19065. this.controllers = [];
  19066. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  19067. this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
  19068. if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
  19069. return;
  19070. }
  19071. var xrFrame = helper._sessionManager._currentXRFrame;
  19072. var inputSources = helper._sessionManager._xrSession.getInputSources();
  19073. inputSources.forEach(function (input, i) {
  19074. var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
  19075. if (inputPose) {
  19076. if (_this.controllers.length <= i) {
  19077. _this.controllers.push(new WebXRController(helper.container.getScene()));
  19078. }
  19079. var controller = _this.controllers[i];
  19080. // Manage the grip if it exists
  19081. if (inputPose.gripMatrix) {
  19082. if (!controller.grip) {
  19083. controller.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", helper.container.getScene());
  19084. }
  19085. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
  19086. if (!controller.grip.getScene().useRightHandedSystem) {
  19087. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  19088. }
  19089. if (!controller.grip.rotationQuaternion) {
  19090. controller.grip.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  19091. }
  19092. _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
  19093. }
  19094. // Manager pointer of controller
  19095. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
  19096. if (!controller.pointer.getScene().useRightHandedSystem) {
  19097. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  19098. }
  19099. if (!controller.pointer.rotationQuaternion) {
  19100. controller.pointer.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  19101. }
  19102. _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
  19103. }
  19104. });
  19105. });
  19106. }
  19107. /**
  19108. * Disposes of the object
  19109. */
  19110. WebXRInput.prototype.dispose = function () {
  19111. this.controllers.forEach(function (c) {
  19112. c.dispose();
  19113. });
  19114. this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
  19115. };
  19116. return WebXRInput;
  19117. }());
  19118. /***/ }),
  19119. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  19120. /*!************************************************!*\
  19121. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  19122. \************************************************/
  19123. /*! exports provided: WebXRManagedOutputCanvas */
  19124. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19125. "use strict";
  19126. __webpack_require__.r(__webpack_exports__);
  19127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  19128. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  19129. /**
  19130. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  19131. */
  19132. var WebXRManagedOutputCanvas = /** @class */ (function () {
  19133. /**
  19134. * Initializes the canvas to be added/removed upon entering/exiting xr
  19135. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  19136. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  19137. */
  19138. function WebXRManagedOutputCanvas(helper, canvas) {
  19139. var _this = this;
  19140. this._canvas = null;
  19141. /**
  19142. * xrpresent context of the canvas which can be used to display/mirror xr content
  19143. */
  19144. this.canvasContext = null;
  19145. if (!canvas) {
  19146. canvas = document.createElement('canvas');
  19147. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
  19148. }
  19149. this._setManagedOutputCanvas(canvas);
  19150. helper.onStateChangedObservable.add(function (stateInfo) {
  19151. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  19152. // 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
  19153. _this._addCanvas();
  19154. }
  19155. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  19156. _this._removeCanvas();
  19157. }
  19158. });
  19159. }
  19160. /**
  19161. * Disposes of the object
  19162. */
  19163. WebXRManagedOutputCanvas.prototype.dispose = function () {
  19164. this._removeCanvas();
  19165. this._setManagedOutputCanvas(null);
  19166. };
  19167. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  19168. this._removeCanvas();
  19169. if (!canvas) {
  19170. this._canvas = null;
  19171. this.canvasContext = null;
  19172. }
  19173. else {
  19174. this._canvas = canvas;
  19175. this.canvasContext = this._canvas.getContext('xrpresent');
  19176. }
  19177. };
  19178. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  19179. if (this._canvas) {
  19180. document.body.appendChild(this._canvas);
  19181. }
  19182. };
  19183. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  19184. if (this._canvas && document.body.contains(this._canvas)) {
  19185. document.body.removeChild(this._canvas);
  19186. }
  19187. };
  19188. return WebXRManagedOutputCanvas;
  19189. }());
  19190. /***/ }),
  19191. /***/ "./Cameras/XR/webXRSessionManager.ts":
  19192. /*!*******************************************!*\
  19193. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  19194. \*******************************************/
  19195. /*! exports provided: WebXRSessionManager */
  19196. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19197. "use strict";
  19198. __webpack_require__.r(__webpack_exports__);
  19199. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  19200. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  19201. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  19202. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  19203. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  19204. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  19205. /**
  19206. * Manages an XRSession
  19207. * @see https://doc.babylonjs.com/how_to/webxr
  19208. */
  19209. var WebXRSessionManager = /** @class */ (function () {
  19210. /**
  19211. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  19212. * @param scene The scene which the session should be created for
  19213. */
  19214. function WebXRSessionManager(scene) {
  19215. this.scene = scene;
  19216. /**
  19217. * Fires every time a new xrFrame arrives which can be used to update the camera
  19218. */
  19219. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19220. /**
  19221. * Fires when the xr session is ended either by the device or manually done
  19222. */
  19223. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  19224. /** @hidden */
  19225. this._sessionRenderTargetTexture = null;
  19226. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  19227. }
  19228. /**
  19229. * Initializes the manager
  19230. * After initialization enterXR can be called to start an XR session
  19231. * @returns Promise which resolves after it is initialized
  19232. */
  19233. WebXRSessionManager.prototype.initializeAsync = function () {
  19234. var _this = this;
  19235. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  19236. // Check if the browser supports webXR
  19237. this._xrNavigator = navigator;
  19238. if (!this._xrNavigator.xr) {
  19239. return Promise.reject("webXR not supported by this browser");
  19240. }
  19241. // Request the webXR device
  19242. return this._xrNavigator.xr.requestDevice().then(function (device) {
  19243. _this._xrDevice = device;
  19244. return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
  19245. });
  19246. };
  19247. /**
  19248. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  19249. * @param sessionCreationOptions xr options to create the session with
  19250. * @param frameOfReferenceType option to configure how the xr pose is expressed
  19251. * @returns Promise which resolves after it enters XR
  19252. */
  19253. WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
  19254. var _this = this;
  19255. // initialize session
  19256. return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
  19257. _this._xrSession = session;
  19258. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  19259. _this._xrSession.addEventListener("end", function () {
  19260. // Remove render target texture and notify frame obervers
  19261. _this._sessionRenderTargetTexture = null;
  19262. // Restore frame buffer to avoid clear on xr framebuffer after session end
  19263. _this.scene.getEngine().restoreDefaultFramebuffer();
  19264. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  19265. _this.scene.getEngine().customAnimationFrameRequester = null;
  19266. _this.onXRSessionEnded.notifyObservers(null);
  19267. _this.scene.getEngine()._renderLoop();
  19268. }, { once: true });
  19269. _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
  19270. return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
  19271. }).then(function (frameOfRef) {
  19272. _this._frameOfReference = frameOfRef;
  19273. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  19274. _this.scene.getEngine().customAnimationFrameRequester = {
  19275. requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
  19276. renderFunction: function (timestamp, xrFrame) {
  19277. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  19278. _this._currentXRFrame = xrFrame;
  19279. _this.onXRFrameObservable.notifyObservers(null);
  19280. _this.scene.getEngine()._renderLoop();
  19281. }
  19282. };
  19283. // Create render target texture from xr's webgl render target
  19284. _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
  19285. // Stop window's animation frame and trigger sessions animation frame
  19286. window.cancelAnimationFrame(_this.scene.getEngine()._frameHandler);
  19287. _this.scene.getEngine()._renderLoop();
  19288. });
  19289. };
  19290. /**
  19291. * Stops the xrSession and restores the renderloop
  19292. * @returns Promise which resolves after it exits XR
  19293. */
  19294. WebXRSessionManager.prototype.exitXRAsync = function () {
  19295. return this._xrSession.end();
  19296. };
  19297. /**
  19298. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  19299. * @param ray ray to cast into the environment
  19300. * @returns Promise which resolves with a collision point in the environment if it exists
  19301. */
  19302. WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
  19303. var _this = this;
  19304. return new Promise(function (res) {
  19305. // Compute left handed inputs to request hit test
  19306. var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
  19307. var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
  19308. if (!_this.scene.useRightHandedSystem) {
  19309. origin[2] *= -1;
  19310. direction[2] *= -1;
  19311. }
  19312. // Fire hittest
  19313. _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
  19314. .then(function (hits) {
  19315. if (hits.length > 0) {
  19316. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
  19317. var hitPoint = _this._tmpMatrix.getTranslation();
  19318. if (!_this.scene.useRightHandedSystem) {
  19319. hitPoint.z *= -1;
  19320. }
  19321. res(hitPoint);
  19322. }
  19323. else {
  19324. res(null);
  19325. }
  19326. }).catch(function () {
  19327. res(null);
  19328. });
  19329. });
  19330. };
  19331. /**
  19332. * Checks if a session would be supported for the creation options specified
  19333. * @param options creation options to check if they are supported
  19334. * @returns true if supported
  19335. */
  19336. WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
  19337. return this._xrDevice.supportsSession(options).then(function () {
  19338. return true;
  19339. }).catch(function () {
  19340. return false;
  19341. });
  19342. };
  19343. /**
  19344. * @hidden
  19345. * Converts the render layer of xrSession to a render target
  19346. * @param session session to create render target for
  19347. * @param scene scene the new render target should be created for
  19348. */
  19349. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
  19350. // Create internal texture
  19351. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  19352. internalTexture.width = session.baseLayer.framebufferWidth;
  19353. internalTexture.height = session.baseLayer.framebufferHeight;
  19354. internalTexture._framebuffer = session.baseLayer.framebuffer;
  19355. // Create render target texture from the internal texture
  19356. 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);
  19357. renderTargetTexture._texture = internalTexture;
  19358. return renderTargetTexture;
  19359. };
  19360. /**
  19361. * Disposes of the session manager
  19362. */
  19363. WebXRSessionManager.prototype.dispose = function () {
  19364. this.onXRFrameObservable.clear();
  19365. this.onXRSessionEnded.clear();
  19366. };
  19367. return WebXRSessionManager;
  19368. }());
  19369. /***/ }),
  19370. /***/ "./Cameras/arcRotateCamera.ts":
  19371. /*!************************************!*\
  19372. !*** ./Cameras/arcRotateCamera.ts ***!
  19373. \************************************/
  19374. /*! exports provided: ArcRotateCamera */
  19375. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19376. "use strict";
  19377. __webpack_require__.r(__webpack_exports__);
  19378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  19379. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19380. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  19381. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  19382. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  19383. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  19384. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  19385. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  19386. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  19387. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  19388. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  19389. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  19390. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  19391. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  19392. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  19393. });
  19394. /**
  19395. * This represents an orbital type of camera.
  19396. *
  19397. * 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.
  19398. * 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.
  19399. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  19400. */
  19401. var ArcRotateCamera = /** @class */ (function (_super) {
  19402. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  19403. /**
  19404. * Instantiates a new ArcRotateCamera in a given scene
  19405. * @param name Defines the name of the camera
  19406. * @param alpha Defines the camera rotation along the logitudinal axis
  19407. * @param beta Defines the camera rotation along the latitudinal axis
  19408. * @param radius Defines the camera distance from its target
  19409. * @param target Defines the camera target
  19410. * @param scene Defines the scene the camera belongs to
  19411. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19412. */
  19413. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  19414. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  19415. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  19416. _this._upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  19417. /**
  19418. * Current inertia value on the longitudinal axis.
  19419. * The bigger this number the longer it will take for the camera to stop.
  19420. */
  19421. _this.inertialAlphaOffset = 0;
  19422. /**
  19423. * Current inertia value on the latitudinal axis.
  19424. * The bigger this number the longer it will take for the camera to stop.
  19425. */
  19426. _this.inertialBetaOffset = 0;
  19427. /**
  19428. * Current inertia value on the radius axis.
  19429. * The bigger this number the longer it will take for the camera to stop.
  19430. */
  19431. _this.inertialRadiusOffset = 0;
  19432. /**
  19433. * Minimum allowed angle on the longitudinal axis.
  19434. * This can help limiting how the Camera is able to move in the scene.
  19435. */
  19436. _this.lowerAlphaLimit = null;
  19437. /**
  19438. * Maximum allowed angle on the longitudinal axis.
  19439. * This can help limiting how the Camera is able to move in the scene.
  19440. */
  19441. _this.upperAlphaLimit = null;
  19442. /**
  19443. * Minimum allowed angle on the latitudinal axis.
  19444. * This can help limiting how the Camera is able to move in the scene.
  19445. */
  19446. _this.lowerBetaLimit = 0.01;
  19447. /**
  19448. * Maximum allowed angle on the latitudinal axis.
  19449. * This can help limiting how the Camera is able to move in the scene.
  19450. */
  19451. _this.upperBetaLimit = Math.PI - 0.01;
  19452. /**
  19453. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  19454. * This can help limiting how the Camera is able to move in the scene.
  19455. */
  19456. _this.lowerRadiusLimit = null;
  19457. /**
  19458. * Maximum allowed distance of the camera to the target (The camera can not get further).
  19459. * This can help limiting how the Camera is able to move in the scene.
  19460. */
  19461. _this.upperRadiusLimit = null;
  19462. /**
  19463. * Defines the current inertia value used during panning of the camera along the X axis.
  19464. */
  19465. _this.inertialPanningX = 0;
  19466. /**
  19467. * Defines the current inertia value used during panning of the camera along the Y axis.
  19468. */
  19469. _this.inertialPanningY = 0;
  19470. /**
  19471. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  19472. * Basically if your fingers moves away from more than this distance you will be considered
  19473. * in pinch mode.
  19474. */
  19475. _this.pinchToPanMaxDistance = 20;
  19476. /**
  19477. * Defines the maximum distance the camera can pan.
  19478. * This could help keeping the cammera always in your scene.
  19479. */
  19480. _this.panningDistanceLimit = null;
  19481. /**
  19482. * Defines the target of the camera before paning.
  19483. */
  19484. _this.panningOriginTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19485. /**
  19486. * Defines the value of the inertia used during panning.
  19487. * 0 would mean stop inertia and one would mean no decelleration at all.
  19488. */
  19489. _this.panningInertia = 0.9;
  19490. //-- end properties for backward compatibility for inputs
  19491. /**
  19492. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  19493. */
  19494. _this.zoomOnFactor = 1;
  19495. /**
  19496. * Defines a screen offset for the camera position.
  19497. */
  19498. _this.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19499. /**
  19500. * Allows the camera to be completely reversed.
  19501. * If false the camera can not arrive upside down.
  19502. */
  19503. _this.allowUpsideDown = true;
  19504. /**
  19505. * Define if double tap/click is used to restore the previously saved state of the camera.
  19506. */
  19507. _this.useInputToRestoreState = true;
  19508. /** @hidden */
  19509. _this._viewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19510. /**
  19511. * Defines the allowed panning axis.
  19512. */
  19513. _this.panningAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  19514. /**
  19515. * Observable triggered when the mesh target has been changed on the camera.
  19516. */
  19517. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  19518. /**
  19519. * Defines whether the camera should check collision with the objects oh the scene.
  19520. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  19521. */
  19522. _this.checkCollisions = false;
  19523. /**
  19524. * Defines the collision radius of the camera.
  19525. * This simulates a sphere around the camera.
  19526. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19527. */
  19528. _this.collisionRadius = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  19529. _this._previousPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19530. _this._collisionVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19531. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19532. _this._computationVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19533. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  19534. if (collidedMesh === void 0) { collidedMesh = null; }
  19535. if (!collidedMesh) {
  19536. _this._previousPosition.copyFrom(_this._position);
  19537. }
  19538. else {
  19539. _this.setPosition(newPosition);
  19540. if (_this.onCollide) {
  19541. _this.onCollide(collidedMesh);
  19542. }
  19543. }
  19544. // Recompute because of constraints
  19545. var cosa = Math.cos(_this.alpha);
  19546. var sina = Math.sin(_this.alpha);
  19547. var cosb = Math.cos(_this.beta);
  19548. var sinb = Math.sin(_this.beta);
  19549. if (sinb === 0) {
  19550. sinb = 0.0001;
  19551. }
  19552. var target = _this._getTargetPosition();
  19553. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  19554. target.addToRef(_this._computationVector, _this._newPosition);
  19555. _this._position.copyFrom(_this._newPosition);
  19556. var up = _this.upVector;
  19557. if (_this.allowUpsideDown && _this.beta < 0) {
  19558. up = up.clone();
  19559. up = up.negate();
  19560. }
  19561. _this._computeViewMatrix(_this._position, target, up);
  19562. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  19563. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  19564. _this._collisionTriggered = false;
  19565. };
  19566. _this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19567. if (target) {
  19568. _this.setTarget(target);
  19569. }
  19570. _this.alpha = alpha;
  19571. _this.beta = beta;
  19572. _this.radius = radius;
  19573. _this.getViewMatrix();
  19574. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["ArcRotateCameraInputsManager"](_this);
  19575. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  19576. return _this;
  19577. }
  19578. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  19579. /**
  19580. * Defines the target point of the camera.
  19581. * The camera looks towards it form the radius distance.
  19582. */
  19583. get: function () {
  19584. return this._target;
  19585. },
  19586. set: function (value) {
  19587. this.setTarget(value);
  19588. },
  19589. enumerable: true,
  19590. configurable: true
  19591. });
  19592. Object.defineProperty(ArcRotateCamera.prototype, "position", {
  19593. /**
  19594. * Define the current local position of the camera in the scene
  19595. */
  19596. get: function () {
  19597. return this._position;
  19598. },
  19599. set: function (newPosition) {
  19600. this.setPosition(newPosition);
  19601. },
  19602. enumerable: true,
  19603. configurable: true
  19604. });
  19605. Object.defineProperty(ArcRotateCamera.prototype, "upVector", {
  19606. get: function () {
  19607. return this._upVector;
  19608. },
  19609. /**
  19610. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  19611. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  19612. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  19613. */
  19614. set: function (vec) {
  19615. if (!this._upToYMatrix) {
  19616. this._YToUpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19617. this._upToYMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19618. this._upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19619. }
  19620. vec.normalize();
  19621. this._upVector.copyFrom(vec);
  19622. this.setMatUp();
  19623. },
  19624. enumerable: true,
  19625. configurable: true
  19626. });
  19627. /**
  19628. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  19629. */
  19630. ArcRotateCamera.prototype.setMatUp = function () {
  19631. // from y-up to custom-up (used in _getViewMatrix)
  19632. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAlignToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this._upVector, this._YToUpMatrix);
  19633. // from custom-up to y-up (used in rebuildAnglesAndRadius)
  19634. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAlignToRef(this._upVector, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this._upToYMatrix);
  19635. };
  19636. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  19637. //-- begin properties for backward compatibility for inputs
  19638. /**
  19639. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  19640. */
  19641. get: function () {
  19642. var pointers = this.inputs.attached["pointers"];
  19643. if (pointers) {
  19644. return pointers.angularSensibilityX;
  19645. }
  19646. return 0;
  19647. },
  19648. set: function (value) {
  19649. var pointers = this.inputs.attached["pointers"];
  19650. if (pointers) {
  19651. pointers.angularSensibilityX = value;
  19652. }
  19653. },
  19654. enumerable: true,
  19655. configurable: true
  19656. });
  19657. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  19658. /**
  19659. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  19660. */
  19661. get: function () {
  19662. var pointers = this.inputs.attached["pointers"];
  19663. if (pointers) {
  19664. return pointers.angularSensibilityY;
  19665. }
  19666. return 0;
  19667. },
  19668. set: function (value) {
  19669. var pointers = this.inputs.attached["pointers"];
  19670. if (pointers) {
  19671. pointers.angularSensibilityY = value;
  19672. }
  19673. },
  19674. enumerable: true,
  19675. configurable: true
  19676. });
  19677. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  19678. /**
  19679. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  19680. */
  19681. get: function () {
  19682. var pointers = this.inputs.attached["pointers"];
  19683. if (pointers) {
  19684. return pointers.pinchPrecision;
  19685. }
  19686. return 0;
  19687. },
  19688. set: function (value) {
  19689. var pointers = this.inputs.attached["pointers"];
  19690. if (pointers) {
  19691. pointers.pinchPrecision = value;
  19692. }
  19693. },
  19694. enumerable: true,
  19695. configurable: true
  19696. });
  19697. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  19698. /**
  19699. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  19700. * It will be used instead of pinchDeltaPrecision if different from 0.
  19701. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19702. */
  19703. get: function () {
  19704. var pointers = this.inputs.attached["pointers"];
  19705. if (pointers) {
  19706. return pointers.pinchDeltaPercentage;
  19707. }
  19708. return 0;
  19709. },
  19710. set: function (value) {
  19711. var pointers = this.inputs.attached["pointers"];
  19712. if (pointers) {
  19713. pointers.pinchDeltaPercentage = value;
  19714. }
  19715. },
  19716. enumerable: true,
  19717. configurable: true
  19718. });
  19719. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  19720. /**
  19721. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  19722. */
  19723. get: function () {
  19724. var pointers = this.inputs.attached["pointers"];
  19725. if (pointers) {
  19726. return pointers.panningSensibility;
  19727. }
  19728. return 0;
  19729. },
  19730. set: function (value) {
  19731. var pointers = this.inputs.attached["pointers"];
  19732. if (pointers) {
  19733. pointers.panningSensibility = value;
  19734. }
  19735. },
  19736. enumerable: true,
  19737. configurable: true
  19738. });
  19739. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  19740. /**
  19741. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  19742. */
  19743. get: function () {
  19744. var keyboard = this.inputs.attached["keyboard"];
  19745. if (keyboard) {
  19746. return keyboard.keysUp;
  19747. }
  19748. return [];
  19749. },
  19750. set: function (value) {
  19751. var keyboard = this.inputs.attached["keyboard"];
  19752. if (keyboard) {
  19753. keyboard.keysUp = value;
  19754. }
  19755. },
  19756. enumerable: true,
  19757. configurable: true
  19758. });
  19759. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  19760. /**
  19761. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  19762. */
  19763. get: function () {
  19764. var keyboard = this.inputs.attached["keyboard"];
  19765. if (keyboard) {
  19766. return keyboard.keysDown;
  19767. }
  19768. return [];
  19769. },
  19770. set: function (value) {
  19771. var keyboard = this.inputs.attached["keyboard"];
  19772. if (keyboard) {
  19773. keyboard.keysDown = value;
  19774. }
  19775. },
  19776. enumerable: true,
  19777. configurable: true
  19778. });
  19779. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  19780. /**
  19781. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  19782. */
  19783. get: function () {
  19784. var keyboard = this.inputs.attached["keyboard"];
  19785. if (keyboard) {
  19786. return keyboard.keysLeft;
  19787. }
  19788. return [];
  19789. },
  19790. set: function (value) {
  19791. var keyboard = this.inputs.attached["keyboard"];
  19792. if (keyboard) {
  19793. keyboard.keysLeft = value;
  19794. }
  19795. },
  19796. enumerable: true,
  19797. configurable: true
  19798. });
  19799. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  19800. /**
  19801. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  19802. */
  19803. get: function () {
  19804. var keyboard = this.inputs.attached["keyboard"];
  19805. if (keyboard) {
  19806. return keyboard.keysRight;
  19807. }
  19808. return [];
  19809. },
  19810. set: function (value) {
  19811. var keyboard = this.inputs.attached["keyboard"];
  19812. if (keyboard) {
  19813. keyboard.keysRight = value;
  19814. }
  19815. },
  19816. enumerable: true,
  19817. configurable: true
  19818. });
  19819. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  19820. /**
  19821. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  19822. */
  19823. get: function () {
  19824. var mousewheel = this.inputs.attached["mousewheel"];
  19825. if (mousewheel) {
  19826. return mousewheel.wheelPrecision;
  19827. }
  19828. return 0;
  19829. },
  19830. set: function (value) {
  19831. var mousewheel = this.inputs.attached["mousewheel"];
  19832. if (mousewheel) {
  19833. mousewheel.wheelPrecision = value;
  19834. }
  19835. },
  19836. enumerable: true,
  19837. configurable: true
  19838. });
  19839. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  19840. /**
  19841. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  19842. * It will be used instead of pinchDeltaPrecision if different from 0.
  19843. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19844. */
  19845. get: function () {
  19846. var mousewheel = this.inputs.attached["mousewheel"];
  19847. if (mousewheel) {
  19848. return mousewheel.wheelDeltaPercentage;
  19849. }
  19850. return 0;
  19851. },
  19852. set: function (value) {
  19853. var mousewheel = this.inputs.attached["mousewheel"];
  19854. if (mousewheel) {
  19855. mousewheel.wheelDeltaPercentage = value;
  19856. }
  19857. },
  19858. enumerable: true,
  19859. configurable: true
  19860. });
  19861. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  19862. /**
  19863. * Gets the bouncing behavior of the camera if it has been enabled.
  19864. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19865. */
  19866. get: function () {
  19867. return this._bouncingBehavior;
  19868. },
  19869. enumerable: true,
  19870. configurable: true
  19871. });
  19872. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  19873. /**
  19874. * Defines if the bouncing behavior of the camera is enabled on the camera.
  19875. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19876. */
  19877. get: function () {
  19878. return this._bouncingBehavior != null;
  19879. },
  19880. set: function (value) {
  19881. if (value === this.useBouncingBehavior) {
  19882. return;
  19883. }
  19884. if (value) {
  19885. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  19886. this.addBehavior(this._bouncingBehavior);
  19887. }
  19888. else if (this._bouncingBehavior) {
  19889. this.removeBehavior(this._bouncingBehavior);
  19890. this._bouncingBehavior = null;
  19891. }
  19892. },
  19893. enumerable: true,
  19894. configurable: true
  19895. });
  19896. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  19897. /**
  19898. * Gets the framing behavior of the camera if it has been enabled.
  19899. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19900. */
  19901. get: function () {
  19902. return this._framingBehavior;
  19903. },
  19904. enumerable: true,
  19905. configurable: true
  19906. });
  19907. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  19908. /**
  19909. * Defines if the framing behavior of the camera is enabled on the camera.
  19910. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19911. */
  19912. get: function () {
  19913. return this._framingBehavior != null;
  19914. },
  19915. set: function (value) {
  19916. if (value === this.useFramingBehavior) {
  19917. return;
  19918. }
  19919. if (value) {
  19920. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  19921. this.addBehavior(this._framingBehavior);
  19922. }
  19923. else if (this._framingBehavior) {
  19924. this.removeBehavior(this._framingBehavior);
  19925. this._framingBehavior = null;
  19926. }
  19927. },
  19928. enumerable: true,
  19929. configurable: true
  19930. });
  19931. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  19932. /**
  19933. * Gets the auto rotation behavior of the camera if it has been enabled.
  19934. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19935. */
  19936. get: function () {
  19937. return this._autoRotationBehavior;
  19938. },
  19939. enumerable: true,
  19940. configurable: true
  19941. });
  19942. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  19943. /**
  19944. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  19945. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19946. */
  19947. get: function () {
  19948. return this._autoRotationBehavior != null;
  19949. },
  19950. set: function (value) {
  19951. if (value === this.useAutoRotationBehavior) {
  19952. return;
  19953. }
  19954. if (value) {
  19955. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  19956. this.addBehavior(this._autoRotationBehavior);
  19957. }
  19958. else if (this._autoRotationBehavior) {
  19959. this.removeBehavior(this._autoRotationBehavior);
  19960. this._autoRotationBehavior = null;
  19961. }
  19962. },
  19963. enumerable: true,
  19964. configurable: true
  19965. });
  19966. // Cache
  19967. /** @hidden */
  19968. ArcRotateCamera.prototype._initCache = function () {
  19969. _super.prototype._initCache.call(this);
  19970. this._cache._target = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19971. this._cache.alpha = undefined;
  19972. this._cache.beta = undefined;
  19973. this._cache.radius = undefined;
  19974. this._cache.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19975. };
  19976. /** @hidden */
  19977. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  19978. if (!ignoreParentClass) {
  19979. _super.prototype._updateCache.call(this);
  19980. }
  19981. this._cache._target.copyFrom(this._getTargetPosition());
  19982. this._cache.alpha = this.alpha;
  19983. this._cache.beta = this.beta;
  19984. this._cache.radius = this.radius;
  19985. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  19986. };
  19987. ArcRotateCamera.prototype._getTargetPosition = function () {
  19988. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  19989. var pos = this._targetHost.absolutePosition;
  19990. if (this._targetBoundingCenter) {
  19991. pos.addToRef(this._targetBoundingCenter, this._target);
  19992. }
  19993. else {
  19994. this._target.copyFrom(pos);
  19995. }
  19996. }
  19997. var lockedTargetPosition = this._getLockedTargetPosition();
  19998. if (lockedTargetPosition) {
  19999. return lockedTargetPosition;
  20000. }
  20001. return this._target;
  20002. };
  20003. /**
  20004. * Stores the current state of the camera (alpha, beta, radius and target)
  20005. * @returns the camera itself
  20006. */
  20007. ArcRotateCamera.prototype.storeState = function () {
  20008. this._storedAlpha = this.alpha;
  20009. this._storedBeta = this.beta;
  20010. this._storedRadius = this.radius;
  20011. this._storedTarget = this._getTargetPosition().clone();
  20012. return _super.prototype.storeState.call(this);
  20013. };
  20014. /**
  20015. * @hidden
  20016. * Restored camera state. You must call storeState() first
  20017. */
  20018. ArcRotateCamera.prototype._restoreStateValues = function () {
  20019. if (!_super.prototype._restoreStateValues.call(this)) {
  20020. return false;
  20021. }
  20022. this.alpha = this._storedAlpha;
  20023. this.beta = this._storedBeta;
  20024. this.radius = this._storedRadius;
  20025. this.setTarget(this._storedTarget.clone());
  20026. this.inertialAlphaOffset = 0;
  20027. this.inertialBetaOffset = 0;
  20028. this.inertialRadiusOffset = 0;
  20029. this.inertialPanningX = 0;
  20030. this.inertialPanningY = 0;
  20031. return true;
  20032. };
  20033. // Synchronized
  20034. /** @hidden */
  20035. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  20036. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  20037. return false;
  20038. }
  20039. return this._cache._target.equals(this._getTargetPosition())
  20040. && this._cache.alpha === this.alpha
  20041. && this._cache.beta === this.beta
  20042. && this._cache.radius === this.radius
  20043. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  20044. };
  20045. /**
  20046. * Attached controls to the current camera.
  20047. * @param element Defines the element the controls should be listened from
  20048. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20049. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  20050. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  20051. */
  20052. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  20053. var _this = this;
  20054. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  20055. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  20056. this._useCtrlForPanning = useCtrlForPanning;
  20057. this._panningMouseButton = panningMouseButton;
  20058. this.inputs.attachElement(element, noPreventDefault);
  20059. this._reset = function () {
  20060. _this.inertialAlphaOffset = 0;
  20061. _this.inertialBetaOffset = 0;
  20062. _this.inertialRadiusOffset = 0;
  20063. _this.inertialPanningX = 0;
  20064. _this.inertialPanningY = 0;
  20065. };
  20066. };
  20067. /**
  20068. * Detach the current controls from the camera.
  20069. * The camera will stop reacting to inputs.
  20070. * @param element Defines the element to stop listening the inputs from
  20071. */
  20072. ArcRotateCamera.prototype.detachControl = function (element) {
  20073. this.inputs.detachElement(element);
  20074. if (this._reset) {
  20075. this._reset();
  20076. }
  20077. };
  20078. /** @hidden */
  20079. ArcRotateCamera.prototype._checkInputs = function () {
  20080. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  20081. if (this._collisionTriggered) {
  20082. return;
  20083. }
  20084. this.inputs.checkInputs();
  20085. // Inertia
  20086. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  20087. var inertialAlphaOffset = this.inertialAlphaOffset;
  20088. if (this.beta <= 0) {
  20089. inertialAlphaOffset *= -1;
  20090. }
  20091. if (this.getScene().useRightHandedSystem) {
  20092. inertialAlphaOffset *= -1;
  20093. }
  20094. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  20095. inertialAlphaOffset *= -1;
  20096. }
  20097. this.alpha += inertialAlphaOffset;
  20098. this.beta += this.inertialBetaOffset;
  20099. this.radius -= this.inertialRadiusOffset;
  20100. this.inertialAlphaOffset *= this.inertia;
  20101. this.inertialBetaOffset *= this.inertia;
  20102. this.inertialRadiusOffset *= this.inertia;
  20103. if (Math.abs(this.inertialAlphaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20104. this.inertialAlphaOffset = 0;
  20105. }
  20106. if (Math.abs(this.inertialBetaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20107. this.inertialBetaOffset = 0;
  20108. }
  20109. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20110. this.inertialRadiusOffset = 0;
  20111. }
  20112. }
  20113. // Panning inertia
  20114. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  20115. if (!this._localDirection) {
  20116. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20117. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  20118. }
  20119. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  20120. this._localDirection.multiplyInPlace(this.panningAxis);
  20121. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  20122. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  20123. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  20124. if (!this.panningAxis.y) {
  20125. this._transformedDirection.y = 0;
  20126. }
  20127. if (!this._targetHost) {
  20128. if (this.panningDistanceLimit) {
  20129. this._transformedDirection.addInPlace(this._target);
  20130. var distanceSquared = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  20131. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  20132. this._target.copyFrom(this._transformedDirection);
  20133. }
  20134. }
  20135. else {
  20136. this._target.addInPlace(this._transformedDirection);
  20137. }
  20138. }
  20139. this.inertialPanningX *= this.panningInertia;
  20140. this.inertialPanningY *= this.panningInertia;
  20141. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20142. this.inertialPanningX = 0;
  20143. }
  20144. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  20145. this.inertialPanningY = 0;
  20146. }
  20147. }
  20148. // Limits
  20149. this._checkLimits();
  20150. _super.prototype._checkInputs.call(this);
  20151. };
  20152. ArcRotateCamera.prototype._checkLimits = function () {
  20153. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  20154. if (this.allowUpsideDown && this.beta > Math.PI) {
  20155. this.beta = this.beta - (2 * Math.PI);
  20156. }
  20157. }
  20158. else {
  20159. if (this.beta < this.lowerBetaLimit) {
  20160. this.beta = this.lowerBetaLimit;
  20161. }
  20162. }
  20163. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  20164. if (this.allowUpsideDown && this.beta < -Math.PI) {
  20165. this.beta = this.beta + (2 * Math.PI);
  20166. }
  20167. }
  20168. else {
  20169. if (this.beta > this.upperBetaLimit) {
  20170. this.beta = this.upperBetaLimit;
  20171. }
  20172. }
  20173. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  20174. this.alpha = this.lowerAlphaLimit;
  20175. }
  20176. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  20177. this.alpha = this.upperAlphaLimit;
  20178. }
  20179. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  20180. this.radius = this.lowerRadiusLimit;
  20181. this.inertialRadiusOffset = 0;
  20182. }
  20183. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  20184. this.radius = this.upperRadiusLimit;
  20185. this.inertialRadiusOffset = 0;
  20186. }
  20187. };
  20188. /**
  20189. * Rebuilds angles (alpha, beta) and radius from the give position and target
  20190. */
  20191. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function () {
  20192. this._position.subtractToRef(this._getTargetPosition(), this._computationVector);
  20193. // need to rotate to Y up equivalent if up vector not Axis.Y
  20194. if (this._upVector.x !== 0 || this._upVector.y !== 1.0 || this._upVector.z !== 0) {
  20195. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._computationVector, this._upToYMatrix, this._computationVector);
  20196. }
  20197. this.radius = this._computationVector.length();
  20198. if (this.radius === 0) {
  20199. this.radius = 0.0001; // Just to avoid division by zero
  20200. }
  20201. // Alpha
  20202. if (this._computationVector.x === 0 && this._computationVector.z === 0) {
  20203. this.alpha = Math.PI / 2; // avoid division by zero when looking along up axis, and set to acos(0)
  20204. }
  20205. else {
  20206. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  20207. }
  20208. if (this._computationVector.z < 0) {
  20209. this.alpha = 2 * Math.PI - this.alpha;
  20210. }
  20211. // Beta
  20212. this.beta = Math.acos(this._computationVector.y / this.radius);
  20213. this._checkLimits();
  20214. };
  20215. /**
  20216. * Use a position to define the current camera related information like aplha, beta and radius
  20217. * @param position Defines the position to set the camera at
  20218. */
  20219. ArcRotateCamera.prototype.setPosition = function (position) {
  20220. if (this._position.equals(position)) {
  20221. return;
  20222. }
  20223. this._position.copyFrom(position);
  20224. this.rebuildAnglesAndRadius();
  20225. };
  20226. /**
  20227. * Defines the target the camera should look at.
  20228. * This will automatically adapt alpha beta and radius to fit within the new target.
  20229. * @param target Defines the new target as a Vector or a mesh
  20230. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  20231. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  20232. */
  20233. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  20234. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  20235. if (allowSamePosition === void 0) { allowSamePosition = false; }
  20236. if (target.getBoundingInfo) {
  20237. if (toBoundingCenter) {
  20238. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  20239. }
  20240. else {
  20241. this._targetBoundingCenter = null;
  20242. }
  20243. target.computeWorldMatrix();
  20244. this._targetHost = target;
  20245. this._target = this._getTargetPosition();
  20246. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  20247. }
  20248. else {
  20249. var newTarget = target;
  20250. var currentTarget = this._getTargetPosition();
  20251. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  20252. return;
  20253. }
  20254. this._targetHost = null;
  20255. this._target = newTarget;
  20256. this._targetBoundingCenter = null;
  20257. this.onMeshTargetChangedObservable.notifyObservers(null);
  20258. }
  20259. this.rebuildAnglesAndRadius();
  20260. };
  20261. /** @hidden */
  20262. ArcRotateCamera.prototype._getViewMatrix = function () {
  20263. // Compute
  20264. var cosa = Math.cos(this.alpha);
  20265. var sina = Math.sin(this.alpha);
  20266. var cosb = Math.cos(this.beta);
  20267. var sinb = Math.sin(this.beta);
  20268. if (sinb === 0) {
  20269. sinb = 0.0001;
  20270. }
  20271. var target = this._getTargetPosition();
  20272. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  20273. // Rotate according to up vector
  20274. if (this._upVector.x !== 0 || this._upVector.y !== 1.0 || this._upVector.z !== 0) {
  20275. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._computationVector, this._YToUpMatrix, this._computationVector);
  20276. }
  20277. target.addToRef(this._computationVector, this._newPosition);
  20278. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  20279. var coordinator = this.getScene().collisionCoordinator;
  20280. if (!this._collider) {
  20281. this._collider = coordinator.createCollider();
  20282. }
  20283. this._collider._radius = this.collisionRadius;
  20284. this._newPosition.subtractToRef(this._position, this._collisionVelocity);
  20285. this._collisionTriggered = true;
  20286. coordinator.getNewPosition(this._position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  20287. }
  20288. else {
  20289. this._position.copyFrom(this._newPosition);
  20290. var up = this.upVector;
  20291. if (this.allowUpsideDown && sinb < 0) {
  20292. up = up.clone();
  20293. up = up.negate();
  20294. }
  20295. this._computeViewMatrix(this._position, target, up);
  20296. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  20297. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  20298. }
  20299. this._currentTarget = target;
  20300. return this._viewMatrix;
  20301. };
  20302. /**
  20303. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  20304. * @param meshes Defines the mesh to zoom on
  20305. * @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)
  20306. */
  20307. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  20308. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  20309. meshes = meshes || this.getScene().meshes;
  20310. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  20311. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  20312. this.radius = distance * this.zoomOnFactor;
  20313. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  20314. };
  20315. /**
  20316. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  20317. * The target will be changed but the radius
  20318. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  20319. * @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)
  20320. */
  20321. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  20322. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  20323. var meshesOrMinMaxVector;
  20324. var distance;
  20325. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  20326. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  20327. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  20328. distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  20329. }
  20330. else { //minMaxVector and distance
  20331. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  20332. meshesOrMinMaxVector = minMaxVectorAndDistance;
  20333. distance = minMaxVectorAndDistance.distance;
  20334. }
  20335. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  20336. if (!doNotUpdateMaxZ) {
  20337. this.maxZ = distance * 2;
  20338. }
  20339. };
  20340. /**
  20341. * @override
  20342. * Override Camera.createRigCamera
  20343. */
  20344. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  20345. var alphaShift = 0;
  20346. switch (this.cameraRigMode) {
  20347. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20348. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20349. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20350. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  20351. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  20352. break;
  20353. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20354. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  20355. break;
  20356. }
  20357. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  20358. rigCam._cameraRigParams = {};
  20359. return rigCam;
  20360. };
  20361. /**
  20362. * @hidden
  20363. * @override
  20364. * Override Camera._updateRigCameras
  20365. */
  20366. ArcRotateCamera.prototype._updateRigCameras = function () {
  20367. var camLeft = this._rigCameras[0];
  20368. var camRight = this._rigCameras[1];
  20369. camLeft.beta = camRight.beta = this.beta;
  20370. switch (this.cameraRigMode) {
  20371. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20372. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20373. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20374. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  20375. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  20376. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  20377. break;
  20378. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20379. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  20380. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  20381. break;
  20382. }
  20383. _super.prototype._updateRigCameras.call(this);
  20384. };
  20385. /**
  20386. * Destroy the camera and release the current resources hold by it.
  20387. */
  20388. ArcRotateCamera.prototype.dispose = function () {
  20389. this.inputs.clear();
  20390. _super.prototype.dispose.call(this);
  20391. };
  20392. /**
  20393. * Gets the current object class name.
  20394. * @return the class name
  20395. */
  20396. ArcRotateCamera.prototype.getClassName = function () {
  20397. return "ArcRotateCamera";
  20398. };
  20399. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20400. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20401. ], ArcRotateCamera.prototype, "alpha", void 0);
  20402. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20403. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20404. ], ArcRotateCamera.prototype, "beta", void 0);
  20405. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20406. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20407. ], ArcRotateCamera.prototype, "radius", void 0);
  20408. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20409. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  20410. ], ArcRotateCamera.prototype, "_target", void 0);
  20411. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20412. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("upVector")
  20413. ], ArcRotateCamera.prototype, "_upVector", void 0);
  20414. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20415. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20416. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  20417. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20418. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20419. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  20420. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20421. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20422. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  20423. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20424. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20425. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  20426. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20427. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20428. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  20429. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20430. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20431. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  20432. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20433. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20434. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  20435. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20436. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20437. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  20438. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20439. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20440. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  20441. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20442. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20443. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  20444. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20445. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20446. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  20447. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20448. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20449. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  20450. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20451. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20452. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  20453. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20454. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20455. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  20456. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20457. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20458. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  20459. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20460. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20461. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  20462. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20463. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20464. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  20465. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20466. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20467. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  20468. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20469. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20470. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  20471. return ArcRotateCamera;
  20472. }(_targetCamera__WEBPACK_IMPORTED_MODULE_10__["TargetCamera"]));
  20473. /***/ }),
  20474. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  20475. /*!*************************************************!*\
  20476. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  20477. \*************************************************/
  20478. /*! exports provided: ArcRotateCameraInputsManager */
  20479. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20480. "use strict";
  20481. __webpack_require__.r(__webpack_exports__);
  20482. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  20483. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20484. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  20485. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  20486. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  20487. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  20488. /**
  20489. * Default Inputs manager for the ArcRotateCamera.
  20490. * It groups all the default supported inputs for ease of use.
  20491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  20492. */
  20493. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  20494. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  20495. /**
  20496. * Instantiates a new ArcRotateCameraInputsManager.
  20497. * @param camera Defines the camera the inputs belong to
  20498. */
  20499. function ArcRotateCameraInputsManager(camera) {
  20500. return _super.call(this, camera) || this;
  20501. }
  20502. /**
  20503. * Add mouse wheel input support to the input manager.
  20504. * @returns the current input manager
  20505. */
  20506. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  20507. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraMouseWheelInput"]());
  20508. return this;
  20509. };
  20510. /**
  20511. * Add pointers input support to the input manager.
  20512. * @returns the current input manager
  20513. */
  20514. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  20515. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraPointersInput"]());
  20516. return this;
  20517. };
  20518. /**
  20519. * Add keyboard input support to the input manager.
  20520. * @returns the current input manager
  20521. */
  20522. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  20523. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraKeyboardMoveInput"]());
  20524. return this;
  20525. };
  20526. return ArcRotateCameraInputsManager;
  20527. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__["CameraInputsManager"]));
  20528. /***/ }),
  20529. /***/ "./Cameras/camera.ts":
  20530. /*!***************************!*\
  20531. !*** ./Cameras/camera.ts ***!
  20532. \***************************/
  20533. /*! exports provided: Camera */
  20534. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  20535. "use strict";
  20536. __webpack_require__.r(__webpack_exports__);
  20537. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  20538. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  20539. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  20540. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  20541. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  20542. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  20543. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  20544. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  20545. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  20546. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  20547. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  20548. /**
  20549. * This is the base class of all the camera used in the application.
  20550. * @see http://doc.babylonjs.com/features/cameras
  20551. */
  20552. var Camera = /** @class */ (function (_super) {
  20553. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  20554. /**
  20555. * Instantiates a new camera object.
  20556. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  20557. * @see http://doc.babylonjs.com/features/cameras
  20558. * @param name Defines the name of the camera in the scene
  20559. * @param position Defines the position of the camera
  20560. * @param scene Defines the scene the camera belongs too
  20561. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  20562. */
  20563. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  20564. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  20565. var _this = _super.call(this, name, scene) || this;
  20566. /** @hidden */
  20567. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20568. /**
  20569. * The vector the camera should consider as up.
  20570. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  20571. */
  20572. _this.upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  20573. /**
  20574. * Define the current limit on the left side for an orthographic camera
  20575. * In scene unit
  20576. */
  20577. _this.orthoLeft = null;
  20578. /**
  20579. * Define the current limit on the right side for an orthographic camera
  20580. * In scene unit
  20581. */
  20582. _this.orthoRight = null;
  20583. /**
  20584. * Define the current limit on the bottom side for an orthographic camera
  20585. * In scene unit
  20586. */
  20587. _this.orthoBottom = null;
  20588. /**
  20589. * Define the current limit on the top side for an orthographic camera
  20590. * In scene unit
  20591. */
  20592. _this.orthoTop = null;
  20593. /**
  20594. * Field Of View is set in Radians. (default is 0.8)
  20595. */
  20596. _this.fov = 0.8;
  20597. /**
  20598. * Define the minimum distance the camera can see from.
  20599. * This is important to note that the depth buffer are not infinite and the closer it starts
  20600. * the more your scene might encounter depth fighting issue.
  20601. */
  20602. _this.minZ = 1;
  20603. /**
  20604. * Define the maximum distance the camera can see to.
  20605. * This is important to note that the depth buffer are not infinite and the further it end
  20606. * the more your scene might encounter depth fighting issue.
  20607. */
  20608. _this.maxZ = 10000.0;
  20609. /**
  20610. * Define the default inertia of the camera.
  20611. * This helps giving a smooth feeling to the camera movement.
  20612. */
  20613. _this.inertia = 0.9;
  20614. /**
  20615. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  20616. */
  20617. _this.mode = Camera.PERSPECTIVE_CAMERA;
  20618. /**
  20619. * Define wether the camera is intermediate.
  20620. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  20621. */
  20622. _this.isIntermediate = false;
  20623. /**
  20624. * Define the viewport of the camera.
  20625. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  20626. */
  20627. _this.viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 1.0, 1.0);
  20628. /**
  20629. * Restricts the camera to viewing objects with the same layerMask.
  20630. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  20631. */
  20632. _this.layerMask = 0x0FFFFFFF;
  20633. /**
  20634. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  20635. */
  20636. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  20637. /**
  20638. * Rig mode of the camera.
  20639. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  20640. * This is normally controlled byt the camera themselves as internal use.
  20641. */
  20642. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  20643. /**
  20644. * 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
  20645. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  20646. * else in the scene.
  20647. */
  20648. _this.customRenderTargets = new Array();
  20649. /**
  20650. * When set, the camera will render to this render target instead of the default canvas
  20651. */
  20652. _this.outputRenderTarget = null;
  20653. /**
  20654. * Observable triggered when the camera view matrix has changed.
  20655. */
  20656. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20657. /**
  20658. * Observable triggered when the camera Projection matrix has changed.
  20659. */
  20660. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20661. /**
  20662. * Observable triggered when the inputs have been processed.
  20663. */
  20664. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20665. /**
  20666. * Observable triggered when reset has been called and applied to the camera.
  20667. */
  20668. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20669. /** @hidden */
  20670. _this._rigCameras = new Array();
  20671. _this._webvrViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20672. /** @hidden */
  20673. _this._skipRendering = false;
  20674. /** @hidden */
  20675. _this._projectionMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  20676. /** @hidden */
  20677. _this._postProcesses = new Array();
  20678. /** @hidden */
  20679. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  20680. _this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20681. /** hidden */
  20682. _this._computedViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20683. _this._doNotComputeProjectionMatrix = false;
  20684. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  20685. _this._refreshFrustumPlanes = true;
  20686. /** @hidden */
  20687. _this._isCamera = true;
  20688. /** @hidden */
  20689. _this._isLeftCamera = false;
  20690. /** @hidden */
  20691. _this._isRightCamera = true;
  20692. _this.getScene().addCamera(_this);
  20693. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  20694. _this.getScene().activeCamera = _this;
  20695. }
  20696. _this.position = position;
  20697. return _this;
  20698. }
  20699. Object.defineProperty(Camera.prototype, "position", {
  20700. /**
  20701. * Define the current local position of the camera in the scene
  20702. */
  20703. get: function () {
  20704. return this._position;
  20705. },
  20706. set: function (newPosition) {
  20707. this._position = newPosition;
  20708. },
  20709. enumerable: true,
  20710. configurable: true
  20711. });
  20712. /**
  20713. * Store current camera state (fov, position, etc..)
  20714. * @returns the camera
  20715. */
  20716. Camera.prototype.storeState = function () {
  20717. this._stateStored = true;
  20718. this._storedFov = this.fov;
  20719. return this;
  20720. };
  20721. /**
  20722. * Restores the camera state values if it has been stored. You must call storeState() first
  20723. */
  20724. Camera.prototype._restoreStateValues = function () {
  20725. if (!this._stateStored) {
  20726. return false;
  20727. }
  20728. this.fov = this._storedFov;
  20729. return true;
  20730. };
  20731. /**
  20732. * Restored camera state. You must call storeState() first.
  20733. * @returns true if restored and false otherwise
  20734. */
  20735. Camera.prototype.restoreState = function () {
  20736. if (this._restoreStateValues()) {
  20737. this.onRestoreStateObservable.notifyObservers(this);
  20738. return true;
  20739. }
  20740. return false;
  20741. };
  20742. /**
  20743. * Gets the class name of the camera.
  20744. * @returns the class name
  20745. */
  20746. Camera.prototype.getClassName = function () {
  20747. return "Camera";
  20748. };
  20749. /**
  20750. * Gets a string representation of the camera useful for debug purpose.
  20751. * @param fullDetails Defines that a more verboe level of logging is required
  20752. * @returns the string representation
  20753. */
  20754. Camera.prototype.toString = function (fullDetails) {
  20755. var ret = "Name: " + this.name;
  20756. ret += ", type: " + this.getClassName();
  20757. if (this.animations) {
  20758. for (var i = 0; i < this.animations.length; i++) {
  20759. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  20760. }
  20761. }
  20762. if (fullDetails) {
  20763. }
  20764. return ret;
  20765. };
  20766. Object.defineProperty(Camera.prototype, "globalPosition", {
  20767. /**
  20768. * Gets the current world space position of the camera.
  20769. */
  20770. get: function () {
  20771. return this._globalPosition;
  20772. },
  20773. enumerable: true,
  20774. configurable: true
  20775. });
  20776. /**
  20777. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  20778. * @returns the active meshe list
  20779. */
  20780. Camera.prototype.getActiveMeshes = function () {
  20781. return this._activeMeshes;
  20782. };
  20783. /**
  20784. * Check wether a mesh is part of the current active mesh list of the camera
  20785. * @param mesh Defines the mesh to check
  20786. * @returns true if active, false otherwise
  20787. */
  20788. Camera.prototype.isActiveMesh = function (mesh) {
  20789. return (this._activeMeshes.indexOf(mesh) !== -1);
  20790. };
  20791. /**
  20792. * Is this camera ready to be used/rendered
  20793. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  20794. * @return true if the camera is ready
  20795. */
  20796. Camera.prototype.isReady = function (completeCheck) {
  20797. if (completeCheck === void 0) { completeCheck = false; }
  20798. if (completeCheck) {
  20799. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  20800. var pp = _a[_i];
  20801. if (pp && !pp.isReady()) {
  20802. return false;
  20803. }
  20804. }
  20805. }
  20806. return _super.prototype.isReady.call(this, completeCheck);
  20807. };
  20808. /** @hidden */
  20809. Camera.prototype._initCache = function () {
  20810. _super.prototype._initCache.call(this);
  20811. this._cache.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20812. this._cache.upVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20813. this._cache.mode = undefined;
  20814. this._cache.minZ = undefined;
  20815. this._cache.maxZ = undefined;
  20816. this._cache.fov = undefined;
  20817. this._cache.fovMode = undefined;
  20818. this._cache.aspectRatio = undefined;
  20819. this._cache.orthoLeft = undefined;
  20820. this._cache.orthoRight = undefined;
  20821. this._cache.orthoBottom = undefined;
  20822. this._cache.orthoTop = undefined;
  20823. this._cache.renderWidth = undefined;
  20824. this._cache.renderHeight = undefined;
  20825. };
  20826. /** @hidden */
  20827. Camera.prototype._updateCache = function (ignoreParentClass) {
  20828. if (!ignoreParentClass) {
  20829. _super.prototype._updateCache.call(this);
  20830. }
  20831. this._cache.position.copyFrom(this.position);
  20832. this._cache.upVector.copyFrom(this.upVector);
  20833. };
  20834. /** @hidden */
  20835. Camera.prototype._isSynchronized = function () {
  20836. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  20837. };
  20838. /** @hidden */
  20839. Camera.prototype._isSynchronizedViewMatrix = function () {
  20840. if (!_super.prototype._isSynchronized.call(this)) {
  20841. return false;
  20842. }
  20843. return this._cache.position.equals(this.position)
  20844. && this._cache.upVector.equals(this.upVector)
  20845. && this.isSynchronizedWithParent();
  20846. };
  20847. /** @hidden */
  20848. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  20849. var check = this._cache.mode === this.mode
  20850. && this._cache.minZ === this.minZ
  20851. && this._cache.maxZ === this.maxZ;
  20852. if (!check) {
  20853. return false;
  20854. }
  20855. var engine = this.getEngine();
  20856. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20857. check = this._cache.fov === this.fov
  20858. && this._cache.fovMode === this.fovMode
  20859. && this._cache.aspectRatio === engine.getAspectRatio(this);
  20860. }
  20861. else {
  20862. check = this._cache.orthoLeft === this.orthoLeft
  20863. && this._cache.orthoRight === this.orthoRight
  20864. && this._cache.orthoBottom === this.orthoBottom
  20865. && this._cache.orthoTop === this.orthoTop
  20866. && this._cache.renderWidth === engine.getRenderWidth()
  20867. && this._cache.renderHeight === engine.getRenderHeight();
  20868. }
  20869. return check;
  20870. };
  20871. /**
  20872. * Attach the input controls to a specific dom element to get the input from.
  20873. * @param element Defines the element the controls should be listened from
  20874. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20875. */
  20876. Camera.prototype.attachControl = function (element, noPreventDefault) {
  20877. };
  20878. /**
  20879. * Detach the current controls from the specified dom element.
  20880. * @param element Defines the element to stop listening the inputs from
  20881. */
  20882. Camera.prototype.detachControl = function (element) {
  20883. };
  20884. /**
  20885. * Update the camera state according to the different inputs gathered during the frame.
  20886. */
  20887. Camera.prototype.update = function () {
  20888. this._checkInputs();
  20889. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20890. this._updateRigCameras();
  20891. }
  20892. };
  20893. /** @hidden */
  20894. Camera.prototype._checkInputs = function () {
  20895. this.onAfterCheckInputsObservable.notifyObservers(this);
  20896. };
  20897. Object.defineProperty(Camera.prototype, "rigCameras", {
  20898. /** @hidden */
  20899. get: function () {
  20900. return this._rigCameras;
  20901. },
  20902. enumerable: true,
  20903. configurable: true
  20904. });
  20905. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  20906. /**
  20907. * Gets the post process used by the rig cameras
  20908. */
  20909. get: function () {
  20910. return this._rigPostProcess;
  20911. },
  20912. enumerable: true,
  20913. configurable: true
  20914. });
  20915. /**
  20916. * Internal, gets the first post proces.
  20917. * @returns the first post process to be run on this camera.
  20918. */
  20919. Camera.prototype._getFirstPostProcess = function () {
  20920. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  20921. if (this._postProcesses[ppIndex] !== null) {
  20922. return this._postProcesses[ppIndex];
  20923. }
  20924. }
  20925. return null;
  20926. };
  20927. Camera.prototype._cascadePostProcessesToRigCams = function () {
  20928. // invalidate framebuffer
  20929. var firstPostProcess = this._getFirstPostProcess();
  20930. if (firstPostProcess) {
  20931. firstPostProcess.markTextureDirty();
  20932. }
  20933. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  20934. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  20935. var cam = this._rigCameras[i];
  20936. var rigPostProcess = cam._rigPostProcess;
  20937. // for VR rig, there does not have to be a post process
  20938. if (rigPostProcess) {
  20939. var isPass = rigPostProcess.getEffectName() === "pass";
  20940. if (isPass) {
  20941. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  20942. cam.isIntermediate = this._postProcesses.length === 0;
  20943. }
  20944. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  20945. rigPostProcess.markTextureDirty();
  20946. }
  20947. else {
  20948. cam._postProcesses = this._postProcesses.slice(0);
  20949. }
  20950. }
  20951. };
  20952. /**
  20953. * Attach a post process to the camera.
  20954. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20955. * @param postProcess The post process to attach to the camera
  20956. * @param insertAt The position of the post process in case several of them are in use in the scene
  20957. * @returns the position the post process has been inserted at
  20958. */
  20959. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  20960. if (insertAt === void 0) { insertAt = null; }
  20961. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  20962. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  20963. return 0;
  20964. }
  20965. if (insertAt == null || insertAt < 0) {
  20966. this._postProcesses.push(postProcess);
  20967. }
  20968. else if (this._postProcesses[insertAt] === null) {
  20969. this._postProcesses[insertAt] = postProcess;
  20970. }
  20971. else {
  20972. this._postProcesses.splice(insertAt, 0, postProcess);
  20973. }
  20974. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20975. return this._postProcesses.indexOf(postProcess);
  20976. };
  20977. /**
  20978. * Detach a post process to the camera.
  20979. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20980. * @param postProcess The post process to detach from the camera
  20981. */
  20982. Camera.prototype.detachPostProcess = function (postProcess) {
  20983. var idx = this._postProcesses.indexOf(postProcess);
  20984. if (idx !== -1) {
  20985. this._postProcesses[idx] = null;
  20986. }
  20987. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20988. };
  20989. /**
  20990. * Gets the current world matrix of the camera
  20991. */
  20992. Camera.prototype.getWorldMatrix = function () {
  20993. if (this._isSynchronizedViewMatrix()) {
  20994. return this._worldMatrix;
  20995. }
  20996. // Getting the the view matrix will also compute the world matrix.
  20997. this.getViewMatrix();
  20998. return this._worldMatrix;
  20999. };
  21000. /** @hidden */
  21001. Camera.prototype._getViewMatrix = function () {
  21002. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21003. };
  21004. /**
  21005. * Gets the current view matrix of the camera.
  21006. * @param force forces the camera to recompute the matrix without looking at the cached state
  21007. * @returns the view matrix
  21008. */
  21009. Camera.prototype.getViewMatrix = function (force) {
  21010. if (!force && this._isSynchronizedViewMatrix()) {
  21011. return this._computedViewMatrix;
  21012. }
  21013. this.updateCache();
  21014. this._computedViewMatrix = this._getViewMatrix();
  21015. this._currentRenderId = this.getScene().getRenderId();
  21016. this._childUpdateId++;
  21017. this._refreshFrustumPlanes = true;
  21018. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  21019. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  21020. }
  21021. this.onViewMatrixChangedObservable.notifyObservers(this);
  21022. this._computedViewMatrix.invertToRef(this._worldMatrix);
  21023. return this._computedViewMatrix;
  21024. };
  21025. /**
  21026. * Freeze the projection matrix.
  21027. * It will prevent the cache check of the camera projection compute and can speed up perf
  21028. * if no parameter of the camera are meant to change
  21029. * @param projection Defines manually a projection if necessary
  21030. */
  21031. Camera.prototype.freezeProjectionMatrix = function (projection) {
  21032. this._doNotComputeProjectionMatrix = true;
  21033. if (projection !== undefined) {
  21034. this._projectionMatrix = projection;
  21035. }
  21036. };
  21037. /**
  21038. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  21039. */
  21040. Camera.prototype.unfreezeProjectionMatrix = function () {
  21041. this._doNotComputeProjectionMatrix = false;
  21042. };
  21043. /**
  21044. * Gets the current projection matrix of the camera.
  21045. * @param force forces the camera to recompute the matrix without looking at the cached state
  21046. * @returns the projection matrix
  21047. */
  21048. Camera.prototype.getProjectionMatrix = function (force) {
  21049. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  21050. return this._projectionMatrix;
  21051. }
  21052. // Cache
  21053. this._cache.mode = this.mode;
  21054. this._cache.minZ = this.minZ;
  21055. this._cache.maxZ = this.maxZ;
  21056. // Matrix
  21057. this._refreshFrustumPlanes = true;
  21058. var engine = this.getEngine();
  21059. var scene = this.getScene();
  21060. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  21061. this._cache.fov = this.fov;
  21062. this._cache.fovMode = this.fovMode;
  21063. this._cache.aspectRatio = engine.getAspectRatio(this);
  21064. if (this.minZ <= 0) {
  21065. this.minZ = 0.1;
  21066. }
  21067. if (scene.useRightHandedSystem) {
  21068. _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);
  21069. }
  21070. else {
  21071. _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);
  21072. }
  21073. }
  21074. else {
  21075. var halfWidth = engine.getRenderWidth() / 2.0;
  21076. var halfHeight = engine.getRenderHeight() / 2.0;
  21077. if (scene.useRightHandedSystem) {
  21078. _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);
  21079. }
  21080. else {
  21081. _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);
  21082. }
  21083. this._cache.orthoLeft = this.orthoLeft;
  21084. this._cache.orthoRight = this.orthoRight;
  21085. this._cache.orthoBottom = this.orthoBottom;
  21086. this._cache.orthoTop = this.orthoTop;
  21087. this._cache.renderWidth = engine.getRenderWidth();
  21088. this._cache.renderHeight = engine.getRenderHeight();
  21089. }
  21090. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  21091. return this._projectionMatrix;
  21092. };
  21093. /**
  21094. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  21095. * @returns a Matrix
  21096. */
  21097. Camera.prototype.getTransformationMatrix = function () {
  21098. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  21099. return this._transformMatrix;
  21100. };
  21101. Camera.prototype._updateFrustumPlanes = function () {
  21102. if (!this._refreshFrustumPlanes) {
  21103. return;
  21104. }
  21105. this.getTransformationMatrix();
  21106. if (!this._frustumPlanes) {
  21107. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanes(this._transformMatrix);
  21108. }
  21109. else {
  21110. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  21111. }
  21112. this._refreshFrustumPlanes = false;
  21113. };
  21114. /**
  21115. * Checks if a cullable object (mesh...) is in the camera frustum
  21116. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  21117. * @param target The object to check
  21118. * @returns true if the object is in frustum otherwise false
  21119. */
  21120. Camera.prototype.isInFrustum = function (target) {
  21121. this._updateFrustumPlanes();
  21122. return target.isInFrustum(this._frustumPlanes);
  21123. };
  21124. /**
  21125. * Checks if a cullable object (mesh...) is in the camera frustum
  21126. * Unlike isInFrustum this cheks the full bounding box
  21127. * @param target The object to check
  21128. * @returns true if the object is in frustum otherwise false
  21129. */
  21130. Camera.prototype.isCompletelyInFrustum = function (target) {
  21131. this._updateFrustumPlanes();
  21132. return target.isCompletelyInFrustum(this._frustumPlanes);
  21133. };
  21134. /**
  21135. * Gets a ray in the forward direction from the camera.
  21136. * @param length Defines the length of the ray to create
  21137. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  21138. * @param origin Defines the start point of the ray which defaults to the camera position
  21139. * @returns the forward ray
  21140. */
  21141. Camera.prototype.getForwardRay = function (length, transform, origin) {
  21142. if (length === void 0) { length = 100; }
  21143. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("Ray");
  21144. };
  21145. /**
  21146. * Releases resources associated with this node.
  21147. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21148. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21149. */
  21150. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  21151. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  21152. // Observables
  21153. this.onViewMatrixChangedObservable.clear();
  21154. this.onProjectionMatrixChangedObservable.clear();
  21155. this.onAfterCheckInputsObservable.clear();
  21156. this.onRestoreStateObservable.clear();
  21157. // Inputs
  21158. if (this.inputs) {
  21159. this.inputs.clear();
  21160. }
  21161. // Animations
  21162. this.getScene().stopAnimation(this);
  21163. // Remove from scene
  21164. this.getScene().removeCamera(this);
  21165. while (this._rigCameras.length > 0) {
  21166. var camera = this._rigCameras.pop();
  21167. if (camera) {
  21168. camera.dispose();
  21169. }
  21170. }
  21171. // Postprocesses
  21172. if (this._rigPostProcess) {
  21173. this._rigPostProcess.dispose(this);
  21174. this._rigPostProcess = null;
  21175. this._postProcesses = [];
  21176. }
  21177. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21178. this._rigPostProcess = null;
  21179. this._postProcesses = [];
  21180. }
  21181. else {
  21182. var i = this._postProcesses.length;
  21183. while (--i >= 0) {
  21184. var postProcess = this._postProcesses[i];
  21185. if (postProcess) {
  21186. postProcess.dispose(this);
  21187. }
  21188. }
  21189. }
  21190. // Render targets
  21191. var i = this.customRenderTargets.length;
  21192. while (--i >= 0) {
  21193. this.customRenderTargets[i].dispose();
  21194. }
  21195. this.customRenderTargets = [];
  21196. // Active Meshes
  21197. this._activeMeshes.dispose();
  21198. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  21199. };
  21200. Object.defineProperty(Camera.prototype, "isLeftCamera", {
  21201. /**
  21202. * Gets the left camera of a rig setup in case of Rigged Camera
  21203. */
  21204. get: function () {
  21205. return this._isLeftCamera;
  21206. },
  21207. enumerable: true,
  21208. configurable: true
  21209. });
  21210. Object.defineProperty(Camera.prototype, "isRightCamera", {
  21211. /**
  21212. * Gets the right camera of a rig setup in case of Rigged Camera
  21213. */
  21214. get: function () {
  21215. return this._isRightCamera;
  21216. },
  21217. enumerable: true,
  21218. configurable: true
  21219. });
  21220. Object.defineProperty(Camera.prototype, "leftCamera", {
  21221. /**
  21222. * Gets the left camera of a rig setup in case of Rigged Camera
  21223. */
  21224. get: function () {
  21225. if (this._rigCameras.length < 1) {
  21226. return null;
  21227. }
  21228. return this._rigCameras[0];
  21229. },
  21230. enumerable: true,
  21231. configurable: true
  21232. });
  21233. Object.defineProperty(Camera.prototype, "rightCamera", {
  21234. /**
  21235. * Gets the right camera of a rig setup in case of Rigged Camera
  21236. */
  21237. get: function () {
  21238. if (this._rigCameras.length < 2) {
  21239. return null;
  21240. }
  21241. return this._rigCameras[1];
  21242. },
  21243. enumerable: true,
  21244. configurable: true
  21245. });
  21246. /**
  21247. * Gets the left camera target of a rig setup in case of Rigged Camera
  21248. * @returns the target position
  21249. */
  21250. Camera.prototype.getLeftTarget = function () {
  21251. if (this._rigCameras.length < 1) {
  21252. return null;
  21253. }
  21254. return this._rigCameras[0].getTarget();
  21255. };
  21256. /**
  21257. * Gets the right camera target of a rig setup in case of Rigged Camera
  21258. * @returns the target position
  21259. */
  21260. Camera.prototype.getRightTarget = function () {
  21261. if (this._rigCameras.length < 2) {
  21262. return null;
  21263. }
  21264. return this._rigCameras[1].getTarget();
  21265. };
  21266. /**
  21267. * @hidden
  21268. */
  21269. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  21270. if (this.cameraRigMode === mode) {
  21271. return;
  21272. }
  21273. while (this._rigCameras.length > 0) {
  21274. var camera = this._rigCameras.pop();
  21275. if (camera) {
  21276. camera.dispose();
  21277. }
  21278. }
  21279. this.cameraRigMode = mode;
  21280. this._cameraRigParams = {};
  21281. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  21282. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  21283. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  21284. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  21285. // create the rig cameras, unless none
  21286. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  21287. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  21288. if (leftCamera) {
  21289. leftCamera._isLeftCamera = true;
  21290. }
  21291. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  21292. if (rightCamera) {
  21293. rightCamera._isRightCamera = true;
  21294. }
  21295. if (leftCamera && rightCamera) {
  21296. this._rigCameras.push(leftCamera);
  21297. this._rigCameras.push(rightCamera);
  21298. }
  21299. }
  21300. switch (this.cameraRigMode) {
  21301. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  21302. Camera._setStereoscopicAnaglyphRigMode(this);
  21303. break;
  21304. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  21305. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  21306. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  21307. Camera._setStereoscopicRigMode(this);
  21308. break;
  21309. case Camera.RIG_MODE_VR:
  21310. Camera._setVRRigMode(this, rigParams);
  21311. break;
  21312. case Camera.RIG_MODE_WEBVR:
  21313. Camera._setWebVRRigMode(this, rigParams);
  21314. break;
  21315. }
  21316. this._cascadePostProcessesToRigCams();
  21317. this.update();
  21318. };
  21319. /** @hidden */
  21320. Camera._setStereoscopicRigMode = function (camera) {
  21321. throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
  21322. };
  21323. /** @hidden */
  21324. Camera._setStereoscopicAnaglyphRigMode = function (camera) {
  21325. throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
  21326. };
  21327. /** @hidden */
  21328. Camera._setVRRigMode = function (camera, rigParams) {
  21329. throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
  21330. };
  21331. /** @hidden */
  21332. Camera._setWebVRRigMode = function (camera, rigParams) {
  21333. throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
  21334. };
  21335. /** @hidden */
  21336. Camera.prototype._getVRProjectionMatrix = function () {
  21337. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  21338. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  21339. return this._projectionMatrix;
  21340. };
  21341. Camera.prototype._updateCameraRotationMatrix = function () {
  21342. //Here for WebVR
  21343. };
  21344. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  21345. //Here for WebVR
  21346. };
  21347. /**
  21348. * This function MUST be overwritten by the different WebVR cameras available.
  21349. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  21350. * @hidden
  21351. */
  21352. Camera.prototype._getWebVRProjectionMatrix = function () {
  21353. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21354. };
  21355. /**
  21356. * This function MUST be overwritten by the different WebVR cameras available.
  21357. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  21358. * @hidden
  21359. */
  21360. Camera.prototype._getWebVRViewMatrix = function () {
  21361. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  21362. };
  21363. /** @hidden */
  21364. Camera.prototype.setCameraRigParameter = function (name, value) {
  21365. if (!this._cameraRigParams) {
  21366. this._cameraRigParams = {};
  21367. }
  21368. this._cameraRigParams[name] = value;
  21369. //provisionnally:
  21370. if (name === "interaxialDistance") {
  21371. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  21372. }
  21373. };
  21374. /**
  21375. * needs to be overridden by children so sub has required properties to be copied
  21376. * @hidden
  21377. */
  21378. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  21379. return null;
  21380. };
  21381. /**
  21382. * May need to be overridden by children
  21383. * @hidden
  21384. */
  21385. Camera.prototype._updateRigCameras = function () {
  21386. for (var i = 0; i < this._rigCameras.length; i++) {
  21387. this._rigCameras[i].minZ = this.minZ;
  21388. this._rigCameras[i].maxZ = this.maxZ;
  21389. this._rigCameras[i].fov = this.fov;
  21390. this._rigCameras[i].upVector.copyFrom(this.upVector);
  21391. }
  21392. // only update viewport when ANAGLYPH
  21393. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  21394. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  21395. }
  21396. };
  21397. /** @hidden */
  21398. Camera.prototype._setupInputs = function () {
  21399. };
  21400. /**
  21401. * Serialiaze the camera setup to a json represention
  21402. * @returns the JSON representation
  21403. */
  21404. Camera.prototype.serialize = function () {
  21405. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  21406. // Type
  21407. serializationObject.type = this.getClassName();
  21408. // Parent
  21409. if (this.parent) {
  21410. serializationObject.parentId = this.parent.id;
  21411. }
  21412. if (this.inputs) {
  21413. this.inputs.serialize(serializationObject);
  21414. }
  21415. // Animations
  21416. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  21417. serializationObject.ranges = this.serializeAnimationRanges();
  21418. return serializationObject;
  21419. };
  21420. /**
  21421. * Clones the current camera.
  21422. * @param name The cloned camera name
  21423. * @returns the cloned camera
  21424. */
  21425. Camera.prototype.clone = function (name) {
  21426. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  21427. };
  21428. /**
  21429. * Gets the direction of the camera relative to a given local axis.
  21430. * @param localAxis Defines the reference axis to provide a relative direction.
  21431. * @return the direction
  21432. */
  21433. Camera.prototype.getDirection = function (localAxis) {
  21434. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  21435. this.getDirectionToRef(localAxis, result);
  21436. return result;
  21437. };
  21438. /**
  21439. * Gets the direction of the camera relative to a given local axis into a passed vector.
  21440. * @param localAxis Defines the reference axis to provide a relative direction.
  21441. * @param result Defines the vector to store the result in
  21442. */
  21443. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  21444. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  21445. };
  21446. /**
  21447. * Gets a camera constructor for a given camera type
  21448. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  21449. * @param name The name of the camera the result will be able to instantiate
  21450. * @param scene The scene the result will construct the camera in
  21451. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  21452. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  21453. * @returns a factory method to construc the camera
  21454. */
  21455. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  21456. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  21457. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  21458. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  21459. interaxial_distance: interaxial_distance,
  21460. isStereoscopicSideBySide: isStereoscopicSideBySide
  21461. });
  21462. if (constructorFunc) {
  21463. return constructorFunc;
  21464. }
  21465. // Default to universal camera
  21466. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  21467. };
  21468. /**
  21469. * Compute the world matrix of the camera.
  21470. * @returns the camera workd matrix
  21471. */
  21472. Camera.prototype.computeWorldMatrix = function () {
  21473. return this.getWorldMatrix();
  21474. };
  21475. /**
  21476. * Parse a JSON and creates the camera from the parsed information
  21477. * @param parsedCamera The JSON to parse
  21478. * @param scene The scene to instantiate the camera in
  21479. * @returns the newly constructed camera
  21480. */
  21481. Camera.Parse = function (parsedCamera, scene) {
  21482. var type = parsedCamera.type;
  21483. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  21484. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  21485. // Parent
  21486. if (parsedCamera.parentId) {
  21487. camera._waitingParentId = parsedCamera.parentId;
  21488. }
  21489. //If camera has an input manager, let it parse inputs settings
  21490. if (camera.inputs) {
  21491. camera.inputs.parse(parsedCamera);
  21492. camera._setupInputs();
  21493. }
  21494. if (camera.setPosition) { // need to force position
  21495. camera.position.copyFromFloats(0, 0, 0);
  21496. camera.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  21497. }
  21498. // Target
  21499. if (parsedCamera.target) {
  21500. if (camera.setTarget) {
  21501. camera.setTarget(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  21502. }
  21503. }
  21504. // Apply 3d rig, when found
  21505. if (parsedCamera.cameraRigMode) {
  21506. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  21507. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  21508. }
  21509. // Animations
  21510. if (parsedCamera.animations) {
  21511. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  21512. var parsedAnimation = parsedCamera.animations[animationIndex];
  21513. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON.Animation");
  21514. if (internalClass) {
  21515. camera.animations.push(internalClass.Parse(parsedAnimation));
  21516. }
  21517. }
  21518. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  21519. }
  21520. if (parsedCamera.autoAnimate) {
  21521. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  21522. }
  21523. return camera;
  21524. };
  21525. /** @hidden */
  21526. Camera._createDefaultParsedCamera = function (name, scene) {
  21527. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("UniversalCamera");
  21528. };
  21529. /**
  21530. * This is the default projection mode used by the cameras.
  21531. * It helps recreating a feeling of perspective and better appreciate depth.
  21532. * This is the best way to simulate real life cameras.
  21533. */
  21534. Camera.PERSPECTIVE_CAMERA = 0;
  21535. /**
  21536. * This helps creating camera with an orthographic mode.
  21537. * 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.
  21538. */
  21539. Camera.ORTHOGRAPHIC_CAMERA = 1;
  21540. /**
  21541. * This is the default FOV mode for perspective cameras.
  21542. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  21543. */
  21544. Camera.FOVMODE_VERTICAL_FIXED = 0;
  21545. /**
  21546. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  21547. */
  21548. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  21549. /**
  21550. * This specifies ther is no need for a camera rig.
  21551. * Basically only one eye is rendered corresponding to the camera.
  21552. */
  21553. Camera.RIG_MODE_NONE = 0;
  21554. /**
  21555. * Simulates a camera Rig with one blue eye and one red eye.
  21556. * This can be use with 3d blue and red glasses.
  21557. */
  21558. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  21559. /**
  21560. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  21561. */
  21562. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  21563. /**
  21564. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  21565. */
  21566. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  21567. /**
  21568. * Defines that both eyes of the camera will be rendered over under each other.
  21569. */
  21570. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  21571. /**
  21572. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  21573. */
  21574. Camera.RIG_MODE_VR = 20;
  21575. /**
  21576. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  21577. */
  21578. Camera.RIG_MODE_WEBVR = 21;
  21579. /**
  21580. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  21581. */
  21582. Camera.RIG_MODE_CUSTOM = 22;
  21583. /**
  21584. * Defines if by default attaching controls should prevent the default javascript event to continue.
  21585. */
  21586. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  21587. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21588. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  21589. ], Camera.prototype, "_position", void 0);
  21590. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21591. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21592. ], Camera.prototype, "upVector", void 0);
  21593. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21594. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21595. ], Camera.prototype, "orthoLeft", void 0);
  21596. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21597. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21598. ], Camera.prototype, "orthoRight", void 0);
  21599. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21600. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21601. ], Camera.prototype, "orthoBottom", void 0);
  21602. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21603. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21604. ], Camera.prototype, "orthoTop", void 0);
  21605. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21606. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21607. ], Camera.prototype, "fov", void 0);
  21608. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21609. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21610. ], Camera.prototype, "minZ", void 0);
  21611. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21612. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21613. ], Camera.prototype, "maxZ", void 0);
  21614. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21615. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21616. ], Camera.prototype, "inertia", void 0);
  21617. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21618. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21619. ], Camera.prototype, "mode", void 0);
  21620. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21621. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21622. ], Camera.prototype, "layerMask", void 0);
  21623. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21624. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21625. ], Camera.prototype, "fovMode", void 0);
  21626. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21627. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21628. ], Camera.prototype, "cameraRigMode", void 0);
  21629. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21630. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21631. ], Camera.prototype, "interaxialDistance", void 0);
  21632. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21633. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21634. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  21635. return Camera;
  21636. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  21637. /***/ }),
  21638. /***/ "./Cameras/cameraInputsManager.ts":
  21639. /*!****************************************!*\
  21640. !*** ./Cameras/cameraInputsManager.ts ***!
  21641. \****************************************/
  21642. /*! exports provided: CameraInputTypes, CameraInputsManager */
  21643. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21644. "use strict";
  21645. __webpack_require__.r(__webpack_exports__);
  21646. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  21647. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  21648. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  21649. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21650. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21651. /**
  21652. * @ignore
  21653. * This is a list of all the different input types that are available in the application.
  21654. * Fo instance: ArcRotateCameraGamepadInput...
  21655. */
  21656. var CameraInputTypes = {};
  21657. /**
  21658. * This represents the input manager used within a camera.
  21659. * It helps dealing with all the different kind of input attached to a camera.
  21660. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21661. */
  21662. var CameraInputsManager = /** @class */ (function () {
  21663. /**
  21664. * Instantiate a new Camera Input Manager.
  21665. * @param camera Defines the camera the input manager blongs to
  21666. */
  21667. function CameraInputsManager(camera) {
  21668. this.attached = {};
  21669. this.camera = camera;
  21670. this.checkInputs = function () { };
  21671. }
  21672. /**
  21673. * Add an input method to a camera
  21674. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21675. * @param input camera input method
  21676. */
  21677. CameraInputsManager.prototype.add = function (input) {
  21678. var type = input.getSimpleName();
  21679. if (this.attached[type]) {
  21680. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  21681. return;
  21682. }
  21683. this.attached[type] = input;
  21684. input.camera = this.camera;
  21685. //for checkInputs, we are dynamically creating a function
  21686. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  21687. if (input.checkInputs) {
  21688. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21689. }
  21690. if (this.attachedElement) {
  21691. input.attachControl(this.attachedElement);
  21692. }
  21693. };
  21694. /**
  21695. * Remove a specific input method from a camera
  21696. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  21697. * @param inputToRemove camera input method
  21698. */
  21699. CameraInputsManager.prototype.remove = function (inputToRemove) {
  21700. for (var cam in this.attached) {
  21701. var input = this.attached[cam];
  21702. if (input === inputToRemove) {
  21703. input.detachControl(this.attachedElement);
  21704. input.camera = null;
  21705. delete this.attached[cam];
  21706. this.rebuildInputCheck();
  21707. }
  21708. }
  21709. };
  21710. /**
  21711. * Remove a specific input type from a camera
  21712. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  21713. * @param inputType the type of the input to remove
  21714. */
  21715. CameraInputsManager.prototype.removeByType = function (inputType) {
  21716. for (var cam in this.attached) {
  21717. var input = this.attached[cam];
  21718. if (input.getClassName() === inputType) {
  21719. input.detachControl(this.attachedElement);
  21720. input.camera = null;
  21721. delete this.attached[cam];
  21722. this.rebuildInputCheck();
  21723. }
  21724. }
  21725. };
  21726. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  21727. var current = this.checkInputs;
  21728. return function () {
  21729. current();
  21730. fn();
  21731. };
  21732. };
  21733. /**
  21734. * Attach the input controls to the currently attached dom element to listen the events from.
  21735. * @param input Defines the input to attach
  21736. */
  21737. CameraInputsManager.prototype.attachInput = function (input) {
  21738. if (this.attachedElement) {
  21739. input.attachControl(this.attachedElement, this.noPreventDefault);
  21740. }
  21741. };
  21742. /**
  21743. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  21744. * @param element Defines the dom element to collect the events from
  21745. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21746. */
  21747. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  21748. if (noPreventDefault === void 0) { noPreventDefault = false; }
  21749. if (this.attachedElement) {
  21750. return;
  21751. }
  21752. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  21753. this.attachedElement = element;
  21754. this.noPreventDefault = noPreventDefault;
  21755. for (var cam in this.attached) {
  21756. this.attached[cam].attachControl(element, noPreventDefault);
  21757. }
  21758. };
  21759. /**
  21760. * Detach the current manager inputs controls from a specific dom element.
  21761. * @param element Defines the dom element to collect the events from
  21762. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  21763. */
  21764. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  21765. if (disconnect === void 0) { disconnect = false; }
  21766. if (this.attachedElement !== element) {
  21767. return;
  21768. }
  21769. for (var cam in this.attached) {
  21770. this.attached[cam].detachControl(element);
  21771. if (disconnect) {
  21772. this.attached[cam].camera = null;
  21773. }
  21774. }
  21775. this.attachedElement = null;
  21776. };
  21777. /**
  21778. * Rebuild the dynamic inputCheck function from the current list of
  21779. * defined inputs in the manager.
  21780. */
  21781. CameraInputsManager.prototype.rebuildInputCheck = function () {
  21782. this.checkInputs = function () { };
  21783. for (var cam in this.attached) {
  21784. var input = this.attached[cam];
  21785. if (input.checkInputs) {
  21786. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21787. }
  21788. }
  21789. };
  21790. /**
  21791. * Remove all attached input methods from a camera
  21792. */
  21793. CameraInputsManager.prototype.clear = function () {
  21794. if (this.attachedElement) {
  21795. this.detachElement(this.attachedElement, true);
  21796. }
  21797. this.attached = {};
  21798. this.attachedElement = null;
  21799. this.checkInputs = function () { };
  21800. };
  21801. /**
  21802. * Serialize the current input manager attached to a camera.
  21803. * This ensures than once parsed,
  21804. * the input associated to the camera will be identical to the current ones
  21805. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  21806. */
  21807. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  21808. var inputs = {};
  21809. for (var cam in this.attached) {
  21810. var input = this.attached[cam];
  21811. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  21812. inputs[input.getClassName()] = res;
  21813. }
  21814. serializedCamera.inputsmgr = inputs;
  21815. };
  21816. /**
  21817. * Parses an input manager serialized JSON to restore the previous list of inputs
  21818. * and states associated to a camera.
  21819. * @param parsedCamera Defines the JSON to parse
  21820. */
  21821. CameraInputsManager.prototype.parse = function (parsedCamera) {
  21822. var parsedInputs = parsedCamera.inputsmgr;
  21823. if (parsedInputs) {
  21824. this.clear();
  21825. for (var n in parsedInputs) {
  21826. var construct = CameraInputTypes[n];
  21827. if (construct) {
  21828. var parsedinput = parsedInputs[n];
  21829. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  21830. this.add(input);
  21831. }
  21832. }
  21833. }
  21834. else {
  21835. //2016-03-08 this part is for managing backward compatibility
  21836. for (var n in this.attached) {
  21837. var construct = CameraInputTypes[this.attached[n].getClassName()];
  21838. if (construct) {
  21839. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  21840. this.remove(this.attached[n]);
  21841. this.add(input);
  21842. }
  21843. }
  21844. }
  21845. };
  21846. return CameraInputsManager;
  21847. }());
  21848. /***/ }),
  21849. /***/ "./Cameras/deviceOrientationCamera.ts":
  21850. /*!********************************************!*\
  21851. !*** ./Cameras/deviceOrientationCamera.ts ***!
  21852. \********************************************/
  21853. /*! exports provided: DeviceOrientationCamera */
  21854. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21855. "use strict";
  21856. __webpack_require__.r(__webpack_exports__);
  21857. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  21858. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21859. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  21860. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21861. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  21862. /* harmony import */ var _Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  21863. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  21864. return function () { return new DeviceOrientationCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  21865. });
  21866. // We're mainly based on the logic defined into the FreeCamera code
  21867. /**
  21868. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  21869. * being tilted forward or back and left or right.
  21870. */
  21871. var DeviceOrientationCamera = /** @class */ (function (_super) {
  21872. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  21873. /**
  21874. * Creates a new device orientation camera
  21875. * @param name The name of the camera
  21876. * @param position The start position camera
  21877. * @param scene The scene the camera belongs to
  21878. */
  21879. function DeviceOrientationCamera(name, position, scene) {
  21880. var _this = _super.call(this, name, position, scene) || this;
  21881. _this._tmpDragQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21882. /**
  21883. * Disabled pointer input on first orientation sensor update (Default: true)
  21884. */
  21885. _this.disablePointerInputWhenUsingDeviceOrientation = true;
  21886. _this._dragFactor = 0;
  21887. _this._quaternionCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21888. _this.inputs.addDeviceOrientation();
  21889. // When the orientation sensor fires it's first event, disable mouse input
  21890. if (_this.inputs._deviceOrientationInput) {
  21891. _this.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce(function () {
  21892. if (_this.disablePointerInputWhenUsingDeviceOrientation) {
  21893. if (_this.inputs._mouseInput) {
  21894. _this.inputs._mouseInput._allowCameraRotation = false;
  21895. _this.inputs._mouseInput.onPointerMovedObservable.add(function (e) {
  21896. if (_this._dragFactor != 0) {
  21897. if (!_this._initialQuaternion) {
  21898. _this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21899. }
  21900. // Rotate the initial space around the y axis to allow users to "turn around" via touch/mouse
  21901. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromEulerAnglesToRef(0, e.offsetX * _this._dragFactor, 0, _this._tmpDragQuaternion);
  21902. _this._initialQuaternion.multiplyToRef(_this._tmpDragQuaternion, _this._initialQuaternion);
  21903. }
  21904. });
  21905. }
  21906. }
  21907. });
  21908. }
  21909. return _this;
  21910. }
  21911. /**
  21912. * Enabled turning on the y axis when the orientation sensor is active
  21913. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  21914. */
  21915. DeviceOrientationCamera.prototype.enableHorizontalDragging = function (dragFactor) {
  21916. if (dragFactor === void 0) { dragFactor = 1 / 300; }
  21917. this._dragFactor = dragFactor;
  21918. };
  21919. /**
  21920. * Gets the current instance class name ("DeviceOrientationCamera").
  21921. * This helps avoiding instanceof at run time.
  21922. * @returns the class name
  21923. */
  21924. DeviceOrientationCamera.prototype.getClassName = function () {
  21925. return "DeviceOrientationCamera";
  21926. };
  21927. /**
  21928. * @hidden
  21929. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  21930. */
  21931. DeviceOrientationCamera.prototype._checkInputs = function () {
  21932. _super.prototype._checkInputs.call(this);
  21933. this._quaternionCache.copyFrom(this.rotationQuaternion);
  21934. if (this._initialQuaternion) {
  21935. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21936. }
  21937. };
  21938. /**
  21939. * Reset the camera to its default orientation on the specified axis only.
  21940. * @param axis The axis to reset
  21941. */
  21942. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  21943. var _this = this;
  21944. if (axis === void 0) { axis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y; }
  21945. //can only work if this camera has a rotation quaternion already.
  21946. if (!this.rotationQuaternion) {
  21947. return;
  21948. }
  21949. if (!this._initialQuaternion) {
  21950. this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21951. }
  21952. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  21953. ['x', 'y', 'z'].forEach(function (axisName) {
  21954. if (!axis[axisName]) {
  21955. _this._initialQuaternion[axisName] = 0;
  21956. }
  21957. else {
  21958. _this._initialQuaternion[axisName] *= -1;
  21959. }
  21960. });
  21961. this._initialQuaternion.normalize();
  21962. //force rotation update
  21963. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21964. };
  21965. return DeviceOrientationCamera;
  21966. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  21967. /***/ }),
  21968. /***/ "./Cameras/flyCamera.ts":
  21969. /*!******************************!*\
  21970. !*** ./Cameras/flyCamera.ts ***!
  21971. \******************************/
  21972. /*! exports provided: FlyCamera */
  21973. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21974. "use strict";
  21975. __webpack_require__.r(__webpack_exports__);
  21976. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  21977. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21978. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21979. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21980. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  21981. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21982. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  21983. /**
  21984. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21985. * such as in a 3D Space Shooter or a Flight Simulator.
  21986. */
  21987. var FlyCamera = /** @class */ (function (_super) {
  21988. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  21989. /**
  21990. * Instantiates a FlyCamera.
  21991. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21992. * such as in a 3D Space Shooter or a Flight Simulator.
  21993. * @param name Define the name of the camera in the scene.
  21994. * @param position Define the starting position of the camera in the scene.
  21995. * @param scene Define the scene the camera belongs to.
  21996. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  21997. */
  21998. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  21999. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22000. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22001. /**
  22002. * Define the collision ellipsoid of the camera.
  22003. * This is helpful for simulating a camera body, like a player's body.
  22004. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22005. */
  22006. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  22007. /**
  22008. * Define an offset for the position of the ellipsoid around the camera.
  22009. * This can be helpful if the camera is attached away from the player's body center,
  22010. * such as at its head.
  22011. */
  22012. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22013. /**
  22014. * Enable or disable collisions of the camera with the rest of the scene objects.
  22015. */
  22016. _this.checkCollisions = false;
  22017. /**
  22018. * Enable or disable gravity on the camera.
  22019. */
  22020. _this.applyGravity = false;
  22021. /**
  22022. * Define the current direction the camera is moving to.
  22023. */
  22024. _this.cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22025. /**
  22026. * Track Roll to maintain the wanted Rolling when looking around.
  22027. */
  22028. _this._trackRoll = 0;
  22029. /**
  22030. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  22031. */
  22032. _this.rollCorrect = 100;
  22033. /**
  22034. * Mimic a banked turn, Rolling the camera when Yawing.
  22035. * It's recommended to use rollCorrect = 10 for faster banking correction.
  22036. */
  22037. _this.bankedTurn = false;
  22038. /**
  22039. * Limit in radians for how much Roll banking will add. (Default: 90°)
  22040. */
  22041. _this.bankedTurnLimit = Math.PI / 2;
  22042. /**
  22043. * Value of 0 disables the banked Roll.
  22044. * Value of 1 is equal to the Yaw angle in radians.
  22045. */
  22046. _this.bankedTurnMultiplier = 1;
  22047. _this._needMoveForGravity = false;
  22048. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22049. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22050. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22051. // Collisions.
  22052. _this._collisionMask = -1;
  22053. /** @hidden */
  22054. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22055. if (collidedMesh === void 0) { collidedMesh = null; }
  22056. var updatePosition = function (newPos) {
  22057. _this._newPosition.copyFrom(newPos);
  22058. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22059. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22060. _this.position.addInPlace(_this._diffPosition);
  22061. if (_this.onCollide && collidedMesh) {
  22062. _this.onCollide(collidedMesh);
  22063. }
  22064. }
  22065. };
  22066. updatePosition(newPosition);
  22067. };
  22068. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FlyCameraInputsManager"](_this);
  22069. _this.inputs.addKeyboard().addMouse();
  22070. return _this;
  22071. }
  22072. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  22073. /**
  22074. * Gets the input sensibility for mouse input.
  22075. * Higher values reduce sensitivity.
  22076. */
  22077. get: function () {
  22078. var mouse = this.inputs.attached["mouse"];
  22079. if (mouse) {
  22080. return mouse.angularSensibility;
  22081. }
  22082. return 0;
  22083. },
  22084. /**
  22085. * Sets the input sensibility for a mouse input.
  22086. * Higher values reduce sensitivity.
  22087. */
  22088. set: function (value) {
  22089. var mouse = this.inputs.attached["mouse"];
  22090. if (mouse) {
  22091. mouse.angularSensibility = value;
  22092. }
  22093. },
  22094. enumerable: true,
  22095. configurable: true
  22096. });
  22097. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  22098. /**
  22099. * Get the keys for camera movement forward.
  22100. */
  22101. get: function () {
  22102. var keyboard = this.inputs.attached["keyboard"];
  22103. if (keyboard) {
  22104. return keyboard.keysForward;
  22105. }
  22106. return [];
  22107. },
  22108. /**
  22109. * Set the keys for camera movement forward.
  22110. */
  22111. set: function (value) {
  22112. var keyboard = this.inputs.attached["keyboard"];
  22113. if (keyboard) {
  22114. keyboard.keysForward = value;
  22115. }
  22116. },
  22117. enumerable: true,
  22118. configurable: true
  22119. });
  22120. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  22121. /**
  22122. * Get the keys for camera movement backward.
  22123. */
  22124. get: function () {
  22125. var keyboard = this.inputs.attached["keyboard"];
  22126. if (keyboard) {
  22127. return keyboard.keysBackward;
  22128. }
  22129. return [];
  22130. },
  22131. set: function (value) {
  22132. var keyboard = this.inputs.attached["keyboard"];
  22133. if (keyboard) {
  22134. keyboard.keysBackward = value;
  22135. }
  22136. },
  22137. enumerable: true,
  22138. configurable: true
  22139. });
  22140. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  22141. /**
  22142. * Get the keys for camera movement up.
  22143. */
  22144. get: function () {
  22145. var keyboard = this.inputs.attached["keyboard"];
  22146. if (keyboard) {
  22147. return keyboard.keysUp;
  22148. }
  22149. return [];
  22150. },
  22151. /**
  22152. * Set the keys for camera movement up.
  22153. */
  22154. set: function (value) {
  22155. var keyboard = this.inputs.attached["keyboard"];
  22156. if (keyboard) {
  22157. keyboard.keysUp = value;
  22158. }
  22159. },
  22160. enumerable: true,
  22161. configurable: true
  22162. });
  22163. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  22164. /**
  22165. * Get the keys for camera movement down.
  22166. */
  22167. get: function () {
  22168. var keyboard = this.inputs.attached["keyboard"];
  22169. if (keyboard) {
  22170. return keyboard.keysDown;
  22171. }
  22172. return [];
  22173. },
  22174. /**
  22175. * Set the keys for camera movement down.
  22176. */
  22177. set: function (value) {
  22178. var keyboard = this.inputs.attached["keyboard"];
  22179. if (keyboard) {
  22180. keyboard.keysDown = value;
  22181. }
  22182. },
  22183. enumerable: true,
  22184. configurable: true
  22185. });
  22186. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  22187. /**
  22188. * Get the keys for camera movement left.
  22189. */
  22190. get: function () {
  22191. var keyboard = this.inputs.attached["keyboard"];
  22192. if (keyboard) {
  22193. return keyboard.keysLeft;
  22194. }
  22195. return [];
  22196. },
  22197. /**
  22198. * Set the keys for camera movement left.
  22199. */
  22200. set: function (value) {
  22201. var keyboard = this.inputs.attached["keyboard"];
  22202. if (keyboard) {
  22203. keyboard.keysLeft = value;
  22204. }
  22205. },
  22206. enumerable: true,
  22207. configurable: true
  22208. });
  22209. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  22210. /**
  22211. * Set the keys for camera movement right.
  22212. */
  22213. get: function () {
  22214. var keyboard = this.inputs.attached["keyboard"];
  22215. if (keyboard) {
  22216. return keyboard.keysRight;
  22217. }
  22218. return [];
  22219. },
  22220. /**
  22221. * Set the keys for camera movement right.
  22222. */
  22223. set: function (value) {
  22224. var keyboard = this.inputs.attached["keyboard"];
  22225. if (keyboard) {
  22226. keyboard.keysRight = value;
  22227. }
  22228. },
  22229. enumerable: true,
  22230. configurable: true
  22231. });
  22232. /**
  22233. * Attach a control to the HTML DOM element.
  22234. * @param element Defines the element that listens to the input events.
  22235. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  22236. */
  22237. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  22238. this.inputs.attachElement(element, noPreventDefault);
  22239. };
  22240. /**
  22241. * Detach a control from the HTML DOM element.
  22242. * The camera will stop reacting to that input.
  22243. * @param element Defines the element that listens to the input events.
  22244. */
  22245. FlyCamera.prototype.detachControl = function (element) {
  22246. this.inputs.detachElement(element);
  22247. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22248. };
  22249. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  22250. /**
  22251. * Get the mask that the camera ignores in collision events.
  22252. */
  22253. get: function () {
  22254. return this._collisionMask;
  22255. },
  22256. /**
  22257. * Set the mask that the camera ignores in collision events.
  22258. */
  22259. set: function (mask) {
  22260. this._collisionMask = !isNaN(mask) ? mask : -1;
  22261. },
  22262. enumerable: true,
  22263. configurable: true
  22264. });
  22265. /** @hidden */
  22266. FlyCamera.prototype._collideWithWorld = function (displacement) {
  22267. var globalPosition;
  22268. if (this.parent) {
  22269. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22270. }
  22271. else {
  22272. globalPosition = this.position;
  22273. }
  22274. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22275. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22276. var coordinator = this.getScene().collisionCoordinator;
  22277. if (!this._collider) {
  22278. this._collider = coordinator.createCollider();
  22279. }
  22280. this._collider._radius = this.ellipsoid;
  22281. this._collider.collisionMask = this._collisionMask;
  22282. // No need for clone, as long as gravity is not on.
  22283. var actualDisplacement = displacement;
  22284. // Add gravity to direction to prevent dual-collision checking.
  22285. if (this.applyGravity) {
  22286. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  22287. actualDisplacement = displacement.add(this.getScene().gravity);
  22288. }
  22289. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22290. };
  22291. /** @hidden */
  22292. FlyCamera.prototype._checkInputs = function () {
  22293. if (!this._localDirection) {
  22294. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22295. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22296. }
  22297. this.inputs.checkInputs();
  22298. _super.prototype._checkInputs.call(this);
  22299. };
  22300. /** @hidden */
  22301. FlyCamera.prototype._decideIfNeedsToMove = function () {
  22302. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22303. };
  22304. /** @hidden */
  22305. FlyCamera.prototype._updatePosition = function () {
  22306. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22307. this._collideWithWorld(this.cameraDirection);
  22308. }
  22309. else {
  22310. _super.prototype._updatePosition.call(this);
  22311. }
  22312. };
  22313. /**
  22314. * Restore the Roll to its target value at the rate specified.
  22315. * @param rate - Higher means slower restoring.
  22316. * @hidden
  22317. */
  22318. FlyCamera.prototype.restoreRoll = function (rate) {
  22319. var limit = this._trackRoll; // Target Roll.
  22320. var z = this.rotation.z; // Current Roll.
  22321. var delta = limit - z; // Difference in Roll.
  22322. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  22323. // If the difference is noticable, restore the Roll.
  22324. if (Math.abs(delta) >= minRad) {
  22325. // Change Z rotation towards the target Roll.
  22326. this.rotation.z += delta / rate;
  22327. // Match when near enough.
  22328. if (Math.abs(limit - this.rotation.z) <= minRad) {
  22329. this.rotation.z = limit;
  22330. }
  22331. }
  22332. };
  22333. /**
  22334. * Destroy the camera and release the current resources held by it.
  22335. */
  22336. FlyCamera.prototype.dispose = function () {
  22337. this.inputs.clear();
  22338. _super.prototype.dispose.call(this);
  22339. };
  22340. /**
  22341. * Get the current object class name.
  22342. * @returns the class name.
  22343. */
  22344. FlyCamera.prototype.getClassName = function () {
  22345. return "FlyCamera";
  22346. };
  22347. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22348. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22349. ], FlyCamera.prototype, "ellipsoid", void 0);
  22350. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22351. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22352. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  22353. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22354. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22355. ], FlyCamera.prototype, "checkCollisions", void 0);
  22356. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22357. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22358. ], FlyCamera.prototype, "applyGravity", void 0);
  22359. return FlyCamera;
  22360. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22361. /***/ }),
  22362. /***/ "./Cameras/flyCameraInputsManager.ts":
  22363. /*!*******************************************!*\
  22364. !*** ./Cameras/flyCameraInputsManager.ts ***!
  22365. \*******************************************/
  22366. /*! exports provided: FlyCameraInputsManager */
  22367. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22368. "use strict";
  22369. __webpack_require__.r(__webpack_exports__);
  22370. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  22371. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22372. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22373. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  22374. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  22375. /**
  22376. * Default Inputs manager for the FlyCamera.
  22377. * It groups all the default supported inputs for ease of use.
  22378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22379. */
  22380. var FlyCameraInputsManager = /** @class */ (function (_super) {
  22381. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  22382. /**
  22383. * Instantiates a new FlyCameraInputsManager.
  22384. * @param camera Defines the camera the inputs belong to.
  22385. */
  22386. function FlyCameraInputsManager(camera) {
  22387. return _super.call(this, camera) || this;
  22388. }
  22389. /**
  22390. * Add keyboard input support to the input manager.
  22391. * @returns the new FlyCameraKeyboardMoveInput().
  22392. */
  22393. FlyCameraInputsManager.prototype.addKeyboard = function () {
  22394. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  22395. return this;
  22396. };
  22397. /**
  22398. * Add mouse input support to the input manager.
  22399. * @param touchEnabled Enable touch screen support.
  22400. * @returns the new FlyCameraMouseInput().
  22401. */
  22402. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22403. if (touchEnabled === void 0) { touchEnabled = true; }
  22404. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  22405. return this;
  22406. };
  22407. return FlyCameraInputsManager;
  22408. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22409. /***/ }),
  22410. /***/ "./Cameras/followCamera.ts":
  22411. /*!*********************************!*\
  22412. !*** ./Cameras/followCamera.ts ***!
  22413. \*********************************/
  22414. /*! exports provided: FollowCamera, ArcFollowCamera */
  22415. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22416. "use strict";
  22417. __webpack_require__.r(__webpack_exports__);
  22418. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  22419. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  22420. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22421. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22422. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  22423. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22424. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22425. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  22426. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  22427. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  22428. return function () { return new FollowCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  22429. });
  22430. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  22431. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  22432. });
  22433. /**
  22434. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  22435. * an arc rotate version arcFollowCamera are available.
  22436. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22437. */
  22438. var FollowCamera = /** @class */ (function (_super) {
  22439. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  22440. /**
  22441. * Instantiates the follow camera.
  22442. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22443. * @param name Define the name of the camera in the scene
  22444. * @param position Define the position of the camera
  22445. * @param scene Define the scene the camera belong to
  22446. * @param lockedTarget Define the target of the camera
  22447. */
  22448. function FollowCamera(name, position, scene, lockedTarget) {
  22449. if (lockedTarget === void 0) { lockedTarget = null; }
  22450. var _this = _super.call(this, name, position, scene) || this;
  22451. /**
  22452. * Distance the follow camera should follow an object at
  22453. */
  22454. _this.radius = 12;
  22455. /**
  22456. * Minimum allowed distance of the camera to the axis of rotation
  22457. * (The camera can not get closer).
  22458. * This can help limiting how the Camera is able to move in the scene.
  22459. */
  22460. _this.lowerRadiusLimit = null;
  22461. /**
  22462. * Maximum allowed distance of the camera to the axis of rotation
  22463. * (The camera can not get further).
  22464. * This can help limiting how the Camera is able to move in the scene.
  22465. */
  22466. _this.upperRadiusLimit = null;
  22467. /**
  22468. * Define a rotation offset between the camera and the object it follows
  22469. */
  22470. _this.rotationOffset = 0;
  22471. /**
  22472. * Minimum allowed angle to camera position relative to target object.
  22473. * This can help limiting how the Camera is able to move in the scene.
  22474. */
  22475. _this.lowerRotationOffsetLimit = null;
  22476. /**
  22477. * Maximum allowed angle to camera position relative to target object.
  22478. * This can help limiting how the Camera is able to move in the scene.
  22479. */
  22480. _this.upperRotationOffsetLimit = null;
  22481. /**
  22482. * Define a height offset between the camera and the object it follows.
  22483. * It can help following an object from the top (like a car chaing a plane)
  22484. */
  22485. _this.heightOffset = 4;
  22486. /**
  22487. * Minimum allowed height of camera position relative to target object.
  22488. * This can help limiting how the Camera is able to move in the scene.
  22489. */
  22490. _this.lowerHeightOffsetLimit = null;
  22491. /**
  22492. * Maximum allowed height of camera position relative to target object.
  22493. * This can help limiting how the Camera is able to move in the scene.
  22494. */
  22495. _this.upperHeightOffsetLimit = null;
  22496. /**
  22497. * Define how fast the camera can accelerate to follow it s target.
  22498. */
  22499. _this.cameraAcceleration = 0.05;
  22500. /**
  22501. * Define the speed limit of the camera following an object.
  22502. */
  22503. _this.maxCameraSpeed = 20;
  22504. _this.lockedTarget = lockedTarget;
  22505. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  22506. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  22507. return _this;
  22508. // Uncomment the following line when the relevant handlers have been implemented.
  22509. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  22510. }
  22511. FollowCamera.prototype._follow = function (cameraTarget) {
  22512. if (!cameraTarget) {
  22513. return;
  22514. }
  22515. var yRotation;
  22516. if (cameraTarget.rotationQuaternion) {
  22517. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  22518. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  22519. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  22520. }
  22521. else {
  22522. yRotation = cameraTarget.rotation.y;
  22523. }
  22524. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  22525. var targetPosition = cameraTarget.getAbsolutePosition();
  22526. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  22527. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  22528. var dx = targetX - this.position.x;
  22529. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  22530. var dz = (targetZ) - this.position.z;
  22531. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  22532. var vy = dy * this.cameraAcceleration;
  22533. var vz = dz * this.cameraAcceleration * 2;
  22534. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  22535. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22536. }
  22537. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  22538. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22539. }
  22540. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  22541. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  22542. }
  22543. this.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  22544. this.setTarget(targetPosition);
  22545. };
  22546. /**
  22547. * Attached controls to the current camera.
  22548. * @param element Defines the element the controls should be listened from
  22549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22550. */
  22551. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  22552. this.inputs.attachElement(element, noPreventDefault);
  22553. this._reset = function () {
  22554. };
  22555. };
  22556. /**
  22557. * Detach the current controls from the camera.
  22558. * The camera will stop reacting to inputs.
  22559. * @param element Defines the element to stop listening the inputs from
  22560. */
  22561. FollowCamera.prototype.detachControl = function (element) {
  22562. this.inputs.detachElement(element);
  22563. if (this._reset) {
  22564. this._reset();
  22565. }
  22566. };
  22567. /** @hidden */
  22568. FollowCamera.prototype._checkInputs = function () {
  22569. this.inputs.checkInputs();
  22570. this._checkLimits();
  22571. _super.prototype._checkInputs.call(this);
  22572. if (this.lockedTarget) {
  22573. this._follow(this.lockedTarget);
  22574. }
  22575. };
  22576. FollowCamera.prototype._checkLimits = function () {
  22577. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  22578. this.radius = this.lowerRadiusLimit;
  22579. }
  22580. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  22581. this.radius = this.upperRadiusLimit;
  22582. }
  22583. if (this.lowerHeightOffsetLimit !== null &&
  22584. this.heightOffset < this.lowerHeightOffsetLimit) {
  22585. this.heightOffset = this.lowerHeightOffsetLimit;
  22586. }
  22587. if (this.upperHeightOffsetLimit !== null &&
  22588. this.heightOffset > this.upperHeightOffsetLimit) {
  22589. this.heightOffset = this.upperHeightOffsetLimit;
  22590. }
  22591. if (this.lowerRotationOffsetLimit !== null &&
  22592. this.rotationOffset < this.lowerRotationOffsetLimit) {
  22593. this.rotationOffset = this.lowerRotationOffsetLimit;
  22594. }
  22595. if (this.upperRotationOffsetLimit !== null &&
  22596. this.rotationOffset > this.upperRotationOffsetLimit) {
  22597. this.rotationOffset = this.upperRotationOffsetLimit;
  22598. }
  22599. };
  22600. /**
  22601. * Gets the camera class name.
  22602. * @returns the class name
  22603. */
  22604. FollowCamera.prototype.getClassName = function () {
  22605. return "FollowCamera";
  22606. };
  22607. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22608. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22609. ], FollowCamera.prototype, "radius", void 0);
  22610. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22611. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22612. ], FollowCamera.prototype, "lowerRadiusLimit", void 0);
  22613. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22614. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22615. ], FollowCamera.prototype, "upperRadiusLimit", void 0);
  22616. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22617. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22618. ], FollowCamera.prototype, "rotationOffset", void 0);
  22619. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22620. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22621. ], FollowCamera.prototype, "lowerRotationOffsetLimit", void 0);
  22622. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22623. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22624. ], FollowCamera.prototype, "upperRotationOffsetLimit", void 0);
  22625. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22626. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22627. ], FollowCamera.prototype, "heightOffset", void 0);
  22628. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22629. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22630. ], FollowCamera.prototype, "lowerHeightOffsetLimit", void 0);
  22631. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22632. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22633. ], FollowCamera.prototype, "upperHeightOffsetLimit", void 0);
  22634. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22635. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22636. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  22637. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22638. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22639. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  22640. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22641. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  22642. ], FollowCamera.prototype, "lockedTarget", void 0);
  22643. return FollowCamera;
  22644. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22645. /**
  22646. * Arc Rotate version of the follow camera.
  22647. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  22648. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22649. */
  22650. var ArcFollowCamera = /** @class */ (function (_super) {
  22651. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  22652. /**
  22653. * Instantiates a new ArcFollowCamera
  22654. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  22655. * @param name Define the name of the camera
  22656. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  22657. * @param beta Define the rotation angle of the camera around the elevation axis
  22658. * @param radius Define the radius of the camera from its target point
  22659. * @param target Define the target of the camera
  22660. * @param scene Define the scene the camera belongs to
  22661. */
  22662. function ArcFollowCamera(name,
  22663. /** The longitudinal angle of the camera */
  22664. alpha,
  22665. /** The latitudinal angle of the camera */
  22666. beta,
  22667. /** The radius of the camera from its target */
  22668. radius,
  22669. /** Define the camera target (the messh it should follow) */
  22670. target, scene) {
  22671. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  22672. _this.alpha = alpha;
  22673. _this.beta = beta;
  22674. _this.radius = radius;
  22675. _this.target = target;
  22676. _this._cartesianCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  22677. _this._follow();
  22678. return _this;
  22679. }
  22680. ArcFollowCamera.prototype._follow = function () {
  22681. if (!this.target) {
  22682. return;
  22683. }
  22684. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  22685. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  22686. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  22687. var targetPosition = this.target.getAbsolutePosition();
  22688. this.position = targetPosition.add(this._cartesianCoordinates);
  22689. this.setTarget(targetPosition);
  22690. };
  22691. /** @hidden */
  22692. ArcFollowCamera.prototype._checkInputs = function () {
  22693. _super.prototype._checkInputs.call(this);
  22694. this._follow();
  22695. };
  22696. /**
  22697. * Returns the class name of the object.
  22698. * It is mostly used internally for serialization purposes.
  22699. */
  22700. ArcFollowCamera.prototype.getClassName = function () {
  22701. return "ArcFollowCamera";
  22702. };
  22703. return ArcFollowCamera;
  22704. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22705. /***/ }),
  22706. /***/ "./Cameras/followCameraInputsManager.ts":
  22707. /*!**********************************************!*\
  22708. !*** ./Cameras/followCameraInputsManager.ts ***!
  22709. \**********************************************/
  22710. /*! exports provided: FollowCameraInputsManager */
  22711. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22712. "use strict";
  22713. __webpack_require__.r(__webpack_exports__);
  22714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  22715. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22716. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22717. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  22718. /* harmony import */ var _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Inputs/followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  22719. /* harmony import */ var _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/followCameraPointersInput */ "./Cameras/Inputs/followCameraPointersInput.ts");
  22720. /**
  22721. * Default Inputs manager for the FollowCamera.
  22722. * It groups all the default supported inputs for ease of use.
  22723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22724. */
  22725. var FollowCameraInputsManager = /** @class */ (function (_super) {
  22726. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  22727. /**
  22728. * Instantiates a new FollowCameraInputsManager.
  22729. * @param camera Defines the camera the inputs belong to
  22730. */
  22731. function FollowCameraInputsManager(camera) {
  22732. return _super.call(this, camera) || this;
  22733. }
  22734. /**
  22735. * Add keyboard input support to the input manager.
  22736. * @returns the current input manager
  22737. */
  22738. FollowCameraInputsManager.prototype.addKeyboard = function () {
  22739. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  22740. return this;
  22741. };
  22742. /**
  22743. * Add mouse wheel input support to the input manager.
  22744. * @returns the current input manager
  22745. */
  22746. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  22747. this.add(new _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["FollowCameraMouseWheelInput"]());
  22748. return this;
  22749. };
  22750. /**
  22751. * Add pointers input support to the input manager.
  22752. * @returns the current input manager
  22753. */
  22754. FollowCameraInputsManager.prototype.addPointers = function () {
  22755. this.add(new _Inputs_followCameraPointersInput__WEBPACK_IMPORTED_MODULE_4__["FollowCameraPointersInput"]());
  22756. return this;
  22757. };
  22758. /**
  22759. * Add orientation input support to the input manager.
  22760. * @returns the current input manager
  22761. */
  22762. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  22763. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  22764. return this;
  22765. };
  22766. return FollowCameraInputsManager;
  22767. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22768. /***/ }),
  22769. /***/ "./Cameras/freeCamera.ts":
  22770. /*!*******************************!*\
  22771. !*** ./Cameras/freeCamera.ts ***!
  22772. \*******************************/
  22773. /*! exports provided: FreeCamera */
  22774. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22775. "use strict";
  22776. __webpack_require__.r(__webpack_exports__);
  22777. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  22778. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22779. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22780. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22781. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22782. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22783. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22784. /**
  22785. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22786. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  22787. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22788. */
  22789. var FreeCamera = /** @class */ (function (_super) {
  22790. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  22791. /**
  22792. * Instantiates a Free Camera.
  22793. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22794. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  22795. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22796. * @param name Define the name of the camera in the scene
  22797. * @param position Define the start position of the camera in the scene
  22798. * @param scene Define the scene the camera belongs to
  22799. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22800. */
  22801. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22802. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22803. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22804. /**
  22805. * Define the collision ellipsoid of the camera.
  22806. * This is helpful to simulate a camera body like the player body around the camera
  22807. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22808. */
  22809. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  22810. /**
  22811. * Define an offset for the position of the ellipsoid around the camera.
  22812. * This can be helpful to determine the center of the body near the gravity center of the body
  22813. * instead of its head.
  22814. */
  22815. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22816. /**
  22817. * Enable or disable collisions of the camera with the rest of the scene objects.
  22818. */
  22819. _this.checkCollisions = false;
  22820. /**
  22821. * Enable or disable gravity on the camera.
  22822. */
  22823. _this.applyGravity = false;
  22824. _this._needMoveForGravity = false;
  22825. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22826. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22827. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22828. // Collisions
  22829. _this._collisionMask = -1;
  22830. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22831. if (collidedMesh === void 0) { collidedMesh = null; }
  22832. var updatePosition = function (newPos) {
  22833. _this._newPosition.copyFrom(newPos);
  22834. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22835. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22836. _this.position.addInPlace(_this._diffPosition);
  22837. if (_this.onCollide && collidedMesh) {
  22838. _this.onCollide(collidedMesh);
  22839. }
  22840. }
  22841. };
  22842. updatePosition(newPosition);
  22843. };
  22844. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"](_this);
  22845. _this.inputs.addKeyboard().addMouse();
  22846. return _this;
  22847. }
  22848. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  22849. /**
  22850. * Gets the input sensibility for a mouse input. (default is 2000.0)
  22851. * Higher values reduce sensitivity.
  22852. */
  22853. get: function () {
  22854. var mouse = this.inputs.attached["mouse"];
  22855. if (mouse) {
  22856. return mouse.angularSensibility;
  22857. }
  22858. return 0;
  22859. },
  22860. /**
  22861. * Sets the input sensibility for a mouse input. (default is 2000.0)
  22862. * Higher values reduce sensitivity.
  22863. */
  22864. set: function (value) {
  22865. var mouse = this.inputs.attached["mouse"];
  22866. if (mouse) {
  22867. mouse.angularSensibility = value;
  22868. }
  22869. },
  22870. enumerable: true,
  22871. configurable: true
  22872. });
  22873. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  22874. /**
  22875. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  22876. */
  22877. get: function () {
  22878. var keyboard = this.inputs.attached["keyboard"];
  22879. if (keyboard) {
  22880. return keyboard.keysUp;
  22881. }
  22882. return [];
  22883. },
  22884. set: function (value) {
  22885. var keyboard = this.inputs.attached["keyboard"];
  22886. if (keyboard) {
  22887. keyboard.keysUp = value;
  22888. }
  22889. },
  22890. enumerable: true,
  22891. configurable: true
  22892. });
  22893. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  22894. /**
  22895. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  22896. */
  22897. get: function () {
  22898. var keyboard = this.inputs.attached["keyboard"];
  22899. if (keyboard) {
  22900. return keyboard.keysDown;
  22901. }
  22902. return [];
  22903. },
  22904. set: function (value) {
  22905. var keyboard = this.inputs.attached["keyboard"];
  22906. if (keyboard) {
  22907. keyboard.keysDown = value;
  22908. }
  22909. },
  22910. enumerable: true,
  22911. configurable: true
  22912. });
  22913. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  22914. /**
  22915. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  22916. */
  22917. get: function () {
  22918. var keyboard = this.inputs.attached["keyboard"];
  22919. if (keyboard) {
  22920. return keyboard.keysLeft;
  22921. }
  22922. return [];
  22923. },
  22924. set: function (value) {
  22925. var keyboard = this.inputs.attached["keyboard"];
  22926. if (keyboard) {
  22927. keyboard.keysLeft = value;
  22928. }
  22929. },
  22930. enumerable: true,
  22931. configurable: true
  22932. });
  22933. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  22934. /**
  22935. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  22936. */
  22937. get: function () {
  22938. var keyboard = this.inputs.attached["keyboard"];
  22939. if (keyboard) {
  22940. return keyboard.keysRight;
  22941. }
  22942. return [];
  22943. },
  22944. set: function (value) {
  22945. var keyboard = this.inputs.attached["keyboard"];
  22946. if (keyboard) {
  22947. keyboard.keysRight = value;
  22948. }
  22949. },
  22950. enumerable: true,
  22951. configurable: true
  22952. });
  22953. /**
  22954. * Attached controls to the current camera.
  22955. * @param element Defines the element the controls should be listened from
  22956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22957. */
  22958. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  22959. this.inputs.attachElement(element, noPreventDefault);
  22960. };
  22961. /**
  22962. * Detach the current controls from the camera.
  22963. * The camera will stop reacting to inputs.
  22964. * @param element Defines the element to stop listening the inputs from
  22965. */
  22966. FreeCamera.prototype.detachControl = function (element) {
  22967. this.inputs.detachElement(element);
  22968. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22969. this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  22970. };
  22971. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  22972. /**
  22973. * Define a collision mask to limit the list of object the camera can collide with
  22974. */
  22975. get: function () {
  22976. return this._collisionMask;
  22977. },
  22978. set: function (mask) {
  22979. this._collisionMask = !isNaN(mask) ? mask : -1;
  22980. },
  22981. enumerable: true,
  22982. configurable: true
  22983. });
  22984. /** @hidden */
  22985. FreeCamera.prototype._collideWithWorld = function (displacement) {
  22986. var globalPosition;
  22987. if (this.parent) {
  22988. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22989. }
  22990. else {
  22991. globalPosition = this.position;
  22992. }
  22993. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22994. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22995. var coordinator = this.getScene().collisionCoordinator;
  22996. if (!this._collider) {
  22997. this._collider = coordinator.createCollider();
  22998. }
  22999. this._collider._radius = this.ellipsoid;
  23000. this._collider.collisionMask = this._collisionMask;
  23001. //no need for clone, as long as gravity is not on.
  23002. var actualDisplacement = displacement;
  23003. //add gravity to the direction to prevent the dual-collision checking
  23004. if (this.applyGravity) {
  23005. //this prevents mending with cameraDirection, a global variable of the free camera class.
  23006. actualDisplacement = displacement.add(this.getScene().gravity);
  23007. }
  23008. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  23009. };
  23010. /** @hidden */
  23011. FreeCamera.prototype._checkInputs = function () {
  23012. if (!this._localDirection) {
  23013. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  23014. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  23015. }
  23016. this.inputs.checkInputs();
  23017. _super.prototype._checkInputs.call(this);
  23018. };
  23019. /** @hidden */
  23020. FreeCamera.prototype._decideIfNeedsToMove = function () {
  23021. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  23022. };
  23023. /** @hidden */
  23024. FreeCamera.prototype._updatePosition = function () {
  23025. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  23026. this._collideWithWorld(this.cameraDirection);
  23027. }
  23028. else {
  23029. _super.prototype._updatePosition.call(this);
  23030. }
  23031. };
  23032. /**
  23033. * Destroy the camera and release the current resources hold by it.
  23034. */
  23035. FreeCamera.prototype.dispose = function () {
  23036. this.inputs.clear();
  23037. _super.prototype.dispose.call(this);
  23038. };
  23039. /**
  23040. * Gets the current object class name.
  23041. * @return the class name
  23042. */
  23043. FreeCamera.prototype.getClassName = function () {
  23044. return "FreeCamera";
  23045. };
  23046. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23047. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23048. ], FreeCamera.prototype, "ellipsoid", void 0);
  23049. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23050. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23051. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  23052. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23053. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23054. ], FreeCamera.prototype, "checkCollisions", void 0);
  23055. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23056. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23057. ], FreeCamera.prototype, "applyGravity", void 0);
  23058. return FreeCamera;
  23059. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  23060. /***/ }),
  23061. /***/ "./Cameras/freeCameraInputsManager.ts":
  23062. /*!********************************************!*\
  23063. !*** ./Cameras/freeCameraInputsManager.ts ***!
  23064. \********************************************/
  23065. /*! exports provided: FreeCameraInputsManager */
  23066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23067. "use strict";
  23068. __webpack_require__.r(__webpack_exports__);
  23069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  23070. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23071. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  23072. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  23073. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  23074. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  23075. /**
  23076. * Default Inputs manager for the FreeCamera.
  23077. * It groups all the default supported inputs for ease of use.
  23078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  23079. */
  23080. var FreeCameraInputsManager = /** @class */ (function (_super) {
  23081. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  23082. /**
  23083. * Instantiates a new FreeCameraInputsManager.
  23084. * @param camera Defines the camera the inputs belong to
  23085. */
  23086. function FreeCameraInputsManager(camera) {
  23087. var _this = _super.call(this, camera) || this;
  23088. /**
  23089. * @hidden
  23090. */
  23091. _this._keyboardInput = null;
  23092. /**
  23093. * @hidden
  23094. */
  23095. _this._mouseInput = null;
  23096. return _this;
  23097. }
  23098. /**
  23099. * Add keyboard input support to the input manager.
  23100. * @returns the current input manager
  23101. */
  23102. FreeCameraInputsManager.prototype.addKeyboard = function () {
  23103. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  23104. return this;
  23105. };
  23106. /**
  23107. * Add mouse input support to the input manager.
  23108. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  23109. * @returns the current input manager
  23110. */
  23111. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  23112. if (touchEnabled === void 0) { touchEnabled = true; }
  23113. if (!this._mouseInput) {
  23114. this._mouseInput = new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled);
  23115. this.add(this._mouseInput);
  23116. }
  23117. return this;
  23118. };
  23119. /**
  23120. * Removes the mouse input support from the manager
  23121. * @returns the current input manager
  23122. */
  23123. FreeCameraInputsManager.prototype.removeMouse = function () {
  23124. if (this._mouseInput) {
  23125. this.remove(this._mouseInput);
  23126. }
  23127. return this;
  23128. };
  23129. /**
  23130. * Add touch input support to the input manager.
  23131. * @returns the current input manager
  23132. */
  23133. FreeCameraInputsManager.prototype.addTouch = function () {
  23134. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraTouchInput"]());
  23135. return this;
  23136. };
  23137. return FreeCameraInputsManager;
  23138. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  23139. /***/ }),
  23140. /***/ "./Cameras/gamepadCamera.ts":
  23141. /*!**********************************!*\
  23142. !*** ./Cameras/gamepadCamera.ts ***!
  23143. \**********************************/
  23144. /*! exports provided: GamepadCamera */
  23145. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23146. "use strict";
  23147. __webpack_require__.r(__webpack_exports__);
  23148. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  23149. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23150. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  23151. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23152. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23153. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  23154. return function () { return new GamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23155. });
  23156. /**
  23157. * This represents a FPS type of camera. This is only here for back compat purpose.
  23158. * Please use the UniversalCamera instead as both are identical.
  23159. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23160. */
  23161. var GamepadCamera = /** @class */ (function (_super) {
  23162. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  23163. /**
  23164. * Instantiates a new Gamepad Camera
  23165. * This represents a FPS type of camera. This is only here for back compat purpose.
  23166. * Please use the UniversalCamera instead as both are identical.
  23167. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23168. * @param name Define the name of the camera in the scene
  23169. * @param position Define the start position of the camera in the scene
  23170. * @param scene Define the scene the camera belongs to
  23171. */
  23172. function GamepadCamera(name, position, scene) {
  23173. return _super.call(this, name, position, scene) || this;
  23174. }
  23175. /**
  23176. * Gets the current object class name.
  23177. * @return the class name
  23178. */
  23179. GamepadCamera.prototype.getClassName = function () {
  23180. return "GamepadCamera";
  23181. };
  23182. return GamepadCamera;
  23183. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  23184. /***/ }),
  23185. /***/ "./Cameras/index.ts":
  23186. /*!**************************!*\
  23187. !*** ./Cameras/index.ts ***!
  23188. \**************************/
  23189. /*! 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 */
  23190. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23191. "use strict";
  23192. __webpack_require__.r(__webpack_exports__);
  23193. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  23194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  23195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  23196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  23197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  23198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  23199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  23200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  23201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  23202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  23203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  23204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  23205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  23206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  23207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  23208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  23209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  23210. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  23211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  23212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  23213. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  23215. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  23216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  23217. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  23219. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  23220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  23221. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  23223. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  23224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  23225. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  23226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  23227. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  23228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  23229. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  23230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  23231. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  23232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  23233. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  23234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  23235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  23236. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  23237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  23238. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  23239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  23240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  23241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  23242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  23243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  23244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  23245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  23246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  23247. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  23248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  23249. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  23250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  23251. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  23252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  23253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  23254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  23255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  23256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["OnAfterEnteringVRObservableEvent"]; });
  23257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  23258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  23259. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  23260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  23261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  23262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  23263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  23264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  23265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  23266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  23267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  23268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  23269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  23270. /***/ }),
  23271. /***/ "./Cameras/targetCamera.ts":
  23272. /*!*********************************!*\
  23273. !*** ./Cameras/targetCamera.ts ***!
  23274. \*********************************/
  23275. /*! exports provided: TargetCamera */
  23276. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23277. "use strict";
  23278. __webpack_require__.r(__webpack_exports__);
  23279. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  23280. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23281. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  23282. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23283. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23284. /**
  23285. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  23286. * This is the base of the follow, arc rotate cameras and Free camera
  23287. * @see http://doc.babylonjs.com/features/cameras
  23288. */
  23289. var TargetCamera = /** @class */ (function (_super) {
  23290. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  23291. /**
  23292. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  23293. * This is the base of the follow, arc rotate cameras and Free camera
  23294. * @see http://doc.babylonjs.com/features/cameras
  23295. * @param name Defines the name of the camera in the scene
  23296. * @param position Defines the start position of the camera in the scene
  23297. * @param scene Defines the scene the camera belongs to
  23298. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  23299. */
  23300. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  23301. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  23302. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  23303. /**
  23304. * Define the current direction the camera is moving to
  23305. */
  23306. _this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  23307. /**
  23308. * Define the current rotation the camera is rotating to
  23309. */
  23310. _this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  23311. /**
  23312. * When set, the up vector of the camera will be updated by the rotation of the camera
  23313. */
  23314. _this.updateUpVectorFromRotation = false;
  23315. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23316. /**
  23317. * Define the current rotation of the camera
  23318. */
  23319. _this.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  23320. /**
  23321. * Define the current speed of the camera
  23322. */
  23323. _this.speed = 2.0;
  23324. /**
  23325. * Add cconstraint to the camera to prevent it to move freely in all directions and
  23326. * around all axis.
  23327. */
  23328. _this.noRotationConstraint = false;
  23329. /**
  23330. * Define the current target of the camera as an object or a position.
  23331. */
  23332. _this.lockedTarget = null;
  23333. /** @hidden */
  23334. _this._currentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23335. /** @hidden */
  23336. _this._initialFocalDistance = 1;
  23337. /** @hidden */
  23338. _this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23339. /** @hidden */
  23340. _this._camMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23341. /** @hidden */
  23342. _this._cameraTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23343. /** @hidden */
  23344. _this._cameraRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  23345. /** @hidden */
  23346. _this._referencePoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  23347. /** @hidden */
  23348. _this._transformedReferencePoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23349. _this._globalCurrentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23350. _this._globalCurrentUpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  23351. _this._defaultUp = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  23352. _this._cachedRotationZ = 0;
  23353. _this._cachedQuaternionRotationZ = 0;
  23354. return _this;
  23355. }
  23356. /**
  23357. * Gets the position in front of the camera at a given distance.
  23358. * @param distance The distance from the camera we want the position to be
  23359. * @returns the position
  23360. */
  23361. TargetCamera.prototype.getFrontPosition = function (distance) {
  23362. this.getWorldMatrix();
  23363. var direction = this.getTarget().subtract(this.position);
  23364. direction.normalize();
  23365. direction.scaleInPlace(distance);
  23366. return this.globalPosition.add(direction);
  23367. };
  23368. /** @hidden */
  23369. TargetCamera.prototype._getLockedTargetPosition = function () {
  23370. if (!this.lockedTarget) {
  23371. return null;
  23372. }
  23373. if (this.lockedTarget.absolutePosition) {
  23374. this.lockedTarget.computeWorldMatrix();
  23375. }
  23376. return this.lockedTarget.absolutePosition || this.lockedTarget;
  23377. };
  23378. /**
  23379. * Store current camera state of the camera (fov, position, rotation, etc..)
  23380. * @returns the camera
  23381. */
  23382. TargetCamera.prototype.storeState = function () {
  23383. this._storedPosition = this.position.clone();
  23384. this._storedRotation = this.rotation.clone();
  23385. if (this.rotationQuaternion) {
  23386. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  23387. }
  23388. return _super.prototype.storeState.call(this);
  23389. };
  23390. /**
  23391. * Restored camera state. You must call storeState() first
  23392. * @returns whether it was successful or not
  23393. * @hidden
  23394. */
  23395. TargetCamera.prototype._restoreStateValues = function () {
  23396. if (!_super.prototype._restoreStateValues.call(this)) {
  23397. return false;
  23398. }
  23399. this.position = this._storedPosition.clone();
  23400. this.rotation = this._storedRotation.clone();
  23401. if (this.rotationQuaternion) {
  23402. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  23403. }
  23404. this.cameraDirection.copyFromFloats(0, 0, 0);
  23405. this.cameraRotation.copyFromFloats(0, 0);
  23406. return true;
  23407. };
  23408. /** @hidden */
  23409. TargetCamera.prototype._initCache = function () {
  23410. _super.prototype._initCache.call(this);
  23411. this._cache.lockedTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23412. this._cache.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23413. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  23414. };
  23415. /** @hidden */
  23416. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  23417. if (!ignoreParentClass) {
  23418. _super.prototype._updateCache.call(this);
  23419. }
  23420. var lockedTargetPosition = this._getLockedTargetPosition();
  23421. if (!lockedTargetPosition) {
  23422. this._cache.lockedTarget = null;
  23423. }
  23424. else {
  23425. if (!this._cache.lockedTarget) {
  23426. this._cache.lockedTarget = lockedTargetPosition.clone();
  23427. }
  23428. else {
  23429. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  23430. }
  23431. }
  23432. this._cache.rotation.copyFrom(this.rotation);
  23433. if (this.rotationQuaternion) {
  23434. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23435. }
  23436. };
  23437. // Synchronized
  23438. /** @hidden */
  23439. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  23440. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  23441. return false;
  23442. }
  23443. var lockedTargetPosition = this._getLockedTargetPosition();
  23444. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  23445. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  23446. };
  23447. // Methods
  23448. /** @hidden */
  23449. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  23450. var engine = this.getEngine();
  23451. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  23452. };
  23453. // Target
  23454. /**
  23455. * Defines the target the camera should look at.
  23456. * This will automatically adapt alpha beta and radius to fit within the new target.
  23457. * @param target Defines the new target as a Vector or a mesh
  23458. */
  23459. TargetCamera.prototype.setTarget = function (target) {
  23460. this.upVector.normalize();
  23461. this._initialFocalDistance = target.subtract(this.position).length();
  23462. if (this.position.z === target.z) {
  23463. this.position.z += _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  23464. }
  23465. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  23466. this._camMatrix.invert();
  23467. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  23468. var vDir = target.subtract(this.position);
  23469. if (vDir.x >= 0.0) {
  23470. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  23471. }
  23472. else {
  23473. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  23474. }
  23475. this.rotation.z = 0;
  23476. if (isNaN(this.rotation.x)) {
  23477. this.rotation.x = 0;
  23478. }
  23479. if (isNaN(this.rotation.y)) {
  23480. this.rotation.y = 0;
  23481. }
  23482. if (isNaN(this.rotation.z)) {
  23483. this.rotation.z = 0;
  23484. }
  23485. if (this.rotationQuaternion) {
  23486. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  23487. }
  23488. };
  23489. /**
  23490. * Return the current target position of the camera. This value is expressed in local space.
  23491. * @returns the target position
  23492. */
  23493. TargetCamera.prototype.getTarget = function () {
  23494. return this._currentTarget;
  23495. };
  23496. /** @hidden */
  23497. TargetCamera.prototype._decideIfNeedsToMove = function () {
  23498. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  23499. };
  23500. /** @hidden */
  23501. TargetCamera.prototype._updatePosition = function () {
  23502. if (this.parent) {
  23503. this.parent.getWorldMatrix().invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  23504. _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]);
  23505. this.position.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  23506. return;
  23507. }
  23508. this.position.addInPlace(this.cameraDirection);
  23509. };
  23510. /** @hidden */
  23511. TargetCamera.prototype._checkInputs = function () {
  23512. var needToMove = this._decideIfNeedsToMove();
  23513. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  23514. // Move
  23515. if (needToMove) {
  23516. this._updatePosition();
  23517. }
  23518. // Rotate
  23519. if (needToRotate) {
  23520. this.rotation.x += this.cameraRotation.x;
  23521. this.rotation.y += this.cameraRotation.y;
  23522. //rotate, if quaternion is set and rotation was used
  23523. if (this.rotationQuaternion) {
  23524. var len = this.rotation.lengthSquared();
  23525. if (len) {
  23526. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  23527. }
  23528. }
  23529. if (!this.noRotationConstraint) {
  23530. var limit = (Math.PI / 2) * 0.95;
  23531. if (this.rotation.x > limit) {
  23532. this.rotation.x = limit;
  23533. }
  23534. if (this.rotation.x < -limit) {
  23535. this.rotation.x = -limit;
  23536. }
  23537. }
  23538. }
  23539. // Inertia
  23540. if (needToMove) {
  23541. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23542. this.cameraDirection.x = 0;
  23543. }
  23544. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23545. this.cameraDirection.y = 0;
  23546. }
  23547. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23548. this.cameraDirection.z = 0;
  23549. }
  23550. this.cameraDirection.scaleInPlace(this.inertia);
  23551. }
  23552. if (needToRotate) {
  23553. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23554. this.cameraRotation.x = 0;
  23555. }
  23556. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  23557. this.cameraRotation.y = 0;
  23558. }
  23559. this.cameraRotation.scaleInPlace(this.inertia);
  23560. }
  23561. _super.prototype._checkInputs.call(this);
  23562. };
  23563. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  23564. if (this.rotationQuaternion) {
  23565. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  23566. }
  23567. else {
  23568. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  23569. }
  23570. };
  23571. /**
  23572. * 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)
  23573. * @returns the current camera
  23574. */
  23575. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  23576. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  23577. return this;
  23578. };
  23579. /** @hidden */
  23580. TargetCamera.prototype._getViewMatrix = function () {
  23581. if (this.lockedTarget) {
  23582. this.setTarget(this._getLockedTargetPosition());
  23583. }
  23584. // Compute
  23585. this._updateCameraRotationMatrix();
  23586. // Apply the changed rotation to the upVector
  23587. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  23588. this._rotateUpVectorWithCameraRotationMatrix();
  23589. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  23590. }
  23591. else if (this._cachedRotationZ != this.rotation.z) {
  23592. this._rotateUpVectorWithCameraRotationMatrix();
  23593. this._cachedRotationZ = this.rotation.z;
  23594. }
  23595. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  23596. // Computing target and final matrix
  23597. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  23598. if (this.updateUpVectorFromRotation) {
  23599. if (this.rotationQuaternion) {
  23600. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  23601. }
  23602. else {
  23603. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  23604. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  23605. }
  23606. }
  23607. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  23608. return this._viewMatrix;
  23609. };
  23610. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  23611. if (this.parent) {
  23612. var parentWorldMatrix = this.parent.getWorldMatrix();
  23613. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  23614. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  23615. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  23616. this._markSyncedWithParent();
  23617. }
  23618. else {
  23619. this._globalPosition.copyFrom(position);
  23620. this._globalCurrentTarget.copyFrom(target);
  23621. this._globalCurrentUpVector.copyFrom(up);
  23622. }
  23623. if (this.getScene().useRightHandedSystem) {
  23624. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  23625. }
  23626. else {
  23627. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  23628. }
  23629. };
  23630. /**
  23631. * @hidden
  23632. */
  23633. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  23634. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  23635. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  23636. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  23637. if (!this.rotationQuaternion) {
  23638. this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23639. }
  23640. rigCamera._cameraRigParams = {};
  23641. rigCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  23642. }
  23643. return rigCamera;
  23644. }
  23645. return null;
  23646. };
  23647. /**
  23648. * @hidden
  23649. */
  23650. TargetCamera.prototype._updateRigCameras = function () {
  23651. var camLeft = this._rigCameras[0];
  23652. var camRight = this._rigCameras[1];
  23653. this.computeWorldMatrix();
  23654. switch (this.cameraRigMode) {
  23655. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  23656. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  23657. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  23658. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  23659. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  23660. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  23661. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  23662. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  23663. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  23664. break;
  23665. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  23666. if (camLeft.rotationQuaternion) {
  23667. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23668. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  23669. }
  23670. else {
  23671. camLeft.rotation.copyFrom(this.rotation);
  23672. camRight.rotation.copyFrom(this.rotation);
  23673. }
  23674. camLeft.position.copyFrom(this.position);
  23675. camRight.position.copyFrom(this.position);
  23676. break;
  23677. }
  23678. _super.prototype._updateRigCameras.call(this);
  23679. };
  23680. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  23681. var target = this.getTarget();
  23682. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  23683. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  23684. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  23685. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  23686. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  23687. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  23688. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  23689. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  23690. rigCamera.setTarget(newFocalTarget);
  23691. };
  23692. /**
  23693. * Gets the current object class name.
  23694. * @return the class name
  23695. */
  23696. TargetCamera.prototype.getClassName = function () {
  23697. return "TargetCamera";
  23698. };
  23699. TargetCamera._RigCamTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23700. TargetCamera._TargetTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23701. TargetCamera._TargetFocalPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  23702. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23703. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23704. ], TargetCamera.prototype, "rotation", void 0);
  23705. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23706. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23707. ], TargetCamera.prototype, "speed", void 0);
  23708. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23709. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  23710. ], TargetCamera.prototype, "lockedTarget", void 0);
  23711. return TargetCamera;
  23712. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  23713. /***/ }),
  23714. /***/ "./Cameras/touchCamera.ts":
  23715. /*!********************************!*\
  23716. !*** ./Cameras/touchCamera.ts ***!
  23717. \********************************/
  23718. /*! exports provided: TouchCamera */
  23719. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23720. "use strict";
  23721. __webpack_require__.r(__webpack_exports__);
  23722. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  23723. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23724. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23725. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23726. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23727. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  23728. return function () { return new TouchCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23729. });
  23730. /**
  23731. * This represents a FPS type of camera controlled by touch.
  23732. * This is like a universal camera minus the Gamepad controls.
  23733. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23734. */
  23735. var TouchCamera = /** @class */ (function (_super) {
  23736. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  23737. /**
  23738. * Instantiates a new touch camera.
  23739. * This represents a FPS type of camera controlled by touch.
  23740. * This is like a universal camera minus the Gamepad controls.
  23741. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23742. * @param name Define the name of the camera in the scene
  23743. * @param position Define the start position of the camera in the scene
  23744. * @param scene Define the scene the camera belongs to
  23745. */
  23746. function TouchCamera(name, position, scene) {
  23747. var _this = _super.call(this, name, position, scene) || this;
  23748. _this.inputs.addTouch();
  23749. _this._setupInputs();
  23750. return _this;
  23751. }
  23752. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  23753. /**
  23754. * Defines the touch sensibility for rotation.
  23755. * The higher the faster.
  23756. */
  23757. get: function () {
  23758. var touch = this.inputs.attached["touch"];
  23759. if (touch) {
  23760. return touch.touchAngularSensibility;
  23761. }
  23762. return 0;
  23763. },
  23764. set: function (value) {
  23765. var touch = this.inputs.attached["touch"];
  23766. if (touch) {
  23767. touch.touchAngularSensibility = value;
  23768. }
  23769. },
  23770. enumerable: true,
  23771. configurable: true
  23772. });
  23773. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  23774. /**
  23775. * Defines the touch sensibility for move.
  23776. * The higher the faster.
  23777. */
  23778. get: function () {
  23779. var touch = this.inputs.attached["touch"];
  23780. if (touch) {
  23781. return touch.touchMoveSensibility;
  23782. }
  23783. return 0;
  23784. },
  23785. set: function (value) {
  23786. var touch = this.inputs.attached["touch"];
  23787. if (touch) {
  23788. touch.touchMoveSensibility = value;
  23789. }
  23790. },
  23791. enumerable: true,
  23792. configurable: true
  23793. });
  23794. /**
  23795. * Gets the current object class name.
  23796. * @return the class name
  23797. */
  23798. TouchCamera.prototype.getClassName = function () {
  23799. return "TouchCamera";
  23800. };
  23801. /** @hidden */
  23802. TouchCamera.prototype._setupInputs = function () {
  23803. var mouse = this.inputs.attached["mouse"];
  23804. if (mouse) {
  23805. mouse.touchEnabled = false;
  23806. }
  23807. };
  23808. return TouchCamera;
  23809. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23810. /***/ }),
  23811. /***/ "./Cameras/universalCamera.ts":
  23812. /*!************************************!*\
  23813. !*** ./Cameras/universalCamera.ts ***!
  23814. \************************************/
  23815. /*! exports provided: UniversalCamera */
  23816. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23817. "use strict";
  23818. __webpack_require__.r(__webpack_exports__);
  23819. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  23820. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23821. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23822. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  23823. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23824. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23825. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  23826. // Forcing to use the Universal camera
  23827. return function () { return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  23828. });
  23829. /**
  23830. * 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,
  23831. * which still works and will still be found in many Playgrounds.
  23832. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23833. */
  23834. var UniversalCamera = /** @class */ (function (_super) {
  23835. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  23836. /**
  23837. * 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,
  23838. * which still works and will still be found in many Playgrounds.
  23839. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23840. * @param name Define the name of the camera in the scene
  23841. * @param position Define the start position of the camera in the scene
  23842. * @param scene Define the scene the camera belongs to
  23843. */
  23844. function UniversalCamera(name, position, scene) {
  23845. var _this = _super.call(this, name, position, scene) || this;
  23846. _this.inputs.addGamepad();
  23847. return _this;
  23848. }
  23849. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  23850. /**
  23851. * Defines the gamepad rotation sensiblity.
  23852. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  23853. */
  23854. get: function () {
  23855. var gamepad = this.inputs.attached["gamepad"];
  23856. if (gamepad) {
  23857. return gamepad.gamepadAngularSensibility;
  23858. }
  23859. return 0;
  23860. },
  23861. set: function (value) {
  23862. var gamepad = this.inputs.attached["gamepad"];
  23863. if (gamepad) {
  23864. gamepad.gamepadAngularSensibility = value;
  23865. }
  23866. },
  23867. enumerable: true,
  23868. configurable: true
  23869. });
  23870. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  23871. /**
  23872. * Defines the gamepad move sensiblity.
  23873. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  23874. */
  23875. get: function () {
  23876. var gamepad = this.inputs.attached["gamepad"];
  23877. if (gamepad) {
  23878. return gamepad.gamepadMoveSensibility;
  23879. }
  23880. return 0;
  23881. },
  23882. set: function (value) {
  23883. var gamepad = this.inputs.attached["gamepad"];
  23884. if (gamepad) {
  23885. gamepad.gamepadMoveSensibility = value;
  23886. }
  23887. },
  23888. enumerable: true,
  23889. configurable: true
  23890. });
  23891. /**
  23892. * Gets the current object class name.
  23893. * @return the class name
  23894. */
  23895. UniversalCamera.prototype.getClassName = function () {
  23896. return "UniversalCamera";
  23897. };
  23898. return UniversalCamera;
  23899. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  23900. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  23901. return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  23902. };
  23903. /***/ }),
  23904. /***/ "./Cameras/virtualJoysticksCamera.ts":
  23905. /*!*******************************************!*\
  23906. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  23907. \*******************************************/
  23908. /*! exports provided: VirtualJoysticksCamera */
  23909. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23910. "use strict";
  23911. __webpack_require__.r(__webpack_exports__);
  23912. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  23913. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23914. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23915. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23916. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23917. /* harmony import */ var _Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  23918. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  23919. return function () { return new VirtualJoysticksCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23920. });
  23921. /**
  23922. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  23923. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23924. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23925. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23926. */
  23927. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  23928. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  23929. /**
  23930. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  23931. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23932. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23933. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23934. * @param name Define the name of the camera in the scene
  23935. * @param position Define the start position of the camera in the scene
  23936. * @param scene Define the scene the camera belongs to
  23937. */
  23938. function VirtualJoysticksCamera(name, position, scene) {
  23939. var _this = _super.call(this, name, position, scene) || this;
  23940. _this.inputs.addVirtualJoystick();
  23941. return _this;
  23942. }
  23943. /**
  23944. * Gets the current object class name.
  23945. * @return the class name
  23946. */
  23947. VirtualJoysticksCamera.prototype.getClassName = function () {
  23948. return "VirtualJoysticksCamera";
  23949. };
  23950. return VirtualJoysticksCamera;
  23951. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23952. /***/ }),
  23953. /***/ "./Collisions/collider.ts":
  23954. /*!********************************!*\
  23955. !*** ./Collisions/collider.ts ***!
  23956. \********************************/
  23957. /*! exports provided: Collider */
  23958. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23959. "use strict";
  23960. __webpack_require__.r(__webpack_exports__);
  23961. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  23962. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23963. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  23964. if (boxMin.x > sphereCenter.x + sphereRadius) {
  23965. return false;
  23966. }
  23967. if (sphereCenter.x - sphereRadius > boxMax.x) {
  23968. return false;
  23969. }
  23970. if (boxMin.y > sphereCenter.y + sphereRadius) {
  23971. return false;
  23972. }
  23973. if (sphereCenter.y - sphereRadius > boxMax.y) {
  23974. return false;
  23975. }
  23976. if (boxMin.z > sphereCenter.z + sphereRadius) {
  23977. return false;
  23978. }
  23979. if (sphereCenter.z - sphereRadius > boxMax.z) {
  23980. return false;
  23981. }
  23982. return true;
  23983. };
  23984. var getLowestRoot = (function () {
  23985. var result = { root: 0, found: false };
  23986. return function (a, b, c, maxR) {
  23987. result.root = 0;
  23988. result.found = false;
  23989. var determinant = b * b - 4.0 * a * c;
  23990. if (determinant < 0) {
  23991. return result;
  23992. }
  23993. var sqrtD = Math.sqrt(determinant);
  23994. var r1 = (-b - sqrtD) / (2.0 * a);
  23995. var r2 = (-b + sqrtD) / (2.0 * a);
  23996. if (r1 > r2) {
  23997. var temp = r2;
  23998. r2 = r1;
  23999. r1 = temp;
  24000. }
  24001. if (r1 > 0 && r1 < maxR) {
  24002. result.root = r1;
  24003. result.found = true;
  24004. return result;
  24005. }
  24006. if (r2 > 0 && r2 < maxR) {
  24007. result.root = r2;
  24008. result.found = true;
  24009. return result;
  24010. }
  24011. return result;
  24012. };
  24013. })();
  24014. /** @hidden */
  24015. var Collider = /** @class */ (function () {
  24016. function Collider() {
  24017. this._collisionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24018. this._planeIntersectionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24019. this._tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24020. this._tempVector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24021. this._tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24022. this._tempVector4 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24023. this._edge = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24024. this._baseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24025. this._destinationPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24026. this._slidePlaneNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24027. this._displacementVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24028. /** @hidden */
  24029. this._radius = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  24030. /** @hidden */
  24031. this._retry = 0;
  24032. /** @hidden */
  24033. this._basePointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24034. this._velocityWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24035. this._normalizedVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  24036. this._collisionMask = -1;
  24037. }
  24038. Object.defineProperty(Collider.prototype, "collisionMask", {
  24039. get: function () {
  24040. return this._collisionMask;
  24041. },
  24042. set: function (mask) {
  24043. this._collisionMask = !isNaN(mask) ? mask : -1;
  24044. },
  24045. enumerable: true,
  24046. configurable: true
  24047. });
  24048. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  24049. /**
  24050. * Gets the plane normal used to compute the sliding response (in local space)
  24051. */
  24052. get: function () {
  24053. return this._slidePlaneNormal;
  24054. },
  24055. enumerable: true,
  24056. configurable: true
  24057. });
  24058. // Methods
  24059. /** @hidden */
  24060. Collider.prototype._initialize = function (source, dir, e) {
  24061. this._velocity = dir;
  24062. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  24063. this._basePoint = source;
  24064. source.multiplyToRef(this._radius, this._basePointWorld);
  24065. dir.multiplyToRef(this._radius, this._velocityWorld);
  24066. this._velocityWorldLength = this._velocityWorld.length();
  24067. this._epsilon = e;
  24068. this.collisionFound = false;
  24069. };
  24070. /** @hidden */
  24071. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  24072. pa.subtractToRef(point, this._tempVector);
  24073. pb.subtractToRef(point, this._tempVector2);
  24074. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  24075. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  24076. if (d < 0) {
  24077. return false;
  24078. }
  24079. pc.subtractToRef(point, this._tempVector3);
  24080. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  24081. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  24082. if (d < 0) {
  24083. return false;
  24084. }
  24085. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  24086. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  24087. return d >= 0;
  24088. };
  24089. /** @hidden */
  24090. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  24091. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  24092. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  24093. if (distance > this._velocityWorldLength + max + sphereRadius) {
  24094. return false;
  24095. }
  24096. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  24097. return false;
  24098. }
  24099. return true;
  24100. };
  24101. /** @hidden */
  24102. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial) {
  24103. var t0;
  24104. var embeddedInPlane = false;
  24105. //defensive programming, actually not needed.
  24106. if (!trianglePlaneArray) {
  24107. trianglePlaneArray = [];
  24108. }
  24109. if (!trianglePlaneArray[faceIndex]) {
  24110. trianglePlaneArray[faceIndex] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"](0, 0, 0, 0);
  24111. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  24112. }
  24113. var trianglePlane = trianglePlaneArray[faceIndex];
  24114. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  24115. return;
  24116. }
  24117. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  24118. var normalDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  24119. if (normalDotVelocity == 0) {
  24120. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  24121. return;
  24122. }
  24123. embeddedInPlane = true;
  24124. t0 = 0;
  24125. }
  24126. else {
  24127. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  24128. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  24129. if (t0 > t1) {
  24130. var temp = t1;
  24131. t1 = t0;
  24132. t0 = temp;
  24133. }
  24134. if (t0 > 1.0 || t1 < 0.0) {
  24135. return;
  24136. }
  24137. if (t0 < 0) {
  24138. t0 = 0;
  24139. }
  24140. if (t0 > 1.0) {
  24141. t0 = 1.0;
  24142. }
  24143. }
  24144. this._collisionPoint.copyFromFloats(0, 0, 0);
  24145. var found = false;
  24146. var t = 1.0;
  24147. if (!embeddedInPlane) {
  24148. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  24149. this._velocity.scaleToRef(t0, this._tempVector);
  24150. this._planeIntersectionPoint.addInPlace(this._tempVector);
  24151. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  24152. found = true;
  24153. t = t0;
  24154. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  24155. }
  24156. }
  24157. if (!found) {
  24158. var velocitySquaredLength = this._velocity.lengthSquared();
  24159. var a = velocitySquaredLength;
  24160. this._basePoint.subtractToRef(p1, this._tempVector);
  24161. var b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  24162. var c = this._tempVector.lengthSquared() - 1.0;
  24163. var lowestRoot = getLowestRoot(a, b, c, t);
  24164. if (lowestRoot.found) {
  24165. t = lowestRoot.root;
  24166. found = true;
  24167. this._collisionPoint.copyFrom(p1);
  24168. }
  24169. this._basePoint.subtractToRef(p2, this._tempVector);
  24170. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  24171. c = this._tempVector.lengthSquared() - 1.0;
  24172. lowestRoot = getLowestRoot(a, b, c, t);
  24173. if (lowestRoot.found) {
  24174. t = lowestRoot.root;
  24175. found = true;
  24176. this._collisionPoint.copyFrom(p2);
  24177. }
  24178. this._basePoint.subtractToRef(p3, this._tempVector);
  24179. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  24180. c = this._tempVector.lengthSquared() - 1.0;
  24181. lowestRoot = getLowestRoot(a, b, c, t);
  24182. if (lowestRoot.found) {
  24183. t = lowestRoot.root;
  24184. found = true;
  24185. this._collisionPoint.copyFrom(p3);
  24186. }
  24187. p2.subtractToRef(p1, this._edge);
  24188. p1.subtractToRef(this._basePoint, this._baseToVertex);
  24189. var edgeSquaredLength = this._edge.lengthSquared();
  24190. var edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24191. var edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24192. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24193. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24194. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24195. lowestRoot = getLowestRoot(a, b, c, t);
  24196. if (lowestRoot.found) {
  24197. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24198. if (f >= 0.0 && f <= 1.0) {
  24199. t = lowestRoot.root;
  24200. found = true;
  24201. this._edge.scaleInPlace(f);
  24202. p1.addToRef(this._edge, this._collisionPoint);
  24203. }
  24204. }
  24205. p3.subtractToRef(p2, this._edge);
  24206. p2.subtractToRef(this._basePoint, this._baseToVertex);
  24207. edgeSquaredLength = this._edge.lengthSquared();
  24208. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24209. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24210. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24211. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24212. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24213. lowestRoot = getLowestRoot(a, b, c, t);
  24214. if (lowestRoot.found) {
  24215. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24216. if (f >= 0.0 && f <= 1.0) {
  24217. t = lowestRoot.root;
  24218. found = true;
  24219. this._edge.scaleInPlace(f);
  24220. p2.addToRef(this._edge, this._collisionPoint);
  24221. }
  24222. }
  24223. p1.subtractToRef(p3, this._edge);
  24224. p3.subtractToRef(this._basePoint, this._baseToVertex);
  24225. edgeSquaredLength = this._edge.lengthSquared();
  24226. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  24227. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  24228. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  24229. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  24230. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  24231. lowestRoot = getLowestRoot(a, b, c, t);
  24232. if (lowestRoot.found) {
  24233. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  24234. if (f >= 0.0 && f <= 1.0) {
  24235. t = lowestRoot.root;
  24236. found = true;
  24237. this._edge.scaleInPlace(f);
  24238. p3.addToRef(this._edge, this._collisionPoint);
  24239. }
  24240. }
  24241. }
  24242. if (found) {
  24243. var distToCollision = t * this._velocity.length();
  24244. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  24245. if (!this.intersectionPoint) {
  24246. this.intersectionPoint = this._collisionPoint.clone();
  24247. }
  24248. else {
  24249. this.intersectionPoint.copyFrom(this._collisionPoint);
  24250. }
  24251. this._nearestDistance = distToCollision;
  24252. this.collisionFound = true;
  24253. }
  24254. }
  24255. };
  24256. /** @hidden */
  24257. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial) {
  24258. for (var i = indexStart; i < indexEnd; i += 3) {
  24259. var p1 = pts[indices[i] - decal];
  24260. var p2 = pts[indices[i + 1] - decal];
  24261. var p3 = pts[indices[i + 2] - decal];
  24262. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial);
  24263. }
  24264. };
  24265. /** @hidden */
  24266. Collider.prototype._getResponse = function (pos, vel) {
  24267. pos.addToRef(vel, this._destinationPoint);
  24268. vel.scaleInPlace((this._nearestDistance / vel.length()));
  24269. this._basePoint.addToRef(vel, pos);
  24270. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  24271. this._slidePlaneNormal.normalize();
  24272. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  24273. pos.addInPlace(this._displacementVector);
  24274. this.intersectionPoint.addInPlace(this._displacementVector);
  24275. this._slidePlaneNormal.scaleInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  24276. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  24277. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  24278. };
  24279. return Collider;
  24280. }());
  24281. /***/ }),
  24282. /***/ "./Collisions/collisionCoordinator.ts":
  24283. /*!********************************************!*\
  24284. !*** ./Collisions/collisionCoordinator.ts ***!
  24285. \********************************************/
  24286. /*! exports provided: DefaultCollisionCoordinator */
  24287. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24288. "use strict";
  24289. __webpack_require__.r(__webpack_exports__);
  24290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return DefaultCollisionCoordinator; });
  24291. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  24292. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24293. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  24294. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  24295. /** @hidden */
  24296. var DefaultCollisionCoordinator = /** @class */ (function () {
  24297. function DefaultCollisionCoordinator() {
  24298. this._scaledPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24299. this._scaledVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24300. this._finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24301. }
  24302. DefaultCollisionCoordinator.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  24303. position.divideToRef(collider._radius, this._scaledPosition);
  24304. displacement.divideToRef(collider._radius, this._scaledVelocity);
  24305. collider.collidedMesh = null;
  24306. collider._retry = 0;
  24307. collider._initialVelocity = this._scaledVelocity;
  24308. collider._initialPosition = this._scaledPosition;
  24309. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  24310. this._finalPosition.multiplyInPlace(collider._radius);
  24311. //run the callback
  24312. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  24313. };
  24314. DefaultCollisionCoordinator.prototype.createCollider = function () {
  24315. return new _collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  24316. };
  24317. DefaultCollisionCoordinator.prototype.init = function (scene) {
  24318. this._scene = scene;
  24319. };
  24320. DefaultCollisionCoordinator.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  24321. if (excludedMesh === void 0) { excludedMesh = null; }
  24322. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].CollisionsEpsilon * 10.0;
  24323. if (collider._retry >= maximumRetry) {
  24324. finalPosition.copyFrom(position);
  24325. return;
  24326. }
  24327. // Check if this is a mesh else camera or -1
  24328. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  24329. collider._initialize(position, velocity, closeDistance);
  24330. // Check all meshes
  24331. for (var index = 0; index < this._scene.meshes.length; index++) {
  24332. var mesh = this._scene.meshes[index];
  24333. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  24334. mesh._checkCollision(collider);
  24335. }
  24336. }
  24337. if (!collider.collisionFound) {
  24338. position.addToRef(velocity, finalPosition);
  24339. return;
  24340. }
  24341. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  24342. collider._getResponse(position, velocity);
  24343. }
  24344. if (velocity.length() <= closeDistance) {
  24345. finalPosition.copyFrom(position);
  24346. return;
  24347. }
  24348. collider._retry++;
  24349. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  24350. };
  24351. return DefaultCollisionCoordinator;
  24352. }());
  24353. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].CollisionCoordinatorFactory = function () {
  24354. return new DefaultCollisionCoordinator();
  24355. };
  24356. /***/ }),
  24357. /***/ "./Collisions/index.ts":
  24358. /*!*****************************!*\
  24359. !*** ./Collisions/index.ts ***!
  24360. \*****************************/
  24361. /*! exports provided: Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo */
  24362. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24363. "use strict";
  24364. __webpack_require__.r(__webpack_exports__);
  24365. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  24366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  24367. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  24368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["DefaultCollisionCoordinator"]; });
  24369. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  24370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  24371. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  24372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  24373. /***/ }),
  24374. /***/ "./Collisions/intersectionInfo.ts":
  24375. /*!****************************************!*\
  24376. !*** ./Collisions/intersectionInfo.ts ***!
  24377. \****************************************/
  24378. /*! exports provided: IntersectionInfo */
  24379. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24380. "use strict";
  24381. __webpack_require__.r(__webpack_exports__);
  24382. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return IntersectionInfo; });
  24383. /**
  24384. * @hidden
  24385. */
  24386. var IntersectionInfo = /** @class */ (function () {
  24387. function IntersectionInfo(bu, bv, distance) {
  24388. this.bu = bu;
  24389. this.bv = bv;
  24390. this.distance = distance;
  24391. this.faceId = 0;
  24392. this.subMeshId = 0;
  24393. }
  24394. return IntersectionInfo;
  24395. }());
  24396. /***/ }),
  24397. /***/ "./Collisions/pickingInfo.ts":
  24398. /*!***********************************!*\
  24399. !*** ./Collisions/pickingInfo.ts ***!
  24400. \***********************************/
  24401. /*! exports provided: PickingInfo */
  24402. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24403. "use strict";
  24404. __webpack_require__.r(__webpack_exports__);
  24405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  24406. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24407. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  24408. /**
  24409. * Information about the result of picking within a scene
  24410. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24411. */
  24412. var PickingInfo = /** @class */ (function () {
  24413. function PickingInfo() {
  24414. /** @hidden */
  24415. this._pickingUnavailable = false;
  24416. /**
  24417. * If the pick collided with an object
  24418. */
  24419. this.hit = false;
  24420. /**
  24421. * Distance away where the pick collided
  24422. */
  24423. this.distance = 0;
  24424. /**
  24425. * The location of pick collision
  24426. */
  24427. this.pickedPoint = null;
  24428. /**
  24429. * The mesh corresponding the the pick collision
  24430. */
  24431. this.pickedMesh = null;
  24432. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  24433. this.bu = 0;
  24434. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  24435. this.bv = 0;
  24436. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24437. this.faceId = -1;
  24438. /** Id of the the submesh that was picked */
  24439. this.subMeshId = 0;
  24440. /** If a sprite was picked, this will be the sprite the pick collided with */
  24441. this.pickedSprite = null;
  24442. /**
  24443. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24444. */
  24445. this.originMesh = null;
  24446. /**
  24447. * The ray that was used to perform the picking.
  24448. */
  24449. this.ray = null;
  24450. }
  24451. /**
  24452. * Gets the normal correspodning to the face the pick collided with
  24453. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24454. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24455. * @returns The normal correspodning to the face the pick collided with
  24456. */
  24457. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  24458. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  24459. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  24460. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  24461. return null;
  24462. }
  24463. var indices = this.pickedMesh.getIndices();
  24464. if (!indices) {
  24465. return null;
  24466. }
  24467. var result;
  24468. if (useVerticesNormals) {
  24469. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  24470. var normal0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  24471. var normal1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  24472. var normal2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  24473. normal0 = normal0.scale(this.bu);
  24474. normal1 = normal1.scale(this.bv);
  24475. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  24476. 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);
  24477. }
  24478. else {
  24479. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  24480. var vertex1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  24481. var vertex2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  24482. var vertex3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  24483. var p1p2 = vertex1.subtract(vertex2);
  24484. var p3p2 = vertex3.subtract(vertex2);
  24485. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  24486. }
  24487. if (useWorldCoordinates) {
  24488. var wm = this.pickedMesh.getWorldMatrix();
  24489. if (this.pickedMesh.nonUniformScaling) {
  24490. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0].copyFrom(wm);
  24491. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  24492. wm.setTranslationFromFloats(0, 0, 0);
  24493. wm.invert();
  24494. wm.transposeToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1]);
  24495. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  24496. }
  24497. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  24498. }
  24499. result.normalize();
  24500. return result;
  24501. };
  24502. /**
  24503. * Gets the texture coordinates of where the pick occured
  24504. * @returns the vector containing the coordnates of the texture
  24505. */
  24506. PickingInfo.prototype.getTextureCoordinates = function () {
  24507. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  24508. return null;
  24509. }
  24510. var indices = this.pickedMesh.getIndices();
  24511. if (!indices) {
  24512. return null;
  24513. }
  24514. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  24515. if (!uvs) {
  24516. return null;
  24517. }
  24518. var uv0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  24519. var uv1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  24520. var uv2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  24521. uv0 = uv0.scale(1.0 - this.bu - this.bv);
  24522. uv1 = uv1.scale(this.bu);
  24523. uv2 = uv2.scale(this.bv);
  24524. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  24525. };
  24526. return PickingInfo;
  24527. }());
  24528. /***/ }),
  24529. /***/ "./Culling/Octrees/index.ts":
  24530. /*!**********************************!*\
  24531. !*** ./Culling/Octrees/index.ts ***!
  24532. \**********************************/
  24533. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  24534. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24535. "use strict";
  24536. __webpack_require__.r(__webpack_exports__);
  24537. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  24539. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  24540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  24541. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  24542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  24543. /***/ }),
  24544. /***/ "./Culling/Octrees/octree.ts":
  24545. /*!***********************************!*\
  24546. !*** ./Culling/Octrees/octree.ts ***!
  24547. \***********************************/
  24548. /*! exports provided: Octree */
  24549. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24550. "use strict";
  24551. __webpack_require__.r(__webpack_exports__);
  24552. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  24553. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  24554. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  24555. /**
  24556. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  24557. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24558. */
  24559. var Octree = /** @class */ (function () {
  24560. /**
  24561. * Creates a octree
  24562. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24563. * @param creationFunc function to be used to instatiate the octree
  24564. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  24565. * @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.)
  24566. */
  24567. function Octree(creationFunc, maxBlockCapacity,
  24568. /** 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.) */
  24569. maxDepth) {
  24570. if (maxDepth === void 0) { maxDepth = 2; }
  24571. this.maxDepth = maxDepth;
  24572. /**
  24573. * Content stored in the octree
  24574. */
  24575. this.dynamicContent = new Array();
  24576. this._maxBlockCapacity = maxBlockCapacity || 64;
  24577. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  24578. this._creationFunc = creationFunc;
  24579. }
  24580. // Methods
  24581. /**
  24582. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  24583. * @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);
  24584. * @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);
  24585. * @param entries meshes to be added to the octree blocks
  24586. */
  24587. Octree.prototype.update = function (worldMin, worldMax, entries) {
  24588. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  24589. };
  24590. /**
  24591. * Adds a mesh to the octree
  24592. * @param entry Mesh to add to the octree
  24593. */
  24594. Octree.prototype.addMesh = function (entry) {
  24595. for (var index = 0; index < this.blocks.length; index++) {
  24596. var block = this.blocks[index];
  24597. block.addEntry(entry);
  24598. }
  24599. };
  24600. /**
  24601. * Remove an element from the octree
  24602. * @param entry defines the element to remove
  24603. */
  24604. Octree.prototype.removeMesh = function (entry) {
  24605. for (var index = 0; index < this.blocks.length; index++) {
  24606. var block = this.blocks[index];
  24607. block.removeEntry(entry);
  24608. }
  24609. };
  24610. /**
  24611. * Selects an array of meshes within the frustum
  24612. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  24613. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  24614. * @returns array of meshes within the frustum
  24615. */
  24616. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  24617. this._selectionContent.reset();
  24618. for (var index = 0; index < this.blocks.length; index++) {
  24619. var block = this.blocks[index];
  24620. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  24621. }
  24622. if (allowDuplicate) {
  24623. this._selectionContent.concat(this.dynamicContent);
  24624. }
  24625. else {
  24626. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24627. }
  24628. return this._selectionContent;
  24629. };
  24630. /**
  24631. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  24632. * @param sphereCenter defines the bounding sphere center
  24633. * @param sphereRadius defines the bounding sphere radius
  24634. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24635. * @returns an array of objects that intersect the sphere
  24636. */
  24637. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  24638. this._selectionContent.reset();
  24639. for (var index = 0; index < this.blocks.length; index++) {
  24640. var block = this.blocks[index];
  24641. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  24642. }
  24643. if (allowDuplicate) {
  24644. this._selectionContent.concat(this.dynamicContent);
  24645. }
  24646. else {
  24647. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24648. }
  24649. return this._selectionContent;
  24650. };
  24651. /**
  24652. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  24653. * @param ray defines the ray to test with
  24654. * @returns array of intersected objects
  24655. */
  24656. Octree.prototype.intersectsRay = function (ray) {
  24657. this._selectionContent.reset();
  24658. for (var index = 0; index < this.blocks.length; index++) {
  24659. var block = this.blocks[index];
  24660. block.intersectsRay(ray, this._selectionContent);
  24661. }
  24662. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  24663. return this._selectionContent;
  24664. };
  24665. /**
  24666. * Adds a mesh into the octree block if it intersects the block
  24667. */
  24668. Octree.CreationFuncForMeshes = function (entry, block) {
  24669. var boundingInfo = entry.getBoundingInfo();
  24670. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  24671. block.entries.push(entry);
  24672. }
  24673. };
  24674. /**
  24675. * Adds a submesh into the octree block if it intersects the block
  24676. */
  24677. Octree.CreationFuncForSubMeshes = function (entry, block) {
  24678. var boundingInfo = entry.getBoundingInfo();
  24679. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  24680. block.entries.push(entry);
  24681. }
  24682. };
  24683. return Octree;
  24684. }());
  24685. /***/ }),
  24686. /***/ "./Culling/Octrees/octreeBlock.ts":
  24687. /*!****************************************!*\
  24688. !*** ./Culling/Octrees/octreeBlock.ts ***!
  24689. \****************************************/
  24690. /*! exports provided: OctreeBlock */
  24691. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24692. "use strict";
  24693. __webpack_require__.r(__webpack_exports__);
  24694. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  24695. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24696. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  24697. /**
  24698. * Class used to store a cell in an octree
  24699. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24700. */
  24701. var OctreeBlock = /** @class */ (function () {
  24702. /**
  24703. * Creates a new block
  24704. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  24705. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  24706. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24707. * @param depth defines the current depth of this block in the octree
  24708. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  24709. * @param creationFunc defines a callback to call when an element is added to the block
  24710. */
  24711. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  24712. /**
  24713. * Gets the content of the current block
  24714. */
  24715. this.entries = new Array();
  24716. this._boundingVectors = new Array();
  24717. this._capacity = capacity;
  24718. this._depth = depth;
  24719. this._maxDepth = maxDepth;
  24720. this._creationFunc = creationFunc;
  24721. this._minPoint = minPoint;
  24722. this._maxPoint = maxPoint;
  24723. this._boundingVectors.push(minPoint.clone());
  24724. this._boundingVectors.push(maxPoint.clone());
  24725. this._boundingVectors.push(minPoint.clone());
  24726. this._boundingVectors[2].x = maxPoint.x;
  24727. this._boundingVectors.push(minPoint.clone());
  24728. this._boundingVectors[3].y = maxPoint.y;
  24729. this._boundingVectors.push(minPoint.clone());
  24730. this._boundingVectors[4].z = maxPoint.z;
  24731. this._boundingVectors.push(maxPoint.clone());
  24732. this._boundingVectors[5].z = minPoint.z;
  24733. this._boundingVectors.push(maxPoint.clone());
  24734. this._boundingVectors[6].x = minPoint.x;
  24735. this._boundingVectors.push(maxPoint.clone());
  24736. this._boundingVectors[7].y = minPoint.y;
  24737. }
  24738. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  24739. // Property
  24740. /**
  24741. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24742. */
  24743. get: function () {
  24744. return this._capacity;
  24745. },
  24746. enumerable: true,
  24747. configurable: true
  24748. });
  24749. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  24750. /**
  24751. * Gets the minimum vector (in world space) of the block's bounding box
  24752. */
  24753. get: function () {
  24754. return this._minPoint;
  24755. },
  24756. enumerable: true,
  24757. configurable: true
  24758. });
  24759. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  24760. /**
  24761. * Gets the maximum vector (in world space) of the block's bounding box
  24762. */
  24763. get: function () {
  24764. return this._maxPoint;
  24765. },
  24766. enumerable: true,
  24767. configurable: true
  24768. });
  24769. // Methods
  24770. /**
  24771. * Add a new element to this block
  24772. * @param entry defines the element to add
  24773. */
  24774. OctreeBlock.prototype.addEntry = function (entry) {
  24775. if (this.blocks) {
  24776. for (var index = 0; index < this.blocks.length; index++) {
  24777. var block = this.blocks[index];
  24778. block.addEntry(entry);
  24779. }
  24780. return;
  24781. }
  24782. this._creationFunc(entry, this);
  24783. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  24784. this.createInnerBlocks();
  24785. }
  24786. };
  24787. /**
  24788. * Remove an element from this block
  24789. * @param entry defines the element to remove
  24790. */
  24791. OctreeBlock.prototype.removeEntry = function (entry) {
  24792. if (this.blocks) {
  24793. for (var index = 0; index < this.blocks.length; index++) {
  24794. var block = this.blocks[index];
  24795. block.removeEntry(entry);
  24796. }
  24797. return;
  24798. }
  24799. var entryIndex = this.entries.indexOf(entry);
  24800. if (entryIndex > -1) {
  24801. this.entries.splice(entryIndex, 1);
  24802. }
  24803. };
  24804. /**
  24805. * Add an array of elements to this block
  24806. * @param entries defines the array of elements to add
  24807. */
  24808. OctreeBlock.prototype.addEntries = function (entries) {
  24809. for (var index = 0; index < entries.length; index++) {
  24810. var mesh = entries[index];
  24811. this.addEntry(mesh);
  24812. }
  24813. };
  24814. /**
  24815. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  24816. * @param frustumPlanes defines the frustum planes to test
  24817. * @param selection defines the array to store current content if selection is positive
  24818. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24819. */
  24820. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  24821. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  24822. if (this.blocks) {
  24823. for (var index = 0; index < this.blocks.length; index++) {
  24824. var block = this.blocks[index];
  24825. block.select(frustumPlanes, selection, allowDuplicate);
  24826. }
  24827. return;
  24828. }
  24829. if (allowDuplicate) {
  24830. selection.concat(this.entries);
  24831. }
  24832. else {
  24833. selection.concatWithNoDuplicate(this.entries);
  24834. }
  24835. }
  24836. };
  24837. /**
  24838. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  24839. * @param sphereCenter defines the bounding sphere center
  24840. * @param sphereRadius defines the bounding sphere radius
  24841. * @param selection defines the array to store current content if selection is positive
  24842. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24843. */
  24844. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  24845. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  24846. if (this.blocks) {
  24847. for (var index = 0; index < this.blocks.length; index++) {
  24848. var block = this.blocks[index];
  24849. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  24850. }
  24851. return;
  24852. }
  24853. if (allowDuplicate) {
  24854. selection.concat(this.entries);
  24855. }
  24856. else {
  24857. selection.concatWithNoDuplicate(this.entries);
  24858. }
  24859. }
  24860. };
  24861. /**
  24862. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  24863. * @param ray defines the ray to test with
  24864. * @param selection defines the array to store current content if selection is positive
  24865. */
  24866. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  24867. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  24868. if (this.blocks) {
  24869. for (var index = 0; index < this.blocks.length; index++) {
  24870. var block = this.blocks[index];
  24871. block.intersectsRay(ray, selection);
  24872. }
  24873. return;
  24874. }
  24875. selection.concatWithNoDuplicate(this.entries);
  24876. }
  24877. };
  24878. /**
  24879. * Subdivide the content into child blocks (this block will then be empty)
  24880. */
  24881. OctreeBlock.prototype.createInnerBlocks = function () {
  24882. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  24883. };
  24884. /**
  24885. * @hidden
  24886. */
  24887. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  24888. target.blocks = new Array();
  24889. 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);
  24890. // Segmenting space
  24891. for (var x = 0; x < 2; x++) {
  24892. for (var y = 0; y < 2; y++) {
  24893. for (var z = 0; z < 2; z++) {
  24894. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  24895. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  24896. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  24897. block.addEntries(entries);
  24898. target.blocks.push(block);
  24899. }
  24900. }
  24901. }
  24902. };
  24903. return OctreeBlock;
  24904. }());
  24905. /***/ }),
  24906. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  24907. /*!*************************************************!*\
  24908. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  24909. \*************************************************/
  24910. /*! exports provided: OctreeSceneComponent */
  24911. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24912. "use strict";
  24913. __webpack_require__.r(__webpack_exports__);
  24914. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  24915. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  24916. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24917. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  24918. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  24919. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  24920. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24921. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  24922. if (maxCapacity === void 0) { maxCapacity = 64; }
  24923. if (maxDepth === void 0) { maxDepth = 2; }
  24924. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24925. if (!component) {
  24926. component = new OctreeSceneComponent(this);
  24927. this._addComponent(component);
  24928. }
  24929. if (!this._selectionOctree) {
  24930. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  24931. }
  24932. var worldExtends = this.getWorldExtends();
  24933. // Update octree
  24934. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  24935. return this._selectionOctree;
  24936. };
  24937. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  24938. get: function () {
  24939. return this._selectionOctree;
  24940. },
  24941. enumerable: true,
  24942. configurable: true
  24943. });
  24944. /**
  24945. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  24946. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24947. * @param maxCapacity defines the maximum size of each block (64 by default)
  24948. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  24949. * @returns the new octree
  24950. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  24951. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24952. */
  24953. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  24954. if (maxCapacity === void 0) { maxCapacity = 64; }
  24955. if (maxDepth === void 0) { maxDepth = 2; }
  24956. var scene = this.getScene();
  24957. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24958. if (!component) {
  24959. component = new OctreeSceneComponent(scene);
  24960. scene._addComponent(component);
  24961. }
  24962. if (!this._submeshesOctree) {
  24963. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  24964. }
  24965. this.computeWorldMatrix(true);
  24966. var boundingInfo = this.getBoundingInfo();
  24967. // Update octree
  24968. var bbox = boundingInfo.boundingBox;
  24969. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  24970. return this._submeshesOctree;
  24971. };
  24972. /**
  24973. * Defines the octree scene component responsible to manage any octrees
  24974. * in a given scene.
  24975. */
  24976. var OctreeSceneComponent = /** @class */ (function () {
  24977. /**
  24978. * Creates a new instance of the component for the given scene
  24979. * @param scene Defines the scene to register the component in
  24980. */
  24981. function OctreeSceneComponent(scene) {
  24982. /**
  24983. * The component name helpfull to identify the component in the list of scene components.
  24984. */
  24985. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  24986. /**
  24987. * Indicates if the meshes have been checked to make sure they are isEnabled()
  24988. */
  24989. this.checksIsEnabled = true;
  24990. 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));
  24991. this.scene = scene;
  24992. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  24993. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  24994. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  24995. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  24996. }
  24997. /**
  24998. * Registers the component in a given scene
  24999. */
  25000. OctreeSceneComponent.prototype.register = function () {
  25001. var _this = this;
  25002. this.scene.onMeshRemovedObservable.add(function (mesh) {
  25003. var sceneOctree = _this.scene.selectionOctree;
  25004. if (sceneOctree !== undefined && sceneOctree !== null) {
  25005. var index = sceneOctree.dynamicContent.indexOf(mesh);
  25006. if (index !== -1) {
  25007. sceneOctree.dynamicContent.splice(index, 1);
  25008. }
  25009. }
  25010. });
  25011. this.scene.onMeshImportedObservable.add(function (mesh) {
  25012. var sceneOctree = _this.scene.selectionOctree;
  25013. if (sceneOctree !== undefined && sceneOctree !== null) {
  25014. sceneOctree.addMesh(mesh);
  25015. }
  25016. });
  25017. };
  25018. /**
  25019. * Return the list of active meshes
  25020. * @returns the list of active meshes
  25021. */
  25022. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  25023. if (this.scene._selectionOctree) {
  25024. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  25025. return selection;
  25026. }
  25027. return this.scene._getDefaultMeshCandidates();
  25028. };
  25029. /**
  25030. * Return the list of active sub meshes
  25031. * @param mesh The mesh to get the candidates sub meshes from
  25032. * @returns the list of active sub meshes
  25033. */
  25034. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  25035. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  25036. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  25037. return intersections;
  25038. }
  25039. return this.scene._getDefaultSubMeshCandidates(mesh);
  25040. };
  25041. /**
  25042. * Return the list of sub meshes intersecting with a given local ray
  25043. * @param mesh defines the mesh to find the submesh for
  25044. * @param localRay defines the ray in local space
  25045. * @returns the list of intersecting sub meshes
  25046. */
  25047. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  25048. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  25049. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  25050. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  25051. return intersections;
  25052. }
  25053. return this.scene._getDefaultSubMeshCandidates(mesh);
  25054. };
  25055. /**
  25056. * Return the list of sub meshes colliding with a collider
  25057. * @param mesh defines the mesh to find the submesh for
  25058. * @param collider defines the collider to evaluate the collision against
  25059. * @returns the list of colliding sub meshes
  25060. */
  25061. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  25062. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  25063. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  25064. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  25065. return intersections;
  25066. }
  25067. return this.scene._getDefaultSubMeshCandidates(mesh);
  25068. };
  25069. /**
  25070. * Rebuilds the elements related to this component in case of
  25071. * context lost for instance.
  25072. */
  25073. OctreeSceneComponent.prototype.rebuild = function () {
  25074. // Nothing to do here.
  25075. };
  25076. /**
  25077. * Disposes the component and the associated ressources.
  25078. */
  25079. OctreeSceneComponent.prototype.dispose = function () {
  25080. // Nothing to do here.
  25081. };
  25082. return OctreeSceneComponent;
  25083. }());
  25084. /***/ }),
  25085. /***/ "./Culling/boundingBox.ts":
  25086. /*!********************************!*\
  25087. !*** ./Culling/boundingBox.ts ***!
  25088. \********************************/
  25089. /*! exports provided: BoundingBox */
  25090. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25091. "use strict";
  25092. __webpack_require__.r(__webpack_exports__);
  25093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  25094. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25095. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25096. /**
  25097. * Class used to store bounding box information
  25098. */
  25099. var BoundingBox = /** @class */ (function () {
  25100. /**
  25101. * Creates a new bounding box
  25102. * @param min defines the minimum vector (in local space)
  25103. * @param max defines the maximum vector (in local space)
  25104. * @param worldMatrix defines the new world matrix
  25105. */
  25106. function BoundingBox(min, max, worldMatrix) {
  25107. /**
  25108. * Gets the 8 vectors representing the bounding box in local space
  25109. */
  25110. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25111. /**
  25112. * Gets the center of the bounding box in local space
  25113. */
  25114. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25115. /**
  25116. * Gets the center of the bounding box in world space
  25117. */
  25118. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25119. /**
  25120. * Gets the extend size in local space
  25121. */
  25122. this.extendSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25123. /**
  25124. * Gets the extend size in world space
  25125. */
  25126. this.extendSizeWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25127. /**
  25128. * Gets the OBB (object bounding box) directions
  25129. */
  25130. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25131. /**
  25132. * Gets the 8 vectors representing the bounding box in world space
  25133. */
  25134. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25135. /**
  25136. * Gets the minimum vector in world space
  25137. */
  25138. this.minimumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25139. /**
  25140. * Gets the maximum vector in world space
  25141. */
  25142. this.maximumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25143. /**
  25144. * Gets the minimum vector in local space
  25145. */
  25146. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25147. /**
  25148. * Gets the maximum vector in local space
  25149. */
  25150. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25151. this.reConstruct(min, max, worldMatrix);
  25152. }
  25153. // Methods
  25154. /**
  25155. * Recreates the entire bounding box from scratch as if we call the constructor in place
  25156. * @param min defines the new minimum vector (in local space)
  25157. * @param max defines the new maximum vector (in local space)
  25158. * @param worldMatrix defines the new world matrix
  25159. */
  25160. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  25161. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25162. var vectors = this.vectors;
  25163. this.minimum.copyFromFloats(minX, minY, minZ);
  25164. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  25165. vectors[0].copyFromFloats(minX, minY, minZ);
  25166. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  25167. vectors[2].copyFromFloats(maxX, minY, minZ);
  25168. vectors[3].copyFromFloats(minX, maxY, minZ);
  25169. vectors[4].copyFromFloats(minX, minY, maxZ);
  25170. vectors[5].copyFromFloats(maxX, maxY, minZ);
  25171. vectors[6].copyFromFloats(minX, maxY, maxZ);
  25172. vectors[7].copyFromFloats(maxX, minY, maxZ);
  25173. // OBB
  25174. max.addToRef(min, this.center).scaleInPlace(0.5);
  25175. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  25176. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  25177. };
  25178. /**
  25179. * Scale the current bounding box by applying a scale factor
  25180. * @param factor defines the scale factor to apply
  25181. * @returns the current bounding box
  25182. */
  25183. BoundingBox.prototype.scale = function (factor) {
  25184. var tmpVectors = BoundingBox.TmpVector3;
  25185. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  25186. var len = diff.length();
  25187. diff.normalizeFromLength(len);
  25188. var distance = len * factor;
  25189. var newRadius = diff.scaleInPlace(distance * 0.5);
  25190. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  25191. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  25192. this.reConstruct(min, max, this._worldMatrix);
  25193. return this;
  25194. };
  25195. /**
  25196. * Gets the world matrix of the bounding box
  25197. * @returns a matrix
  25198. */
  25199. BoundingBox.prototype.getWorldMatrix = function () {
  25200. return this._worldMatrix;
  25201. };
  25202. /** @hidden */
  25203. BoundingBox.prototype._update = function (world) {
  25204. var minWorld = this.minimumWorld;
  25205. var maxWorld = this.maximumWorld;
  25206. var directions = this.directions;
  25207. var vectorsWorld = this.vectorsWorld;
  25208. var vectors = this.vectors;
  25209. if (!world.isIdentity()) {
  25210. minWorld.setAll(Number.MAX_VALUE);
  25211. maxWorld.setAll(-Number.MAX_VALUE);
  25212. for (var index = 0; index < 8; ++index) {
  25213. var v = vectorsWorld[index];
  25214. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  25215. minWorld.minimizeInPlace(v);
  25216. maxWorld.maximizeInPlace(v);
  25217. }
  25218. // Extend
  25219. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  25220. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  25221. }
  25222. else {
  25223. minWorld.copyFrom(this.minimum);
  25224. maxWorld.copyFrom(this.maximum);
  25225. for (var index = 0; index < 8; ++index) {
  25226. vectorsWorld[index].copyFrom(vectors[index]);
  25227. }
  25228. // Extend
  25229. this.extendSizeWorld.copyFrom(this.extendSize);
  25230. this.centerWorld.copyFrom(this.center);
  25231. }
  25232. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  25233. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  25234. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  25235. this._worldMatrix = world;
  25236. };
  25237. /**
  25238. * Tests if the bounding box is intersecting the frustum planes
  25239. * @param frustumPlanes defines the frustum planes to test
  25240. * @returns true if there is an intersection
  25241. */
  25242. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  25243. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  25244. };
  25245. /**
  25246. * Tests if the bounding box is entirely inside the frustum planes
  25247. * @param frustumPlanes defines the frustum planes to test
  25248. * @returns true if there is an inclusion
  25249. */
  25250. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  25251. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  25252. };
  25253. /**
  25254. * Tests if a point is inside the bounding box
  25255. * @param point defines the point to test
  25256. * @returns true if the point is inside the bounding box
  25257. */
  25258. BoundingBox.prototype.intersectsPoint = function (point) {
  25259. var min = this.minimumWorld;
  25260. var max = this.maximumWorld;
  25261. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25262. var pointX = point.x, pointY = point.y, pointZ = point.z;
  25263. var delta = -_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  25264. if (maxX - pointX < delta || delta > pointX - minX) {
  25265. return false;
  25266. }
  25267. if (maxY - pointY < delta || delta > pointY - minY) {
  25268. return false;
  25269. }
  25270. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  25271. return false;
  25272. }
  25273. return true;
  25274. };
  25275. /**
  25276. * Tests if the bounding box intersects with a bounding sphere
  25277. * @param sphere defines the sphere to test
  25278. * @returns true if there is an intersection
  25279. */
  25280. BoundingBox.prototype.intersectsSphere = function (sphere) {
  25281. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  25282. };
  25283. /**
  25284. * Tests if the bounding box intersects with a box defined by a min and max vectors
  25285. * @param min defines the min vector to use
  25286. * @param max defines the max vector to use
  25287. * @returns true if there is an intersection
  25288. */
  25289. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  25290. var myMin = this.minimumWorld;
  25291. var myMax = this.maximumWorld;
  25292. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  25293. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  25294. if (myMaxX < minX || myMinX > maxX) {
  25295. return false;
  25296. }
  25297. if (myMaxY < minY || myMinY > maxY) {
  25298. return false;
  25299. }
  25300. if (myMaxZ < minZ || myMinZ > maxZ) {
  25301. return false;
  25302. }
  25303. return true;
  25304. };
  25305. // Statics
  25306. /**
  25307. * Tests if two bounding boxes are intersections
  25308. * @param box0 defines the first box to test
  25309. * @param box1 defines the second box to test
  25310. * @returns true if there is an intersection
  25311. */
  25312. BoundingBox.Intersects = function (box0, box1) {
  25313. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  25314. };
  25315. /**
  25316. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  25317. * @param minPoint defines the minimum vector of the bounding box
  25318. * @param maxPoint defines the maximum vector of the bounding box
  25319. * @param sphereCenter defines the sphere center
  25320. * @param sphereRadius defines the sphere radius
  25321. * @returns true if there is an intersection
  25322. */
  25323. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  25324. var vector = BoundingBox.TmpVector3[0];
  25325. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  25326. var num = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  25327. return (num <= (sphereRadius * sphereRadius));
  25328. };
  25329. /**
  25330. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  25331. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  25332. * @param frustumPlanes defines the frustum planes to test
  25333. * @return true if there is an inclusion
  25334. */
  25335. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  25336. for (var p = 0; p < 6; ++p) {
  25337. var frustumPlane = frustumPlanes[p];
  25338. for (var i = 0; i < 8; ++i) {
  25339. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  25340. return false;
  25341. }
  25342. }
  25343. }
  25344. return true;
  25345. };
  25346. /**
  25347. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  25348. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  25349. * @param frustumPlanes defines the frustum planes to test
  25350. * @return true if there is an intersection
  25351. */
  25352. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  25353. for (var p = 0; p < 6; ++p) {
  25354. var canReturnFalse = true;
  25355. var frustumPlane = frustumPlanes[p];
  25356. for (var i = 0; i < 8; ++i) {
  25357. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  25358. canReturnFalse = false;
  25359. break;
  25360. }
  25361. }
  25362. if (canReturnFalse) {
  25363. return false;
  25364. }
  25365. }
  25366. return true;
  25367. };
  25368. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25369. return BoundingBox;
  25370. }());
  25371. /***/ }),
  25372. /***/ "./Culling/boundingInfo.ts":
  25373. /*!*********************************!*\
  25374. !*** ./Culling/boundingInfo.ts ***!
  25375. \*********************************/
  25376. /*! exports provided: BoundingInfo */
  25377. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25378. "use strict";
  25379. __webpack_require__.r(__webpack_exports__);
  25380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  25381. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25382. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25383. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  25384. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25385. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25386. var _result0 = { min: 0, max: 0 };
  25387. var _result1 = { min: 0, max: 0 };
  25388. var computeBoxExtents = function (axis, box, result) {
  25389. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  25390. var r0 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  25391. var r1 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  25392. var r2 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  25393. var r = r0 + r1 + r2;
  25394. result.min = p - r;
  25395. result.max = p + r;
  25396. };
  25397. var axisOverlap = function (axis, box0, box1) {
  25398. computeBoxExtents(axis, box0, _result0);
  25399. computeBoxExtents(axis, box1, _result1);
  25400. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  25401. };
  25402. /**
  25403. * Info for a bounding data of a mesh
  25404. */
  25405. var BoundingInfo = /** @class */ (function () {
  25406. /**
  25407. * Constructs bounding info
  25408. * @param minimum min vector of the bounding box/sphere
  25409. * @param maximum max vector of the bounding box/sphere
  25410. * @param worldMatrix defines the new world matrix
  25411. */
  25412. function BoundingInfo(minimum, maximum, worldMatrix) {
  25413. this._isLocked = false;
  25414. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  25415. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  25416. }
  25417. /**
  25418. * Recreates the entire bounding info from scratch as if we call the constructor in place
  25419. * @param min defines the new minimum vector (in local space)
  25420. * @param max defines the new maximum vector (in local space)
  25421. * @param worldMatrix defines the new world matrix
  25422. */
  25423. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  25424. this.boundingBox.reConstruct(min, max, worldMatrix);
  25425. this.boundingSphere.reConstruct(min, max, worldMatrix);
  25426. };
  25427. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  25428. /**
  25429. * min vector of the bounding box/sphere
  25430. */
  25431. get: function () {
  25432. return this.boundingBox.minimum;
  25433. },
  25434. enumerable: true,
  25435. configurable: true
  25436. });
  25437. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  25438. /**
  25439. * max vector of the bounding box/sphere
  25440. */
  25441. get: function () {
  25442. return this.boundingBox.maximum;
  25443. },
  25444. enumerable: true,
  25445. configurable: true
  25446. });
  25447. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  25448. /**
  25449. * If the info is locked and won't be updated to avoid perf overhead
  25450. */
  25451. get: function () {
  25452. return this._isLocked;
  25453. },
  25454. set: function (value) {
  25455. this._isLocked = value;
  25456. },
  25457. enumerable: true,
  25458. configurable: true
  25459. });
  25460. // Methods
  25461. /**
  25462. * Updates the bounding sphere and box
  25463. * @param world world matrix to be used to update
  25464. */
  25465. BoundingInfo.prototype.update = function (world) {
  25466. if (this._isLocked) {
  25467. return;
  25468. }
  25469. this.boundingBox._update(world);
  25470. this.boundingSphere._update(world);
  25471. };
  25472. /**
  25473. * Recreate the bounding info to be centered around a specific point given a specific extend.
  25474. * @param center New center of the bounding info
  25475. * @param extend New extend of the bounding info
  25476. * @returns the current bounding info
  25477. */
  25478. BoundingInfo.prototype.centerOn = function (center, extend) {
  25479. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  25480. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  25481. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  25482. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  25483. return this;
  25484. };
  25485. /**
  25486. * Scale the current bounding info by applying a scale factor
  25487. * @param factor defines the scale factor to apply
  25488. * @returns the current bounding info
  25489. */
  25490. BoundingInfo.prototype.scale = function (factor) {
  25491. this.boundingBox.scale(factor);
  25492. this.boundingSphere.scale(factor);
  25493. return this;
  25494. };
  25495. /**
  25496. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  25497. * @param frustumPlanes defines the frustum to test
  25498. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  25499. * @returns true if the bounding info is in the frustum planes
  25500. */
  25501. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  25502. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  25503. 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);
  25504. if (inclusionTest) {
  25505. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  25506. return true;
  25507. }
  25508. }
  25509. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  25510. return false;
  25511. }
  25512. 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);
  25513. if (bSphereOnlyTest) {
  25514. return true;
  25515. }
  25516. return this.boundingBox.isInFrustum(frustumPlanes);
  25517. };
  25518. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  25519. /**
  25520. * Gets the world distance between the min and max points of the bounding box
  25521. */
  25522. get: function () {
  25523. var boundingBox = this.boundingBox;
  25524. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  25525. return diag.length();
  25526. },
  25527. enumerable: true,
  25528. configurable: true
  25529. });
  25530. /**
  25531. * Checks if a cullable object (mesh...) is in the camera frustum
  25532. * Unlike isInFrustum this cheks the full bounding box
  25533. * @param frustumPlanes Camera near/planes
  25534. * @returns true if the object is in frustum otherwise false
  25535. */
  25536. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  25537. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  25538. };
  25539. /** @hidden */
  25540. BoundingInfo.prototype._checkCollision = function (collider) {
  25541. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  25542. };
  25543. /**
  25544. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  25545. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25546. * @param point the point to check intersection with
  25547. * @returns if the point intersects
  25548. */
  25549. BoundingInfo.prototype.intersectsPoint = function (point) {
  25550. if (!this.boundingSphere.centerWorld) {
  25551. return false;
  25552. }
  25553. if (!this.boundingSphere.intersectsPoint(point)) {
  25554. return false;
  25555. }
  25556. if (!this.boundingBox.intersectsPoint(point)) {
  25557. return false;
  25558. }
  25559. return true;
  25560. };
  25561. /**
  25562. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  25563. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25564. * @param boundingInfo the bounding info to check intersection with
  25565. * @param precise if the intersection should be done using OBB
  25566. * @returns if the bounding info intersects
  25567. */
  25568. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  25569. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  25570. return false;
  25571. }
  25572. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  25573. return false;
  25574. }
  25575. if (!precise) {
  25576. return true;
  25577. }
  25578. var box0 = this.boundingBox;
  25579. var box1 = boundingInfo.boundingBox;
  25580. if (!axisOverlap(box0.directions[0], box0, box1)) {
  25581. return false;
  25582. }
  25583. if (!axisOverlap(box0.directions[1], box0, box1)) {
  25584. return false;
  25585. }
  25586. if (!axisOverlap(box0.directions[2], box0, box1)) {
  25587. return false;
  25588. }
  25589. if (!axisOverlap(box1.directions[0], box0, box1)) {
  25590. return false;
  25591. }
  25592. if (!axisOverlap(box1.directions[1], box0, box1)) {
  25593. return false;
  25594. }
  25595. if (!axisOverlap(box1.directions[2], box0, box1)) {
  25596. return false;
  25597. }
  25598. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  25599. return false;
  25600. }
  25601. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  25602. return false;
  25603. }
  25604. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  25605. return false;
  25606. }
  25607. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  25608. return false;
  25609. }
  25610. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  25611. return false;
  25612. }
  25613. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  25614. return false;
  25615. }
  25616. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  25617. return false;
  25618. }
  25619. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  25620. return false;
  25621. }
  25622. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  25623. return false;
  25624. }
  25625. return true;
  25626. };
  25627. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25628. return BoundingInfo;
  25629. }());
  25630. /***/ }),
  25631. /***/ "./Culling/boundingSphere.ts":
  25632. /*!***********************************!*\
  25633. !*** ./Culling/boundingSphere.ts ***!
  25634. \***********************************/
  25635. /*! exports provided: BoundingSphere */
  25636. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25637. "use strict";
  25638. __webpack_require__.r(__webpack_exports__);
  25639. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return BoundingSphere; });
  25640. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25641. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25642. /**
  25643. * Class used to store bounding sphere information
  25644. */
  25645. var BoundingSphere = /** @class */ (function () {
  25646. /**
  25647. * Creates a new bounding sphere
  25648. * @param min defines the minimum vector (in local space)
  25649. * @param max defines the maximum vector (in local space)
  25650. * @param worldMatrix defines the new world matrix
  25651. */
  25652. function BoundingSphere(min, max, worldMatrix) {
  25653. /**
  25654. * Gets the center of the bounding sphere in local space
  25655. */
  25656. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25657. /**
  25658. * Gets the center of the bounding sphere in world space
  25659. */
  25660. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25661. /**
  25662. * Gets the minimum vector in local space
  25663. */
  25664. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25665. /**
  25666. * Gets the maximum vector in local space
  25667. */
  25668. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  25669. this.reConstruct(min, max, worldMatrix);
  25670. }
  25671. /**
  25672. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  25673. * @param min defines the new minimum vector (in local space)
  25674. * @param max defines the new maximum vector (in local space)
  25675. * @param worldMatrix defines the new world matrix
  25676. */
  25677. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  25678. this.minimum.copyFrom(min);
  25679. this.maximum.copyFrom(max);
  25680. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  25681. max.addToRef(min, this.center).scaleInPlace(0.5);
  25682. this.radius = distance * 0.5;
  25683. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  25684. };
  25685. /**
  25686. * Scale the current bounding sphere by applying a scale factor
  25687. * @param factor defines the scale factor to apply
  25688. * @returns the current bounding box
  25689. */
  25690. BoundingSphere.prototype.scale = function (factor) {
  25691. var newRadius = this.radius * factor;
  25692. var tmpVectors = BoundingSphere.TmpVector3;
  25693. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  25694. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  25695. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  25696. this.reConstruct(min, max, this._worldMatrix);
  25697. return this;
  25698. };
  25699. /**
  25700. * Gets the world matrix of the bounding box
  25701. * @returns a matrix
  25702. */
  25703. BoundingSphere.prototype.getWorldMatrix = function () {
  25704. return this._worldMatrix;
  25705. };
  25706. // Methods
  25707. /** @hidden */
  25708. BoundingSphere.prototype._update = function (worldMatrix) {
  25709. if (!worldMatrix.isIdentity()) {
  25710. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  25711. var tempVector = BoundingSphere.TmpVector3[0];
  25712. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  25713. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  25714. }
  25715. else {
  25716. this.centerWorld.copyFrom(this.center);
  25717. this.radiusWorld = this.radius;
  25718. }
  25719. };
  25720. /**
  25721. * Tests if the bounding sphere is intersecting the frustum planes
  25722. * @param frustumPlanes defines the frustum planes to test
  25723. * @returns true if there is an intersection
  25724. */
  25725. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  25726. var center = this.centerWorld;
  25727. var radius = this.radiusWorld;
  25728. for (var i = 0; i < 6; i++) {
  25729. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  25730. return false;
  25731. }
  25732. }
  25733. return true;
  25734. };
  25735. /**
  25736. * Tests if the bounding sphere center is in between the frustum planes.
  25737. * Used for optimistic fast inclusion.
  25738. * @param frustumPlanes defines the frustum planes to test
  25739. * @returns true if the sphere center is in between the frustum planes
  25740. */
  25741. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  25742. var center = this.centerWorld;
  25743. for (var i = 0; i < 6; i++) {
  25744. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  25745. return false;
  25746. }
  25747. }
  25748. return true;
  25749. };
  25750. /**
  25751. * Tests if a point is inside the bounding sphere
  25752. * @param point defines the point to test
  25753. * @returns true if the point is inside the bounding sphere
  25754. */
  25755. BoundingSphere.prototype.intersectsPoint = function (point) {
  25756. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  25757. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  25758. return false;
  25759. }
  25760. return true;
  25761. };
  25762. // Statics
  25763. /**
  25764. * Checks if two sphere intersct
  25765. * @param sphere0 sphere 0
  25766. * @param sphere1 sphere 1
  25767. * @returns true if the speres intersect
  25768. */
  25769. BoundingSphere.Intersects = function (sphere0, sphere1) {
  25770. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  25771. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  25772. if (radiusSum * radiusSum < squareDistance) {
  25773. return false;
  25774. }
  25775. return true;
  25776. };
  25777. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25778. return BoundingSphere;
  25779. }());
  25780. /***/ }),
  25781. /***/ "./Culling/index.ts":
  25782. /*!**************************!*\
  25783. !*** ./Culling/index.ts ***!
  25784. \**************************/
  25785. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  25786. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25787. "use strict";
  25788. __webpack_require__.r(__webpack_exports__);
  25789. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  25791. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  25792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  25793. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  25795. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  25796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  25797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  25798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  25799. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  25800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  25801. /***/ }),
  25802. /***/ "./Culling/ray.ts":
  25803. /*!************************!*\
  25804. !*** ./Culling/ray.ts ***!
  25805. \************************/
  25806. /*! exports provided: Ray */
  25807. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25808. "use strict";
  25809. __webpack_require__.r(__webpack_exports__);
  25810. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  25811. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25812. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25813. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  25814. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  25815. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25816. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  25817. /**
  25818. * Class representing a ray with position and direction
  25819. */
  25820. var Ray = /** @class */ (function () {
  25821. /**
  25822. * Creates a new ray
  25823. * @param origin origin point
  25824. * @param direction direction
  25825. * @param length length of the ray
  25826. */
  25827. function Ray(
  25828. /** origin point */
  25829. origin,
  25830. /** direction */
  25831. direction,
  25832. /** length of the ray */
  25833. length) {
  25834. if (length === void 0) { length = Number.MAX_VALUE; }
  25835. this.origin = origin;
  25836. this.direction = direction;
  25837. this.length = length;
  25838. }
  25839. // Methods
  25840. /**
  25841. * Checks if the ray intersects a box
  25842. * @param minimum bound of the box
  25843. * @param maximum bound of the box
  25844. * @param intersectionTreshold extra extend to be added to the box in all direction
  25845. * @returns if the box was hit
  25846. */
  25847. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  25848. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25849. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  25850. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  25851. var d = 0.0;
  25852. var maxValue = Number.MAX_VALUE;
  25853. var inv;
  25854. var min;
  25855. var max;
  25856. var temp;
  25857. if (Math.abs(this.direction.x) < 0.0000001) {
  25858. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  25859. return false;
  25860. }
  25861. }
  25862. else {
  25863. inv = 1.0 / this.direction.x;
  25864. min = (newMinimum.x - this.origin.x) * inv;
  25865. max = (newMaximum.x - this.origin.x) * inv;
  25866. if (max === -Infinity) {
  25867. max = Infinity;
  25868. }
  25869. if (min > max) {
  25870. temp = min;
  25871. min = max;
  25872. max = temp;
  25873. }
  25874. d = Math.max(min, d);
  25875. maxValue = Math.min(max, maxValue);
  25876. if (d > maxValue) {
  25877. return false;
  25878. }
  25879. }
  25880. if (Math.abs(this.direction.y) < 0.0000001) {
  25881. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  25882. return false;
  25883. }
  25884. }
  25885. else {
  25886. inv = 1.0 / this.direction.y;
  25887. min = (newMinimum.y - this.origin.y) * inv;
  25888. max = (newMaximum.y - this.origin.y) * inv;
  25889. if (max === -Infinity) {
  25890. max = Infinity;
  25891. }
  25892. if (min > max) {
  25893. temp = min;
  25894. min = max;
  25895. max = temp;
  25896. }
  25897. d = Math.max(min, d);
  25898. maxValue = Math.min(max, maxValue);
  25899. if (d > maxValue) {
  25900. return false;
  25901. }
  25902. }
  25903. if (Math.abs(this.direction.z) < 0.0000001) {
  25904. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  25905. return false;
  25906. }
  25907. }
  25908. else {
  25909. inv = 1.0 / this.direction.z;
  25910. min = (newMinimum.z - this.origin.z) * inv;
  25911. max = (newMaximum.z - this.origin.z) * inv;
  25912. if (max === -Infinity) {
  25913. max = Infinity;
  25914. }
  25915. if (min > max) {
  25916. temp = min;
  25917. min = max;
  25918. max = temp;
  25919. }
  25920. d = Math.max(min, d);
  25921. maxValue = Math.min(max, maxValue);
  25922. if (d > maxValue) {
  25923. return false;
  25924. }
  25925. }
  25926. return true;
  25927. };
  25928. /**
  25929. * Checks if the ray intersects a box
  25930. * @param box the bounding box to check
  25931. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  25932. * @returns if the box was hit
  25933. */
  25934. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  25935. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25936. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  25937. };
  25938. /**
  25939. * If the ray hits a sphere
  25940. * @param sphere the bounding sphere to check
  25941. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  25942. * @returns true if it hits the sphere
  25943. */
  25944. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  25945. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25946. var x = sphere.center.x - this.origin.x;
  25947. var y = sphere.center.y - this.origin.y;
  25948. var z = sphere.center.z - this.origin.z;
  25949. var pyth = (x * x) + (y * y) + (z * z);
  25950. var radius = sphere.radius + intersectionTreshold;
  25951. var rr = radius * radius;
  25952. if (pyth <= rr) {
  25953. return true;
  25954. }
  25955. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  25956. if (dot < 0.0) {
  25957. return false;
  25958. }
  25959. var temp = pyth - (dot * dot);
  25960. return temp <= rr;
  25961. };
  25962. /**
  25963. * If the ray hits a triange
  25964. * @param vertex0 triangle vertex
  25965. * @param vertex1 triangle vertex
  25966. * @param vertex2 triangle vertex
  25967. * @returns intersection information if hit
  25968. */
  25969. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  25970. var edge1 = Ray.TmpVector3[0];
  25971. var edge2 = Ray.TmpVector3[1];
  25972. var pvec = Ray.TmpVector3[2];
  25973. var tvec = Ray.TmpVector3[3];
  25974. var qvec = Ray.TmpVector3[4];
  25975. vertex1.subtractToRef(vertex0, edge1);
  25976. vertex2.subtractToRef(vertex0, edge2);
  25977. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  25978. var det = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  25979. if (det === 0) {
  25980. return null;
  25981. }
  25982. var invdet = 1 / det;
  25983. this.origin.subtractToRef(vertex0, tvec);
  25984. var bu = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  25985. if (bu < 0 || bu > 1.0) {
  25986. return null;
  25987. }
  25988. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  25989. var bv = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  25990. if (bv < 0 || bu + bv > 1.0) {
  25991. return null;
  25992. }
  25993. //check if the distance is longer than the predefined length.
  25994. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  25995. if (distance > this.length) {
  25996. return null;
  25997. }
  25998. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](bu, bv, distance);
  25999. };
  26000. /**
  26001. * Checks if ray intersects a plane
  26002. * @param plane the plane to check
  26003. * @returns the distance away it was hit
  26004. */
  26005. Ray.prototype.intersectsPlane = function (plane) {
  26006. var distance;
  26007. var result1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  26008. if (Math.abs(result1) < 9.99999997475243E-07) {
  26009. return null;
  26010. }
  26011. else {
  26012. var result2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  26013. distance = (-plane.d - result2) / result1;
  26014. if (distance < 0.0) {
  26015. if (distance < -9.99999997475243E-07) {
  26016. return null;
  26017. }
  26018. else {
  26019. return 0;
  26020. }
  26021. }
  26022. return distance;
  26023. }
  26024. };
  26025. /**
  26026. * Checks if ray intersects a mesh
  26027. * @param mesh the mesh to check
  26028. * @param fastCheck if only the bounding box should checked
  26029. * @returns picking info of the intersecton
  26030. */
  26031. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  26032. var tm = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  26033. mesh.getWorldMatrix().invertToRef(tm);
  26034. if (this._tmpRay) {
  26035. Ray.TransformToRef(this, tm, this._tmpRay);
  26036. }
  26037. else {
  26038. this._tmpRay = Ray.Transform(this, tm);
  26039. }
  26040. return mesh.intersects(this._tmpRay, fastCheck);
  26041. };
  26042. /**
  26043. * Checks if ray intersects a mesh
  26044. * @param meshes the meshes to check
  26045. * @param fastCheck if only the bounding box should checked
  26046. * @param results array to store result in
  26047. * @returns Array of picking infos
  26048. */
  26049. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  26050. if (results) {
  26051. results.length = 0;
  26052. }
  26053. else {
  26054. results = [];
  26055. }
  26056. for (var i = 0; i < meshes.length; i++) {
  26057. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  26058. if (pickInfo.hit) {
  26059. results.push(pickInfo);
  26060. }
  26061. }
  26062. results.sort(this._comparePickingInfo);
  26063. return results;
  26064. };
  26065. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  26066. if (pickingInfoA.distance < pickingInfoB.distance) {
  26067. return -1;
  26068. }
  26069. else if (pickingInfoA.distance > pickingInfoB.distance) {
  26070. return 1;
  26071. }
  26072. else {
  26073. return 0;
  26074. }
  26075. };
  26076. /**
  26077. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  26078. * @param sega the first point of the segment to test the intersection against
  26079. * @param segb the second point of the segment to test the intersection against
  26080. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  26081. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  26082. */
  26083. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  26084. var o = this.origin;
  26085. var u = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  26086. var rsegb = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  26087. var v = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  26088. var w = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  26089. segb.subtractToRef(sega, u);
  26090. this.direction.scaleToRef(Ray.rayl, v);
  26091. o.addToRef(v, rsegb);
  26092. sega.subtractToRef(o, w);
  26093. var a = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  26094. var b = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  26095. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  26096. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  26097. var e = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  26098. var D = a * c - b * b; // always >= 0
  26099. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  26100. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  26101. // compute the line parameters of the two closest points
  26102. if (D < Ray.smallnum) { // the lines are almost parallel
  26103. sN = 0.0; // force using point P0 on segment S1
  26104. sD = 1.0; // to prevent possible division by 0.0 later
  26105. tN = e;
  26106. tD = c;
  26107. }
  26108. else { // get the closest points on the infinite lines
  26109. sN = (b * e - c * d);
  26110. tN = (a * e - b * d);
  26111. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  26112. sN = 0.0;
  26113. tN = e;
  26114. tD = c;
  26115. }
  26116. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  26117. sN = sD;
  26118. tN = e + b;
  26119. tD = c;
  26120. }
  26121. }
  26122. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  26123. tN = 0.0;
  26124. // recompute sc for this edge
  26125. if (-d < 0.0) {
  26126. sN = 0.0;
  26127. }
  26128. else if (-d > a) {
  26129. sN = sD;
  26130. }
  26131. else {
  26132. sN = -d;
  26133. sD = a;
  26134. }
  26135. }
  26136. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  26137. tN = tD;
  26138. // recompute sc for this edge
  26139. if ((-d + b) < 0.0) {
  26140. sN = 0;
  26141. }
  26142. else if ((-d + b) > a) {
  26143. sN = sD;
  26144. }
  26145. else {
  26146. sN = (-d + b);
  26147. sD = a;
  26148. }
  26149. }
  26150. // finally do the division to get sc and tc
  26151. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  26152. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  26153. // get the difference of the two closest points
  26154. var qtc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  26155. v.scaleToRef(tc, qtc);
  26156. var qsc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  26157. u.scaleToRef(sc, qsc);
  26158. qsc.addInPlace(w);
  26159. var dP = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  26160. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  26161. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  26162. if (isIntersected) {
  26163. return qsc.length();
  26164. }
  26165. return -1;
  26166. };
  26167. /**
  26168. * Update the ray from viewport position
  26169. * @param x position
  26170. * @param y y position
  26171. * @param viewportWidth viewport width
  26172. * @param viewportHeight viewport height
  26173. * @param world world matrix
  26174. * @param view view matrix
  26175. * @param projection projection matrix
  26176. * @returns this ray updated
  26177. */
  26178. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  26179. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  26180. return this;
  26181. };
  26182. // Statics
  26183. /**
  26184. * Creates a ray with origin and direction of 0,0,0
  26185. * @returns the new ray
  26186. */
  26187. Ray.Zero = function () {
  26188. return new Ray(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  26189. };
  26190. /**
  26191. * Creates a new ray from screen space and viewport
  26192. * @param x position
  26193. * @param y y position
  26194. * @param viewportWidth viewport width
  26195. * @param viewportHeight viewport height
  26196. * @param world world matrix
  26197. * @param view view matrix
  26198. * @param projection projection matrix
  26199. * @returns new ray
  26200. */
  26201. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  26202. var result = Ray.Zero();
  26203. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  26204. };
  26205. /**
  26206. * 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
  26207. * transformed to the given world matrix.
  26208. * @param origin The origin point
  26209. * @param end The end point
  26210. * @param world a matrix to transform the ray to. Default is the identity matrix.
  26211. * @returns the new ray
  26212. */
  26213. Ray.CreateNewFromTo = function (origin, end, world) {
  26214. if (world === void 0) { world = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  26215. var direction = end.subtract(origin);
  26216. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  26217. direction.normalize();
  26218. return Ray.Transform(new Ray(origin, direction, length), world);
  26219. };
  26220. /**
  26221. * Transforms a ray by a matrix
  26222. * @param ray ray to transform
  26223. * @param matrix matrix to apply
  26224. * @returns the resulting new ray
  26225. */
  26226. Ray.Transform = function (ray, matrix) {
  26227. 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));
  26228. Ray.TransformToRef(ray, matrix, result);
  26229. return result;
  26230. };
  26231. /**
  26232. * Transforms a ray by a matrix
  26233. * @param ray ray to transform
  26234. * @param matrix matrix to apply
  26235. * @param result ray to store result in
  26236. */
  26237. Ray.TransformToRef = function (ray, matrix, result) {
  26238. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  26239. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  26240. result.length = ray.length;
  26241. var dir = result.direction;
  26242. var len = dir.length();
  26243. if (!(len === 0 || len === 1)) {
  26244. var num = 1.0 / len;
  26245. dir.x *= num;
  26246. dir.y *= num;
  26247. dir.z *= num;
  26248. result.length *= len;
  26249. }
  26250. };
  26251. /**
  26252. * Unproject a ray from screen space to object space
  26253. * @param sourceX defines the screen space x coordinate to use
  26254. * @param sourceY defines the screen space y coordinate to use
  26255. * @param viewportWidth defines the current width of the viewport
  26256. * @param viewportHeight defines the current height of the viewport
  26257. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  26258. * @param view defines the view matrix to use
  26259. * @param projection defines the projection matrix to use
  26260. */
  26261. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  26262. var matrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  26263. world.multiplyToRef(view, matrix);
  26264. matrix.multiplyToRef(projection, matrix);
  26265. matrix.invert();
  26266. var nearScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  26267. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  26268. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  26269. nearScreenSource.z = -1.0;
  26270. var farScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  26271. var nearVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  26272. var farVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  26273. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  26274. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  26275. this.origin.copyFrom(nearVec3);
  26276. farVec3.subtractToRef(nearVec3, this.direction);
  26277. this.direction.normalize();
  26278. };
  26279. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  26280. Ray.smallnum = 0.00000001;
  26281. Ray.rayl = 10e8;
  26282. return Ray;
  26283. }());
  26284. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  26285. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  26286. var result = Ray.Zero();
  26287. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  26288. return result;
  26289. };
  26290. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  26291. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  26292. var engine = this.getEngine();
  26293. if (!camera) {
  26294. if (!this.activeCamera) {
  26295. throw new Error("Active camera not set");
  26296. }
  26297. camera = this.activeCamera;
  26298. }
  26299. var cameraViewport = camera.viewport;
  26300. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  26301. // Moving coordinates to local viewport world
  26302. x = x / engine.getHardwareScalingLevel() - viewport.x;
  26303. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  26304. 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());
  26305. return this;
  26306. };
  26307. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  26308. var result = Ray.Zero();
  26309. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  26310. return result;
  26311. };
  26312. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  26313. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26314. return this;
  26315. }
  26316. var engine = this.getEngine();
  26317. if (!camera) {
  26318. if (!this.activeCamera) {
  26319. throw new Error("Active camera not set");
  26320. }
  26321. camera = this.activeCamera;
  26322. }
  26323. var cameraViewport = camera.viewport;
  26324. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  26325. var identity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26326. // Moving coordinates to local viewport world
  26327. x = x / engine.getHardwareScalingLevel() - viewport.x;
  26328. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  26329. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  26330. return this;
  26331. };
  26332. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPick = function (rayFunction, predicate, fastCheck, trianglePredicate) {
  26333. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26334. return null;
  26335. }
  26336. var pickingInfo = null;
  26337. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  26338. var mesh = this.meshes[meshIndex];
  26339. if (predicate) {
  26340. if (!predicate(mesh)) {
  26341. continue;
  26342. }
  26343. }
  26344. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  26345. continue;
  26346. }
  26347. var world = mesh.getWorldMatrix();
  26348. var ray = rayFunction(world);
  26349. var result = mesh.intersects(ray, fastCheck, trianglePredicate);
  26350. if (!result || !result.hit) {
  26351. continue;
  26352. }
  26353. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  26354. continue;
  26355. }
  26356. pickingInfo = result;
  26357. if (fastCheck) {
  26358. break;
  26359. }
  26360. }
  26361. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]();
  26362. };
  26363. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalMultiPick = function (rayFunction, predicate, trianglePredicate) {
  26364. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26365. return null;
  26366. }
  26367. var pickingInfos = new Array();
  26368. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  26369. var mesh = this.meshes[meshIndex];
  26370. if (predicate) {
  26371. if (!predicate(mesh)) {
  26372. continue;
  26373. }
  26374. }
  26375. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  26376. continue;
  26377. }
  26378. var world = mesh.getWorldMatrix();
  26379. var ray = rayFunction(world);
  26380. var result = mesh.intersects(ray, false, trianglePredicate);
  26381. if (!result || !result.hit) {
  26382. continue;
  26383. }
  26384. pickingInfos.push(result);
  26385. }
  26386. return pickingInfos;
  26387. };
  26388. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  26389. var _this = this;
  26390. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  26391. return null;
  26392. }
  26393. var result = this._internalPick(function (world) {
  26394. if (!_this._tempPickingRay) {
  26395. _this._tempPickingRay = Ray.Zero();
  26396. }
  26397. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  26398. return _this._tempPickingRay;
  26399. }, predicate, fastCheck, trianglePredicate);
  26400. if (result) {
  26401. result.ray = this.createPickingRay(x, y, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), camera || null);
  26402. }
  26403. return result;
  26404. };
  26405. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  26406. var _this = this;
  26407. var result = this._internalPick(function (world) {
  26408. if (!_this._pickWithRayInverseMatrix) {
  26409. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26410. }
  26411. world.invertToRef(_this._pickWithRayInverseMatrix);
  26412. if (!_this._cachedRayForTransform) {
  26413. _this._cachedRayForTransform = Ray.Zero();
  26414. }
  26415. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  26416. return _this._cachedRayForTransform;
  26417. }, predicate, fastCheck, trianglePredicate);
  26418. if (result) {
  26419. result.ray = ray;
  26420. }
  26421. return result;
  26422. };
  26423. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  26424. var _this = this;
  26425. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate, trianglePredicate);
  26426. };
  26427. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  26428. var _this = this;
  26429. return this._internalMultiPick(function (world) {
  26430. if (!_this._pickWithRayInverseMatrix) {
  26431. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  26432. }
  26433. world.invertToRef(_this._pickWithRayInverseMatrix);
  26434. if (!_this._cachedRayForTransform) {
  26435. _this._cachedRayForTransform = Ray.Zero();
  26436. }
  26437. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  26438. return _this._cachedRayForTransform;
  26439. }, predicate, trianglePredicate);
  26440. };
  26441. _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].prototype.getForwardRay = function (length, transform, origin) {
  26442. if (length === void 0) { length = 100; }
  26443. if (!transform) {
  26444. transform = this.getWorldMatrix();
  26445. }
  26446. if (!origin) {
  26447. origin = this.position;
  26448. }
  26449. 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);
  26450. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(forward, transform);
  26451. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Normalize(forwardWorld);
  26452. return new Ray(origin, direction, length);
  26453. };
  26454. /***/ }),
  26455. /***/ "./Debug/axesViewer.ts":
  26456. /*!*****************************!*\
  26457. !*** ./Debug/axesViewer.ts ***!
  26458. \*****************************/
  26459. /*! exports provided: AxesViewer */
  26460. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26461. "use strict";
  26462. __webpack_require__.r(__webpack_exports__);
  26463. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  26464. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26465. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26466. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  26467. /**
  26468. * The Axes viewer will show 3 axes in a specific point in space
  26469. */
  26470. var AxesViewer = /** @class */ (function () {
  26471. /**
  26472. * Creates a new AxesViewer
  26473. * @param scene defines the hosting scene
  26474. * @param scaleLines defines a number used to scale line length (1 by default)
  26475. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  26476. * @param xAxis defines the node hierarchy used to render the x-axis
  26477. * @param yAxis defines the node hierarchy used to render the y-axis
  26478. * @param zAxis defines the node hierarchy used to render the z-axis
  26479. */
  26480. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  26481. if (scaleLines === void 0) { scaleLines = 1; }
  26482. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  26483. this._scaleLinesFactor = 4;
  26484. this._instanced = false;
  26485. /**
  26486. * Gets or sets a number used to scale line length
  26487. */
  26488. this.scaleLines = 1;
  26489. this.scaleLines = scaleLines;
  26490. if (!xAxis) {
  26491. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26492. redColoredMaterial.disableLighting = true;
  26493. redColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Red().scale(0.5);
  26494. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  26495. }
  26496. if (!yAxis) {
  26497. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26498. greenColoredMaterial.disableLighting = true;
  26499. greenColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Green().scale(0.5);
  26500. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  26501. }
  26502. if (!zAxis) {
  26503. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  26504. blueColoredMaterial.disableLighting = true;
  26505. blueColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Blue().scale(0.5);
  26506. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  26507. }
  26508. this._xAxis = xAxis;
  26509. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26510. this._yAxis = yAxis;
  26511. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26512. this._zAxis = zAxis;
  26513. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26514. if (renderingGroupId != null) {
  26515. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  26516. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  26517. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  26518. }
  26519. this.scene = scene;
  26520. 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());
  26521. }
  26522. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  26523. /** Gets the node hierarchy used to render x-axis */
  26524. get: function () {
  26525. return this._xAxis;
  26526. },
  26527. enumerable: true,
  26528. configurable: true
  26529. });
  26530. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  26531. /** Gets the node hierarchy used to render y-axis */
  26532. get: function () {
  26533. return this._yAxis;
  26534. },
  26535. enumerable: true,
  26536. configurable: true
  26537. });
  26538. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  26539. /** Gets the node hierarchy used to render z-axis */
  26540. get: function () {
  26541. return this._zAxis;
  26542. },
  26543. enumerable: true,
  26544. configurable: true
  26545. });
  26546. /**
  26547. * Force the viewer to update
  26548. * @param position defines the position of the viewer
  26549. * @param xaxis defines the x axis of the viewer
  26550. * @param yaxis defines the y axis of the viewer
  26551. * @param zaxis defines the z axis of the viewer
  26552. */
  26553. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  26554. this._xAxis.position.copyFrom(position);
  26555. this._xAxis.setDirection(xaxis);
  26556. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26557. this._yAxis.position.copyFrom(position);
  26558. this._yAxis.setDirection(yaxis);
  26559. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26560. this._zAxis.position.copyFrom(position);
  26561. this._zAxis.setDirection(zaxis);
  26562. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  26563. };
  26564. /**
  26565. * Creates an instance of this axes viewer.
  26566. * @returns a new axes viewer with instanced meshes
  26567. */
  26568. AxesViewer.prototype.createInstance = function () {
  26569. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  26570. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  26571. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  26572. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  26573. axesViewer._instanced = true;
  26574. return axesViewer;
  26575. };
  26576. /** Releases resources */
  26577. AxesViewer.prototype.dispose = function () {
  26578. if (this._xAxis) {
  26579. this._xAxis.dispose(false, !this._instanced);
  26580. delete this._xAxis;
  26581. }
  26582. if (this._yAxis) {
  26583. this._yAxis.dispose(false, !this._instanced);
  26584. delete this._yAxis;
  26585. }
  26586. if (this._zAxis) {
  26587. this._zAxis.dispose(false, !this._instanced);
  26588. delete this._zAxis;
  26589. }
  26590. delete this.scene;
  26591. };
  26592. AxesViewer._SetRenderingGroupId = function (node, id) {
  26593. node.getChildMeshes().forEach(function (mesh) {
  26594. mesh.renderingGroupId = id;
  26595. });
  26596. };
  26597. return AxesViewer;
  26598. }());
  26599. /***/ }),
  26600. /***/ "./Debug/boneAxesViewer.ts":
  26601. /*!*********************************!*\
  26602. !*** ./Debug/boneAxesViewer.ts ***!
  26603. \*********************************/
  26604. /*! exports provided: BoneAxesViewer */
  26605. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26606. "use strict";
  26607. __webpack_require__.r(__webpack_exports__);
  26608. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  26609. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26610. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  26611. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26612. /**
  26613. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  26614. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  26615. */
  26616. var BoneAxesViewer = /** @class */ (function (_super) {
  26617. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  26618. /**
  26619. * Creates a new BoneAxesViewer
  26620. * @param scene defines the hosting scene
  26621. * @param bone defines the target bone
  26622. * @param mesh defines the target mesh
  26623. * @param scaleLines defines a scaling factor for line length (1 by default)
  26624. */
  26625. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  26626. if (scaleLines === void 0) { scaleLines = 1; }
  26627. var _this = _super.call(this, scene, scaleLines) || this;
  26628. /** Gets current position */
  26629. _this.pos = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26630. /** Gets direction of X axis */
  26631. _this.xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26632. /** Gets direction of Y axis */
  26633. _this.yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26634. /** Gets direction of Z axis */
  26635. _this.zaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  26636. _this.mesh = mesh;
  26637. _this.bone = bone;
  26638. return _this;
  26639. }
  26640. /**
  26641. * Force the viewer to update
  26642. */
  26643. BoneAxesViewer.prototype.update = function () {
  26644. if (!this.mesh || !this.bone) {
  26645. return;
  26646. }
  26647. var bone = this.bone;
  26648. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  26649. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].X, this.mesh, this.xaxis);
  26650. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y, this.mesh, this.yaxis);
  26651. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z, this.mesh, this.zaxis);
  26652. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  26653. };
  26654. /** Releases resources */
  26655. BoneAxesViewer.prototype.dispose = function () {
  26656. if (this.mesh) {
  26657. this.mesh = null;
  26658. this.bone = null;
  26659. _super.prototype.dispose.call(this);
  26660. }
  26661. };
  26662. return BoneAxesViewer;
  26663. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  26664. /***/ }),
  26665. /***/ "./Debug/debugLayer.ts":
  26666. /*!*****************************!*\
  26667. !*** ./Debug/debugLayer.ts ***!
  26668. \*****************************/
  26669. /*! exports provided: DebugLayer */
  26670. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26671. "use strict";
  26672. __webpack_require__.r(__webpack_exports__);
  26673. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  26674. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  26675. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  26676. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  26677. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  26678. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  26679. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  26680. get: function () {
  26681. if (!this._debugLayer) {
  26682. this._debugLayer = new DebugLayer(this);
  26683. }
  26684. return this._debugLayer;
  26685. },
  26686. enumerable: true,
  26687. configurable: true
  26688. });
  26689. /**
  26690. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26691. * what is happening in your scene
  26692. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26693. */
  26694. var DebugLayer = /** @class */ (function () {
  26695. /**
  26696. * Instantiates a new debug layer.
  26697. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26698. * what is happening in your scene
  26699. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26700. * @param scene Defines the scene to inspect
  26701. */
  26702. function DebugLayer(scene) {
  26703. var _this = this;
  26704. this.BJSINSPECTOR = this._getGlobalInspector();
  26705. /**
  26706. * Observable triggered when a property is changed through the inspector.
  26707. */
  26708. this.onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  26709. this._scene = scene;
  26710. this._scene.onDisposeObservable.add(function () {
  26711. // Debug layer
  26712. if (_this._scene._debugLayer) {
  26713. _this._scene._debugLayer.hide();
  26714. }
  26715. });
  26716. }
  26717. /** Creates the inspector window. */
  26718. DebugLayer.prototype._createInspector = function (config) {
  26719. if (this.isVisible()) {
  26720. return;
  26721. }
  26722. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  26723. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  26724. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  26725. };
  26726. /**
  26727. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  26728. * @param entity defines the entity to select
  26729. * @param lineContainerTitle defines the specific block to highlight
  26730. */
  26731. DebugLayer.prototype.select = function (entity, lineContainerTitle) {
  26732. if (this.BJSINSPECTOR) {
  26733. this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(lineContainerTitle);
  26734. this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(entity);
  26735. }
  26736. };
  26737. /** Get the inspector from bundle or global */
  26738. DebugLayer.prototype._getGlobalInspector = function () {
  26739. // UMD Global name detection from Webpack Bundle UMD Name.
  26740. if (typeof INSPECTOR !== 'undefined') {
  26741. return INSPECTOR;
  26742. }
  26743. // In case of module let s check the global emitted from the Inspector entry point.
  26744. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  26745. return BABYLON;
  26746. }
  26747. return undefined;
  26748. };
  26749. /**
  26750. * Get if the inspector is visible or not.
  26751. * @returns true if visible otherwise, false
  26752. */
  26753. DebugLayer.prototype.isVisible = function () {
  26754. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  26755. };
  26756. /**
  26757. * Hide the inspector and close its window.
  26758. */
  26759. DebugLayer.prototype.hide = function () {
  26760. if (this.BJSINSPECTOR) {
  26761. this.BJSINSPECTOR.Inspector.Hide();
  26762. }
  26763. };
  26764. /**
  26765. * Launch the debugLayer.
  26766. * @param config Define the configuration of the inspector
  26767. * @return a promise fulfilled when the debug layer is visible
  26768. */
  26769. DebugLayer.prototype.show = function (config) {
  26770. var _this = this;
  26771. return new Promise(function (resolve, reject) {
  26772. if (typeof _this.BJSINSPECTOR == 'undefined') {
  26773. var inspectorUrl = config && config.inspectorURL ? config.inspectorURL : DebugLayer.InspectorURL;
  26774. // Load inspector and add it to the DOM
  26775. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(inspectorUrl, function () {
  26776. _this._createInspector(config);
  26777. resolve(_this);
  26778. });
  26779. }
  26780. else {
  26781. // Otherwise creates the inspector
  26782. _this._createInspector(config);
  26783. resolve(_this);
  26784. }
  26785. });
  26786. };
  26787. /**
  26788. * Define the url to get the inspector script from.
  26789. * By default it uses the babylonjs CDN.
  26790. * @ignoreNaming
  26791. */
  26792. DebugLayer.InspectorURL = "https://unpkg.com/babylonjs-inspector@" + _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].Version + "/babylon.inspector.bundle.js";
  26793. return DebugLayer;
  26794. }());
  26795. /***/ }),
  26796. /***/ "./Debug/index.ts":
  26797. /*!************************!*\
  26798. !*** ./Debug/index.ts ***!
  26799. \************************/
  26800. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  26801. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26802. "use strict";
  26803. __webpack_require__.r(__webpack_exports__);
  26804. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  26805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  26806. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  26807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  26808. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  26809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  26810. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  26811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  26812. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  26813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  26814. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  26815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  26816. /***/ }),
  26817. /***/ "./Debug/physicsViewer.ts":
  26818. /*!********************************!*\
  26819. !*** ./Debug/physicsViewer.ts ***!
  26820. \********************************/
  26821. /*! exports provided: PhysicsViewer */
  26822. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26823. "use strict";
  26824. __webpack_require__.r(__webpack_exports__);
  26825. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  26826. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  26827. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  26828. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  26829. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26830. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  26831. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26832. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  26833. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26834. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  26835. /**
  26836. * Used to show the physics impostor around the specific mesh
  26837. */
  26838. var PhysicsViewer = /** @class */ (function () {
  26839. /**
  26840. * Creates a new PhysicsViewer
  26841. * @param scene defines the hosting scene
  26842. */
  26843. function PhysicsViewer(scene) {
  26844. /** @hidden */
  26845. this._impostors = [];
  26846. /** @hidden */
  26847. this._meshes = [];
  26848. /** @hidden */
  26849. this._numMeshes = 0;
  26850. this._debugMeshMeshes = new Array();
  26851. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  26852. var physicEngine = this._scene.getPhysicsEngine();
  26853. if (physicEngine) {
  26854. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  26855. }
  26856. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"](this._scene, false);
  26857. this._utilityLayer.pickUtilitySceneFirst = false;
  26858. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26859. }
  26860. /** @hidden */
  26861. PhysicsViewer.prototype._updateDebugMeshes = function () {
  26862. var plugin = this._physicsEnginePlugin;
  26863. for (var i = 0; i < this._numMeshes; i++) {
  26864. var impostor = this._impostors[i];
  26865. if (!impostor) {
  26866. continue;
  26867. }
  26868. if (impostor.isDisposed) {
  26869. this.hideImpostor(this._impostors[i--]);
  26870. }
  26871. else {
  26872. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].MeshImpostor) {
  26873. continue;
  26874. }
  26875. var mesh = this._meshes[i];
  26876. if (mesh && plugin) {
  26877. plugin.syncMeshWithImpostor(mesh, impostor);
  26878. }
  26879. }
  26880. }
  26881. };
  26882. /**
  26883. * Renders a specified physic impostor
  26884. * @param impostor defines the impostor to render
  26885. * @param targetMesh defines the mesh represented by the impostor
  26886. * @returns the new debug mesh used to render the impostor
  26887. */
  26888. PhysicsViewer.prototype.showImpostor = function (impostor, targetMesh) {
  26889. if (!this._scene) {
  26890. return null;
  26891. }
  26892. for (var i = 0; i < this._numMeshes; i++) {
  26893. if (this._impostors[i] == impostor) {
  26894. return null;
  26895. }
  26896. }
  26897. var debugMesh = this._getDebugMesh(impostor, targetMesh);
  26898. if (debugMesh) {
  26899. this._impostors[this._numMeshes] = impostor;
  26900. this._meshes[this._numMeshes] = debugMesh;
  26901. if (this._numMeshes === 0) {
  26902. this._renderFunction = this._updateDebugMeshes.bind(this);
  26903. this._scene.registerBeforeRender(this._renderFunction);
  26904. }
  26905. this._numMeshes++;
  26906. }
  26907. return debugMesh;
  26908. };
  26909. /**
  26910. * Hides a specified physic impostor
  26911. * @param impostor defines the impostor to hide
  26912. */
  26913. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  26914. if (!impostor || !this._scene || !this._utilityLayer) {
  26915. return;
  26916. }
  26917. var removed = false;
  26918. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26919. for (var i = 0; i < this._numMeshes; i++) {
  26920. if (this._impostors[i] == impostor) {
  26921. var mesh = this._meshes[i];
  26922. if (!mesh) {
  26923. continue;
  26924. }
  26925. utilityLayerScene.removeMesh(mesh);
  26926. mesh.dispose();
  26927. var index = this._debugMeshMeshes.indexOf(mesh);
  26928. if (index > -1) {
  26929. this._debugMeshMeshes.splice(index, 1);
  26930. }
  26931. this._numMeshes--;
  26932. if (this._numMeshes > 0) {
  26933. this._meshes[i] = this._meshes[this._numMeshes];
  26934. this._impostors[i] = this._impostors[this._numMeshes];
  26935. this._meshes[this._numMeshes] = null;
  26936. this._impostors[this._numMeshes] = null;
  26937. }
  26938. else {
  26939. this._meshes[0] = null;
  26940. this._impostors[0] = null;
  26941. }
  26942. removed = true;
  26943. break;
  26944. }
  26945. }
  26946. if (removed && this._numMeshes === 0) {
  26947. this._scene.unregisterBeforeRender(this._renderFunction);
  26948. }
  26949. };
  26950. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  26951. if (!this._debugMaterial) {
  26952. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]('', scene);
  26953. this._debugMaterial.wireframe = true;
  26954. this._debugMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].White();
  26955. this._debugMaterial.disableLighting = true;
  26956. }
  26957. return this._debugMaterial;
  26958. };
  26959. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  26960. if (!this._debugBoxMesh) {
  26961. this._debugBoxMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  26962. this._debugBoxMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  26963. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  26964. this._debugBoxMesh.setEnabled(false);
  26965. }
  26966. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  26967. };
  26968. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  26969. if (!this._debugSphereMesh) {
  26970. this._debugSphereMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__["SphereBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  26971. this._debugSphereMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  26972. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  26973. this._debugSphereMesh.setEnabled(false);
  26974. }
  26975. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  26976. };
  26977. PhysicsViewer.prototype._getDebugCylinderMesh = function (scene) {
  26978. if (!this._debugCylinderMesh) {
  26979. this._debugCylinderMesh = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_8__["CylinderBuilder"].CreateCylinder('physicsBodyCylinderViewMesh', { diameterTop: 1, diameterBottom: 1, height: 1 }, scene);
  26980. this._debugCylinderMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].Identity();
  26981. this._debugCylinderMesh.material = this._getDebugMaterial(scene);
  26982. this._debugCylinderMesh.setEnabled(false);
  26983. }
  26984. return this._debugCylinderMesh.createInstance('physicsBodyBoxViewInstance');
  26985. };
  26986. PhysicsViewer.prototype._getDebugMeshMesh = function (mesh, scene) {
  26987. var wireframeOver = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](mesh.name, scene, null, mesh);
  26988. wireframeOver.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  26989. wireframeOver.setParent(mesh);
  26990. wireframeOver.material = this._getDebugMaterial(scene);
  26991. this._debugMeshMeshes.push(wireframeOver);
  26992. return wireframeOver;
  26993. };
  26994. PhysicsViewer.prototype._getDebugMesh = function (impostor, targetMesh) {
  26995. var _this = this;
  26996. if (!this._utilityLayer) {
  26997. return null;
  26998. }
  26999. // Only create child impostor debug meshes when evaluating the parent
  27000. if (targetMesh && targetMesh.parent && targetMesh.parent.physicsImpostor) {
  27001. return null;
  27002. }
  27003. var mesh = null;
  27004. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  27005. switch (impostor.type) {
  27006. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].BoxImpostor:
  27007. mesh = this._getDebugBoxMesh(utilityLayerScene);
  27008. impostor.getBoxSizeToRef(mesh.scaling);
  27009. break;
  27010. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].SphereImpostor:
  27011. mesh = this._getDebugSphereMesh(utilityLayerScene);
  27012. var radius = impostor.getRadius();
  27013. mesh.scaling.x = radius * 2;
  27014. mesh.scaling.y = radius * 2;
  27015. mesh.scaling.z = radius * 2;
  27016. break;
  27017. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].MeshImpostor:
  27018. if (targetMesh) {
  27019. mesh = this._getDebugMeshMesh(targetMesh, utilityLayerScene);
  27020. }
  27021. break;
  27022. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].NoImpostor:
  27023. if (targetMesh) {
  27024. // Handle compound impostors
  27025. var childMeshes = targetMesh.getChildMeshes().filter(function (c) { return c.physicsImpostor ? 1 : 0; });
  27026. childMeshes.forEach(function (m) {
  27027. var a = _this._getDebugBoxMesh(utilityLayerScene);
  27028. a.parent = m;
  27029. });
  27030. }
  27031. break;
  27032. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].CylinderImpostor:
  27033. mesh = this._getDebugCylinderMesh(utilityLayerScene);
  27034. var bi = impostor.object.getBoundingInfo();
  27035. mesh.scaling.x = bi.boundingBox.maximum.x - bi.boundingBox.minimum.x;
  27036. mesh.scaling.y = bi.boundingBox.maximum.y - bi.boundingBox.minimum.y;
  27037. mesh.scaling.z = bi.boundingBox.maximum.z - bi.boundingBox.minimum.z;
  27038. break;
  27039. }
  27040. return mesh;
  27041. };
  27042. /** Releases all resources */
  27043. PhysicsViewer.prototype.dispose = function () {
  27044. var count = this._numMeshes;
  27045. for (var index = 0; index < count; index++) {
  27046. this.hideImpostor(this._impostors[0]);
  27047. }
  27048. if (this._debugBoxMesh) {
  27049. this._debugBoxMesh.dispose();
  27050. }
  27051. if (this._debugSphereMesh) {
  27052. this._debugSphereMesh.dispose();
  27053. }
  27054. if (this._debugCylinderMesh) {
  27055. this._debugCylinderMesh.dispose();
  27056. }
  27057. if (this._debugMaterial) {
  27058. this._debugMaterial.dispose();
  27059. }
  27060. this._impostors.length = 0;
  27061. this._scene = null;
  27062. this._physicsEnginePlugin = null;
  27063. if (this._utilityLayer) {
  27064. this._utilityLayer.dispose();
  27065. this._utilityLayer = null;
  27066. }
  27067. };
  27068. return PhysicsViewer;
  27069. }());
  27070. /***/ }),
  27071. /***/ "./Debug/rayHelper.ts":
  27072. /*!****************************!*\
  27073. !*** ./Debug/rayHelper.ts ***!
  27074. \****************************/
  27075. /*! exports provided: RayHelper */
  27076. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27077. "use strict";
  27078. __webpack_require__.r(__webpack_exports__);
  27079. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  27080. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27081. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  27082. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  27083. /**
  27084. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  27085. * in order to better appreciate the issue one might have.
  27086. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  27087. */
  27088. var RayHelper = /** @class */ (function () {
  27089. /**
  27090. * Instantiate a new ray helper.
  27091. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  27092. * in order to better appreciate the issue one might have.
  27093. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  27094. * @param ray Defines the ray we are currently tryin to visualize
  27095. */
  27096. function RayHelper(ray) {
  27097. this.ray = ray;
  27098. }
  27099. /**
  27100. * Helper function to create a colored helper in a scene in one line.
  27101. * @param ray Defines the ray we are currently tryin to visualize
  27102. * @param scene Defines the scene the ray is used in
  27103. * @param color Defines the color we want to see the ray in
  27104. * @returns The newly created ray helper.
  27105. */
  27106. RayHelper.CreateAndShow = function (ray, scene, color) {
  27107. var helper = new RayHelper(ray);
  27108. helper.show(scene, color);
  27109. return helper;
  27110. };
  27111. /**
  27112. * Shows the ray we are willing to debug.
  27113. * @param scene Defines the scene the ray needs to be rendered in
  27114. * @param color Defines the color the ray needs to be rendered in
  27115. */
  27116. RayHelper.prototype.show = function (scene, color) {
  27117. if (!this._renderFunction && this.ray) {
  27118. var ray = this.ray;
  27119. this._renderFunction = this._render.bind(this);
  27120. this._scene = scene;
  27121. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  27122. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  27123. if (this._renderFunction) {
  27124. this._scene.registerBeforeRender(this._renderFunction);
  27125. }
  27126. }
  27127. if (color && this._renderLine) {
  27128. this._renderLine.color.copyFrom(color);
  27129. }
  27130. };
  27131. /**
  27132. * Hides the ray we are debugging.
  27133. */
  27134. RayHelper.prototype.hide = function () {
  27135. if (this._renderFunction && this._scene) {
  27136. this._scene.unregisterBeforeRender(this._renderFunction);
  27137. this._scene = null;
  27138. this._renderFunction = null;
  27139. if (this._renderLine) {
  27140. this._renderLine.dispose();
  27141. this._renderLine = null;
  27142. }
  27143. this._renderPoints = [];
  27144. }
  27145. };
  27146. RayHelper.prototype._render = function () {
  27147. var ray = this.ray;
  27148. if (!ray) {
  27149. return;
  27150. }
  27151. var point = this._renderPoints[1];
  27152. var len = Math.min(ray.length, 1000000);
  27153. point.copyFrom(ray.direction);
  27154. point.scaleInPlace(len);
  27155. point.addInPlace(ray.origin);
  27156. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  27157. };
  27158. /**
  27159. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  27160. * @param mesh Defines the mesh we want the helper attached to
  27161. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  27162. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  27163. * @param length Defines the length of the ray
  27164. */
  27165. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  27166. this._attachedToMesh = mesh;
  27167. var ray = this.ray;
  27168. if (!ray) {
  27169. return;
  27170. }
  27171. if (!ray.direction) {
  27172. ray.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  27173. }
  27174. if (!ray.origin) {
  27175. ray.origin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  27176. }
  27177. if (length) {
  27178. ray.length = length;
  27179. }
  27180. if (!meshSpaceOrigin) {
  27181. meshSpaceOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  27182. }
  27183. if (!meshSpaceDirection) {
  27184. // -1 so that this will work with Mesh.lookAt
  27185. meshSpaceDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  27186. }
  27187. if (!this._meshSpaceDirection) {
  27188. this._meshSpaceDirection = meshSpaceDirection.clone();
  27189. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  27190. }
  27191. else {
  27192. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  27193. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  27194. }
  27195. if (!this._updateToMeshFunction) {
  27196. this._updateToMeshFunction = this._updateToMesh.bind(this);
  27197. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  27198. }
  27199. this._updateToMesh();
  27200. };
  27201. /**
  27202. * Detach the ray helper from the mesh it has previously been attached to.
  27203. */
  27204. RayHelper.prototype.detachFromMesh = function () {
  27205. if (this._attachedToMesh) {
  27206. if (this._updateToMeshFunction) {
  27207. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  27208. }
  27209. this._attachedToMesh = null;
  27210. this._updateToMeshFunction = null;
  27211. }
  27212. };
  27213. RayHelper.prototype._updateToMesh = function () {
  27214. var ray = this.ray;
  27215. if (!this._attachedToMesh || !ray) {
  27216. return;
  27217. }
  27218. if (this._attachedToMesh._isDisposed) {
  27219. this.detachFromMesh();
  27220. return;
  27221. }
  27222. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  27223. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  27224. };
  27225. /**
  27226. * Dispose the helper and release its associated resources.
  27227. */
  27228. RayHelper.prototype.dispose = function () {
  27229. this.hide();
  27230. this.detachFromMesh();
  27231. this.ray = null;
  27232. };
  27233. return RayHelper;
  27234. }());
  27235. /***/ }),
  27236. /***/ "./Debug/skeletonViewer.ts":
  27237. /*!*********************************!*\
  27238. !*** ./Debug/skeletonViewer.ts ***!
  27239. \*********************************/
  27240. /*! exports provided: SkeletonViewer */
  27241. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27242. "use strict";
  27243. __webpack_require__.r(__webpack_exports__);
  27244. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  27245. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27246. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  27247. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  27248. /**
  27249. * Class used to render a debug view of a given skeleton
  27250. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  27251. */
  27252. var SkeletonViewer = /** @class */ (function () {
  27253. /**
  27254. * Creates a new SkeletonViewer
  27255. * @param skeleton defines the skeleton to render
  27256. * @param mesh defines the mesh attached to the skeleton
  27257. * @param scene defines the hosting scene
  27258. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  27259. * @param renderingGroupId defines the rendering group id to use with the viewer
  27260. */
  27261. function SkeletonViewer(
  27262. /** defines the skeleton to render */
  27263. skeleton,
  27264. /** defines the mesh attached to the skeleton */
  27265. mesh, scene,
  27266. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  27267. autoUpdateBonesMatrices,
  27268. /** defines the rendering group id to use with the viewer */
  27269. renderingGroupId) {
  27270. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  27271. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  27272. this.skeleton = skeleton;
  27273. this.mesh = mesh;
  27274. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  27275. this.renderingGroupId = renderingGroupId;
  27276. /** Gets or sets the color used to render the skeleton */
  27277. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  27278. this._debugLines = new Array();
  27279. this._isEnabled = false;
  27280. this._scene = scene;
  27281. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"](this._scene, false);
  27282. this._utilityLayer.pickUtilitySceneFirst = false;
  27283. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  27284. this.update();
  27285. this._renderFunction = this.update.bind(this);
  27286. }
  27287. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  27288. /**
  27289. * Returns the mesh used to render the bones
  27290. */
  27291. get: function () {
  27292. return this._debugMesh;
  27293. },
  27294. enumerable: true,
  27295. configurable: true
  27296. });
  27297. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  27298. get: function () {
  27299. return this._isEnabled;
  27300. },
  27301. /** Gets or sets a boolean indicating if the viewer is enabled */
  27302. set: function (value) {
  27303. if (this._isEnabled === value) {
  27304. return;
  27305. }
  27306. this._isEnabled = value;
  27307. if (value) {
  27308. this._scene.registerBeforeRender(this._renderFunction);
  27309. }
  27310. else {
  27311. this._scene.unregisterBeforeRender(this._renderFunction);
  27312. }
  27313. },
  27314. enumerable: true,
  27315. configurable: true
  27316. });
  27317. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  27318. if (x === void 0) { x = 0; }
  27319. if (y === void 0) { y = 0; }
  27320. if (z === void 0) { z = 0; }
  27321. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  27322. var parentBone = bone.getParent();
  27323. tmat.copyFrom(bone.getLocalMatrix());
  27324. if (x !== 0 || y !== 0 || z !== 0) {
  27325. var tmat2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  27326. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  27327. tmat2.setTranslationFromFloats(x, y, z);
  27328. tmat2.multiplyToRef(tmat, tmat);
  27329. }
  27330. if (parentBone) {
  27331. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  27332. }
  27333. tmat.multiplyToRef(meshMat, tmat);
  27334. position.x = tmat.m[12];
  27335. position.y = tmat.m[13];
  27336. position.z = tmat.m[14];
  27337. };
  27338. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  27339. var len = bones.length;
  27340. var mesh = this.mesh._effectiveMesh;
  27341. var meshPos = mesh.position;
  27342. for (var i = 0; i < len; i++) {
  27343. var bone = bones[i];
  27344. var points = this._debugLines[i];
  27345. if (!points) {
  27346. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  27347. this._debugLines[i] = points;
  27348. }
  27349. this._getBonePosition(points[0], bone, meshMat);
  27350. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  27351. points[0].subtractInPlace(meshPos);
  27352. points[1].subtractInPlace(meshPos);
  27353. }
  27354. };
  27355. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  27356. var len = bones.length;
  27357. var boneNum = 0;
  27358. var mesh = this.mesh._effectiveMesh;
  27359. var meshPos = mesh.position;
  27360. for (var i = len - 1; i >= 0; i--) {
  27361. var childBone = bones[i];
  27362. var parentBone = childBone.getParent();
  27363. if (!parentBone) {
  27364. continue;
  27365. }
  27366. var points = this._debugLines[boneNum];
  27367. if (!points) {
  27368. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  27369. this._debugLines[boneNum] = points;
  27370. }
  27371. childBone.getAbsolutePositionToRef(mesh, points[0]);
  27372. parentBone.getAbsolutePositionToRef(mesh, points[1]);
  27373. points[0].subtractInPlace(meshPos);
  27374. points[1].subtractInPlace(meshPos);
  27375. boneNum++;
  27376. }
  27377. };
  27378. /** Update the viewer to sync with current skeleton state */
  27379. SkeletonViewer.prototype.update = function () {
  27380. if (!this._utilityLayer) {
  27381. return;
  27382. }
  27383. if (this.autoUpdateBonesMatrices) {
  27384. this.skeleton.computeAbsoluteTransforms();
  27385. }
  27386. var mesh = this.mesh._effectiveMesh;
  27387. if (this.skeleton.bones[0].length === undefined) {
  27388. this._getLinesForBonesNoLength(this.skeleton.bones, mesh.getWorldMatrix());
  27389. }
  27390. else {
  27391. this._getLinesForBonesWithLength(this.skeleton.bones, mesh.getWorldMatrix());
  27392. }
  27393. var targetScene = this._utilityLayer.utilityLayerScene;
  27394. if (!this._debugMesh) {
  27395. this._debugMesh = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  27396. this._debugMesh.renderingGroupId = this.renderingGroupId;
  27397. }
  27398. else {
  27399. _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  27400. }
  27401. this._debugMesh.position.copyFrom(this.mesh.position);
  27402. this._debugMesh.color = this.color;
  27403. };
  27404. /** Release associated resources */
  27405. SkeletonViewer.prototype.dispose = function () {
  27406. this.isEnabled = false;
  27407. if (this._debugMesh) {
  27408. this.isEnabled = false;
  27409. this._debugMesh.dispose();
  27410. this._debugMesh = null;
  27411. }
  27412. if (this._utilityLayer) {
  27413. this._utilityLayer.dispose();
  27414. this._utilityLayer = null;
  27415. }
  27416. };
  27417. return SkeletonViewer;
  27418. }());
  27419. /***/ }),
  27420. /***/ "./Engines/Extensions/engine.multiview.ts":
  27421. /*!************************************************!*\
  27422. !*** ./Engines/Extensions/engine.multiview.ts ***!
  27423. \************************************************/
  27424. /*! no exports provided */
  27425. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27426. "use strict";
  27427. __webpack_require__.r(__webpack_exports__);
  27428. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  27429. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27430. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  27431. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  27432. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  27433. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  27434. /* harmony import */ var _Materials_Textures_MultiviewRenderTarget__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/MultiviewRenderTarget */ "./Materials/Textures/MultiviewRenderTarget.ts");
  27435. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype.createMultiviewRenderTargetTexture = function (width, height) {
  27436. var gl = this._gl;
  27437. if (!this.getCaps().multiview) {
  27438. throw "Multiview is not supported";
  27439. }
  27440. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  27441. internalTexture.width = width;
  27442. internalTexture.height = height;
  27443. internalTexture._framebuffer = gl.createFramebuffer();
  27444. internalTexture._colorTextureArray = gl.createTexture();
  27445. gl.bindTexture(gl.TEXTURE_2D_ARRAY, internalTexture._colorTextureArray);
  27446. gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.RGBA8, width, height, 2);
  27447. internalTexture._depthStencilTextureArray = gl.createTexture();
  27448. gl.bindTexture(gl.TEXTURE_2D_ARRAY, internalTexture._depthStencilTextureArray);
  27449. gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.DEPTH32F_STENCIL8, width, height, 2);
  27450. internalTexture.isReady = true;
  27451. return internalTexture;
  27452. };
  27453. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].prototype.bindMultiviewFramebuffer = function (multiviewTexture) {
  27454. var gl = this._gl;
  27455. var ext = this.getCaps().multiview;
  27456. this.bindFramebuffer(multiviewTexture, undefined, undefined, undefined, true);
  27457. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, multiviewTexture._framebuffer);
  27458. if (multiviewTexture._colorTextureArray && multiviewTexture._depthStencilTextureArray) {
  27459. ext.framebufferTextureMultiviewWEBGL(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, multiviewTexture._colorTextureArray, 0, 0, 2);
  27460. ext.framebufferTextureMultiviewWEBGL(gl.DRAW_FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, multiviewTexture._depthStencilTextureArray, 0, 0, 2);
  27461. }
  27462. else {
  27463. throw "Invalid multiview frame buffer";
  27464. }
  27465. };
  27466. _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].prototype._useMultiviewToSingleView = false;
  27467. _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].prototype._multiviewTexture = null;
  27468. _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].prototype._resizeOrCreateMultiviewTexture = function (width, height) {
  27469. if (!this._multiviewTexture) {
  27470. this._multiviewTexture = new _Materials_Textures_MultiviewRenderTarget__WEBPACK_IMPORTED_MODULE_6__["MultiviewRenderTarget"](this.getScene(), { width: width, height: height });
  27471. }
  27472. else if (this._multiviewTexture.getRenderWidth() != width || this._multiviewTexture.getRenderHeight() != height) {
  27473. this._multiviewTexture.dispose();
  27474. this._multiviewTexture = new _Materials_Textures_MultiviewRenderTarget__WEBPACK_IMPORTED_MODULE_6__["MultiviewRenderTarget"](this.getScene(), { width: width, height: height });
  27475. }
  27476. };
  27477. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._transformMatrixR = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  27478. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._multiviewSceneUbo = null;
  27479. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._createMultiviewUbo = function () {
  27480. this._multiviewSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_5__["UniformBuffer"](this.getEngine(), undefined, true);
  27481. this._multiviewSceneUbo.addUniform("viewProjection", 16);
  27482. this._multiviewSceneUbo.addUniform("viewProjectionR", 16);
  27483. this._multiviewSceneUbo.addUniform("view", 16);
  27484. };
  27485. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._updateMultiviewUbo = function (viewR, projectionR) {
  27486. if (viewR && projectionR) {
  27487. viewR.multiplyToRef(projectionR, this._transformMatrixR);
  27488. }
  27489. if (viewR && projectionR) {
  27490. viewR.multiplyToRef(projectionR, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0]);
  27491. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Frustum"].GetRightPlaneToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Matrix[0], this._frustumPlanes[3]); // Replace right plane by second camera right plane
  27492. }
  27493. if (this._multiviewSceneUbo) {
  27494. this._multiviewSceneUbo.updateMatrix("viewProjection", this.getTransformMatrix());
  27495. this._multiviewSceneUbo.updateMatrix("viewProjectionR", this._transformMatrixR);
  27496. this._multiviewSceneUbo.updateMatrix("view", this._viewMatrix);
  27497. this._multiviewSceneUbo.update();
  27498. }
  27499. };
  27500. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype._renderMultiviewToSingleView = function (camera) {
  27501. // Multiview is only able to be displayed directly for API's such as webXR
  27502. // This displays a multiview image by rendering to the multiview image and then
  27503. // copying the result into the sub cameras instead of rendering them and proceeding as normal from there
  27504. // Render to a multiview texture
  27505. camera._resizeOrCreateMultiviewTexture((camera._rigPostProcess && camera._rigPostProcess && camera._rigPostProcess.width > 0) ? camera._rigPostProcess.width / 2 : this.getEngine().getRenderWidth(true) / 2, (camera._rigPostProcess && camera._rigPostProcess && camera._rigPostProcess.height > 0) ? camera._rigPostProcess.height : this.getEngine().getRenderHeight(true));
  27506. if (!this._multiviewSceneUbo) {
  27507. this._createMultiviewUbo();
  27508. }
  27509. camera.outputRenderTarget = camera._multiviewTexture;
  27510. this._renderForCamera(camera);
  27511. camera.outputRenderTarget = null;
  27512. // Consume the multiview texture through a shader for each eye
  27513. for (var index = 0; index < camera._rigCameras.length; index++) {
  27514. var engine = this.getEngine();
  27515. this._activeCamera = camera._rigCameras[index];
  27516. engine.setViewport(this._activeCamera.viewport);
  27517. if (this.postProcessManager) {
  27518. this.postProcessManager._prepareFrame();
  27519. this.postProcessManager._finalizeFrame(this._activeCamera.isIntermediate);
  27520. }
  27521. }
  27522. };
  27523. /***/ }),
  27524. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  27525. /*!*****************************************************!*\
  27526. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  27527. \*****************************************************/
  27528. /*! exports provided: _OcclusionDataStorage */
  27529. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27530. "use strict";
  27531. __webpack_require__.r(__webpack_exports__);
  27532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  27533. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27534. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  27535. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  27536. /** @hidden */
  27537. var _OcclusionDataStorage = /** @class */ (function () {
  27538. function _OcclusionDataStorage() {
  27539. /** @hidden */
  27540. this.occlusionInternalRetryCounter = 0;
  27541. /** @hidden */
  27542. this.isOcclusionQueryInProgress = false;
  27543. /** @hidden */
  27544. this.isOccluded = false;
  27545. /** @hidden */
  27546. this.occlusionRetryCount = -1;
  27547. /** @hidden */
  27548. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  27549. /** @hidden */
  27550. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  27551. }
  27552. return _OcclusionDataStorage;
  27553. }());
  27554. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  27555. return this._gl.createQuery();
  27556. };
  27557. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  27558. this._gl.deleteQuery(query);
  27559. return this;
  27560. };
  27561. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  27562. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  27563. };
  27564. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  27565. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  27566. };
  27567. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  27568. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  27569. this._gl.beginQuery(glAlgorithm, query);
  27570. return this;
  27571. };
  27572. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  27573. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  27574. this._gl.endQuery(glAlgorithm);
  27575. return this;
  27576. };
  27577. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  27578. var timerQuery = this.getCaps().timerQuery;
  27579. if (timerQuery.createQueryEXT) {
  27580. return timerQuery.createQueryEXT();
  27581. }
  27582. return this.createQuery();
  27583. };
  27584. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  27585. var timerQuery = this.getCaps().timerQuery;
  27586. if (timerQuery.deleteQueryEXT) {
  27587. timerQuery.deleteQueryEXT(query);
  27588. return;
  27589. }
  27590. this.deleteQuery(query);
  27591. };
  27592. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  27593. var timerQuery = this.getCaps().timerQuery;
  27594. if (timerQuery.getQueryObjectEXT) {
  27595. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  27596. }
  27597. return this.getQueryResult(query);
  27598. };
  27599. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  27600. var timerQuery = this.getCaps().timerQuery;
  27601. if (timerQuery.getQueryObjectEXT) {
  27602. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  27603. }
  27604. return this.isQueryResultAvailable(query);
  27605. };
  27606. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  27607. var caps = this.getCaps();
  27608. var timerQuery = caps.timerQuery;
  27609. if (!timerQuery) {
  27610. return null;
  27611. }
  27612. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  27613. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  27614. if (caps.canUseTimestampForTimerQuery) {
  27615. token._startTimeQuery = this._createTimeQuery();
  27616. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  27617. }
  27618. else {
  27619. if (this._currentNonTimestampToken) {
  27620. return this._currentNonTimestampToken;
  27621. }
  27622. token._timeElapsedQuery = this._createTimeQuery();
  27623. if (timerQuery.beginQueryEXT) {
  27624. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  27625. }
  27626. else {
  27627. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  27628. }
  27629. this._currentNonTimestampToken = token;
  27630. }
  27631. return token;
  27632. };
  27633. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  27634. var caps = this.getCaps();
  27635. var timerQuery = caps.timerQuery;
  27636. if (!timerQuery || !token) {
  27637. return -1;
  27638. }
  27639. if (caps.canUseTimestampForTimerQuery) {
  27640. if (!token._startTimeQuery) {
  27641. return -1;
  27642. }
  27643. if (!token._endTimeQuery) {
  27644. token._endTimeQuery = this._createTimeQuery();
  27645. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  27646. }
  27647. }
  27648. else if (!token._timeElapsedQueryEnded) {
  27649. if (!token._timeElapsedQuery) {
  27650. return -1;
  27651. }
  27652. if (timerQuery.endQueryEXT) {
  27653. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  27654. }
  27655. else {
  27656. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  27657. }
  27658. token._timeElapsedQueryEnded = true;
  27659. }
  27660. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  27661. var available = false;
  27662. if (token._endTimeQuery) {
  27663. available = this._getTimeQueryAvailability(token._endTimeQuery);
  27664. }
  27665. else if (token._timeElapsedQuery) {
  27666. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  27667. }
  27668. if (available && !disjoint) {
  27669. var result = 0;
  27670. if (caps.canUseTimestampForTimerQuery) {
  27671. if (!token._startTimeQuery || !token._endTimeQuery) {
  27672. return -1;
  27673. }
  27674. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  27675. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  27676. result = timeEnd - timeStart;
  27677. this._deleteTimeQuery(token._startTimeQuery);
  27678. this._deleteTimeQuery(token._endTimeQuery);
  27679. token._startTimeQuery = null;
  27680. token._endTimeQuery = null;
  27681. }
  27682. else {
  27683. if (!token._timeElapsedQuery) {
  27684. return -1;
  27685. }
  27686. result = this._getTimeQueryResult(token._timeElapsedQuery);
  27687. this._deleteTimeQuery(token._timeElapsedQuery);
  27688. token._timeElapsedQuery = null;
  27689. token._timeElapsedQueryEnded = false;
  27690. this._currentNonTimestampToken = null;
  27691. }
  27692. return result;
  27693. }
  27694. return -1;
  27695. };
  27696. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  27697. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  27698. };
  27699. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  27700. get: function () {
  27701. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  27702. },
  27703. enumerable: false,
  27704. configurable: true
  27705. });
  27706. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  27707. get: function () {
  27708. if (!this.__occlusionDataStorage) {
  27709. this.__occlusionDataStorage = new _OcclusionDataStorage();
  27710. }
  27711. return this.__occlusionDataStorage;
  27712. },
  27713. enumerable: false,
  27714. configurable: true
  27715. });
  27716. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  27717. get: function () {
  27718. return this._occlusionDataStorage.isOccluded;
  27719. },
  27720. set: function (value) {
  27721. this._occlusionDataStorage.isOccluded = value;
  27722. },
  27723. enumerable: true,
  27724. configurable: true
  27725. });
  27726. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  27727. get: function () {
  27728. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  27729. },
  27730. set: function (value) {
  27731. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  27732. },
  27733. enumerable: true,
  27734. configurable: true
  27735. });
  27736. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  27737. get: function () {
  27738. return this._occlusionDataStorage.occlusionType;
  27739. },
  27740. set: function (value) {
  27741. this._occlusionDataStorage.occlusionType = value;
  27742. },
  27743. enumerable: true,
  27744. configurable: true
  27745. });
  27746. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  27747. get: function () {
  27748. return this._occlusionDataStorage.occlusionRetryCount;
  27749. },
  27750. set: function (value) {
  27751. this._occlusionDataStorage.occlusionRetryCount = value;
  27752. },
  27753. enumerable: true,
  27754. configurable: true
  27755. });
  27756. // We also need to update AbstractMesh as there is a portion of the code there
  27757. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  27758. var dataStorage = this._occlusionDataStorage;
  27759. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  27760. dataStorage.isOccluded = false;
  27761. return false;
  27762. }
  27763. var engine = this.getEngine();
  27764. if (engine.webGLVersion < 2) {
  27765. dataStorage.isOccluded = false;
  27766. return false;
  27767. }
  27768. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  27769. dataStorage.isOccluded = false;
  27770. return false;
  27771. }
  27772. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  27773. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  27774. if (isOcclusionQueryAvailable) {
  27775. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  27776. dataStorage.isOcclusionQueryInProgress = false;
  27777. dataStorage.occlusionInternalRetryCounter = 0;
  27778. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  27779. }
  27780. else {
  27781. dataStorage.occlusionInternalRetryCounter++;
  27782. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  27783. dataStorage.isOcclusionQueryInProgress = false;
  27784. dataStorage.occlusionInternalRetryCounter = 0;
  27785. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  27786. // if strict continue the last state of the object.
  27787. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  27788. }
  27789. else {
  27790. return false;
  27791. }
  27792. }
  27793. }
  27794. var scene = this.getScene();
  27795. if (scene.getBoundingBoxRenderer) {
  27796. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  27797. if (!this._occlusionQuery) {
  27798. this._occlusionQuery = engine.createQuery();
  27799. }
  27800. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  27801. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  27802. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  27803. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  27804. }
  27805. return dataStorage.isOccluded;
  27806. };
  27807. /***/ }),
  27808. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  27809. /*!********************************************************!*\
  27810. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  27811. \********************************************************/
  27812. /*! exports provided: _forceTransformFeedbackToBundle */
  27813. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27814. "use strict";
  27815. __webpack_require__.r(__webpack_exports__);
  27816. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  27817. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  27818. /** @hidden */
  27819. var _forceTransformFeedbackToBundle = true;
  27820. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  27821. return this._gl.createTransformFeedback();
  27822. };
  27823. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  27824. this._gl.deleteTransformFeedback(value);
  27825. };
  27826. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  27827. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  27828. };
  27829. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  27830. if (usePoints === void 0) { usePoints = true; }
  27831. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  27832. };
  27833. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  27834. this._gl.endTransformFeedback();
  27835. };
  27836. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  27837. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  27838. };
  27839. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  27840. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value);
  27841. };
  27842. /***/ }),
  27843. /***/ "./Engines/Extensions/index.ts":
  27844. /*!*************************************!*\
  27845. !*** ./Engines/Extensions/index.ts ***!
  27846. \*************************************/
  27847. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  27848. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27849. "use strict";
  27850. __webpack_require__.r(__webpack_exports__);
  27851. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  27852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  27853. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  27854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  27855. /***/ }),
  27856. /***/ "./Engines/constants.ts":
  27857. /*!******************************!*\
  27858. !*** ./Engines/constants.ts ***!
  27859. \******************************/
  27860. /*! exports provided: Constants */
  27861. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27862. "use strict";
  27863. __webpack_require__.r(__webpack_exports__);
  27864. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  27865. /** Defines the cross module used constants to avoid circular dependncies */
  27866. var Constants = /** @class */ (function () {
  27867. function Constants() {
  27868. }
  27869. /** Defines that alpha blending is disabled */
  27870. Constants.ALPHA_DISABLE = 0;
  27871. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27872. Constants.ALPHA_ADD = 1;
  27873. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27874. Constants.ALPHA_COMBINE = 2;
  27875. /** Defines that alpha blending to DEST - SRC * DEST */
  27876. Constants.ALPHA_SUBTRACT = 3;
  27877. /** Defines that alpha blending to SRC * DEST */
  27878. Constants.ALPHA_MULTIPLY = 4;
  27879. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27880. Constants.ALPHA_MAXIMIZED = 5;
  27881. /** Defines that alpha blending to SRC + DEST */
  27882. Constants.ALPHA_ONEONE = 6;
  27883. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27884. Constants.ALPHA_PREMULTIPLIED = 7;
  27885. /**
  27886. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27887. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27888. */
  27889. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  27890. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27891. Constants.ALPHA_INTERPOLATE = 9;
  27892. /**
  27893. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27894. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27895. */
  27896. Constants.ALPHA_SCREENMODE = 10;
  27897. /** Defines that the ressource is not delayed*/
  27898. Constants.DELAYLOADSTATE_NONE = 0;
  27899. /** Defines that the ressource was successfully delay loaded */
  27900. Constants.DELAYLOADSTATE_LOADED = 1;
  27901. /** Defines that the ressource is currently delay loading */
  27902. Constants.DELAYLOADSTATE_LOADING = 2;
  27903. /** Defines that the ressource is delayed and has not started loading */
  27904. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  27905. // Depht or Stencil test Constants.
  27906. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27907. Constants.NEVER = 0x0200;
  27908. /** 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 */
  27909. Constants.ALWAYS = 0x0207;
  27910. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27911. Constants.LESS = 0x0201;
  27912. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27913. Constants.EQUAL = 0x0202;
  27914. /** 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 */
  27915. Constants.LEQUAL = 0x0203;
  27916. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27917. Constants.GREATER = 0x0204;
  27918. /** 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 */
  27919. Constants.GEQUAL = 0x0206;
  27920. /** 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 */
  27921. Constants.NOTEQUAL = 0x0205;
  27922. // Stencil Actions Constants.
  27923. /** Passed to stencilOperation to specify that stencil value must be kept */
  27924. Constants.KEEP = 0x1E00;
  27925. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27926. Constants.REPLACE = 0x1E01;
  27927. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27928. Constants.INCR = 0x1E02;
  27929. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27930. Constants.DECR = 0x1E03;
  27931. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27932. Constants.INVERT = 0x150A;
  27933. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27934. Constants.INCR_WRAP = 0x8507;
  27935. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27936. Constants.DECR_WRAP = 0x8508;
  27937. /** Texture is not repeating outside of 0..1 UVs */
  27938. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  27939. /** Texture is repeating outside of 0..1 UVs */
  27940. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  27941. /** Texture is repeating and mirrored */
  27942. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  27943. /** ALPHA */
  27944. Constants.TEXTUREFORMAT_ALPHA = 0;
  27945. /** LUMINANCE */
  27946. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  27947. /** LUMINANCE_ALPHA */
  27948. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  27949. /** RGB */
  27950. Constants.TEXTUREFORMAT_RGB = 4;
  27951. /** RGBA */
  27952. Constants.TEXTUREFORMAT_RGBA = 5;
  27953. /** RED */
  27954. Constants.TEXTUREFORMAT_RED = 6;
  27955. /** RED (2nd reference) */
  27956. Constants.TEXTUREFORMAT_R = 6;
  27957. /** RG */
  27958. Constants.TEXTUREFORMAT_RG = 7;
  27959. /** RED_INTEGER */
  27960. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  27961. /** RED_INTEGER (2nd reference) */
  27962. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  27963. /** RG_INTEGER */
  27964. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  27965. /** RGB_INTEGER */
  27966. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  27967. /** RGBA_INTEGER */
  27968. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  27969. /** UNSIGNED_BYTE */
  27970. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  27971. /** UNSIGNED_BYTE (2nd reference) */
  27972. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  27973. /** FLOAT */
  27974. Constants.TEXTURETYPE_FLOAT = 1;
  27975. /** HALF_FLOAT */
  27976. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  27977. /** BYTE */
  27978. Constants.TEXTURETYPE_BYTE = 3;
  27979. /** SHORT */
  27980. Constants.TEXTURETYPE_SHORT = 4;
  27981. /** UNSIGNED_SHORT */
  27982. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  27983. /** INT */
  27984. Constants.TEXTURETYPE_INT = 6;
  27985. /** UNSIGNED_INT */
  27986. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  27987. /** UNSIGNED_SHORT_4_4_4_4 */
  27988. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  27989. /** UNSIGNED_SHORT_5_5_5_1 */
  27990. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  27991. /** UNSIGNED_SHORT_5_6_5 */
  27992. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  27993. /** UNSIGNED_INT_2_10_10_10_REV */
  27994. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  27995. /** UNSIGNED_INT_24_8 */
  27996. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  27997. /** UNSIGNED_INT_10F_11F_11F_REV */
  27998. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  27999. /** UNSIGNED_INT_5_9_9_9_REV */
  28000. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  28001. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28002. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  28003. /** nearest is mag = nearest and min = nearest and mip = linear */
  28004. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  28005. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28006. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  28007. /** Trilinear is mag = linear and min = linear and mip = linear */
  28008. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  28009. /** nearest is mag = nearest and min = nearest and mip = linear */
  28010. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  28011. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28012. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  28013. /** Trilinear is mag = linear and min = linear and mip = linear */
  28014. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  28015. /** mag = nearest and min = nearest and mip = nearest */
  28016. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  28017. /** mag = nearest and min = linear and mip = nearest */
  28018. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  28019. /** mag = nearest and min = linear and mip = linear */
  28020. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  28021. /** mag = nearest and min = linear and mip = none */
  28022. Constants.TEXTURE_NEAREST_LINEAR = 7;
  28023. /** mag = nearest and min = nearest and mip = none */
  28024. Constants.TEXTURE_NEAREST_NEAREST = 8;
  28025. /** mag = linear and min = nearest and mip = nearest */
  28026. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  28027. /** mag = linear and min = nearest and mip = linear */
  28028. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  28029. /** mag = linear and min = linear and mip = none */
  28030. Constants.TEXTURE_LINEAR_LINEAR = 11;
  28031. /** mag = linear and min = nearest and mip = none */
  28032. Constants.TEXTURE_LINEAR_NEAREST = 12;
  28033. /** Explicit coordinates mode */
  28034. Constants.TEXTURE_EXPLICIT_MODE = 0;
  28035. /** Spherical coordinates mode */
  28036. Constants.TEXTURE_SPHERICAL_MODE = 1;
  28037. /** Planar coordinates mode */
  28038. Constants.TEXTURE_PLANAR_MODE = 2;
  28039. /** Cubic coordinates mode */
  28040. Constants.TEXTURE_CUBIC_MODE = 3;
  28041. /** Projection coordinates mode */
  28042. Constants.TEXTURE_PROJECTION_MODE = 4;
  28043. /** Skybox coordinates mode */
  28044. Constants.TEXTURE_SKYBOX_MODE = 5;
  28045. /** Inverse Cubic coordinates mode */
  28046. Constants.TEXTURE_INVCUBIC_MODE = 6;
  28047. /** Equirectangular coordinates mode */
  28048. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  28049. /** Equirectangular Fixed coordinates mode */
  28050. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  28051. /** Equirectangular Fixed Mirrored coordinates mode */
  28052. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  28053. // Texture rescaling mode
  28054. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28055. Constants.SCALEMODE_FLOOR = 1;
  28056. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28057. Constants.SCALEMODE_NEAREST = 2;
  28058. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28059. Constants.SCALEMODE_CEILING = 3;
  28060. /**
  28061. * The dirty texture flag value
  28062. */
  28063. Constants.MATERIAL_TextureDirtyFlag = 1;
  28064. /**
  28065. * The dirty light flag value
  28066. */
  28067. Constants.MATERIAL_LightDirtyFlag = 2;
  28068. /**
  28069. * The dirty fresnel flag value
  28070. */
  28071. Constants.MATERIAL_FresnelDirtyFlag = 4;
  28072. /**
  28073. * The dirty attribute flag value
  28074. */
  28075. Constants.MATERIAL_AttributesDirtyFlag = 8;
  28076. /**
  28077. * The dirty misc flag value
  28078. */
  28079. Constants.MATERIAL_MiscDirtyFlag = 16;
  28080. /**
  28081. * The all dirty flag value
  28082. */
  28083. Constants.MATERIAL_AllDirtyFlag = 31;
  28084. /**
  28085. * Returns the triangle fill mode
  28086. */
  28087. Constants.MATERIAL_TriangleFillMode = 0;
  28088. /**
  28089. * Returns the wireframe mode
  28090. */
  28091. Constants.MATERIAL_WireFrameFillMode = 1;
  28092. /**
  28093. * Returns the point fill mode
  28094. */
  28095. Constants.MATERIAL_PointFillMode = 2;
  28096. /**
  28097. * Returns the point list draw mode
  28098. */
  28099. Constants.MATERIAL_PointListDrawMode = 3;
  28100. /**
  28101. * Returns the line list draw mode
  28102. */
  28103. Constants.MATERIAL_LineListDrawMode = 4;
  28104. /**
  28105. * Returns the line loop draw mode
  28106. */
  28107. Constants.MATERIAL_LineLoopDrawMode = 5;
  28108. /**
  28109. * Returns the line strip draw mode
  28110. */
  28111. Constants.MATERIAL_LineStripDrawMode = 6;
  28112. /**
  28113. * Returns the triangle strip draw mode
  28114. */
  28115. Constants.MATERIAL_TriangleStripDrawMode = 7;
  28116. /**
  28117. * Returns the triangle fan draw mode
  28118. */
  28119. Constants.MATERIAL_TriangleFanDrawMode = 8;
  28120. /**
  28121. * Stores the clock-wise side orientation
  28122. */
  28123. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  28124. /**
  28125. * Stores the counter clock-wise side orientation
  28126. */
  28127. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  28128. /**
  28129. * Nothing
  28130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28131. */
  28132. Constants.ACTION_NothingTrigger = 0;
  28133. /**
  28134. * On pick
  28135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28136. */
  28137. Constants.ACTION_OnPickTrigger = 1;
  28138. /**
  28139. * On left pick
  28140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28141. */
  28142. Constants.ACTION_OnLeftPickTrigger = 2;
  28143. /**
  28144. * On right pick
  28145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28146. */
  28147. Constants.ACTION_OnRightPickTrigger = 3;
  28148. /**
  28149. * On center pick
  28150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28151. */
  28152. Constants.ACTION_OnCenterPickTrigger = 4;
  28153. /**
  28154. * On pick down
  28155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28156. */
  28157. Constants.ACTION_OnPickDownTrigger = 5;
  28158. /**
  28159. * On double pick
  28160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28161. */
  28162. Constants.ACTION_OnDoublePickTrigger = 6;
  28163. /**
  28164. * On pick up
  28165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28166. */
  28167. Constants.ACTION_OnPickUpTrigger = 7;
  28168. /**
  28169. * On pick out.
  28170. * This trigger will only be raised if you also declared a OnPickDown
  28171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28172. */
  28173. Constants.ACTION_OnPickOutTrigger = 16;
  28174. /**
  28175. * On long press
  28176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28177. */
  28178. Constants.ACTION_OnLongPressTrigger = 8;
  28179. /**
  28180. * On pointer over
  28181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28182. */
  28183. Constants.ACTION_OnPointerOverTrigger = 9;
  28184. /**
  28185. * On pointer out
  28186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28187. */
  28188. Constants.ACTION_OnPointerOutTrigger = 10;
  28189. /**
  28190. * On every frame
  28191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28192. */
  28193. Constants.ACTION_OnEveryFrameTrigger = 11;
  28194. /**
  28195. * On intersection enter
  28196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28197. */
  28198. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  28199. /**
  28200. * On intersection exit
  28201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28202. */
  28203. Constants.ACTION_OnIntersectionExitTrigger = 13;
  28204. /**
  28205. * On key down
  28206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28207. */
  28208. Constants.ACTION_OnKeyDownTrigger = 14;
  28209. /**
  28210. * On key up
  28211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  28212. */
  28213. Constants.ACTION_OnKeyUpTrigger = 15;
  28214. /**
  28215. * Billboard mode will only apply to Y axis
  28216. */
  28217. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  28218. /**
  28219. * Billboard mode will apply to all axes
  28220. */
  28221. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  28222. /**
  28223. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  28224. */
  28225. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  28226. /**
  28227. * Gets or sets base Assets URL
  28228. */
  28229. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  28230. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28231. * Test order :
  28232. * Is the bounding sphere outside the frustum ?
  28233. * If not, are the bounding box vertices outside the frustum ?
  28234. * It not, then the cullable object is in the frustum.
  28235. */
  28236. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  28237. /** Culling strategy : Bounding Sphere Only.
  28238. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28239. * It's also less accurate than the standard because some not visible objects can still be selected.
  28240. * Test : is the bounding sphere outside the frustum ?
  28241. * If not, then the cullable object is in the frustum.
  28242. */
  28243. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  28244. /** Culling strategy : Optimistic Inclusion.
  28245. * This in an inclusion test first, then the standard exclusion test.
  28246. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28247. * 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.
  28248. * Anyway, it's as accurate as the standard strategy.
  28249. * Test :
  28250. * Is the cullable object bounding sphere center in the frustum ?
  28251. * If not, apply the default culling strategy.
  28252. */
  28253. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  28254. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28255. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28256. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28257. * 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.
  28258. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28259. * Test :
  28260. * Is the cullable object bounding sphere center in the frustum ?
  28261. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28262. */
  28263. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  28264. /**
  28265. * No logging while loading
  28266. */
  28267. Constants.SCENELOADER_NO_LOGGING = 0;
  28268. /**
  28269. * Minimal logging while loading
  28270. */
  28271. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  28272. /**
  28273. * Summary logging while loading
  28274. */
  28275. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  28276. /**
  28277. * Detailled logging while loading
  28278. */
  28279. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  28280. return Constants;
  28281. }());
  28282. /***/ }),
  28283. /***/ "./Engines/engine.ts":
  28284. /*!***************************!*\
  28285. !*** ./Engines/engine.ts ***!
  28286. \***************************/
  28287. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  28288. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  28289. "use strict";
  28290. __webpack_require__.r(__webpack_exports__);
  28291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  28292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  28293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  28294. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  28295. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  28296. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  28297. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  28298. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  28299. /* harmony import */ var _Misc_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/promise */ "./Misc/promise.ts");
  28300. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  28301. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  28302. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  28303. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  28304. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  28305. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  28306. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  28307. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  28308. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  28309. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  28310. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  28311. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  28312. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  28313. /**
  28314. * Keeps track of all the buffer info used in engine.
  28315. */
  28316. var BufferPointer = /** @class */ (function () {
  28317. function BufferPointer() {
  28318. }
  28319. return BufferPointer;
  28320. }());
  28321. /**
  28322. * Interface for attribute information associated with buffer instanciation
  28323. */
  28324. var InstancingAttributeInfo = /** @class */ (function () {
  28325. function InstancingAttributeInfo() {
  28326. }
  28327. return InstancingAttributeInfo;
  28328. }());
  28329. /**
  28330. * Define options used to create a depth texture
  28331. */
  28332. var DepthTextureCreationOptions = /** @class */ (function () {
  28333. function DepthTextureCreationOptions() {
  28334. }
  28335. return DepthTextureCreationOptions;
  28336. }());
  28337. /**
  28338. * Class used to describe the capabilities of the engine relatively to the current browser
  28339. */
  28340. var EngineCapabilities = /** @class */ (function () {
  28341. function EngineCapabilities() {
  28342. }
  28343. return EngineCapabilities;
  28344. }());
  28345. /**
  28346. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28347. */
  28348. var Engine = /** @class */ (function () {
  28349. /**
  28350. * Creates a new engine
  28351. * @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
  28352. * @param antialias defines enable antialiasing (default: false)
  28353. * @param options defines further options to be sent to the getContext() function
  28354. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28355. */
  28356. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  28357. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  28358. var _this = this;
  28359. // Public members
  28360. /**
  28361. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28362. */
  28363. this.forcePOTTextures = false;
  28364. /**
  28365. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28366. */
  28367. this.isFullscreen = false;
  28368. /**
  28369. * Gets a boolean indicating if the pointer is currently locked
  28370. */
  28371. this.isPointerLock = false;
  28372. /**
  28373. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28374. */
  28375. this.cullBackFaces = true;
  28376. /**
  28377. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28378. */
  28379. this.renderEvenInBackground = true;
  28380. /**
  28381. * Gets or sets a boolean indicating that cache can be kept between frames
  28382. */
  28383. this.preventCacheWipeBetweenFrames = false;
  28384. /**
  28385. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28386. **/
  28387. this.enableOfflineSupport = false;
  28388. /**
  28389. * 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)
  28390. **/
  28391. this.disableManifestCheck = false;
  28392. /**
  28393. * Gets the list of created scenes
  28394. */
  28395. this.scenes = new Array();
  28396. /**
  28397. * Event raised when a new scene is created
  28398. */
  28399. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28400. /**
  28401. * Gets the list of created postprocesses
  28402. */
  28403. this.postProcesses = new Array();
  28404. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28405. this.validateShaderPrograms = false;
  28406. // Observables
  28407. /**
  28408. * Observable event triggered each time the rendering canvas is resized
  28409. */
  28410. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28411. /**
  28412. * Observable event triggered each time the canvas loses focus
  28413. */
  28414. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28415. /**
  28416. * Observable event triggered each time the canvas gains focus
  28417. */
  28418. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28419. /**
  28420. * Observable event triggered each time the canvas receives pointerout event
  28421. */
  28422. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28423. /**
  28424. * Observable event triggered before each texture is initialized
  28425. */
  28426. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28427. //WebVR
  28428. this._vrDisplay = undefined;
  28429. this._vrSupported = false;
  28430. this._vrExclusivePointerMode = false;
  28431. // Uniform buffers list
  28432. /**
  28433. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28434. */
  28435. this.disableUniformBuffers = false;
  28436. /** @hidden */
  28437. this._uniformBuffers = new Array();
  28438. // Observables
  28439. /**
  28440. * Observable raised when the engine begins a new frame
  28441. */
  28442. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28443. /**
  28444. * If set, will be used to request the next animation frame for the render loop
  28445. */
  28446. this.customAnimationFrameRequester = null;
  28447. /**
  28448. * Observable raised when the engine ends the current frame
  28449. */
  28450. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28451. /**
  28452. * Observable raised when the engine is about to compile a shader
  28453. */
  28454. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28455. /**
  28456. * Observable raised when the engine has jsut compiled a shader
  28457. */
  28458. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28459. this._windowIsBackground = false;
  28460. this._webGLVersion = 1.0;
  28461. this._highPrecisionShadersAllowed = true;
  28462. /** @hidden */
  28463. this._badOS = false;
  28464. /** @hidden */
  28465. this._badDesktopOS = false;
  28466. /**
  28467. * Observable signaled when VR display mode changes
  28468. */
  28469. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28470. /**
  28471. * Observable signaled when VR request present is complete
  28472. */
  28473. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28474. /**
  28475. * Observable signaled when VR request present starts
  28476. */
  28477. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28478. this._colorWrite = true;
  28479. /** @hidden */
  28480. this._drawCalls = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  28481. this._renderingQueueLaunched = false;
  28482. this._activeRenderLoops = new Array();
  28483. // Deterministic lockstepMaxSteps
  28484. this._deterministicLockstep = false;
  28485. this._lockstepMaxSteps = 4;
  28486. // Lost context
  28487. /**
  28488. * Observable signaled when a context lost event is raised
  28489. */
  28490. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28491. /**
  28492. * Observable signaled when a context restored event is raised
  28493. */
  28494. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  28495. this._contextWasLost = false;
  28496. this._doNotHandleContextLost = false;
  28497. // FPS
  28498. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  28499. this._fps = 60;
  28500. this._deltaTime = 0;
  28501. /**
  28502. * Turn this value on if you want to pause FPS computation when in background
  28503. */
  28504. this.disablePerformanceMonitorInBackground = false;
  28505. /**
  28506. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28507. */
  28508. this.disableVertexArrayObjects = false;
  28509. // States
  28510. /** @hidden */
  28511. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_11__["_DepthCullingState"]();
  28512. /** @hidden */
  28513. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_11__["_StencilState"]();
  28514. /** @hidden */
  28515. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_11__["_AlphaState"]();
  28516. /** @hidden */
  28517. this._alphaMode = Engine.ALPHA_DISABLE;
  28518. // Cache
  28519. this._internalTexturesCache = new Array();
  28520. /** @hidden */
  28521. this._activeChannel = 0;
  28522. this._currentTextureChannel = -1;
  28523. /** @hidden */
  28524. this._boundTexturesCache = {};
  28525. this._compiledEffects = {};
  28526. this._vertexAttribArraysEnabled = [];
  28527. this._uintIndicesCurrentlySet = false;
  28528. this._currentBoundBuffer = new Array();
  28529. /** @hidden */
  28530. this._currentFramebuffer = null;
  28531. this._currentBufferPointers = new Array();
  28532. this._currentInstanceLocations = new Array();
  28533. this._currentInstanceBuffers = new Array();
  28534. this._vaoRecordInProgress = false;
  28535. this._mustWipeVertexAttributes = false;
  28536. this._nextFreeTextureSlots = new Array();
  28537. this._maxSimultaneousTextures = 0;
  28538. this._activeRequests = new Array();
  28539. // Hardware supported Compressed Textures
  28540. this._texturesSupported = new Array();
  28541. /**
  28542. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28543. */
  28544. this.premultipliedAlpha = true;
  28545. this._viewportCached = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](0, 0, 0, 0);
  28546. this._onVRFullScreenTriggered = function () {
  28547. if (_this._vrDisplay && _this._vrDisplay.isPresenting) {
  28548. //get the old size before we change
  28549. _this._oldSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Size"](_this.getRenderWidth(), _this.getRenderHeight());
  28550. _this._oldHardwareScaleFactor = _this.getHardwareScalingLevel();
  28551. //get the width and height, change the render size
  28552. var leftEye = _this._vrDisplay.getEyeParameters('left');
  28553. _this.setHardwareScalingLevel(1);
  28554. _this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  28555. }
  28556. else {
  28557. _this.setHardwareScalingLevel(_this._oldHardwareScaleFactor);
  28558. _this.setSize(_this._oldSize.width, _this._oldSize.height);
  28559. }
  28560. };
  28561. this._unpackFlipYCached = null;
  28562. /**
  28563. * In case you are sharing the context with other applications, it might
  28564. * be interested to not cache the unpack flip y state to ensure a consistent
  28565. * value would be set.
  28566. */
  28567. this.enableUnpackFlipYCached = true;
  28568. this._boundUniforms = {};
  28569. // Register promises
  28570. _Misc_promise__WEBPACK_IMPORTED_MODULE_4__["PromisePolyfill"].Apply();
  28571. var canvas = null;
  28572. Engine.Instances.push(this);
  28573. if (!canvasOrContext) {
  28574. return;
  28575. }
  28576. options = options || {};
  28577. if (canvasOrContext.getContext) {
  28578. canvas = canvasOrContext;
  28579. this._renderingCanvas = canvas;
  28580. if (antialias != null) {
  28581. options.antialias = antialias;
  28582. }
  28583. if (options.deterministicLockstep === undefined) {
  28584. options.deterministicLockstep = false;
  28585. }
  28586. if (options.lockstepMaxSteps === undefined) {
  28587. options.lockstepMaxSteps = 4;
  28588. }
  28589. if (options.preserveDrawingBuffer === undefined) {
  28590. options.preserveDrawingBuffer = false;
  28591. }
  28592. if (options.audioEngine === undefined) {
  28593. options.audioEngine = true;
  28594. }
  28595. if (options.stencil === undefined) {
  28596. options.stencil = true;
  28597. }
  28598. if (options.premultipliedAlpha === false) {
  28599. this.premultipliedAlpha = false;
  28600. }
  28601. this._deterministicLockstep = options.deterministicLockstep;
  28602. this._lockstepMaxSteps = options.lockstepMaxSteps;
  28603. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  28604. // Exceptions
  28605. if (navigator && navigator.userAgent) {
  28606. var ua = navigator.userAgent;
  28607. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  28608. var exception = _a[_i];
  28609. var key = exception.key;
  28610. var targets = exception.targets;
  28611. var check = new RegExp(key);
  28612. if (check.test(ua)) {
  28613. if (exception.capture && exception.captureConstraint) {
  28614. var capture = exception.capture;
  28615. var constraint = exception.captureConstraint;
  28616. var regex = new RegExp(capture);
  28617. var matches = regex.exec(ua);
  28618. if (matches && matches.length > 0) {
  28619. var capturedValue = parseInt(matches[matches.length - 1]);
  28620. if (capturedValue >= constraint) {
  28621. continue;
  28622. }
  28623. }
  28624. }
  28625. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  28626. var target = targets_1[_b];
  28627. switch (target) {
  28628. case "uniformBuffer":
  28629. this.disableUniformBuffers = true;
  28630. break;
  28631. case "vao":
  28632. this.disableVertexArrayObjects = true;
  28633. break;
  28634. }
  28635. }
  28636. }
  28637. }
  28638. }
  28639. // GL
  28640. if (!options.disableWebGL2Support) {
  28641. try {
  28642. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  28643. if (this._gl) {
  28644. this._webGLVersion = 2.0;
  28645. // Prevent weird browsers to lie :-)
  28646. if (!this._gl.deleteQuery) {
  28647. this._webGLVersion = 1.0;
  28648. }
  28649. }
  28650. }
  28651. catch (e) {
  28652. // Do nothing
  28653. }
  28654. }
  28655. if (!this._gl) {
  28656. if (!canvas) {
  28657. throw new Error("The provided canvas is null or undefined.");
  28658. }
  28659. try {
  28660. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  28661. }
  28662. catch (e) {
  28663. throw new Error("WebGL not supported");
  28664. }
  28665. }
  28666. if (!this._gl) {
  28667. throw new Error("WebGL not supported");
  28668. }
  28669. // Ensures a consistent color space unpacking of textures cross browser.
  28670. this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, this._gl.NONE);
  28671. this._onCanvasFocus = function () {
  28672. _this.onCanvasFocusObservable.notifyObservers(_this);
  28673. };
  28674. this._onCanvasBlur = function () {
  28675. _this.onCanvasBlurObservable.notifyObservers(_this);
  28676. };
  28677. canvas.addEventListener("focus", this._onCanvasFocus);
  28678. canvas.addEventListener("blur", this._onCanvasBlur);
  28679. this._onBlur = function () {
  28680. if (_this.disablePerformanceMonitorInBackground) {
  28681. _this._performanceMonitor.disable();
  28682. }
  28683. _this._windowIsBackground = true;
  28684. };
  28685. this._onFocus = function () {
  28686. if (_this.disablePerformanceMonitorInBackground) {
  28687. _this._performanceMonitor.enable();
  28688. }
  28689. _this._windowIsBackground = false;
  28690. };
  28691. this._onCanvasPointerOut = function (ev) {
  28692. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  28693. };
  28694. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  28695. window.addEventListener("blur", this._onBlur);
  28696. window.addEventListener("focus", this._onFocus);
  28697. }
  28698. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  28699. // Context lost
  28700. if (!this._doNotHandleContextLost) {
  28701. this._onContextLost = function (evt) {
  28702. evt.preventDefault();
  28703. _this._contextWasLost = true;
  28704. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("WebGL context lost.");
  28705. _this.onContextLostObservable.notifyObservers(_this);
  28706. };
  28707. this._onContextRestored = function () {
  28708. // Adding a timeout to avoid race condition at browser level
  28709. setTimeout(function () {
  28710. // Rebuild gl context
  28711. _this._initGLContext();
  28712. // Rebuild effects
  28713. _this._rebuildEffects();
  28714. // Rebuild textures
  28715. _this._rebuildInternalTextures();
  28716. // Rebuild buffers
  28717. _this._rebuildBuffers();
  28718. // Cache
  28719. _this.wipeCaches(true);
  28720. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("WebGL context successfully restored.");
  28721. _this.onContextRestoredObservable.notifyObservers(_this);
  28722. _this._contextWasLost = false;
  28723. }, 0);
  28724. };
  28725. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  28726. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  28727. }
  28728. if (!options.doNotHandleTouchAction) {
  28729. this._disableTouchAction();
  28730. }
  28731. }
  28732. else {
  28733. this._gl = canvasOrContext;
  28734. this._renderingCanvas = this._gl.canvas;
  28735. if (this._gl.renderbufferStorageMultisample) {
  28736. this._webGLVersion = 2.0;
  28737. }
  28738. var attributes = this._gl.getContextAttributes();
  28739. if (attributes) {
  28740. options.stencil = attributes.stencil;
  28741. }
  28742. }
  28743. if (options.useHighPrecisionFloats !== undefined) {
  28744. this._highPrecisionShadersAllowed = options.useHighPrecisionFloats;
  28745. }
  28746. // Viewport
  28747. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  28748. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  28749. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  28750. this.resize();
  28751. this._isStencilEnable = options.stencil ? true : false;
  28752. this._initGLContext();
  28753. if (canvas) {
  28754. var anyDoc_1 = document;
  28755. // Fullscreen
  28756. this._onFullscreenChange = function () {
  28757. if (anyDoc_1.fullscreen !== undefined) {
  28758. _this.isFullscreen = anyDoc_1.fullscreen;
  28759. }
  28760. else if (anyDoc_1.mozFullScreen !== undefined) {
  28761. _this.isFullscreen = anyDoc_1.mozFullScreen;
  28762. }
  28763. else if (anyDoc_1.webkitIsFullScreen !== undefined) {
  28764. _this.isFullscreen = anyDoc_1.webkitIsFullScreen;
  28765. }
  28766. else if (anyDoc_1.msIsFullScreen !== undefined) {
  28767. _this.isFullscreen = anyDoc_1.msIsFullScreen;
  28768. }
  28769. // Pointer lock
  28770. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  28771. canvas.requestPointerLock = canvas.requestPointerLock ||
  28772. canvas.msRequestPointerLock ||
  28773. canvas.mozRequestPointerLock ||
  28774. canvas.webkitRequestPointerLock;
  28775. if (canvas.requestPointerLock) {
  28776. canvas.requestPointerLock();
  28777. }
  28778. }
  28779. };
  28780. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  28781. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  28782. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  28783. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  28784. // Pointer lock
  28785. this._onPointerLockChange = function () {
  28786. _this.isPointerLock = (anyDoc_1.mozPointerLockElement === canvas ||
  28787. anyDoc_1.webkitPointerLockElement === canvas ||
  28788. anyDoc_1.msPointerLockElement === canvas ||
  28789. anyDoc_1.pointerLockElement === canvas);
  28790. };
  28791. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  28792. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  28793. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  28794. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  28795. this._onVRDisplayPointerRestricted = function () {
  28796. if (canvas) {
  28797. canvas.requestPointerLock();
  28798. }
  28799. };
  28800. this._onVRDisplayPointerUnrestricted = function () {
  28801. if (!anyDoc_1.exitPointerLock) {
  28802. return;
  28803. }
  28804. anyDoc_1.exitPointerLock();
  28805. };
  28806. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  28807. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  28808. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  28809. }
  28810. }
  28811. // Create Audio Engine if needed.
  28812. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  28813. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  28814. }
  28815. // Prepare buffer pointers
  28816. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  28817. this._currentBufferPointers[i] = new BufferPointer();
  28818. }
  28819. // Load WebVR Devices
  28820. if (options.autoEnableWebVR) {
  28821. this.initWebVR();
  28822. }
  28823. // Detect if we are running on a faulty buggy OS.
  28824. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  28825. // Detect if we are running on a faulty buggy desktop OS.
  28826. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  28827. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  28828. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  28829. }
  28830. Object.defineProperty(Engine, "Instances", {
  28831. /** Gets the list of created engines */
  28832. get: function () {
  28833. return _engineStore__WEBPACK_IMPORTED_MODULE_15__["EngineStore"].Instances;
  28834. },
  28835. enumerable: true,
  28836. configurable: true
  28837. });
  28838. Object.defineProperty(Engine, "LastCreatedEngine", {
  28839. /**
  28840. * Gets the latest created engine
  28841. */
  28842. get: function () {
  28843. return _engineStore__WEBPACK_IMPORTED_MODULE_15__["EngineStore"].LastCreatedEngine;
  28844. },
  28845. enumerable: true,
  28846. configurable: true
  28847. });
  28848. Object.defineProperty(Engine, "LastCreatedScene", {
  28849. /**
  28850. * Gets the latest created scene
  28851. */
  28852. get: function () {
  28853. return _engineStore__WEBPACK_IMPORTED_MODULE_15__["EngineStore"].LastCreatedScene;
  28854. },
  28855. enumerable: true,
  28856. configurable: true
  28857. });
  28858. /**
  28859. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28860. * @param flag defines which part of the materials must be marked as dirty
  28861. * @param predicate defines a predicate used to filter which materials should be affected
  28862. */
  28863. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  28864. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  28865. var engine = Engine.Instances[engineIndex];
  28866. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  28867. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  28868. }
  28869. }
  28870. };
  28871. Object.defineProperty(Engine, "NpmPackage", {
  28872. /**
  28873. * Returns the current npm package of the sdk
  28874. */
  28875. // Not mixed with Version for tooling purpose.
  28876. get: function () {
  28877. return "babylonjs@4.0.0-beta.3";
  28878. },
  28879. enumerable: true,
  28880. configurable: true
  28881. });
  28882. Object.defineProperty(Engine, "Version", {
  28883. /**
  28884. * Returns the current version of the framework
  28885. */
  28886. get: function () {
  28887. return "4.0.0-beta.3";
  28888. },
  28889. enumerable: true,
  28890. configurable: true
  28891. });
  28892. Object.defineProperty(Engine.prototype, "description", {
  28893. /**
  28894. * Returns a string describing the current engine
  28895. */
  28896. get: function () {
  28897. var description = "WebGL" + this.webGLVersion;
  28898. if (this._caps.parallelShaderCompile) {
  28899. description += " - Parallel shader compilation";
  28900. }
  28901. return description;
  28902. },
  28903. enumerable: true,
  28904. configurable: true
  28905. });
  28906. Object.defineProperty(Engine, "ShadersRepository", {
  28907. /**
  28908. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28909. */
  28910. get: function () {
  28911. return _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository;
  28912. },
  28913. set: function (value) {
  28914. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository = value;
  28915. },
  28916. enumerable: true,
  28917. configurable: true
  28918. });
  28919. /**
  28920. * Method called to create the default loading screen.
  28921. * This can be overriden in your own app.
  28922. * @param canvas The rendering canvas element
  28923. * @returns The loading screen
  28924. */
  28925. Engine.DefaultLoadingScreenFactory = function (canvas) {
  28926. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_17__["_DevTools"].WarnImport("LoadingScreen");
  28927. };
  28928. Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
  28929. /**
  28930. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28931. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28932. */
  28933. get: function () {
  28934. return this._vrExclusivePointerMode;
  28935. },
  28936. enumerable: true,
  28937. configurable: true
  28938. });
  28939. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  28940. /**
  28941. * Gets a boolean indicating that the engine supports uniform buffers
  28942. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28943. */
  28944. get: function () {
  28945. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  28946. },
  28947. enumerable: true,
  28948. configurable: true
  28949. });
  28950. Object.defineProperty(Engine.prototype, "_shouldUseHighPrecisionShader", {
  28951. /** @hidden */
  28952. get: function () {
  28953. return this._caps.highPrecisionShaderSupported && this._highPrecisionShadersAllowed;
  28954. },
  28955. enumerable: true,
  28956. configurable: true
  28957. });
  28958. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  28959. /**
  28960. * Gets a boolean indicating that only power of 2 textures are supported
  28961. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28962. */
  28963. get: function () {
  28964. return this._webGLVersion < 2 || this.forcePOTTextures;
  28965. },
  28966. enumerable: true,
  28967. configurable: true
  28968. });
  28969. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  28970. /**
  28971. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28972. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28973. */
  28974. get: function () {
  28975. return this._doNotHandleContextLost;
  28976. },
  28977. set: function (value) {
  28978. this._doNotHandleContextLost = value;
  28979. },
  28980. enumerable: true,
  28981. configurable: true
  28982. });
  28983. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  28984. /**
  28985. * Gets the performance monitor attached to this engine
  28986. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28987. */
  28988. get: function () {
  28989. return this._performanceMonitor;
  28990. },
  28991. enumerable: true,
  28992. configurable: true
  28993. });
  28994. Object.defineProperty(Engine.prototype, "texturesSupported", {
  28995. /**
  28996. * Gets the list of texture formats supported
  28997. */
  28998. get: function () {
  28999. return this._texturesSupported;
  29000. },
  29001. enumerable: true,
  29002. configurable: true
  29003. });
  29004. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  29005. /**
  29006. * Gets the list of texture formats in use
  29007. */
  29008. get: function () {
  29009. return this._textureFormatInUse;
  29010. },
  29011. enumerable: true,
  29012. configurable: true
  29013. });
  29014. Object.defineProperty(Engine.prototype, "currentViewport", {
  29015. /**
  29016. * Gets the current viewport
  29017. */
  29018. get: function () {
  29019. return this._cachedViewport;
  29020. },
  29021. enumerable: true,
  29022. configurable: true
  29023. });
  29024. Object.defineProperty(Engine.prototype, "emptyTexture", {
  29025. /**
  29026. * Gets the default empty texture
  29027. */
  29028. get: function () {
  29029. if (!this._emptyTexture) {
  29030. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  29031. }
  29032. return this._emptyTexture;
  29033. },
  29034. enumerable: true,
  29035. configurable: true
  29036. });
  29037. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  29038. /**
  29039. * Gets the default empty 3D texture
  29040. */
  29041. get: function () {
  29042. if (!this._emptyTexture3D) {
  29043. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  29044. }
  29045. return this._emptyTexture3D;
  29046. },
  29047. enumerable: true,
  29048. configurable: true
  29049. });
  29050. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  29051. /**
  29052. * Gets the default empty cube texture
  29053. */
  29054. get: function () {
  29055. if (!this._emptyCubeTexture) {
  29056. var faceData = new Uint8Array(4);
  29057. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  29058. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  29059. }
  29060. return this._emptyCubeTexture;
  29061. },
  29062. enumerable: true,
  29063. configurable: true
  29064. });
  29065. Engine.prototype._disableTouchAction = function () {
  29066. if (!this._renderingCanvas) {
  29067. return;
  29068. }
  29069. this._renderingCanvas.setAttribute("touch-action", "none");
  29070. this._renderingCanvas.style.touchAction = "none";
  29071. this._renderingCanvas.style.msTouchAction = "none";
  29072. };
  29073. Engine.prototype._rebuildInternalTextures = function () {
  29074. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  29075. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  29076. var internalTexture = currentState_1[_i];
  29077. internalTexture._rebuild();
  29078. }
  29079. };
  29080. Engine.prototype._rebuildEffects = function () {
  29081. for (var key in this._compiledEffects) {
  29082. var effect = this._compiledEffects[key];
  29083. effect._prepareEffect();
  29084. }
  29085. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  29086. };
  29087. /**
  29088. * Gets a boolean indicating if all created effects are ready
  29089. * @returns true if all effects are ready
  29090. */
  29091. Engine.prototype.areAllEffectsReady = function () {
  29092. for (var key in this._compiledEffects) {
  29093. var effect = this._compiledEffects[key];
  29094. if (!effect.isReady()) {
  29095. return false;
  29096. }
  29097. }
  29098. return true;
  29099. };
  29100. Engine.prototype._rebuildBuffers = function () {
  29101. // Index / Vertex
  29102. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  29103. var scene = _a[_i];
  29104. scene.resetCachedMaterial();
  29105. scene._rebuildGeometries();
  29106. scene._rebuildTextures();
  29107. }
  29108. // Uniforms
  29109. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  29110. var uniformBuffer = _c[_b];
  29111. uniformBuffer._rebuild();
  29112. }
  29113. };
  29114. Engine.prototype._initGLContext = function () {
  29115. // Caps
  29116. this._caps = new EngineCapabilities();
  29117. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  29118. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  29119. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  29120. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  29121. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  29122. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  29123. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  29124. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  29125. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  29126. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  29127. // Infos
  29128. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  29129. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  29130. if (rendererInfo != null) {
  29131. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  29132. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  29133. }
  29134. if (!this._glVendor) {
  29135. this._glVendor = "Unknown vendor";
  29136. }
  29137. if (!this._glRenderer) {
  29138. this._glRenderer = "Unknown renderer";
  29139. }
  29140. // Constants
  29141. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  29142. if (this._gl.RGBA16F !== 0x881A) {
  29143. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  29144. }
  29145. if (this._gl.RGBA32F !== 0x8814) {
  29146. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  29147. }
  29148. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  29149. this._gl.DEPTH24_STENCIL8 = 35056;
  29150. }
  29151. // Extensions
  29152. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  29153. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  29154. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  29155. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  29156. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  29157. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  29158. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  29159. 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');
  29160. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  29161. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  29162. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  29163. this._caps.highPrecisionShaderSupported = false;
  29164. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  29165. if (this._caps.timerQuery) {
  29166. if (this._webGLVersion === 1) {
  29167. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  29168. }
  29169. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  29170. }
  29171. // Checks if some of the format renders first to allow the use of webgl inspector.
  29172. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  29173. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  29174. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  29175. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  29176. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  29177. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  29178. if (this._webGLVersion > 1) {
  29179. this._gl.HALF_FLOAT_OES = 0x140B;
  29180. }
  29181. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  29182. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  29183. this._caps.multiview = this._gl.getExtension('WEBGL_multiview');
  29184. // Draw buffers
  29185. if (this._webGLVersion > 1) {
  29186. this._caps.drawBuffersExtension = true;
  29187. }
  29188. else {
  29189. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  29190. if (drawBuffersExtension !== null) {
  29191. this._caps.drawBuffersExtension = true;
  29192. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  29193. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  29194. for (var i = 0; i < 16; i++) {
  29195. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  29196. }
  29197. }
  29198. else {
  29199. this._caps.drawBuffersExtension = false;
  29200. }
  29201. }
  29202. // Shader compiler threads
  29203. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  29204. // Depth Texture
  29205. if (this._webGLVersion > 1) {
  29206. this._caps.depthTextureExtension = true;
  29207. }
  29208. else {
  29209. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  29210. if (depthTextureExtension != null) {
  29211. this._caps.depthTextureExtension = true;
  29212. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  29213. }
  29214. }
  29215. // Vertex array object
  29216. if (this.disableVertexArrayObjects) {
  29217. this._caps.vertexArrayObject = false;
  29218. }
  29219. else if (this._webGLVersion > 1) {
  29220. this._caps.vertexArrayObject = true;
  29221. }
  29222. else {
  29223. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  29224. if (vertexArrayObjectExtension != null) {
  29225. this._caps.vertexArrayObject = true;
  29226. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  29227. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  29228. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  29229. }
  29230. else {
  29231. this._caps.vertexArrayObject = false;
  29232. }
  29233. }
  29234. // Instances count
  29235. if (this._webGLVersion > 1) {
  29236. this._caps.instancedArrays = true;
  29237. }
  29238. else {
  29239. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  29240. if (instanceExtension != null) {
  29241. this._caps.instancedArrays = true;
  29242. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  29243. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  29244. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  29245. }
  29246. else {
  29247. this._caps.instancedArrays = false;
  29248. }
  29249. }
  29250. // Intelligently add supported compressed formats in order to check for.
  29251. // Check for ASTC support first as it is most powerful and to be very cross platform.
  29252. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  29253. // Likely no hardware which supports both PVR & DXT, so order matters little.
  29254. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  29255. if (this._caps.astc) {
  29256. this.texturesSupported.push('-astc.ktx');
  29257. }
  29258. if (this._caps.s3tc) {
  29259. this.texturesSupported.push('-dxt.ktx');
  29260. }
  29261. if (this._caps.pvrtc) {
  29262. this.texturesSupported.push('-pvrtc.ktx');
  29263. }
  29264. if (this._caps.etc2) {
  29265. this.texturesSupported.push('-etc2.ktx');
  29266. }
  29267. if (this._caps.etc1) {
  29268. this.texturesSupported.push('-etc1.ktx');
  29269. }
  29270. if (this._gl.getShaderPrecisionFormat) {
  29271. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  29272. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  29273. if (vertex_highp && fragment_highp) {
  29274. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  29275. }
  29276. }
  29277. // Depth buffer
  29278. this.setDepthBuffer(true);
  29279. this.setDepthFunctionToLessOrEqual();
  29280. this.setDepthWrite(true);
  29281. // Texture maps
  29282. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  29283. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  29284. this._nextFreeTextureSlots.push(slot);
  29285. }
  29286. };
  29287. Object.defineProperty(Engine.prototype, "webGLVersion", {
  29288. /**
  29289. * Gets version of the current webGL context
  29290. */
  29291. get: function () {
  29292. return this._webGLVersion;
  29293. },
  29294. enumerable: true,
  29295. configurable: true
  29296. });
  29297. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  29298. /**
  29299. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29300. */
  29301. get: function () {
  29302. return this._isStencilEnable;
  29303. },
  29304. enumerable: true,
  29305. configurable: true
  29306. });
  29307. Engine.prototype._prepareWorkingCanvas = function () {
  29308. if (this._workingCanvas) {
  29309. return;
  29310. }
  29311. this._workingCanvas = document.createElement("canvas");
  29312. var context = this._workingCanvas.getContext("2d");
  29313. if (context) {
  29314. this._workingContext = context;
  29315. }
  29316. };
  29317. /**
  29318. * Reset the texture cache to empty state
  29319. */
  29320. Engine.prototype.resetTextureCache = function () {
  29321. for (var key in this._boundTexturesCache) {
  29322. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  29323. continue;
  29324. }
  29325. this._boundTexturesCache[key] = null;
  29326. }
  29327. this._currentTextureChannel = -1;
  29328. };
  29329. /**
  29330. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  29331. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29332. * @returns true if engine is in deterministic lock step mode
  29333. */
  29334. Engine.prototype.isDeterministicLockStep = function () {
  29335. return this._deterministicLockstep;
  29336. };
  29337. /**
  29338. * Gets the max steps when engine is running in deterministic lock step
  29339. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29340. * @returns the max steps
  29341. */
  29342. Engine.prototype.getLockstepMaxSteps = function () {
  29343. return this._lockstepMaxSteps;
  29344. };
  29345. /**
  29346. * Gets an object containing information about the current webGL context
  29347. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29348. */
  29349. Engine.prototype.getGlInfo = function () {
  29350. return {
  29351. vendor: this._glVendor,
  29352. renderer: this._glRenderer,
  29353. version: this._glVersion
  29354. };
  29355. };
  29356. /**
  29357. * Gets current aspect ratio
  29358. * @param camera defines the camera to use to get the aspect ratio
  29359. * @param useScreen defines if screen size must be used (or the current render target if any)
  29360. * @returns a number defining the aspect ratio
  29361. */
  29362. Engine.prototype.getAspectRatio = function (camera, useScreen) {
  29363. if (useScreen === void 0) { useScreen = false; }
  29364. var viewport = camera.viewport;
  29365. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  29366. };
  29367. /**
  29368. * Gets current screen aspect ratio
  29369. * @returns a number defining the aspect ratio
  29370. */
  29371. Engine.prototype.getScreenAspectRatio = function () {
  29372. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  29373. };
  29374. /**
  29375. * Gets the current render width
  29376. * @param useScreen defines if screen size must be used (or the current render target if any)
  29377. * @returns a number defining the current render width
  29378. */
  29379. Engine.prototype.getRenderWidth = function (useScreen) {
  29380. if (useScreen === void 0) { useScreen = false; }
  29381. if (!useScreen && this._currentRenderTarget) {
  29382. return this._currentRenderTarget.width;
  29383. }
  29384. return this._gl.drawingBufferWidth;
  29385. };
  29386. /**
  29387. * Gets the current render height
  29388. * @param useScreen defines if screen size must be used (or the current render target if any)
  29389. * @returns a number defining the current render height
  29390. */
  29391. Engine.prototype.getRenderHeight = function (useScreen) {
  29392. if (useScreen === void 0) { useScreen = false; }
  29393. if (!useScreen && this._currentRenderTarget) {
  29394. return this._currentRenderTarget.height;
  29395. }
  29396. return this._gl.drawingBufferHeight;
  29397. };
  29398. /**
  29399. * Gets the HTML canvas attached with the current webGL context
  29400. * @returns a HTML canvas
  29401. */
  29402. Engine.prototype.getRenderingCanvas = function () {
  29403. return this._renderingCanvas;
  29404. };
  29405. /**
  29406. * Gets the client rect of the HTML canvas attached with the current webGL context
  29407. * @returns a client rectanglee
  29408. */
  29409. Engine.prototype.getRenderingCanvasClientRect = function () {
  29410. if (!this._renderingCanvas) {
  29411. return null;
  29412. }
  29413. return this._renderingCanvas.getBoundingClientRect();
  29414. };
  29415. /**
  29416. * Defines the hardware scaling level.
  29417. * By default the hardware scaling level is computed from the window device ratio.
  29418. * 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.
  29419. * @param level defines the level to use
  29420. */
  29421. Engine.prototype.setHardwareScalingLevel = function (level) {
  29422. this._hardwareScalingLevel = level;
  29423. this.resize();
  29424. };
  29425. /**
  29426. * Gets the current hardware scaling level.
  29427. * By default the hardware scaling level is computed from the window device ratio.
  29428. * 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.
  29429. * @returns a number indicating the current hardware scaling level
  29430. */
  29431. Engine.prototype.getHardwareScalingLevel = function () {
  29432. return this._hardwareScalingLevel;
  29433. };
  29434. /**
  29435. * Gets the list of loaded textures
  29436. * @returns an array containing all loaded textures
  29437. */
  29438. Engine.prototype.getLoadedTexturesCache = function () {
  29439. return this._internalTexturesCache;
  29440. };
  29441. /**
  29442. * Gets the object containing all engine capabilities
  29443. * @returns the EngineCapabilities object
  29444. */
  29445. Engine.prototype.getCaps = function () {
  29446. return this._caps;
  29447. };
  29448. /**
  29449. * Gets the current depth function
  29450. * @returns a number defining the depth function
  29451. */
  29452. Engine.prototype.getDepthFunction = function () {
  29453. return this._depthCullingState.depthFunc;
  29454. };
  29455. /**
  29456. * Sets the current depth function
  29457. * @param depthFunc defines the function to use
  29458. */
  29459. Engine.prototype.setDepthFunction = function (depthFunc) {
  29460. this._depthCullingState.depthFunc = depthFunc;
  29461. };
  29462. /**
  29463. * Sets the current depth function to GREATER
  29464. */
  29465. Engine.prototype.setDepthFunctionToGreater = function () {
  29466. this._depthCullingState.depthFunc = this._gl.GREATER;
  29467. };
  29468. /**
  29469. * Sets the current depth function to GEQUAL
  29470. */
  29471. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  29472. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  29473. };
  29474. /**
  29475. * Sets the current depth function to LESS
  29476. */
  29477. Engine.prototype.setDepthFunctionToLess = function () {
  29478. this._depthCullingState.depthFunc = this._gl.LESS;
  29479. };
  29480. /**
  29481. * Caches the the state of the stencil buffer
  29482. */
  29483. Engine.prototype.cacheStencilState = function () {
  29484. this._cachedStencilBuffer = this.getStencilBuffer();
  29485. this._cachedStencilFunction = this.getStencilFunction();
  29486. this._cachedStencilMask = this.getStencilMask();
  29487. this._cachedStencilOperationPass = this.getStencilOperationPass();
  29488. this._cachedStencilOperationFail = this.getStencilOperationFail();
  29489. this._cachedStencilOperationDepthFail = this.getStencilOperationDepthFail();
  29490. this._cachedStencilReference = this.getStencilFunctionReference();
  29491. };
  29492. /**
  29493. * Restores the state of the stencil buffer
  29494. */
  29495. Engine.prototype.restoreStencilState = function () {
  29496. this.setStencilFunction(this._cachedStencilFunction);
  29497. this.setStencilMask(this._cachedStencilMask);
  29498. this.setStencilBuffer(this._cachedStencilBuffer);
  29499. this.setStencilOperationPass(this._cachedStencilOperationPass);
  29500. this.setStencilOperationFail(this._cachedStencilOperationFail);
  29501. this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail);
  29502. this.setStencilFunctionReference(this._cachedStencilReference);
  29503. };
  29504. /**
  29505. * Sets the current depth function to LEQUAL
  29506. */
  29507. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  29508. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  29509. };
  29510. /**
  29511. * Gets a boolean indicating if stencil buffer is enabled
  29512. * @returns the current stencil buffer state
  29513. */
  29514. Engine.prototype.getStencilBuffer = function () {
  29515. return this._stencilState.stencilTest;
  29516. };
  29517. /**
  29518. * Enable or disable the stencil buffer
  29519. * @param enable defines if the stencil buffer must be enabled or disabled
  29520. */
  29521. Engine.prototype.setStencilBuffer = function (enable) {
  29522. this._stencilState.stencilTest = enable;
  29523. };
  29524. /**
  29525. * Gets the current stencil mask
  29526. * @returns a number defining the new stencil mask to use
  29527. */
  29528. Engine.prototype.getStencilMask = function () {
  29529. return this._stencilState.stencilMask;
  29530. };
  29531. /**
  29532. * Sets the current stencil mask
  29533. * @param mask defines the new stencil mask to use
  29534. */
  29535. Engine.prototype.setStencilMask = function (mask) {
  29536. this._stencilState.stencilMask = mask;
  29537. };
  29538. /**
  29539. * Gets the current stencil function
  29540. * @returns a number defining the stencil function to use
  29541. */
  29542. Engine.prototype.getStencilFunction = function () {
  29543. return this._stencilState.stencilFunc;
  29544. };
  29545. /**
  29546. * Gets the current stencil reference value
  29547. * @returns a number defining the stencil reference value to use
  29548. */
  29549. Engine.prototype.getStencilFunctionReference = function () {
  29550. return this._stencilState.stencilFuncRef;
  29551. };
  29552. /**
  29553. * Gets the current stencil mask
  29554. * @returns a number defining the stencil mask to use
  29555. */
  29556. Engine.prototype.getStencilFunctionMask = function () {
  29557. return this._stencilState.stencilFuncMask;
  29558. };
  29559. /**
  29560. * Sets the current stencil function
  29561. * @param stencilFunc defines the new stencil function to use
  29562. */
  29563. Engine.prototype.setStencilFunction = function (stencilFunc) {
  29564. this._stencilState.stencilFunc = stencilFunc;
  29565. };
  29566. /**
  29567. * Sets the current stencil reference
  29568. * @param reference defines the new stencil reference to use
  29569. */
  29570. Engine.prototype.setStencilFunctionReference = function (reference) {
  29571. this._stencilState.stencilFuncRef = reference;
  29572. };
  29573. /**
  29574. * Sets the current stencil mask
  29575. * @param mask defines the new stencil mask to use
  29576. */
  29577. Engine.prototype.setStencilFunctionMask = function (mask) {
  29578. this._stencilState.stencilFuncMask = mask;
  29579. };
  29580. /**
  29581. * Gets the current stencil operation when stencil fails
  29582. * @returns a number defining stencil operation to use when stencil fails
  29583. */
  29584. Engine.prototype.getStencilOperationFail = function () {
  29585. return this._stencilState.stencilOpStencilFail;
  29586. };
  29587. /**
  29588. * Gets the current stencil operation when depth fails
  29589. * @returns a number defining stencil operation to use when depth fails
  29590. */
  29591. Engine.prototype.getStencilOperationDepthFail = function () {
  29592. return this._stencilState.stencilOpDepthFail;
  29593. };
  29594. /**
  29595. * Gets the current stencil operation when stencil passes
  29596. * @returns a number defining stencil operation to use when stencil passes
  29597. */
  29598. Engine.prototype.getStencilOperationPass = function () {
  29599. return this._stencilState.stencilOpStencilDepthPass;
  29600. };
  29601. /**
  29602. * Sets the stencil operation to use when stencil fails
  29603. * @param operation defines the stencil operation to use when stencil fails
  29604. */
  29605. Engine.prototype.setStencilOperationFail = function (operation) {
  29606. this._stencilState.stencilOpStencilFail = operation;
  29607. };
  29608. /**
  29609. * Sets the stencil operation to use when depth fails
  29610. * @param operation defines the stencil operation to use when depth fails
  29611. */
  29612. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  29613. this._stencilState.stencilOpDepthFail = operation;
  29614. };
  29615. /**
  29616. * Sets the stencil operation to use when stencil passes
  29617. * @param operation defines the stencil operation to use when stencil passes
  29618. */
  29619. Engine.prototype.setStencilOperationPass = function (operation) {
  29620. this._stencilState.stencilOpStencilDepthPass = operation;
  29621. };
  29622. /**
  29623. * Sets a boolean indicating if the dithering state is enabled or disabled
  29624. * @param value defines the dithering state
  29625. */
  29626. Engine.prototype.setDitheringState = function (value) {
  29627. if (value) {
  29628. this._gl.enable(this._gl.DITHER);
  29629. }
  29630. else {
  29631. this._gl.disable(this._gl.DITHER);
  29632. }
  29633. };
  29634. /**
  29635. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29636. * @param value defines the rasterizer state
  29637. */
  29638. Engine.prototype.setRasterizerState = function (value) {
  29639. if (value) {
  29640. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  29641. }
  29642. else {
  29643. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  29644. }
  29645. };
  29646. /**
  29647. * stop executing a render loop function and remove it from the execution array
  29648. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29649. */
  29650. Engine.prototype.stopRenderLoop = function (renderFunction) {
  29651. if (!renderFunction) {
  29652. this._activeRenderLoops = [];
  29653. return;
  29654. }
  29655. var index = this._activeRenderLoops.indexOf(renderFunction);
  29656. if (index >= 0) {
  29657. this._activeRenderLoops.splice(index, 1);
  29658. }
  29659. };
  29660. /** @hidden */
  29661. Engine.prototype._renderLoop = function () {
  29662. if (!this._contextWasLost) {
  29663. var shouldRender = true;
  29664. if (!this.renderEvenInBackground && this._windowIsBackground) {
  29665. shouldRender = false;
  29666. }
  29667. if (shouldRender) {
  29668. // Start new frame
  29669. this.beginFrame();
  29670. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  29671. var renderFunction = this._activeRenderLoops[index];
  29672. renderFunction();
  29673. }
  29674. // Present
  29675. this.endFrame();
  29676. }
  29677. }
  29678. if (this._activeRenderLoops.length > 0) {
  29679. // Register new frame
  29680. if (this.customAnimationFrameRequester) {
  29681. this.customAnimationFrameRequester.requestID = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  29682. this._frameHandler = this.customAnimationFrameRequester.requestID;
  29683. }
  29684. else if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29685. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  29686. }
  29687. else {
  29688. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  29689. }
  29690. }
  29691. else {
  29692. this._renderingQueueLaunched = false;
  29693. }
  29694. };
  29695. /**
  29696. * Register and execute a render loop. The engine can have more than one render function
  29697. * @param renderFunction defines the function to continuously execute
  29698. */
  29699. Engine.prototype.runRenderLoop = function (renderFunction) {
  29700. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  29701. return;
  29702. }
  29703. this._activeRenderLoops.push(renderFunction);
  29704. if (!this._renderingQueueLaunched) {
  29705. this._renderingQueueLaunched = true;
  29706. this._bindedRenderFunction = this._renderLoop.bind(this);
  29707. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  29708. }
  29709. };
  29710. /**
  29711. * Toggle full screen mode
  29712. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29713. */
  29714. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  29715. if (this.isFullscreen) {
  29716. this.exitFullscreen();
  29717. }
  29718. else {
  29719. this.enterFullscreen(requestPointerLock);
  29720. }
  29721. };
  29722. /**
  29723. * Enters full screen mode
  29724. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29725. */
  29726. Engine.prototype.enterFullscreen = function (requestPointerLock) {
  29727. if (!this.isFullscreen) {
  29728. this._pointerLockRequested = requestPointerLock;
  29729. if (this._renderingCanvas) {
  29730. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].RequestFullscreen(this._renderingCanvas);
  29731. }
  29732. }
  29733. };
  29734. /**
  29735. * Exits full screen mode
  29736. */
  29737. Engine.prototype.exitFullscreen = function () {
  29738. if (this.isFullscreen) {
  29739. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].ExitFullscreen();
  29740. }
  29741. };
  29742. /**
  29743. * Clear the current render buffer or the current render target (if any is set up)
  29744. * @param color defines the color to use
  29745. * @param backBuffer defines if the back buffer must be cleared
  29746. * @param depth defines if the depth buffer must be cleared
  29747. * @param stencil defines if the stencil buffer must be cleared
  29748. */
  29749. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  29750. if (stencil === void 0) { stencil = false; }
  29751. this.applyStates();
  29752. var mode = 0;
  29753. if (backBuffer && color) {
  29754. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  29755. mode |= this._gl.COLOR_BUFFER_BIT;
  29756. }
  29757. if (depth) {
  29758. this._gl.clearDepth(1.0);
  29759. mode |= this._gl.DEPTH_BUFFER_BIT;
  29760. }
  29761. if (stencil) {
  29762. this._gl.clearStencil(0);
  29763. mode |= this._gl.STENCIL_BUFFER_BIT;
  29764. }
  29765. this._gl.clear(mode);
  29766. };
  29767. /**
  29768. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29769. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29770. * @param y defines the y-coordinate of the corner of the clear rectangle
  29771. * @param width defines the width of the clear rectangle
  29772. * @param height defines the height of the clear rectangle
  29773. * @param clearColor defines the clear color
  29774. */
  29775. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  29776. this.enableScissor(x, y, width, height);
  29777. this.clear(clearColor, true, true, true);
  29778. this.disableScissor();
  29779. };
  29780. /**
  29781. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29782. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29783. * @param y defines the y-coordinate of the corner of the clear rectangle
  29784. * @param width defines the width of the clear rectangle
  29785. * @param height defines the height of the clear rectangle
  29786. */
  29787. Engine.prototype.enableScissor = function (x, y, width, height) {
  29788. var gl = this._gl;
  29789. // Change state
  29790. gl.enable(gl.SCISSOR_TEST);
  29791. gl.scissor(x, y, width, height);
  29792. };
  29793. /**
  29794. * Disable previously set scissor test rectangle
  29795. */
  29796. Engine.prototype.disableScissor = function () {
  29797. var gl = this._gl;
  29798. gl.disable(gl.SCISSOR_TEST);
  29799. };
  29800. /** @hidden */
  29801. Engine.prototype._viewport = function (x, y, width, height) {
  29802. if (x !== this._viewportCached.x ||
  29803. y !== this._viewportCached.y ||
  29804. width !== this._viewportCached.z ||
  29805. height !== this._viewportCached.w) {
  29806. this._viewportCached.x = x;
  29807. this._viewportCached.y = y;
  29808. this._viewportCached.z = width;
  29809. this._viewportCached.w = height;
  29810. this._gl.viewport(x, y, width, height);
  29811. }
  29812. };
  29813. /**
  29814. * Set the WebGL's viewport
  29815. * @param viewport defines the viewport element to be used
  29816. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29817. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29818. */
  29819. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  29820. var width = requiredWidth || this.getRenderWidth();
  29821. var height = requiredHeight || this.getRenderHeight();
  29822. var x = viewport.x || 0;
  29823. var y = viewport.y || 0;
  29824. this._cachedViewport = viewport;
  29825. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  29826. };
  29827. /**
  29828. * Directly set the WebGL Viewport
  29829. * @param x defines the x coordinate of the viewport (in screen space)
  29830. * @param y defines the y coordinate of the viewport (in screen space)
  29831. * @param width defines the width of the viewport (in screen space)
  29832. * @param height defines the height of the viewport (in screen space)
  29833. * @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
  29834. */
  29835. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  29836. var currentViewport = this._cachedViewport;
  29837. this._cachedViewport = null;
  29838. this._viewport(x, y, width, height);
  29839. return currentViewport;
  29840. };
  29841. /**
  29842. * Begin a new frame
  29843. */
  29844. Engine.prototype.beginFrame = function () {
  29845. this.onBeginFrameObservable.notifyObservers(this);
  29846. this._measureFps();
  29847. };
  29848. /**
  29849. * Enf the current frame
  29850. */
  29851. Engine.prototype.endFrame = function () {
  29852. // Force a flush in case we are using a bad OS.
  29853. if (this._badOS) {
  29854. this.flushFramebuffer();
  29855. }
  29856. // Submit frame to the vr device, if enabled
  29857. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29858. // TODO: We should only submit the frame if we read frameData successfully.
  29859. try {
  29860. this._vrDisplay.submitFrame();
  29861. }
  29862. catch (e) {
  29863. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].Warn("webVR submitFrame has had an unexpected failure: " + e);
  29864. }
  29865. }
  29866. this.onEndFrameObservable.notifyObservers(this);
  29867. };
  29868. /**
  29869. * Resize the view according to the canvas' size
  29870. */
  29871. Engine.prototype.resize = function () {
  29872. // We're not resizing the size of the canvas while in VR mode & presenting
  29873. if (!(this._vrDisplay && this._vrDisplay.isPresenting)) {
  29874. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  29875. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  29876. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  29877. }
  29878. };
  29879. /**
  29880. * Force a specific size of the canvas
  29881. * @param width defines the new canvas' width
  29882. * @param height defines the new canvas' height
  29883. */
  29884. Engine.prototype.setSize = function (width, height) {
  29885. if (!this._renderingCanvas) {
  29886. return;
  29887. }
  29888. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  29889. return;
  29890. }
  29891. this._renderingCanvas.width = width;
  29892. this._renderingCanvas.height = height;
  29893. for (var index = 0; index < this.scenes.length; index++) {
  29894. var scene = this.scenes[index];
  29895. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  29896. var cam = scene.cameras[camIndex];
  29897. cam._currentRenderId = 0;
  29898. }
  29899. }
  29900. if (this.onResizeObservable.hasObservers) {
  29901. this.onResizeObservable.notifyObservers(this);
  29902. }
  29903. };
  29904. // WebVR functions
  29905. /**
  29906. * Gets a boolean indicating if a webVR device was detected
  29907. * @returns true if a webVR device was detected
  29908. */
  29909. Engine.prototype.isVRDevicePresent = function () {
  29910. return !!this._vrDisplay;
  29911. };
  29912. /**
  29913. * Gets the current webVR device
  29914. * @returns the current webVR device (or null)
  29915. */
  29916. Engine.prototype.getVRDevice = function () {
  29917. return this._vrDisplay;
  29918. };
  29919. /**
  29920. * Initializes a webVR display and starts listening to display change events
  29921. * The onVRDisplayChangedObservable will be notified upon these changes
  29922. * @returns The onVRDisplayChangedObservable
  29923. */
  29924. Engine.prototype.initWebVR = function () {
  29925. this.initWebVRAsync();
  29926. return this.onVRDisplayChangedObservable;
  29927. };
  29928. /**
  29929. * Initializes a webVR display and starts listening to display change events
  29930. * The onVRDisplayChangedObservable will be notified upon these changes
  29931. * @returns A promise containing a VRDisplay and if vr is supported
  29932. */
  29933. Engine.prototype.initWebVRAsync = function () {
  29934. var _this = this;
  29935. var notifyObservers = function () {
  29936. var eventArgs = {
  29937. vrDisplay: _this._vrDisplay,
  29938. vrSupported: _this._vrSupported
  29939. };
  29940. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  29941. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  29942. };
  29943. if (!this._onVrDisplayConnect) {
  29944. this._onVrDisplayConnect = function (event) {
  29945. _this._vrDisplay = event.display;
  29946. notifyObservers();
  29947. };
  29948. this._onVrDisplayDisconnect = function () {
  29949. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  29950. _this._vrDisplay = undefined;
  29951. _this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(_this._bindedRenderFunction);
  29952. notifyObservers();
  29953. };
  29954. this._onVrDisplayPresentChange = function () {
  29955. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  29956. };
  29957. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  29958. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  29959. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  29960. }
  29961. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  29962. this._webVRInitPromise.then(notifyObservers);
  29963. return this._webVRInitPromise;
  29964. };
  29965. /**
  29966. * Call this function to switch to webVR mode
  29967. * Will do nothing if webVR is not supported or if there is no webVR device
  29968. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29969. */
  29970. Engine.prototype.enableVR = function () {
  29971. var _this = this;
  29972. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  29973. var onResolved = function () {
  29974. _this.onVRRequestPresentComplete.notifyObservers(true);
  29975. _this._onVRFullScreenTriggered();
  29976. };
  29977. var onRejected = function () {
  29978. _this.onVRRequestPresentComplete.notifyObservers(false);
  29979. };
  29980. this.onVRRequestPresentStart.notifyObservers(this);
  29981. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  29982. }
  29983. };
  29984. /**
  29985. * Call this function to leave webVR mode
  29986. * Will do nothing if webVR is not supported or if there is no webVR device
  29987. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29988. */
  29989. Engine.prototype.disableVR = function () {
  29990. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29991. this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
  29992. }
  29993. };
  29994. Engine.prototype._getVRDisplaysAsync = function () {
  29995. var _this = this;
  29996. return new Promise(function (res) {
  29997. if (navigator.getVRDisplays) {
  29998. navigator.getVRDisplays().then(function (devices) {
  29999. _this._vrSupported = true;
  30000. // note that devices may actually be an empty array. This is fine;
  30001. // we expect this._vrDisplay to be undefined in this case.
  30002. _this._vrDisplay = devices[0];
  30003. res({
  30004. vrDisplay: _this._vrDisplay,
  30005. vrSupported: _this._vrSupported
  30006. });
  30007. });
  30008. }
  30009. else {
  30010. _this._vrDisplay = undefined;
  30011. _this._vrSupported = false;
  30012. res({
  30013. vrDisplay: _this._vrDisplay,
  30014. vrSupported: _this._vrSupported
  30015. });
  30016. }
  30017. });
  30018. };
  30019. /**
  30020. * Binds the frame buffer to the specified texture.
  30021. * @param texture The texture to render to or null for the default canvas
  30022. * @param faceIndex The face of the texture to render to in case of cube texture
  30023. * @param requiredWidth The width of the target to render to
  30024. * @param requiredHeight The height of the target to render to
  30025. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30026. * @param depthStencilTexture The depth stencil texture to use to render
  30027. * @param lodLevel defines le lod level to bind to the frame buffer
  30028. */
  30029. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  30030. if (lodLevel === void 0) { lodLevel = 0; }
  30031. if (this._currentRenderTarget) {
  30032. this.unBindFramebuffer(this._currentRenderTarget);
  30033. }
  30034. this._currentRenderTarget = texture;
  30035. this.bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  30036. var gl = this._gl;
  30037. if (texture.isCube) {
  30038. if (faceIndex === undefined) {
  30039. faceIndex = 0;
  30040. }
  30041. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  30042. if (depthStencilTexture) {
  30043. if (depthStencilTexture._generateStencilBuffer) {
  30044. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  30045. }
  30046. else {
  30047. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  30048. }
  30049. }
  30050. }
  30051. if (this._cachedViewport && !forceFullscreenViewport) {
  30052. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  30053. }
  30054. else {
  30055. if (!requiredWidth) {
  30056. requiredWidth = texture.width;
  30057. if (lodLevel) {
  30058. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  30059. }
  30060. }
  30061. if (!requiredHeight) {
  30062. requiredHeight = texture.height;
  30063. if (lodLevel) {
  30064. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  30065. }
  30066. }
  30067. this._viewport(0, 0, requiredWidth, requiredHeight);
  30068. }
  30069. this.wipeCaches();
  30070. };
  30071. Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
  30072. if (this._currentFramebuffer !== framebuffer) {
  30073. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  30074. this._currentFramebuffer = framebuffer;
  30075. }
  30076. };
  30077. /**
  30078. * Unbind the current render target texture from the webGL context
  30079. * @param texture defines the render target texture to unbind
  30080. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30081. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30082. */
  30083. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  30084. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  30085. this._currentRenderTarget = null;
  30086. // If MSAA, we need to bitblt back to main texture
  30087. var gl = this._gl;
  30088. if (texture._MSAAFramebuffer) {
  30089. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  30090. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  30091. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  30092. }
  30093. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  30094. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  30095. gl.generateMipmap(gl.TEXTURE_2D);
  30096. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  30097. }
  30098. if (onBeforeUnbind) {
  30099. if (texture._MSAAFramebuffer) {
  30100. // Bind the correct framebuffer
  30101. this.bindUnboundFramebuffer(texture._framebuffer);
  30102. }
  30103. onBeforeUnbind();
  30104. }
  30105. this.bindUnboundFramebuffer(null);
  30106. };
  30107. /**
  30108. * Unbind a list of render target textures from the webGL context
  30109. * This is used only when drawBuffer extension or webGL2 are active
  30110. * @param textures defines the render target textures to unbind
  30111. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30112. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30113. */
  30114. Engine.prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  30115. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  30116. this._currentRenderTarget = null;
  30117. // If MSAA, we need to bitblt back to main texture
  30118. var gl = this._gl;
  30119. if (textures[0]._MSAAFramebuffer) {
  30120. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  30121. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  30122. var attachments = textures[0]._attachments;
  30123. if (!attachments) {
  30124. attachments = new Array(textures.length);
  30125. textures[0]._attachments = attachments;
  30126. }
  30127. for (var i = 0; i < textures.length; i++) {
  30128. var texture = textures[i];
  30129. for (var j = 0; j < attachments.length; j++) {
  30130. attachments[j] = gl.NONE;
  30131. }
  30132. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  30133. gl.readBuffer(attachments[i]);
  30134. gl.drawBuffers(attachments);
  30135. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  30136. }
  30137. for (var i = 0; i < attachments.length; i++) {
  30138. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  30139. }
  30140. gl.drawBuffers(attachments);
  30141. }
  30142. for (var i = 0; i < textures.length; i++) {
  30143. var texture = textures[i];
  30144. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  30145. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  30146. gl.generateMipmap(gl.TEXTURE_2D);
  30147. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  30148. }
  30149. }
  30150. if (onBeforeUnbind) {
  30151. if (textures[0]._MSAAFramebuffer) {
  30152. // Bind the correct framebuffer
  30153. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  30154. }
  30155. onBeforeUnbind();
  30156. }
  30157. this.bindUnboundFramebuffer(null);
  30158. };
  30159. /**
  30160. * Force the mipmap generation for the given render target texture
  30161. * @param texture defines the render target texture to use
  30162. */
  30163. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  30164. if (texture.generateMipMaps) {
  30165. var gl = this._gl;
  30166. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  30167. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  30168. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  30169. }
  30170. };
  30171. /**
  30172. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30173. */
  30174. Engine.prototype.flushFramebuffer = function () {
  30175. this._gl.flush();
  30176. };
  30177. /**
  30178. * Unbind the current render target and bind the default framebuffer
  30179. */
  30180. Engine.prototype.restoreDefaultFramebuffer = function () {
  30181. if (this._currentRenderTarget) {
  30182. this.unBindFramebuffer(this._currentRenderTarget);
  30183. }
  30184. else {
  30185. this.bindUnboundFramebuffer(null);
  30186. }
  30187. if (this._cachedViewport) {
  30188. this.setViewport(this._cachedViewport);
  30189. }
  30190. this.wipeCaches();
  30191. };
  30192. // UBOs
  30193. /**
  30194. * Create an uniform buffer
  30195. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30196. * @param elements defines the content of the uniform buffer
  30197. * @returns the webGL uniform buffer
  30198. */
  30199. Engine.prototype.createUniformBuffer = function (elements) {
  30200. var ubo = this._gl.createBuffer();
  30201. if (!ubo) {
  30202. throw new Error("Unable to create uniform buffer");
  30203. }
  30204. this.bindUniformBuffer(ubo);
  30205. if (elements instanceof Float32Array) {
  30206. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  30207. }
  30208. else {
  30209. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  30210. }
  30211. this.bindUniformBuffer(null);
  30212. ubo.references = 1;
  30213. return ubo;
  30214. };
  30215. /**
  30216. * Create a dynamic uniform buffer
  30217. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30218. * @param elements defines the content of the uniform buffer
  30219. * @returns the webGL uniform buffer
  30220. */
  30221. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  30222. var ubo = this._gl.createBuffer();
  30223. if (!ubo) {
  30224. throw new Error("Unable to create dynamic uniform buffer");
  30225. }
  30226. this.bindUniformBuffer(ubo);
  30227. if (elements instanceof Float32Array) {
  30228. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  30229. }
  30230. else {
  30231. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  30232. }
  30233. this.bindUniformBuffer(null);
  30234. ubo.references = 1;
  30235. return ubo;
  30236. };
  30237. /**
  30238. * Update an existing uniform buffer
  30239. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30240. * @param uniformBuffer defines the target uniform buffer
  30241. * @param elements defines the content to update
  30242. * @param offset defines the offset in the uniform buffer where update should start
  30243. * @param count defines the size of the data to update
  30244. */
  30245. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  30246. this.bindUniformBuffer(uniformBuffer);
  30247. if (offset === undefined) {
  30248. offset = 0;
  30249. }
  30250. if (count === undefined) {
  30251. if (elements instanceof Float32Array) {
  30252. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  30253. }
  30254. else {
  30255. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  30256. }
  30257. }
  30258. else {
  30259. if (elements instanceof Float32Array) {
  30260. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  30261. }
  30262. else {
  30263. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  30264. }
  30265. }
  30266. this.bindUniformBuffer(null);
  30267. };
  30268. // VBOs
  30269. Engine.prototype._resetVertexBufferBinding = function () {
  30270. this.bindArrayBuffer(null);
  30271. this._cachedVertexBuffers = null;
  30272. };
  30273. /**
  30274. * Creates a vertex buffer
  30275. * @param data the data for the vertex buffer
  30276. * @returns the new WebGL static buffer
  30277. */
  30278. Engine.prototype.createVertexBuffer = function (data) {
  30279. var vbo = this._gl.createBuffer();
  30280. if (!vbo) {
  30281. throw new Error("Unable to create vertex buffer");
  30282. }
  30283. this.bindArrayBuffer(vbo);
  30284. if (data instanceof Array) {
  30285. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  30286. }
  30287. else {
  30288. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  30289. }
  30290. this._resetVertexBufferBinding();
  30291. vbo.references = 1;
  30292. return vbo;
  30293. };
  30294. /**
  30295. * Creates a dynamic vertex buffer
  30296. * @param data the data for the dynamic vertex buffer
  30297. * @returns the new WebGL dynamic buffer
  30298. */
  30299. Engine.prototype.createDynamicVertexBuffer = function (data) {
  30300. var vbo = this._gl.createBuffer();
  30301. if (!vbo) {
  30302. throw new Error("Unable to create dynamic vertex buffer");
  30303. }
  30304. this.bindArrayBuffer(vbo);
  30305. if (data instanceof Array) {
  30306. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  30307. }
  30308. else {
  30309. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  30310. }
  30311. this._resetVertexBufferBinding();
  30312. vbo.references = 1;
  30313. return vbo;
  30314. };
  30315. /**
  30316. * Update a dynamic index buffer
  30317. * @param indexBuffer defines the target index buffer
  30318. * @param indices defines the data to update
  30319. * @param offset defines the offset in the target index buffer where update should start
  30320. */
  30321. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  30322. if (offset === void 0) { offset = 0; }
  30323. // Force cache update
  30324. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  30325. this.bindIndexBuffer(indexBuffer);
  30326. var arrayBuffer;
  30327. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  30328. arrayBuffer = indices;
  30329. }
  30330. else {
  30331. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  30332. }
  30333. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  30334. this._resetIndexBufferBinding();
  30335. };
  30336. /**
  30337. * Updates a dynamic vertex buffer.
  30338. * @param vertexBuffer the vertex buffer to update
  30339. * @param data the data used to update the vertex buffer
  30340. * @param byteOffset the byte offset of the data
  30341. * @param byteLength the byte length of the data
  30342. */
  30343. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  30344. this.bindArrayBuffer(vertexBuffer);
  30345. if (byteOffset === undefined) {
  30346. byteOffset = 0;
  30347. }
  30348. if (byteLength === undefined) {
  30349. if (data instanceof Array) {
  30350. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  30351. }
  30352. else {
  30353. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  30354. }
  30355. }
  30356. else {
  30357. if (data instanceof Array) {
  30358. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  30359. }
  30360. else {
  30361. if (data instanceof ArrayBuffer) {
  30362. data = new Uint8Array(data, byteOffset, byteLength);
  30363. }
  30364. else {
  30365. var offset = data.byteOffset + byteOffset;
  30366. if (offset || byteLength !== data.byteLength) {
  30367. data = new Uint8Array(data.buffer, offset, byteLength);
  30368. }
  30369. }
  30370. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30371. }
  30372. }
  30373. this._resetVertexBufferBinding();
  30374. };
  30375. Engine.prototype._resetIndexBufferBinding = function () {
  30376. this.bindIndexBuffer(null);
  30377. this._cachedIndexBuffer = null;
  30378. };
  30379. /**
  30380. * Creates a new index buffer
  30381. * @param indices defines the content of the index buffer
  30382. * @param updatable defines if the index buffer must be updatable
  30383. * @returns a new webGL buffer
  30384. */
  30385. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  30386. var vbo = this._gl.createBuffer();
  30387. if (!vbo) {
  30388. throw new Error("Unable to create index buffer");
  30389. }
  30390. this.bindIndexBuffer(vbo);
  30391. // Check for 32 bits indices
  30392. var arrayBuffer;
  30393. var need32Bits = false;
  30394. if (indices instanceof Uint16Array) {
  30395. arrayBuffer = indices;
  30396. }
  30397. else {
  30398. //check 32 bit support
  30399. if (this._caps.uintIndices) {
  30400. if (indices instanceof Uint32Array) {
  30401. arrayBuffer = indices;
  30402. need32Bits = true;
  30403. }
  30404. else {
  30405. //number[] or Int32Array, check if 32 bit is necessary
  30406. for (var index = 0; index < indices.length; index++) {
  30407. if (indices[index] > 65535) {
  30408. need32Bits = true;
  30409. break;
  30410. }
  30411. }
  30412. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  30413. }
  30414. }
  30415. else {
  30416. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  30417. arrayBuffer = new Uint16Array(indices);
  30418. }
  30419. }
  30420. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  30421. this._resetIndexBufferBinding();
  30422. vbo.references = 1;
  30423. vbo.is32Bits = need32Bits;
  30424. return vbo;
  30425. };
  30426. /**
  30427. * Bind a webGL buffer to the webGL context
  30428. * @param buffer defines the buffer to bind
  30429. */
  30430. Engine.prototype.bindArrayBuffer = function (buffer) {
  30431. if (!this._vaoRecordInProgress) {
  30432. this._unbindVertexArrayObject();
  30433. }
  30434. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  30435. };
  30436. /**
  30437. * Bind an uniform buffer to the current webGL context
  30438. * @param buffer defines the buffer to bind
  30439. */
  30440. Engine.prototype.bindUniformBuffer = function (buffer) {
  30441. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer);
  30442. };
  30443. /**
  30444. * Bind a buffer to the current webGL context at a given location
  30445. * @param buffer defines the buffer to bind
  30446. * @param location defines the index where to bind the buffer
  30447. */
  30448. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  30449. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer);
  30450. };
  30451. /**
  30452. * Bind a specific block at a given index in a specific shader program
  30453. * @param shaderProgram defines the shader program
  30454. * @param blockName defines the block name
  30455. * @param index defines the index where to bind the block
  30456. */
  30457. Engine.prototype.bindUniformBlock = function (shaderProgram, blockName, index) {
  30458. var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, blockName);
  30459. this._gl.uniformBlockBinding(shaderProgram, uniformLocation, index);
  30460. };
  30461. Engine.prototype.bindIndexBuffer = function (buffer) {
  30462. if (!this._vaoRecordInProgress) {
  30463. this._unbindVertexArrayObject();
  30464. }
  30465. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  30466. };
  30467. Engine.prototype.bindBuffer = function (buffer, target) {
  30468. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  30469. this._gl.bindBuffer(target, buffer);
  30470. this._currentBoundBuffer[target] = buffer;
  30471. }
  30472. };
  30473. /**
  30474. * update the bound buffer with the given data
  30475. * @param data defines the data to update
  30476. */
  30477. Engine.prototype.updateArrayBuffer = function (data) {
  30478. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30479. };
  30480. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  30481. var pointer = this._currentBufferPointers[indx];
  30482. var changed = false;
  30483. if (!pointer.active) {
  30484. changed = true;
  30485. pointer.active = true;
  30486. pointer.index = indx;
  30487. pointer.size = size;
  30488. pointer.type = type;
  30489. pointer.normalized = normalized;
  30490. pointer.stride = stride;
  30491. pointer.offset = offset;
  30492. pointer.buffer = buffer;
  30493. }
  30494. else {
  30495. if (pointer.buffer !== buffer) {
  30496. pointer.buffer = buffer;
  30497. changed = true;
  30498. }
  30499. if (pointer.size !== size) {
  30500. pointer.size = size;
  30501. changed = true;
  30502. }
  30503. if (pointer.type !== type) {
  30504. pointer.type = type;
  30505. changed = true;
  30506. }
  30507. if (pointer.normalized !== normalized) {
  30508. pointer.normalized = normalized;
  30509. changed = true;
  30510. }
  30511. if (pointer.stride !== stride) {
  30512. pointer.stride = stride;
  30513. changed = true;
  30514. }
  30515. if (pointer.offset !== offset) {
  30516. pointer.offset = offset;
  30517. changed = true;
  30518. }
  30519. }
  30520. if (changed || this._vaoRecordInProgress) {
  30521. this.bindArrayBuffer(buffer);
  30522. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  30523. }
  30524. };
  30525. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  30526. if (indexBuffer == null) {
  30527. return;
  30528. }
  30529. if (this._cachedIndexBuffer !== indexBuffer) {
  30530. this._cachedIndexBuffer = indexBuffer;
  30531. this.bindIndexBuffer(indexBuffer);
  30532. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  30533. }
  30534. };
  30535. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  30536. var attributes = effect.getAttributesNames();
  30537. if (!this._vaoRecordInProgress) {
  30538. this._unbindVertexArrayObject();
  30539. }
  30540. this.unbindAllAttributes();
  30541. for (var index = 0; index < attributes.length; index++) {
  30542. var order = effect.getAttributeLocation(index);
  30543. if (order >= 0) {
  30544. var vertexBuffer = vertexBuffers[attributes[index]];
  30545. if (!vertexBuffer) {
  30546. continue;
  30547. }
  30548. this._gl.enableVertexAttribArray(order);
  30549. if (!this._vaoRecordInProgress) {
  30550. this._vertexAttribArraysEnabled[order] = true;
  30551. }
  30552. var buffer = vertexBuffer.getBuffer();
  30553. if (buffer) {
  30554. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  30555. if (vertexBuffer.getIsInstanced()) {
  30556. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  30557. if (!this._vaoRecordInProgress) {
  30558. this._currentInstanceLocations.push(order);
  30559. this._currentInstanceBuffers.push(buffer);
  30560. }
  30561. }
  30562. }
  30563. }
  30564. }
  30565. };
  30566. /**
  30567. * Records a vertex array object
  30568. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30569. * @param vertexBuffers defines the list of vertex buffers to store
  30570. * @param indexBuffer defines the index buffer to store
  30571. * @param effect defines the effect to store
  30572. * @returns the new vertex array object
  30573. */
  30574. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  30575. var vao = this._gl.createVertexArray();
  30576. this._vaoRecordInProgress = true;
  30577. this._gl.bindVertexArray(vao);
  30578. this._mustWipeVertexAttributes = true;
  30579. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  30580. this.bindIndexBuffer(indexBuffer);
  30581. this._vaoRecordInProgress = false;
  30582. this._gl.bindVertexArray(null);
  30583. return vao;
  30584. };
  30585. /**
  30586. * Bind a specific vertex array object
  30587. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30588. * @param vertexArrayObject defines the vertex array object to bind
  30589. * @param indexBuffer defines the index buffer to bind
  30590. */
  30591. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  30592. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  30593. this._cachedVertexArrayObject = vertexArrayObject;
  30594. this._gl.bindVertexArray(vertexArrayObject);
  30595. this._cachedVertexBuffers = null;
  30596. this._cachedIndexBuffer = null;
  30597. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  30598. this._mustWipeVertexAttributes = true;
  30599. }
  30600. };
  30601. /**
  30602. * Bind webGl buffers directly to the webGL context
  30603. * @param vertexBuffer defines the vertex buffer to bind
  30604. * @param indexBuffer defines the index buffer to bind
  30605. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30606. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30607. * @param effect defines the effect associated with the vertex buffer
  30608. */
  30609. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  30610. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  30611. this._cachedVertexBuffers = vertexBuffer;
  30612. this._cachedEffectForVertexBuffers = effect;
  30613. var attributesCount = effect.getAttributesCount();
  30614. this._unbindVertexArrayObject();
  30615. this.unbindAllAttributes();
  30616. var offset = 0;
  30617. for (var index = 0; index < attributesCount; index++) {
  30618. if (index < vertexDeclaration.length) {
  30619. var order = effect.getAttributeLocation(index);
  30620. if (order >= 0) {
  30621. this._gl.enableVertexAttribArray(order);
  30622. this._vertexAttribArraysEnabled[order] = true;
  30623. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  30624. }
  30625. offset += vertexDeclaration[index] * 4;
  30626. }
  30627. }
  30628. }
  30629. this._bindIndexBufferWithCache(indexBuffer);
  30630. };
  30631. Engine.prototype._unbindVertexArrayObject = function () {
  30632. if (!this._cachedVertexArrayObject) {
  30633. return;
  30634. }
  30635. this._cachedVertexArrayObject = null;
  30636. this._gl.bindVertexArray(null);
  30637. };
  30638. /**
  30639. * Bind a list of vertex buffers to the webGL context
  30640. * @param vertexBuffers defines the list of vertex buffers to bind
  30641. * @param indexBuffer defines the index buffer to bind
  30642. * @param effect defines the effect associated with the vertex buffers
  30643. */
  30644. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  30645. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  30646. this._cachedVertexBuffers = vertexBuffers;
  30647. this._cachedEffectForVertexBuffers = effect;
  30648. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  30649. }
  30650. this._bindIndexBufferWithCache(indexBuffer);
  30651. };
  30652. /**
  30653. * Unbind all instance attributes
  30654. */
  30655. Engine.prototype.unbindInstanceAttributes = function () {
  30656. var boundBuffer;
  30657. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  30658. var instancesBuffer = this._currentInstanceBuffers[i];
  30659. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  30660. boundBuffer = instancesBuffer;
  30661. this.bindArrayBuffer(instancesBuffer);
  30662. }
  30663. var offsetLocation = this._currentInstanceLocations[i];
  30664. this._gl.vertexAttribDivisor(offsetLocation, 0);
  30665. }
  30666. this._currentInstanceBuffers.length = 0;
  30667. this._currentInstanceLocations.length = 0;
  30668. };
  30669. /**
  30670. * Release and free the memory of a vertex array object
  30671. * @param vao defines the vertex array object to delete
  30672. */
  30673. Engine.prototype.releaseVertexArrayObject = function (vao) {
  30674. this._gl.deleteVertexArray(vao);
  30675. };
  30676. /** @hidden */
  30677. Engine.prototype._releaseBuffer = function (buffer) {
  30678. buffer.references--;
  30679. if (buffer.references === 0) {
  30680. this._gl.deleteBuffer(buffer);
  30681. return true;
  30682. }
  30683. return false;
  30684. };
  30685. /**
  30686. * Creates a webGL buffer to use with instanciation
  30687. * @param capacity defines the size of the buffer
  30688. * @returns the webGL buffer
  30689. */
  30690. Engine.prototype.createInstancesBuffer = function (capacity) {
  30691. var buffer = this._gl.createBuffer();
  30692. if (!buffer) {
  30693. throw new Error("Unable to create instance buffer");
  30694. }
  30695. buffer.capacity = capacity;
  30696. this.bindArrayBuffer(buffer);
  30697. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  30698. return buffer;
  30699. };
  30700. /**
  30701. * Delete a webGL buffer used with instanciation
  30702. * @param buffer defines the webGL buffer to delete
  30703. */
  30704. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  30705. this._gl.deleteBuffer(buffer);
  30706. };
  30707. /**
  30708. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30709. * @param instancesBuffer defines the webGL buffer to update and bind
  30710. * @param data defines the data to store in the buffer
  30711. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30712. */
  30713. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  30714. this.bindArrayBuffer(instancesBuffer);
  30715. if (data) {
  30716. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  30717. }
  30718. if (offsetLocations[0].index !== undefined) {
  30719. var stride = 0;
  30720. for (var i = 0; i < offsetLocations.length; i++) {
  30721. var ai = offsetLocations[i];
  30722. stride += ai.attributeSize * 4;
  30723. }
  30724. for (var i = 0; i < offsetLocations.length; i++) {
  30725. var ai = offsetLocations[i];
  30726. if (!this._vertexAttribArraysEnabled[ai.index]) {
  30727. this._gl.enableVertexAttribArray(ai.index);
  30728. this._vertexAttribArraysEnabled[ai.index] = true;
  30729. }
  30730. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  30731. this._gl.vertexAttribDivisor(ai.index, 1);
  30732. this._currentInstanceLocations.push(ai.index);
  30733. this._currentInstanceBuffers.push(instancesBuffer);
  30734. }
  30735. }
  30736. else {
  30737. for (var index = 0; index < 4; index++) {
  30738. var offsetLocation = offsetLocations[index];
  30739. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  30740. this._gl.enableVertexAttribArray(offsetLocation);
  30741. this._vertexAttribArraysEnabled[offsetLocation] = true;
  30742. }
  30743. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  30744. this._gl.vertexAttribDivisor(offsetLocation, 1);
  30745. this._currentInstanceLocations.push(offsetLocation);
  30746. this._currentInstanceBuffers.push(instancesBuffer);
  30747. }
  30748. }
  30749. };
  30750. /**
  30751. * Apply all cached states (depth, culling, stencil and alpha)
  30752. */
  30753. Engine.prototype.applyStates = function () {
  30754. this._depthCullingState.apply(this._gl);
  30755. this._stencilState.apply(this._gl);
  30756. this._alphaState.apply(this._gl);
  30757. };
  30758. /**
  30759. * Send a draw order
  30760. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30761. * @param indexStart defines the starting index
  30762. * @param indexCount defines the number of index to draw
  30763. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30764. */
  30765. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  30766. this.drawElementsType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, indexStart, indexCount, instancesCount);
  30767. };
  30768. /**
  30769. * Draw a list of points
  30770. * @param verticesStart defines the index of first vertex to draw
  30771. * @param verticesCount defines the count of vertices to draw
  30772. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30773. */
  30774. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  30775. this.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode, verticesStart, verticesCount, instancesCount);
  30776. };
  30777. /**
  30778. * Draw a list of unindexed primitives
  30779. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30780. * @param verticesStart defines the index of first vertex to draw
  30781. * @param verticesCount defines the count of vertices to draw
  30782. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30783. */
  30784. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  30785. this.drawArraysType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  30786. };
  30787. /**
  30788. * Draw a list of indexed primitives
  30789. * @param fillMode defines the primitive to use
  30790. * @param indexStart defines the starting index
  30791. * @param indexCount defines the number of index to draw
  30792. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30793. */
  30794. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  30795. // Apply states
  30796. this.applyStates();
  30797. this._drawCalls.addCount(1, false);
  30798. // Render
  30799. var drawMode = this._drawMode(fillMode);
  30800. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  30801. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  30802. if (instancesCount) {
  30803. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  30804. }
  30805. else {
  30806. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  30807. }
  30808. };
  30809. /**
  30810. * Draw a list of unindexed primitives
  30811. * @param fillMode defines the primitive to use
  30812. * @param verticesStart defines the index of first vertex to draw
  30813. * @param verticesCount defines the count of vertices to draw
  30814. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30815. */
  30816. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  30817. // Apply states
  30818. this.applyStates();
  30819. this._drawCalls.addCount(1, false);
  30820. var drawMode = this._drawMode(fillMode);
  30821. if (instancesCount) {
  30822. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  30823. }
  30824. else {
  30825. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  30826. }
  30827. };
  30828. Engine.prototype._drawMode = function (fillMode) {
  30829. switch (fillMode) {
  30830. // Triangle views
  30831. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode:
  30832. return this._gl.TRIANGLES;
  30833. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode:
  30834. return this._gl.POINTS;
  30835. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode:
  30836. return this._gl.LINES;
  30837. // Draw modes
  30838. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointListDrawMode:
  30839. return this._gl.POINTS;
  30840. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineListDrawMode:
  30841. return this._gl.LINES;
  30842. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineLoopDrawMode:
  30843. return this._gl.LINE_LOOP;
  30844. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineStripDrawMode:
  30845. return this._gl.LINE_STRIP;
  30846. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleStripDrawMode:
  30847. return this._gl.TRIANGLE_STRIP;
  30848. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFanDrawMode:
  30849. return this._gl.TRIANGLE_FAN;
  30850. default:
  30851. return this._gl.TRIANGLES;
  30852. }
  30853. };
  30854. // Shaders
  30855. /** @hidden */
  30856. Engine.prototype._releaseEffect = function (effect) {
  30857. if (this._compiledEffects[effect._key]) {
  30858. delete this._compiledEffects[effect._key];
  30859. this._deleteProgram(effect.getProgram());
  30860. }
  30861. };
  30862. /** @hidden */
  30863. Engine.prototype._deleteProgram = function (program) {
  30864. if (program) {
  30865. program.__SPECTOR_rebuildProgram = null;
  30866. if (program.transformFeedback) {
  30867. this.deleteTransformFeedback(program.transformFeedback);
  30868. program.transformFeedback = null;
  30869. }
  30870. this._gl.deleteProgram(program);
  30871. }
  30872. };
  30873. /**
  30874. * Create a new effect (used to store vertex/fragment shaders)
  30875. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30876. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30877. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30878. * @param samplers defines an array of string used to represent textures
  30879. * @param defines defines the string containing the defines to use to compile the shaders
  30880. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30881. * @param onCompiled defines a function to call when the effect creation is successful
  30882. * @param onError defines a function to call when the effect creation has failed
  30883. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30884. * @returns the new Effect
  30885. */
  30886. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  30887. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  30888. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  30889. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  30890. if (this._compiledEffects[name]) {
  30891. var compiledEffect = this._compiledEffects[name];
  30892. if (onCompiled && compiledEffect.isReady()) {
  30893. onCompiled(compiledEffect);
  30894. }
  30895. return compiledEffect;
  30896. }
  30897. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  30898. effect._key = name;
  30899. this._compiledEffects[name] = effect;
  30900. return effect;
  30901. };
  30902. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  30903. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  30904. };
  30905. Engine.prototype._compileRawShader = function (source, type) {
  30906. var gl = this._gl;
  30907. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  30908. if (!shader) {
  30909. throw new Error("Something went wrong while compile the shader.");
  30910. }
  30911. gl.shaderSource(shader, source);
  30912. gl.compileShader(shader);
  30913. return shader;
  30914. };
  30915. /**
  30916. * Directly creates a webGL program
  30917. * @param vertexCode defines the vertex shader code to use
  30918. * @param fragmentCode defines the fragment shader code to use
  30919. * @param context defines the webGL context to use (if not set, the current one will be used)
  30920. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30921. * @returns the new webGL program
  30922. */
  30923. Engine.prototype.createRawShaderProgram = function (vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  30924. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30925. context = context || this._gl;
  30926. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  30927. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  30928. return this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30929. };
  30930. /**
  30931. * Creates a webGL program
  30932. * @param vertexCode defines the vertex shader code to use
  30933. * @param fragmentCode defines the fragment shader code to use
  30934. * @param defines defines the string containing the defines to use to compile the shaders
  30935. * @param context defines the webGL context to use (if not set, the current one will be used)
  30936. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30937. * @returns the new webGL program
  30938. */
  30939. Engine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  30940. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30941. context = context || this._gl;
  30942. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  30943. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  30944. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  30945. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  30946. var program = this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30947. this.onAfterShaderCompilationObservable.notifyObservers(this);
  30948. return program;
  30949. };
  30950. Engine.prototype._createShaderProgram = function (vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  30951. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30952. var shaderProgram = context.createProgram();
  30953. if (!shaderProgram) {
  30954. throw new Error("Unable to create program");
  30955. }
  30956. if (this._caps.parallelShaderCompile) {
  30957. shaderProgram.isParallelCompiled = true;
  30958. }
  30959. context.attachShader(shaderProgram, vertexShader);
  30960. context.attachShader(shaderProgram, fragmentShader);
  30961. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30962. var transformFeedback = this.createTransformFeedback();
  30963. this.bindTransformFeedback(transformFeedback);
  30964. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  30965. shaderProgram.transformFeedback = transformFeedback;
  30966. }
  30967. context.linkProgram(shaderProgram);
  30968. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30969. this.bindTransformFeedback(null);
  30970. }
  30971. shaderProgram.context = context;
  30972. shaderProgram.vertexShader = vertexShader;
  30973. shaderProgram.fragmentShader = fragmentShader;
  30974. if (!shaderProgram.isParallelCompiled) {
  30975. this._finalizeProgram(shaderProgram);
  30976. }
  30977. return shaderProgram;
  30978. };
  30979. Engine.prototype._finalizeProgram = function (shaderProgram) {
  30980. var context = shaderProgram.context;
  30981. var vertexShader = shaderProgram.vertexShader;
  30982. var fragmentShader = shaderProgram.fragmentShader;
  30983. var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
  30984. if (!linked) { // Get more info
  30985. // Vertex
  30986. if (!this._gl.getShaderParameter(vertexShader, this._gl.COMPILE_STATUS)) {
  30987. var log = this._gl.getShaderInfoLog(vertexShader);
  30988. if (log) {
  30989. throw new Error(log);
  30990. }
  30991. }
  30992. // Fragment
  30993. if (!this._gl.getShaderParameter(fragmentShader, this._gl.COMPILE_STATUS)) {
  30994. var log = this._gl.getShaderInfoLog(fragmentShader);
  30995. if (log) {
  30996. throw new Error(log);
  30997. }
  30998. }
  30999. var error = context.getProgramInfoLog(shaderProgram);
  31000. if (error) {
  31001. throw new Error(error);
  31002. }
  31003. }
  31004. if (this.validateShaderPrograms) {
  31005. context.validateProgram(shaderProgram);
  31006. var validated = context.getProgramParameter(shaderProgram, context.VALIDATE_STATUS);
  31007. if (!validated) {
  31008. var error = context.getProgramInfoLog(shaderProgram);
  31009. if (error) {
  31010. throw new Error(error);
  31011. }
  31012. }
  31013. }
  31014. context.deleteShader(vertexShader);
  31015. context.deleteShader(fragmentShader);
  31016. shaderProgram.context = undefined;
  31017. shaderProgram.vertexShader = undefined;
  31018. shaderProgram.fragmentShader = undefined;
  31019. if (shaderProgram.onCompiled) {
  31020. shaderProgram.onCompiled();
  31021. shaderProgram.onCompiled = undefined;
  31022. }
  31023. };
  31024. /** @hidden */
  31025. Engine.prototype._isProgramCompiled = function (shaderProgram) {
  31026. if (!shaderProgram.isParallelCompiled) {
  31027. return true;
  31028. }
  31029. if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  31030. this._finalizeProgram(shaderProgram);
  31031. return true;
  31032. }
  31033. return false;
  31034. };
  31035. /** @hidden */
  31036. Engine.prototype._executeWhenProgramIsCompiled = function (shaderProgram, action) {
  31037. if (!shaderProgram.isParallelCompiled) {
  31038. action();
  31039. return;
  31040. }
  31041. shaderProgram.onCompiled = action;
  31042. };
  31043. /**
  31044. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31045. * @param shaderProgram defines the webGL program to use
  31046. * @param uniformsNames defines the list of uniform names
  31047. * @returns an array of webGL uniform locations
  31048. */
  31049. Engine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  31050. var results = new Array();
  31051. for (var index = 0; index < uniformsNames.length; index++) {
  31052. results.push(this._gl.getUniformLocation(shaderProgram, uniformsNames[index]));
  31053. }
  31054. return results;
  31055. };
  31056. /**
  31057. * Gets the lsit of active attributes for a given webGL program
  31058. * @param shaderProgram defines the webGL program to use
  31059. * @param attributesNames defines the list of attribute names to get
  31060. * @returns an array of indices indicating the offset of each attribute
  31061. */
  31062. Engine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  31063. var results = [];
  31064. for (var index = 0; index < attributesNames.length; index++) {
  31065. try {
  31066. results.push(this._gl.getAttribLocation(shaderProgram, attributesNames[index]));
  31067. }
  31068. catch (e) {
  31069. results.push(-1);
  31070. }
  31071. }
  31072. return results;
  31073. };
  31074. /**
  31075. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31076. * @param effect defines the effect to activate
  31077. */
  31078. Engine.prototype.enableEffect = function (effect) {
  31079. if (!effect || effect === this._currentEffect) {
  31080. return;
  31081. }
  31082. // Use program
  31083. this.bindSamplers(effect);
  31084. this._currentEffect = effect;
  31085. if (effect.onBind) {
  31086. effect.onBind(effect);
  31087. }
  31088. if (effect._onBindObservable) {
  31089. effect._onBindObservable.notifyObservers(effect);
  31090. }
  31091. };
  31092. /**
  31093. * Set the value of an uniform to an array of int32
  31094. * @param uniform defines the webGL uniform location where to store the value
  31095. * @param array defines the array of int32 to store
  31096. */
  31097. Engine.prototype.setIntArray = function (uniform, array) {
  31098. if (!uniform) {
  31099. return;
  31100. }
  31101. this._gl.uniform1iv(uniform, array);
  31102. };
  31103. /**
  31104. * Set the value of an uniform to an array of int32 (stored as vec2)
  31105. * @param uniform defines the webGL uniform location where to store the value
  31106. * @param array defines the array of int32 to store
  31107. */
  31108. Engine.prototype.setIntArray2 = function (uniform, array) {
  31109. if (!uniform || array.length % 2 !== 0) {
  31110. return;
  31111. }
  31112. this._gl.uniform2iv(uniform, array);
  31113. };
  31114. /**
  31115. * Set the value of an uniform to an array of int32 (stored as vec3)
  31116. * @param uniform defines the webGL uniform location where to store the value
  31117. * @param array defines the array of int32 to store
  31118. */
  31119. Engine.prototype.setIntArray3 = function (uniform, array) {
  31120. if (!uniform || array.length % 3 !== 0) {
  31121. return;
  31122. }
  31123. this._gl.uniform3iv(uniform, array);
  31124. };
  31125. /**
  31126. * Set the value of an uniform to an array of int32 (stored as vec4)
  31127. * @param uniform defines the webGL uniform location where to store the value
  31128. * @param array defines the array of int32 to store
  31129. */
  31130. Engine.prototype.setIntArray4 = function (uniform, array) {
  31131. if (!uniform || array.length % 4 !== 0) {
  31132. return;
  31133. }
  31134. this._gl.uniform4iv(uniform, array);
  31135. };
  31136. /**
  31137. * Set the value of an uniform to an array of float32
  31138. * @param uniform defines the webGL uniform location where to store the value
  31139. * @param array defines the array of float32 to store
  31140. */
  31141. Engine.prototype.setFloatArray = function (uniform, array) {
  31142. if (!uniform) {
  31143. return;
  31144. }
  31145. this._gl.uniform1fv(uniform, array);
  31146. };
  31147. /**
  31148. * Set the value of an uniform to an array of float32 (stored as vec2)
  31149. * @param uniform defines the webGL uniform location where to store the value
  31150. * @param array defines the array of float32 to store
  31151. */
  31152. Engine.prototype.setFloatArray2 = function (uniform, array) {
  31153. if (!uniform || array.length % 2 !== 0) {
  31154. return;
  31155. }
  31156. this._gl.uniform2fv(uniform, array);
  31157. };
  31158. /**
  31159. * Set the value of an uniform to an array of float32 (stored as vec3)
  31160. * @param uniform defines the webGL uniform location where to store the value
  31161. * @param array defines the array of float32 to store
  31162. */
  31163. Engine.prototype.setFloatArray3 = function (uniform, array) {
  31164. if (!uniform || array.length % 3 !== 0) {
  31165. return;
  31166. }
  31167. this._gl.uniform3fv(uniform, array);
  31168. };
  31169. /**
  31170. * Set the value of an uniform to an array of float32 (stored as vec4)
  31171. * @param uniform defines the webGL uniform location where to store the value
  31172. * @param array defines the array of float32 to store
  31173. */
  31174. Engine.prototype.setFloatArray4 = function (uniform, array) {
  31175. if (!uniform || array.length % 4 !== 0) {
  31176. return;
  31177. }
  31178. this._gl.uniform4fv(uniform, array);
  31179. };
  31180. /**
  31181. * Set the value of an uniform to an array of number
  31182. * @param uniform defines the webGL uniform location where to store the value
  31183. * @param array defines the array of number to store
  31184. */
  31185. Engine.prototype.setArray = function (uniform, array) {
  31186. if (!uniform) {
  31187. return;
  31188. }
  31189. this._gl.uniform1fv(uniform, array);
  31190. };
  31191. /**
  31192. * Set the value of an uniform to an array of number (stored as vec2)
  31193. * @param uniform defines the webGL uniform location where to store the value
  31194. * @param array defines the array of number to store
  31195. */
  31196. Engine.prototype.setArray2 = function (uniform, array) {
  31197. if (!uniform || array.length % 2 !== 0) {
  31198. return;
  31199. }
  31200. this._gl.uniform2fv(uniform, array);
  31201. };
  31202. /**
  31203. * Set the value of an uniform to an array of number (stored as vec3)
  31204. * @param uniform defines the webGL uniform location where to store the value
  31205. * @param array defines the array of number to store
  31206. */
  31207. Engine.prototype.setArray3 = function (uniform, array) {
  31208. if (!uniform || array.length % 3 !== 0) {
  31209. return;
  31210. }
  31211. this._gl.uniform3fv(uniform, array);
  31212. };
  31213. /**
  31214. * Set the value of an uniform to an array of number (stored as vec4)
  31215. * @param uniform defines the webGL uniform location where to store the value
  31216. * @param array defines the array of number to store
  31217. */
  31218. Engine.prototype.setArray4 = function (uniform, array) {
  31219. if (!uniform || array.length % 4 !== 0) {
  31220. return;
  31221. }
  31222. this._gl.uniform4fv(uniform, array);
  31223. };
  31224. /**
  31225. * Set the value of an uniform to an array of float32 (stored as matrices)
  31226. * @param uniform defines the webGL uniform location where to store the value
  31227. * @param matrices defines the array of float32 to store
  31228. */
  31229. Engine.prototype.setMatrices = function (uniform, matrices) {
  31230. if (!uniform) {
  31231. return;
  31232. }
  31233. this._gl.uniformMatrix4fv(uniform, false, matrices);
  31234. };
  31235. /**
  31236. * Set the value of an uniform to a matrix
  31237. * @param uniform defines the webGL uniform location where to store the value
  31238. * @param matrix defines the matrix to store
  31239. */
  31240. Engine.prototype.setMatrix = function (uniform, matrix) {
  31241. if (!uniform) {
  31242. return;
  31243. }
  31244. this._gl.uniformMatrix4fv(uniform, false, matrix.toArray());
  31245. };
  31246. /**
  31247. * Set the value of an uniform to a matrix (3x3)
  31248. * @param uniform defines the webGL uniform location where to store the value
  31249. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31250. */
  31251. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  31252. if (!uniform) {
  31253. return;
  31254. }
  31255. this._gl.uniformMatrix3fv(uniform, false, matrix);
  31256. };
  31257. /**
  31258. * Set the value of an uniform to a matrix (2x2)
  31259. * @param uniform defines the webGL uniform location where to store the value
  31260. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31261. */
  31262. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  31263. if (!uniform) {
  31264. return;
  31265. }
  31266. this._gl.uniformMatrix2fv(uniform, false, matrix);
  31267. };
  31268. /**
  31269. * Set the value of an uniform to a number (int)
  31270. * @param uniform defines the webGL uniform location where to store the value
  31271. * @param value defines the int number to store
  31272. */
  31273. Engine.prototype.setInt = function (uniform, value) {
  31274. if (!uniform) {
  31275. return;
  31276. }
  31277. this._gl.uniform1i(uniform, value);
  31278. };
  31279. /**
  31280. * Set the value of an uniform to a number (float)
  31281. * @param uniform defines the webGL uniform location where to store the value
  31282. * @param value defines the float number to store
  31283. */
  31284. Engine.prototype.setFloat = function (uniform, value) {
  31285. if (!uniform) {
  31286. return;
  31287. }
  31288. this._gl.uniform1f(uniform, value);
  31289. };
  31290. /**
  31291. * Set the value of an uniform to a vec2
  31292. * @param uniform defines the webGL uniform location where to store the value
  31293. * @param x defines the 1st component of the value
  31294. * @param y defines the 2nd component of the value
  31295. */
  31296. Engine.prototype.setFloat2 = function (uniform, x, y) {
  31297. if (!uniform) {
  31298. return;
  31299. }
  31300. this._gl.uniform2f(uniform, x, y);
  31301. };
  31302. /**
  31303. * Set the value of an uniform to a vec3
  31304. * @param uniform defines the webGL uniform location where to store the value
  31305. * @param x defines the 1st component of the value
  31306. * @param y defines the 2nd component of the value
  31307. * @param z defines the 3rd component of the value
  31308. */
  31309. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  31310. if (!uniform) {
  31311. return;
  31312. }
  31313. this._gl.uniform3f(uniform, x, y, z);
  31314. };
  31315. /**
  31316. * Set the value of an uniform to a boolean
  31317. * @param uniform defines the webGL uniform location where to store the value
  31318. * @param bool defines the boolean to store
  31319. */
  31320. Engine.prototype.setBool = function (uniform, bool) {
  31321. if (!uniform) {
  31322. return;
  31323. }
  31324. this._gl.uniform1i(uniform, bool);
  31325. };
  31326. /**
  31327. * Set the value of an uniform to a vec4
  31328. * @param uniform defines the webGL uniform location where to store the value
  31329. * @param x defines the 1st component of the value
  31330. * @param y defines the 2nd component of the value
  31331. * @param z defines the 3rd component of the value
  31332. * @param w defines the 4th component of the value
  31333. */
  31334. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  31335. if (!uniform) {
  31336. return;
  31337. }
  31338. this._gl.uniform4f(uniform, x, y, z, w);
  31339. };
  31340. /**
  31341. * Set the value of an uniform to a Color3
  31342. * @param uniform defines the webGL uniform location where to store the value
  31343. * @param color3 defines the color to store
  31344. */
  31345. Engine.prototype.setColor3 = function (uniform, color3) {
  31346. if (!uniform) {
  31347. return;
  31348. }
  31349. this._gl.uniform3f(uniform, color3.r, color3.g, color3.b);
  31350. };
  31351. /**
  31352. * Set the value of an uniform to a Color3 and an alpha value
  31353. * @param uniform defines the webGL uniform location where to store the value
  31354. * @param color3 defines the color to store
  31355. * @param alpha defines the alpha component to store
  31356. */
  31357. Engine.prototype.setColor4 = function (uniform, color3, alpha) {
  31358. if (!uniform) {
  31359. return;
  31360. }
  31361. this._gl.uniform4f(uniform, color3.r, color3.g, color3.b, alpha);
  31362. };
  31363. /**
  31364. * Sets a Color4 on a uniform variable
  31365. * @param uniform defines the uniform location
  31366. * @param color4 defines the value to be set
  31367. */
  31368. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  31369. if (!uniform) {
  31370. return;
  31371. }
  31372. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  31373. };
  31374. // States
  31375. /**
  31376. * Set various states to the webGL context
  31377. * @param culling defines backface culling state
  31378. * @param zOffset defines the value to apply to zOffset (0 by default)
  31379. * @param force defines if states must be applied even if cache is up to date
  31380. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31381. */
  31382. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  31383. if (zOffset === void 0) { zOffset = 0; }
  31384. if (reverseSide === void 0) { reverseSide = false; }
  31385. // Culling
  31386. if (this._depthCullingState.cull !== culling || force) {
  31387. this._depthCullingState.cull = culling;
  31388. }
  31389. // Cull face
  31390. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  31391. if (this._depthCullingState.cullFace !== cullFace || force) {
  31392. this._depthCullingState.cullFace = cullFace;
  31393. }
  31394. // Z offset
  31395. this.setZOffset(zOffset);
  31396. // Front face
  31397. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  31398. if (this._depthCullingState.frontFace !== frontFace || force) {
  31399. this._depthCullingState.frontFace = frontFace;
  31400. }
  31401. };
  31402. /**
  31403. * Set the z offset to apply to current rendering
  31404. * @param value defines the offset to apply
  31405. */
  31406. Engine.prototype.setZOffset = function (value) {
  31407. this._depthCullingState.zOffset = value;
  31408. };
  31409. /**
  31410. * Gets the current value of the zOffset
  31411. * @returns the current zOffset state
  31412. */
  31413. Engine.prototype.getZOffset = function () {
  31414. return this._depthCullingState.zOffset;
  31415. };
  31416. /**
  31417. * Enable or disable depth buffering
  31418. * @param enable defines the state to set
  31419. */
  31420. Engine.prototype.setDepthBuffer = function (enable) {
  31421. this._depthCullingState.depthTest = enable;
  31422. };
  31423. /**
  31424. * Gets a boolean indicating if depth writing is enabled
  31425. * @returns the current depth writing state
  31426. */
  31427. Engine.prototype.getDepthWrite = function () {
  31428. return this._depthCullingState.depthMask;
  31429. };
  31430. /**
  31431. * Enable or disable depth writing
  31432. * @param enable defines the state to set
  31433. */
  31434. Engine.prototype.setDepthWrite = function (enable) {
  31435. this._depthCullingState.depthMask = enable;
  31436. };
  31437. /**
  31438. * Enable or disable color writing
  31439. * @param enable defines the state to set
  31440. */
  31441. Engine.prototype.setColorWrite = function (enable) {
  31442. this._gl.colorMask(enable, enable, enable, enable);
  31443. this._colorWrite = enable;
  31444. };
  31445. /**
  31446. * Gets a boolean indicating if color writing is enabled
  31447. * @returns the current color writing state
  31448. */
  31449. Engine.prototype.getColorWrite = function () {
  31450. return this._colorWrite;
  31451. };
  31452. /**
  31453. * Sets alpha constants used by some alpha blending modes
  31454. * @param r defines the red component
  31455. * @param g defines the green component
  31456. * @param b defines the blue component
  31457. * @param a defines the alpha component
  31458. */
  31459. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  31460. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  31461. };
  31462. /**
  31463. * Sets the current alpha mode
  31464. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31465. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31466. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31467. */
  31468. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  31469. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  31470. if (this._alphaMode === mode) {
  31471. return;
  31472. }
  31473. switch (mode) {
  31474. case Engine.ALPHA_DISABLE:
  31475. this._alphaState.alphaBlend = false;
  31476. break;
  31477. case Engine.ALPHA_PREMULTIPLIED:
  31478. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  31479. this._alphaState.alphaBlend = true;
  31480. break;
  31481. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  31482. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  31483. this._alphaState.alphaBlend = true;
  31484. break;
  31485. case Engine.ALPHA_COMBINE:
  31486. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  31487. this._alphaState.alphaBlend = true;
  31488. break;
  31489. case Engine.ALPHA_ONEONE:
  31490. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  31491. this._alphaState.alphaBlend = true;
  31492. break;
  31493. case Engine.ALPHA_ADD:
  31494. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  31495. this._alphaState.alphaBlend = true;
  31496. break;
  31497. case Engine.ALPHA_SUBTRACT:
  31498. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  31499. this._alphaState.alphaBlend = true;
  31500. break;
  31501. case Engine.ALPHA_MULTIPLY:
  31502. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  31503. this._alphaState.alphaBlend = true;
  31504. break;
  31505. case Engine.ALPHA_MAXIMIZED:
  31506. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  31507. this._alphaState.alphaBlend = true;
  31508. break;
  31509. case Engine.ALPHA_INTERPOLATE:
  31510. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  31511. this._alphaState.alphaBlend = true;
  31512. break;
  31513. case Engine.ALPHA_SCREENMODE:
  31514. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  31515. this._alphaState.alphaBlend = true;
  31516. break;
  31517. }
  31518. if (!noDepthWriteChange) {
  31519. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  31520. }
  31521. this._alphaMode = mode;
  31522. };
  31523. /**
  31524. * Gets the current alpha mode
  31525. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31526. * @returns the current alpha mode
  31527. */
  31528. Engine.prototype.getAlphaMode = function () {
  31529. return this._alphaMode;
  31530. };
  31531. // Textures
  31532. /**
  31533. * Clears the list of texture accessible through engine.
  31534. * This can help preventing texture load conflict due to name collision.
  31535. */
  31536. Engine.prototype.clearInternalTexturesCache = function () {
  31537. this._internalTexturesCache = [];
  31538. };
  31539. /**
  31540. * Force the entire cache to be cleared
  31541. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31542. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31543. */
  31544. Engine.prototype.wipeCaches = function (bruteForce) {
  31545. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  31546. return;
  31547. }
  31548. this._currentEffect = null;
  31549. this._viewportCached.x = 0;
  31550. this._viewportCached.y = 0;
  31551. this._viewportCached.z = 0;
  31552. this._viewportCached.w = 0;
  31553. if (bruteForce) {
  31554. this.resetTextureCache();
  31555. this._currentProgram = null;
  31556. this._stencilState.reset();
  31557. this._depthCullingState.reset();
  31558. this.setDepthFunctionToLessOrEqual();
  31559. this._alphaState.reset();
  31560. this._unpackFlipYCached = null;
  31561. }
  31562. this._resetVertexBufferBinding();
  31563. this._cachedIndexBuffer = null;
  31564. this._cachedEffectForVertexBuffers = null;
  31565. this._unbindVertexArrayObject();
  31566. this.bindIndexBuffer(null);
  31567. };
  31568. /**
  31569. * Set the compressed texture format to use, based on the formats you have, and the formats
  31570. * supported by the hardware / browser.
  31571. *
  31572. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31573. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31574. * to API arguments needed to compressed textures. This puts the burden on the container
  31575. * generator to house the arcane code for determining these for current & future formats.
  31576. *
  31577. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31578. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31579. *
  31580. * Note: The result of this call is not taken into account when a texture is base64.
  31581. *
  31582. * @param formatsAvailable defines the list of those format families you have created
  31583. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31584. *
  31585. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31586. * @returns The extension selected.
  31587. */
  31588. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  31589. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  31590. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  31591. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  31592. return this._textureFormatInUse = this._texturesSupported[i];
  31593. }
  31594. }
  31595. }
  31596. // actively set format to nothing, to allow this to be called more than once
  31597. // and possibly fail the 2nd time
  31598. this._textureFormatInUse = null;
  31599. return null;
  31600. };
  31601. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  31602. var gl = this._gl;
  31603. var magFilter = gl.NEAREST;
  31604. var minFilter = gl.NEAREST;
  31605. switch (samplingMode) {
  31606. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  31607. magFilter = gl.LINEAR;
  31608. if (generateMipMaps) {
  31609. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  31610. }
  31611. else {
  31612. minFilter = gl.LINEAR;
  31613. }
  31614. break;
  31615. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  31616. magFilter = gl.LINEAR;
  31617. if (generateMipMaps) {
  31618. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  31619. }
  31620. else {
  31621. minFilter = gl.LINEAR;
  31622. }
  31623. break;
  31624. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  31625. magFilter = gl.NEAREST;
  31626. if (generateMipMaps) {
  31627. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  31628. }
  31629. else {
  31630. minFilter = gl.NEAREST;
  31631. }
  31632. break;
  31633. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  31634. magFilter = gl.NEAREST;
  31635. if (generateMipMaps) {
  31636. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  31637. }
  31638. else {
  31639. minFilter = gl.NEAREST;
  31640. }
  31641. break;
  31642. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  31643. magFilter = gl.NEAREST;
  31644. if (generateMipMaps) {
  31645. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  31646. }
  31647. else {
  31648. minFilter = gl.LINEAR;
  31649. }
  31650. break;
  31651. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  31652. magFilter = gl.NEAREST;
  31653. if (generateMipMaps) {
  31654. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  31655. }
  31656. else {
  31657. minFilter = gl.LINEAR;
  31658. }
  31659. break;
  31660. case Engine.TEXTURE_NEAREST_LINEAR:
  31661. magFilter = gl.NEAREST;
  31662. minFilter = gl.LINEAR;
  31663. break;
  31664. case Engine.TEXTURE_NEAREST_NEAREST:
  31665. magFilter = gl.NEAREST;
  31666. minFilter = gl.NEAREST;
  31667. break;
  31668. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  31669. magFilter = gl.LINEAR;
  31670. if (generateMipMaps) {
  31671. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  31672. }
  31673. else {
  31674. minFilter = gl.NEAREST;
  31675. }
  31676. break;
  31677. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  31678. magFilter = gl.LINEAR;
  31679. if (generateMipMaps) {
  31680. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  31681. }
  31682. else {
  31683. minFilter = gl.NEAREST;
  31684. }
  31685. break;
  31686. case Engine.TEXTURE_LINEAR_LINEAR:
  31687. magFilter = gl.LINEAR;
  31688. minFilter = gl.LINEAR;
  31689. break;
  31690. case Engine.TEXTURE_LINEAR_NEAREST:
  31691. magFilter = gl.LINEAR;
  31692. minFilter = gl.NEAREST;
  31693. break;
  31694. }
  31695. return {
  31696. min: minFilter,
  31697. mag: magFilter
  31698. };
  31699. };
  31700. Engine.prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  31701. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  31702. var img;
  31703. var onload = function () {
  31704. loadedImages[index] = img;
  31705. loadedImages._internalCount++;
  31706. if (scene) {
  31707. scene._removePendingData(img);
  31708. }
  31709. if (loadedImages._internalCount === 6) {
  31710. onfinish(loadedImages);
  31711. }
  31712. };
  31713. var onerror = function (message, exception) {
  31714. if (scene) {
  31715. scene._removePendingData(img);
  31716. }
  31717. if (onErrorCallBack) {
  31718. onErrorCallBack(message, exception);
  31719. }
  31720. };
  31721. img = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  31722. if (scene) {
  31723. scene._addPendingData(img);
  31724. }
  31725. };
  31726. Engine.prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  31727. if (onError === void 0) { onError = null; }
  31728. var loadedImages = [];
  31729. loadedImages._internalCount = 0;
  31730. for (var index = 0; index < 6; index++) {
  31731. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  31732. }
  31733. };
  31734. /** @hidden */
  31735. Engine.prototype._createTexture = function () {
  31736. var texture = this._gl.createTexture();
  31737. if (!texture) {
  31738. throw new Error("Unable to create texture");
  31739. }
  31740. return texture;
  31741. };
  31742. /**
  31743. * Usually called from Texture.ts.
  31744. * Passed information to create a WebGLTexture
  31745. * @param urlArg defines a value which contains one of the following:
  31746. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31747. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31748. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31749. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31750. * @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)
  31751. * @param scene needed for loading to the correct scene
  31752. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31753. * @param onLoad optional callback to be called upon successful completion
  31754. * @param onError optional callback to be called upon failure
  31755. * @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
  31756. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31757. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31758. * @param forcedExtension defines the extension to use to pick the right loader
  31759. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31760. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31761. */
  31762. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  31763. var _this = this;
  31764. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  31765. if (onLoad === void 0) { onLoad = null; }
  31766. if (onError === void 0) { onError = null; }
  31767. if (buffer === void 0) { buffer = null; }
  31768. if (fallback === void 0) { fallback = null; }
  31769. if (format === void 0) { format = null; }
  31770. if (forcedExtension === void 0) { forcedExtension = null; }
  31771. if (excludeLoaders === void 0) { excludeLoaders = []; }
  31772. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  31773. var fromData = url.substr(0, 5) === "data:";
  31774. var fromBlob = url.substr(0, 5) === "blob:";
  31775. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  31776. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_URL);
  31777. // establish the file extension, if possible
  31778. var lastDot = url.lastIndexOf('.');
  31779. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  31780. var loader = null;
  31781. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  31782. var availableLoader = _a[_i];
  31783. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  31784. loader = availableLoader;
  31785. break;
  31786. }
  31787. }
  31788. if (loader) {
  31789. url = loader.transformUrl(url, this._textureFormatInUse);
  31790. }
  31791. if (scene) {
  31792. scene._addPendingData(texture);
  31793. }
  31794. texture.url = url;
  31795. texture.generateMipMaps = !noMipmap;
  31796. texture.samplingMode = samplingMode;
  31797. texture.invertY = invertY;
  31798. if (!this._doNotHandleContextLost) {
  31799. // Keep a link to the buffer only if we plan to handle context lost
  31800. texture._buffer = buffer;
  31801. }
  31802. var onLoadObserver = null;
  31803. if (onLoad && !fallback) {
  31804. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  31805. }
  31806. if (!fallback) {
  31807. this._internalTexturesCache.push(texture);
  31808. }
  31809. var onInternalError = function (message, exception) {
  31810. if (scene) {
  31811. scene._removePendingData(texture);
  31812. }
  31813. var customFallback = false;
  31814. if (loader) {
  31815. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  31816. if (fallbackUrl) {
  31817. // Add Back
  31818. customFallback = true;
  31819. excludeLoaders.push(loader);
  31820. _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");
  31821. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture, undefined, undefined, excludeLoaders);
  31822. }
  31823. }
  31824. if (!customFallback) {
  31825. if (onLoadObserver) {
  31826. texture.onLoadedObservable.remove(onLoadObserver);
  31827. }
  31828. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].UseFallbackTexture) {
  31829. _this.createTexture(_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].fallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture);
  31830. }
  31831. }
  31832. if (onError) {
  31833. onError(message || "Unknown error", exception);
  31834. }
  31835. };
  31836. // processing for non-image formats
  31837. if (loader) {
  31838. var callback = function (data) {
  31839. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  31840. if (loadFailed) {
  31841. onInternalError("TextureLoader failed to load data");
  31842. }
  31843. else {
  31844. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  31845. done();
  31846. return false;
  31847. }, samplingMode);
  31848. }
  31849. });
  31850. };
  31851. if (!buffer) {
  31852. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  31853. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  31854. });
  31855. }
  31856. else {
  31857. callback(buffer);
  31858. }
  31859. }
  31860. else {
  31861. var onload = function (img) {
  31862. if (fromBlob && !_this._doNotHandleContextLost) {
  31863. // We need to store the image if we need to rebuild the texture
  31864. // in case of a webgl context lost
  31865. texture._buffer = img;
  31866. }
  31867. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  31868. var gl = _this._gl;
  31869. var isPot = (img.width === potWidth && img.height === potHeight);
  31870. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  31871. if (isPot) {
  31872. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  31873. return false;
  31874. }
  31875. var maxTextureSize = _this._caps.maxTextureSize;
  31876. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  31877. _this._prepareWorkingCanvas();
  31878. if (!_this._workingCanvas || !_this._workingContext) {
  31879. return false;
  31880. }
  31881. _this._workingCanvas.width = potWidth;
  31882. _this._workingCanvas.height = potHeight;
  31883. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  31884. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  31885. texture.width = potWidth;
  31886. texture.height = potHeight;
  31887. return false;
  31888. }
  31889. else {
  31890. // Using shaders when possible to rescale because canvas.drawImage is lossy
  31891. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_TEMP);
  31892. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  31893. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  31894. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  31895. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  31896. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31897. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31898. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  31899. _this._releaseTexture(source_1);
  31900. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31901. continuationCallback();
  31902. });
  31903. }
  31904. return true;
  31905. }, samplingMode);
  31906. };
  31907. if (!fromData || isBase64) {
  31908. if (buffer instanceof HTMLImageElement) {
  31909. onload(buffer);
  31910. }
  31911. else {
  31912. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  31913. }
  31914. }
  31915. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  31916. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  31917. }
  31918. else {
  31919. onload(buffer);
  31920. }
  31921. }
  31922. return texture;
  31923. };
  31924. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  31925. var _this = this;
  31926. var rtt = this.createRenderTargetTexture({
  31927. width: destination.width,
  31928. height: destination.height,
  31929. }, {
  31930. generateMipMaps: false,
  31931. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  31932. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  31933. generateDepthBuffer: false,
  31934. generateStencilBuffer: false
  31935. });
  31936. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  31937. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  31938. }
  31939. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  31940. _this._rescalePostProcess.onApply = function (effect) {
  31941. effect._bindTexture("textureSampler", source);
  31942. };
  31943. var hostingScene = scene;
  31944. if (!hostingScene) {
  31945. hostingScene = _this.scenes[_this.scenes.length - 1];
  31946. }
  31947. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  31948. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  31949. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  31950. _this.unBindFramebuffer(rtt);
  31951. _this._releaseTexture(rtt);
  31952. if (onComplete) {
  31953. onComplete();
  31954. }
  31955. });
  31956. };
  31957. /**
  31958. * Update a raw texture
  31959. * @param texture defines the texture to update
  31960. * @param data defines the data to store in the texture
  31961. * @param format defines the format of the data
  31962. * @param invertY defines if data must be stored with Y axis inverted
  31963. * @param compression defines the compression used (null by default)
  31964. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31965. */
  31966. Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  31967. if (compression === void 0) { compression = null; }
  31968. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31969. if (!texture) {
  31970. return;
  31971. }
  31972. // babylon's internalSizedFomat but gl's texImage2D internalFormat
  31973. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  31974. // babylon's internalFormat but gl's texImage2D format
  31975. var internalFormat = this._getInternalFormat(format);
  31976. var textureType = this._getWebGLTextureType(type);
  31977. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31978. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31979. if (!this._doNotHandleContextLost) {
  31980. texture._bufferView = data;
  31981. texture.format = format;
  31982. texture.type = type;
  31983. texture.invertY = invertY;
  31984. texture._compression = compression;
  31985. }
  31986. if (texture.width % 4 !== 0) {
  31987. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  31988. }
  31989. if (compression && data) {
  31990. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  31991. }
  31992. else {
  31993. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  31994. }
  31995. if (texture.generateMipMaps) {
  31996. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31997. }
  31998. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31999. // this.resetTextureCache();
  32000. texture.isReady = true;
  32001. };
  32002. /**
  32003. * Creates a raw texture
  32004. * @param data defines the data to store in the texture
  32005. * @param width defines the width of the texture
  32006. * @param height defines the height of the texture
  32007. * @param format defines the format of the data
  32008. * @param generateMipMaps defines if the engine should generate the mip levels
  32009. * @param invertY defines if data must be stored with Y axis inverted
  32010. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32011. * @param compression defines the compression used (null by default)
  32012. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32013. * @returns the raw texture inside an InternalTexture
  32014. */
  32015. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  32016. if (compression === void 0) { compression = null; }
  32017. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32018. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_RAW);
  32019. texture.baseWidth = width;
  32020. texture.baseHeight = height;
  32021. texture.width = width;
  32022. texture.height = height;
  32023. texture.format = format;
  32024. texture.generateMipMaps = generateMipMaps;
  32025. texture.samplingMode = samplingMode;
  32026. texture.invertY = invertY;
  32027. texture._compression = compression;
  32028. texture.type = type;
  32029. if (!this._doNotHandleContextLost) {
  32030. texture._bufferView = data;
  32031. }
  32032. this.updateRawTexture(texture, data, format, invertY, compression, type);
  32033. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  32034. // Filters
  32035. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32036. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  32037. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32038. if (generateMipMaps) {
  32039. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32040. }
  32041. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32042. this._internalTexturesCache.push(texture);
  32043. return texture;
  32044. };
  32045. /** @hidden */
  32046. Engine.prototype._unpackFlipY = function (value) {
  32047. if (this._unpackFlipYCached !== value) {
  32048. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  32049. if (this.enableUnpackFlipYCached) {
  32050. this._unpackFlipYCached = value;
  32051. }
  32052. }
  32053. };
  32054. /** @hidden */
  32055. Engine.prototype._getUnpackAlignement = function () {
  32056. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  32057. };
  32058. /**
  32059. * Creates a dynamic texture
  32060. * @param width defines the width of the texture
  32061. * @param height defines the height of the texture
  32062. * @param generateMipMaps defines if the engine should generate the mip levels
  32063. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32064. * @returns the dynamic texture inside an InternalTexture
  32065. */
  32066. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  32067. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_DYNAMIC);
  32068. texture.baseWidth = width;
  32069. texture.baseHeight = height;
  32070. if (generateMipMaps) {
  32071. width = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  32072. height = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  32073. }
  32074. // this.resetTextureCache();
  32075. texture.width = width;
  32076. texture.height = height;
  32077. texture.isReady = false;
  32078. texture.generateMipMaps = generateMipMaps;
  32079. texture.samplingMode = samplingMode;
  32080. this.updateTextureSamplingMode(samplingMode, texture);
  32081. this._internalTexturesCache.push(texture);
  32082. return texture;
  32083. };
  32084. /**
  32085. * Update the sampling mode of a given texture
  32086. * @param samplingMode defines the required sampling mode
  32087. * @param texture defines the texture to update
  32088. */
  32089. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  32090. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  32091. if (texture.isCube) {
  32092. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  32093. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32094. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32095. }
  32096. else if (texture.is3D) {
  32097. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  32098. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32099. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32100. }
  32101. else {
  32102. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  32103. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32104. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32105. }
  32106. texture.samplingMode = samplingMode;
  32107. };
  32108. /**
  32109. * Update the content of a dynamic texture
  32110. * @param texture defines the texture to update
  32111. * @param canvas defines the canvas containing the source
  32112. * @param invertY defines if data must be stored with Y axis inverted
  32113. * @param premulAlpha defines if alpha is stored as premultiplied
  32114. * @param format defines the format of the data
  32115. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32116. */
  32117. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  32118. if (premulAlpha === void 0) { premulAlpha = false; }
  32119. if (forceBindTexture === void 0) { forceBindTexture = false; }
  32120. if (!texture) {
  32121. return;
  32122. }
  32123. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  32124. this._unpackFlipY(invertY);
  32125. if (premulAlpha) {
  32126. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  32127. }
  32128. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  32129. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  32130. if (texture.generateMipMaps) {
  32131. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32132. }
  32133. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32134. if (premulAlpha) {
  32135. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  32136. }
  32137. texture.isReady = true;
  32138. };
  32139. /**
  32140. * Update a video texture
  32141. * @param texture defines the texture to update
  32142. * @param video defines the video element to use
  32143. * @param invertY defines if data must be stored with Y axis inverted
  32144. */
  32145. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  32146. if (!texture || texture._isDisabled) {
  32147. return;
  32148. }
  32149. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  32150. this._unpackFlipY(!invertY); // Video are upside down by default
  32151. try {
  32152. // Testing video texture support
  32153. if (this._videoTextureSupported === undefined) {
  32154. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  32155. if (this._gl.getError() !== 0) {
  32156. this._videoTextureSupported = false;
  32157. }
  32158. else {
  32159. this._videoTextureSupported = true;
  32160. }
  32161. }
  32162. // Copy video through the current working canvas if video texture is not supported
  32163. if (!this._videoTextureSupported) {
  32164. if (!texture._workingCanvas) {
  32165. texture._workingCanvas = document.createElement("canvas");
  32166. var context = texture._workingCanvas.getContext("2d");
  32167. if (!context) {
  32168. throw new Error("Unable to get 2d context");
  32169. }
  32170. texture._workingContext = context;
  32171. texture._workingCanvas.width = texture.width;
  32172. texture._workingCanvas.height = texture.height;
  32173. }
  32174. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  32175. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  32176. }
  32177. else {
  32178. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  32179. }
  32180. if (texture.generateMipMaps) {
  32181. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32182. }
  32183. if (!wasPreviouslyBound) {
  32184. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32185. }
  32186. // this.resetTextureCache();
  32187. texture.isReady = true;
  32188. }
  32189. catch (ex) {
  32190. // Something unexpected
  32191. // Let's disable the texture
  32192. texture._isDisabled = true;
  32193. }
  32194. };
  32195. /**
  32196. * Updates a depth texture Comparison Mode and Function.
  32197. * If the comparison Function is equal to 0, the mode will be set to none.
  32198. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32199. * @param texture The texture to set the comparison function for
  32200. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32201. */
  32202. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  32203. if (this.webGLVersion === 1) {
  32204. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Error("WebGL 1 does not support texture comparison.");
  32205. return;
  32206. }
  32207. var gl = this._gl;
  32208. if (texture.isCube) {
  32209. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  32210. if (comparisonFunction === 0) {
  32211. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  32212. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  32213. }
  32214. else {
  32215. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  32216. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  32217. }
  32218. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32219. }
  32220. else {
  32221. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  32222. if (comparisonFunction === 0) {
  32223. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  32224. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  32225. }
  32226. else {
  32227. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  32228. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  32229. }
  32230. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32231. }
  32232. texture._comparisonFunction = comparisonFunction;
  32233. };
  32234. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  32235. var width = size.width || size;
  32236. var height = size.height || size;
  32237. internalTexture.baseWidth = width;
  32238. internalTexture.baseHeight = height;
  32239. internalTexture.width = width;
  32240. internalTexture.height = height;
  32241. internalTexture.isReady = true;
  32242. internalTexture.samples = 1;
  32243. internalTexture.generateMipMaps = false;
  32244. internalTexture._generateDepthBuffer = true;
  32245. internalTexture._generateStencilBuffer = generateStencil;
  32246. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32247. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32248. internalTexture._comparisonFunction = comparisonFunction;
  32249. var gl = this._gl;
  32250. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32251. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  32252. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  32253. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  32254. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32255. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32256. if (comparisonFunction === 0) {
  32257. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  32258. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  32259. }
  32260. else {
  32261. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  32262. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  32263. }
  32264. };
  32265. /**
  32266. * Creates a depth stencil texture.
  32267. * This is only available in WebGL 2 or with the depth texture extension available.
  32268. * @param size The size of face edge in the texture.
  32269. * @param options The options defining the texture.
  32270. * @returns The texture
  32271. */
  32272. Engine.prototype.createDepthStencilTexture = function (size, options) {
  32273. if (options.isCube) {
  32274. var width = size.width || size;
  32275. return this._createDepthStencilCubeTexture(width, options);
  32276. }
  32277. else {
  32278. return this._createDepthStencilTexture(size, options);
  32279. }
  32280. };
  32281. /**
  32282. * Creates a depth stencil texture.
  32283. * This is only available in WebGL 2 or with the depth texture extension available.
  32284. * @param size The size of face edge in the texture.
  32285. * @param options The options defining the texture.
  32286. * @returns The texture
  32287. */
  32288. Engine.prototype._createDepthStencilTexture = function (size, options) {
  32289. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  32290. if (!this._caps.depthTextureExtension) {
  32291. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  32292. return internalTexture;
  32293. }
  32294. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  32295. var gl = this._gl;
  32296. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  32297. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  32298. if (this.webGLVersion > 1) {
  32299. if (internalOptions.generateStencil) {
  32300. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  32301. }
  32302. else {
  32303. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  32304. }
  32305. }
  32306. else {
  32307. if (internalOptions.generateStencil) {
  32308. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  32309. }
  32310. else {
  32311. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  32312. }
  32313. }
  32314. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32315. return internalTexture;
  32316. };
  32317. /**
  32318. * Creates a depth stencil cube texture.
  32319. * This is only available in WebGL 2.
  32320. * @param size The size of face edge in the cube texture.
  32321. * @param options The options defining the cube texture.
  32322. * @returns The cube texture
  32323. */
  32324. Engine.prototype._createDepthStencilCubeTexture = function (size, options) {
  32325. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_UNKNOWN);
  32326. internalTexture.isCube = true;
  32327. if (this.webGLVersion === 1) {
  32328. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  32329. return internalTexture;
  32330. }
  32331. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  32332. var gl = this._gl;
  32333. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  32334. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  32335. // Create the depth/stencil buffer
  32336. for (var face = 0; face < 6; face++) {
  32337. if (internalOptions.generateStencil) {
  32338. 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);
  32339. }
  32340. else {
  32341. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  32342. }
  32343. }
  32344. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32345. return internalTexture;
  32346. };
  32347. /**
  32348. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32349. * @param renderTarget The render target to set the frame buffer for
  32350. */
  32351. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  32352. // Create the framebuffer
  32353. var internalTexture = renderTarget.getInternalTexture();
  32354. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  32355. return;
  32356. }
  32357. var gl = this._gl;
  32358. var depthStencilTexture = renderTarget.depthStencilTexture;
  32359. this.bindUnboundFramebuffer(internalTexture._framebuffer);
  32360. if (depthStencilTexture.isCube) {
  32361. if (depthStencilTexture._generateStencilBuffer) {
  32362. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  32363. }
  32364. else {
  32365. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  32366. }
  32367. }
  32368. else {
  32369. if (depthStencilTexture._generateStencilBuffer) {
  32370. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  32371. }
  32372. else {
  32373. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  32374. }
  32375. }
  32376. this.bindUnboundFramebuffer(null);
  32377. };
  32378. /**
  32379. * Creates a new render target texture
  32380. * @param size defines the size of the texture
  32381. * @param options defines the options used to create the texture
  32382. * @returns a new render target texture stored in an InternalTexture
  32383. */
  32384. Engine.prototype.createRenderTargetTexture = function (size, options) {
  32385. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_16__["RenderTargetCreationOptions"]();
  32386. if (options !== undefined && typeof options === "object") {
  32387. fullOptions.generateMipMaps = options.generateMipMaps;
  32388. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  32389. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  32390. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  32391. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  32392. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  32393. }
  32394. else {
  32395. fullOptions.generateMipMaps = options;
  32396. fullOptions.generateDepthBuffer = true;
  32397. fullOptions.generateStencilBuffer = false;
  32398. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32399. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  32400. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  32401. }
  32402. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32403. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32404. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32405. }
  32406. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32407. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32408. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32409. }
  32410. var gl = this._gl;
  32411. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_RENDERTARGET);
  32412. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  32413. var width = size.width || size;
  32414. var height = size.height || size;
  32415. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  32416. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32417. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32418. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  32419. }
  32420. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32421. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32422. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32423. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32424. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  32425. // Create the framebuffer
  32426. var currentFrameBuffer = this._currentFramebuffer;
  32427. var framebuffer = gl.createFramebuffer();
  32428. this.bindUnboundFramebuffer(framebuffer);
  32429. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  32430. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  32431. if (fullOptions.generateMipMaps) {
  32432. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32433. }
  32434. // Unbind
  32435. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32436. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32437. this.bindUnboundFramebuffer(currentFrameBuffer);
  32438. texture._framebuffer = framebuffer;
  32439. texture.baseWidth = width;
  32440. texture.baseHeight = height;
  32441. texture.width = width;
  32442. texture.height = height;
  32443. texture.isReady = true;
  32444. texture.samples = 1;
  32445. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  32446. texture.samplingMode = fullOptions.samplingMode;
  32447. texture.type = fullOptions.type;
  32448. texture.format = fullOptions.format;
  32449. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  32450. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  32451. // this.resetTextureCache();
  32452. this._internalTexturesCache.push(texture);
  32453. return texture;
  32454. };
  32455. /**
  32456. * Create a multi render target texture
  32457. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  32458. * @param size defines the size of the texture
  32459. * @param options defines the creation options
  32460. * @returns the cube texture as an InternalTexture
  32461. */
  32462. Engine.prototype.createMultipleRenderTarget = function (size, options) {
  32463. var generateMipMaps = false;
  32464. var generateDepthBuffer = true;
  32465. var generateStencilBuffer = false;
  32466. var generateDepthTexture = false;
  32467. var textureCount = 1;
  32468. var defaultType = Engine.TEXTURETYPE_UNSIGNED_INT;
  32469. var defaultSamplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  32470. var types = new Array();
  32471. var samplingModes = new Array();
  32472. if (options !== undefined) {
  32473. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  32474. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  32475. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  32476. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  32477. textureCount = options.textureCount || 1;
  32478. if (options.types) {
  32479. types = options.types;
  32480. }
  32481. if (options.samplingModes) {
  32482. samplingModes = options.samplingModes;
  32483. }
  32484. }
  32485. var gl = this._gl;
  32486. // Create the framebuffer
  32487. var framebuffer = gl.createFramebuffer();
  32488. this.bindUnboundFramebuffer(framebuffer);
  32489. var width = size.width || size;
  32490. var height = size.height || size;
  32491. var textures = [];
  32492. var attachments = [];
  32493. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  32494. for (var i = 0; i < textureCount; i++) {
  32495. var samplingMode = samplingModes[i] || defaultSamplingMode;
  32496. var type = types[i] || defaultType;
  32497. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32498. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32499. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32500. }
  32501. else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32502. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32503. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32504. }
  32505. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32506. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32507. type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32508. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  32509. }
  32510. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  32511. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  32512. textures.push(texture);
  32513. attachments.push(attachment);
  32514. gl.activeTexture(gl["TEXTURE" + i]);
  32515. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  32516. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32517. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32518. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32519. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32520. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  32521. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  32522. if (generateMipMaps) {
  32523. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  32524. }
  32525. // Unbind
  32526. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32527. texture._framebuffer = framebuffer;
  32528. texture._depthStencilBuffer = depthStencilBuffer;
  32529. texture.baseWidth = width;
  32530. texture.baseHeight = height;
  32531. texture.width = width;
  32532. texture.height = height;
  32533. texture.isReady = true;
  32534. texture.samples = 1;
  32535. texture.generateMipMaps = generateMipMaps;
  32536. texture.samplingMode = samplingMode;
  32537. texture.type = type;
  32538. texture._generateDepthBuffer = generateDepthBuffer;
  32539. texture._generateStencilBuffer = generateStencilBuffer;
  32540. texture._attachments = attachments;
  32541. this._internalTexturesCache.push(texture);
  32542. }
  32543. if (generateDepthTexture && this._caps.depthTextureExtension) {
  32544. // Depth texture
  32545. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  32546. gl.activeTexture(gl.TEXTURE0);
  32547. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  32548. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32549. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32550. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32551. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32552. 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);
  32553. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  32554. depthTexture._framebuffer = framebuffer;
  32555. depthTexture.baseWidth = width;
  32556. depthTexture.baseHeight = height;
  32557. depthTexture.width = width;
  32558. depthTexture.height = height;
  32559. depthTexture.isReady = true;
  32560. depthTexture.samples = 1;
  32561. depthTexture.generateMipMaps = generateMipMaps;
  32562. depthTexture.samplingMode = gl.NEAREST;
  32563. depthTexture._generateDepthBuffer = generateDepthBuffer;
  32564. depthTexture._generateStencilBuffer = generateStencilBuffer;
  32565. textures.push(depthTexture);
  32566. this._internalTexturesCache.push(depthTexture);
  32567. }
  32568. gl.drawBuffers(attachments);
  32569. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32570. this.bindUnboundFramebuffer(null);
  32571. this.resetTextureCache();
  32572. return textures;
  32573. };
  32574. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  32575. if (samples === void 0) { samples = 1; }
  32576. var depthStencilBuffer = null;
  32577. var gl = this._gl;
  32578. // Create the depth/stencil buffer
  32579. if (generateStencilBuffer) {
  32580. depthStencilBuffer = gl.createRenderbuffer();
  32581. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  32582. if (samples > 1) {
  32583. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  32584. }
  32585. else {
  32586. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  32587. }
  32588. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  32589. }
  32590. else if (generateDepthBuffer) {
  32591. depthStencilBuffer = gl.createRenderbuffer();
  32592. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  32593. if (samples > 1) {
  32594. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  32595. }
  32596. else {
  32597. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  32598. }
  32599. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  32600. }
  32601. return depthStencilBuffer;
  32602. };
  32603. /**
  32604. * Updates the sample count of a render target texture
  32605. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32606. * @param texture defines the texture to update
  32607. * @param samples defines the sample count to set
  32608. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32609. */
  32610. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  32611. if (this.webGLVersion < 2 || !texture) {
  32612. return 1;
  32613. }
  32614. if (texture.samples === samples) {
  32615. return samples;
  32616. }
  32617. var gl = this._gl;
  32618. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  32619. // Dispose previous render buffers
  32620. if (texture._depthStencilBuffer) {
  32621. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  32622. texture._depthStencilBuffer = null;
  32623. }
  32624. if (texture._MSAAFramebuffer) {
  32625. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  32626. texture._MSAAFramebuffer = null;
  32627. }
  32628. if (texture._MSAARenderBuffer) {
  32629. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  32630. texture._MSAARenderBuffer = null;
  32631. }
  32632. if (samples > 1) {
  32633. var framebuffer = gl.createFramebuffer();
  32634. if (!framebuffer) {
  32635. throw new Error("Unable to create multi sampled framebuffer");
  32636. }
  32637. texture._MSAAFramebuffer = framebuffer;
  32638. this.bindUnboundFramebuffer(texture._MSAAFramebuffer);
  32639. var colorRenderbuffer = gl.createRenderbuffer();
  32640. if (!colorRenderbuffer) {
  32641. throw new Error("Unable to create multi sampled framebuffer");
  32642. }
  32643. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  32644. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  32645. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  32646. texture._MSAARenderBuffer = colorRenderbuffer;
  32647. }
  32648. else {
  32649. this.bindUnboundFramebuffer(texture._framebuffer);
  32650. }
  32651. texture.samples = samples;
  32652. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  32653. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32654. this.bindUnboundFramebuffer(null);
  32655. return samples;
  32656. };
  32657. /**
  32658. * Update the sample count for a given multiple render target texture
  32659. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32660. * @param textures defines the textures to update
  32661. * @param samples defines the sample count to set
  32662. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32663. */
  32664. Engine.prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  32665. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  32666. return 1;
  32667. }
  32668. if (textures[0].samples === samples) {
  32669. return samples;
  32670. }
  32671. var gl = this._gl;
  32672. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  32673. // Dispose previous render buffers
  32674. if (textures[0]._depthStencilBuffer) {
  32675. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  32676. textures[0]._depthStencilBuffer = null;
  32677. }
  32678. if (textures[0]._MSAAFramebuffer) {
  32679. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  32680. textures[0]._MSAAFramebuffer = null;
  32681. }
  32682. for (var i = 0; i < textures.length; i++) {
  32683. if (textures[i]._MSAARenderBuffer) {
  32684. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  32685. textures[i]._MSAARenderBuffer = null;
  32686. }
  32687. }
  32688. if (samples > 1) {
  32689. var framebuffer = gl.createFramebuffer();
  32690. if (!framebuffer) {
  32691. throw new Error("Unable to create multi sampled framebuffer");
  32692. }
  32693. this.bindUnboundFramebuffer(framebuffer);
  32694. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  32695. var attachments = [];
  32696. for (var i = 0; i < textures.length; i++) {
  32697. var texture = textures[i];
  32698. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  32699. var colorRenderbuffer = gl.createRenderbuffer();
  32700. if (!colorRenderbuffer) {
  32701. throw new Error("Unable to create multi sampled framebuffer");
  32702. }
  32703. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  32704. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  32705. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  32706. texture._MSAAFramebuffer = framebuffer;
  32707. texture._MSAARenderBuffer = colorRenderbuffer;
  32708. texture.samples = samples;
  32709. texture._depthStencilBuffer = depthStencilBuffer;
  32710. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32711. attachments.push(attachment);
  32712. }
  32713. gl.drawBuffers(attachments);
  32714. }
  32715. else {
  32716. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  32717. }
  32718. this.bindUnboundFramebuffer(null);
  32719. return samples;
  32720. };
  32721. /** @hidden */
  32722. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  32723. if (faceIndex === void 0) { faceIndex = 0; }
  32724. if (lod === void 0) { lod = 0; }
  32725. var gl = this._gl;
  32726. var target = gl.TEXTURE_2D;
  32727. if (texture.isCube) {
  32728. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32729. }
  32730. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  32731. };
  32732. /** @hidden */
  32733. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  32734. if (faceIndex === void 0) { faceIndex = 0; }
  32735. if (lod === void 0) { lod = 0; }
  32736. var gl = this._gl;
  32737. var textureType = this._getWebGLTextureType(texture.type);
  32738. var format = this._getInternalFormat(texture.format);
  32739. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  32740. this._unpackFlipY(texture.invertY);
  32741. var target = gl.TEXTURE_2D;
  32742. if (texture.isCube) {
  32743. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32744. }
  32745. var lodMaxWidth = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.width));
  32746. var lodMaxHeight = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.height));
  32747. var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  32748. var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  32749. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  32750. };
  32751. /** @hidden */
  32752. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  32753. if (faceIndex === void 0) { faceIndex = 0; }
  32754. if (lod === void 0) { lod = 0; }
  32755. var gl = this._gl;
  32756. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32757. this._bindTextureDirectly(bindTarget, texture, true);
  32758. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  32759. this._bindTextureDirectly(bindTarget, null, true);
  32760. };
  32761. /** @hidden */
  32762. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  32763. if (faceIndex === void 0) { faceIndex = 0; }
  32764. if (lod === void 0) { lod = 0; }
  32765. var gl = this._gl;
  32766. var textureType = this._getWebGLTextureType(texture.type);
  32767. var format = this._getInternalFormat(texture.format);
  32768. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  32769. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  32770. this._bindTextureDirectly(bindTarget, texture, true);
  32771. this._unpackFlipY(texture.invertY);
  32772. var target = gl.TEXTURE_2D;
  32773. if (texture.isCube) {
  32774. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  32775. }
  32776. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  32777. this._bindTextureDirectly(bindTarget, null, true);
  32778. };
  32779. /**
  32780. * Creates a new render target cube texture
  32781. * @param size defines the size of the texture
  32782. * @param options defines the options used to create the texture
  32783. * @returns a new render target cube texture stored in an InternalTexture
  32784. */
  32785. Engine.prototype.createRenderTargetCubeTexture = function (size, options) {
  32786. 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);
  32787. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  32788. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  32789. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  32790. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32791. }
  32792. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  32793. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  32794. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32795. }
  32796. var gl = this._gl;
  32797. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_RENDERTARGET);
  32798. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32799. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  32800. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  32801. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  32802. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  32803. }
  32804. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  32805. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  32806. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32807. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32808. for (var face = 0; face < 6; face++) {
  32809. 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);
  32810. }
  32811. // Create the framebuffer
  32812. var framebuffer = gl.createFramebuffer();
  32813. this.bindUnboundFramebuffer(framebuffer);
  32814. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  32815. // MipMaps
  32816. if (fullOptions.generateMipMaps) {
  32817. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32818. }
  32819. // Unbind
  32820. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32821. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  32822. this.bindUnboundFramebuffer(null);
  32823. texture._framebuffer = framebuffer;
  32824. texture.width = size;
  32825. texture.height = size;
  32826. texture.isReady = true;
  32827. texture.isCube = true;
  32828. texture.samples = 1;
  32829. texture.generateMipMaps = fullOptions.generateMipMaps;
  32830. texture.samplingMode = fullOptions.samplingMode;
  32831. texture.type = fullOptions.type;
  32832. texture.format = fullOptions.format;
  32833. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  32834. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  32835. this._internalTexturesCache.push(texture);
  32836. return texture;
  32837. };
  32838. /**
  32839. * Creates a cube texture
  32840. * @param rootUrl defines the url where the files to load is located
  32841. * @param scene defines the current scene
  32842. * @param files defines the list of files to load (1 per face)
  32843. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  32844. * @param onLoad defines an optional callback raised when the texture is loaded
  32845. * @param onError defines an optional callback raised if there is an issue to load the texture
  32846. * @param format defines the format of the data
  32847. * @param forcedExtension defines the extension to use to pick the right loader
  32848. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  32849. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  32850. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  32851. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  32852. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  32853. * @returns the cube texture as an InternalTexture
  32854. */
  32855. Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  32856. var _this = this;
  32857. if (onLoad === void 0) { onLoad = null; }
  32858. if (onError === void 0) { onError = null; }
  32859. if (forcedExtension === void 0) { forcedExtension = null; }
  32860. if (createPolynomials === void 0) { createPolynomials = false; }
  32861. if (lodScale === void 0) { lodScale = 0; }
  32862. if (lodOffset === void 0) { lodOffset = 0; }
  32863. if (fallback === void 0) { fallback = null; }
  32864. if (excludeLoaders === void 0) { excludeLoaders = []; }
  32865. var gl = this._gl;
  32866. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_CUBE);
  32867. texture.isCube = true;
  32868. texture.url = rootUrl;
  32869. texture.generateMipMaps = !noMipmap;
  32870. texture._lodGenerationScale = lodScale;
  32871. texture._lodGenerationOffset = lodOffset;
  32872. if (!this._doNotHandleContextLost) {
  32873. texture._extension = forcedExtension;
  32874. texture._files = files;
  32875. }
  32876. var lastDot = rootUrl.lastIndexOf('.');
  32877. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  32878. var loader = null;
  32879. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  32880. var availableLoader = _a[_i];
  32881. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  32882. loader = availableLoader;
  32883. break;
  32884. }
  32885. }
  32886. var onInternalError = function (request, exception) {
  32887. if (loader) {
  32888. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  32889. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn(loader.constructor.name + " failed when trying to load " + texture.url + ", falling back to the next supported loader");
  32890. if (fallbackUrl) {
  32891. excludeLoaders.push(loader);
  32892. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  32893. return;
  32894. }
  32895. }
  32896. if (onError && request) {
  32897. onError(request.status + " " + request.statusText, exception);
  32898. }
  32899. };
  32900. if (loader) {
  32901. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  32902. var onloaddata = function (data) {
  32903. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32904. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  32905. };
  32906. if (files && files.length === 6) {
  32907. if (loader.supportCascades) {
  32908. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  32909. }
  32910. else {
  32911. if (onError) {
  32912. onError("Textures type does not support cascades.");
  32913. }
  32914. else {
  32915. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Texture loader does not support cascades.");
  32916. }
  32917. }
  32918. }
  32919. else {
  32920. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  32921. }
  32922. }
  32923. else {
  32924. if (!files) {
  32925. throw new Error("Cannot load cubemap because files were not defined");
  32926. }
  32927. this._cascadeLoadImgs(scene, function (imgs) {
  32928. var width = _this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  32929. var height = width;
  32930. _this._prepareWorkingCanvas();
  32931. if (!_this._workingCanvas || !_this._workingContext) {
  32932. return;
  32933. }
  32934. _this._workingCanvas.width = width;
  32935. _this._workingCanvas.height = height;
  32936. var faces = [
  32937. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  32938. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  32939. ];
  32940. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32941. _this._unpackFlipY(false);
  32942. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  32943. for (var index = 0; index < faces.length; index++) {
  32944. if (imgs[index].width !== width || imgs[index].height !== height) {
  32945. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  32946. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  32947. }
  32948. else {
  32949. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, imgs[index]);
  32950. }
  32951. }
  32952. if (!noMipmap) {
  32953. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32954. }
  32955. _this._setCubeMapTextureParams(!noMipmap);
  32956. texture.width = width;
  32957. texture.height = height;
  32958. texture.isReady = true;
  32959. if (format) {
  32960. texture.format = format;
  32961. }
  32962. texture.onLoadedObservable.notifyObservers(texture);
  32963. texture.onLoadedObservable.clear();
  32964. if (onLoad) {
  32965. onLoad();
  32966. }
  32967. }, files, onError);
  32968. }
  32969. this._internalTexturesCache.push(texture);
  32970. return texture;
  32971. };
  32972. /**
  32973. * @hidden
  32974. */
  32975. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  32976. var gl = this._gl;
  32977. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  32978. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  32979. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32980. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32981. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32982. // this.resetTextureCache();
  32983. };
  32984. /**
  32985. * Update a raw cube texture
  32986. * @param texture defines the texture to udpdate
  32987. * @param data defines the data to store
  32988. * @param format defines the data format
  32989. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32990. * @param invertY defines if data must be stored with Y axis inverted
  32991. * @param compression defines the compression used (null by default)
  32992. * @param level defines which level of the texture to update
  32993. */
  32994. Engine.prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  32995. if (compression === void 0) { compression = null; }
  32996. if (level === void 0) { level = 0; }
  32997. texture._bufferViewArray = data;
  32998. texture.format = format;
  32999. texture.type = type;
  33000. texture.invertY = invertY;
  33001. texture._compression = compression;
  33002. var gl = this._gl;
  33003. var textureType = this._getWebGLTextureType(type);
  33004. var internalFormat = this._getInternalFormat(format);
  33005. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  33006. var needConversion = false;
  33007. if (internalFormat === gl.RGB) {
  33008. internalFormat = gl.RGBA;
  33009. needConversion = true;
  33010. }
  33011. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  33012. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  33013. if (texture.width % 4 !== 0) {
  33014. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  33015. }
  33016. // Data are known to be in +X +Y +Z -X -Y -Z
  33017. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  33018. var faceData = data[faceIndex];
  33019. if (compression) {
  33020. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  33021. }
  33022. else {
  33023. if (needConversion) {
  33024. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  33025. }
  33026. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  33027. }
  33028. }
  33029. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  33030. if (isPot && texture.generateMipMaps && level === 0) {
  33031. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  33032. }
  33033. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33034. // this.resetTextureCache();
  33035. texture.isReady = true;
  33036. };
  33037. /**
  33038. * Creates a new raw cube texture
  33039. * @param data defines the array of data to use to create each face
  33040. * @param size defines the size of the textures
  33041. * @param format defines the format of the data
  33042. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  33043. * @param generateMipMaps defines if the engine should generate the mip levels
  33044. * @param invertY defines if data must be stored with Y axis inverted
  33045. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33046. * @param compression defines the compression used (null by default)
  33047. * @returns the cube texture as an InternalTexture
  33048. */
  33049. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  33050. if (compression === void 0) { compression = null; }
  33051. var gl = this._gl;
  33052. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_CUBERAW);
  33053. texture.isCube = true;
  33054. texture.format = format;
  33055. texture.type = type;
  33056. if (!this._doNotHandleContextLost) {
  33057. texture._bufferViewArray = data;
  33058. }
  33059. var textureType = this._getWebGLTextureType(type);
  33060. var internalFormat = this._getInternalFormat(format);
  33061. if (internalFormat === gl.RGB) {
  33062. internalFormat = gl.RGBA;
  33063. }
  33064. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  33065. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  33066. generateMipMaps = false;
  33067. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  33068. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
  33069. }
  33070. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  33071. generateMipMaps = false;
  33072. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  33073. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
  33074. }
  33075. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  33076. generateMipMaps = false;
  33077. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  33078. }
  33079. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  33080. generateMipMaps = false;
  33081. _Misc_logger__WEBPACK_IMPORTED_MODULE_14__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  33082. }
  33083. var width = size;
  33084. var height = width;
  33085. texture.width = width;
  33086. texture.height = height;
  33087. // Double check on POT to generate Mips.
  33088. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  33089. if (!isPot) {
  33090. generateMipMaps = false;
  33091. }
  33092. // Upload data if needed. The texture won't be ready until then.
  33093. if (data) {
  33094. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  33095. }
  33096. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  33097. // Filters
  33098. if (data && generateMipMaps) {
  33099. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  33100. }
  33101. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  33102. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  33103. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  33104. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  33105. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  33106. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  33107. texture.generateMipMaps = generateMipMaps;
  33108. return texture;
  33109. };
  33110. /**
  33111. * Creates a new raw cube texture from a specified url
  33112. * @param url defines the url where the data is located
  33113. * @param scene defines the current scene
  33114. * @param size defines the size of the textures
  33115. * @param format defines the format of the data
  33116. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  33117. * @param noMipmap defines if the engine should avoid generating the mip levels
  33118. * @param callback defines a callback used to extract texture data from loaded data
  33119. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  33120. * @param onLoad defines a callback called when texture is loaded
  33121. * @param onError defines a callback called if there is an error
  33122. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33123. * @param invertY defines if data must be stored with Y axis inverted
  33124. * @returns the cube texture as an InternalTexture
  33125. */
  33126. Engine.prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  33127. var _this = this;
  33128. if (onLoad === void 0) { onLoad = null; }
  33129. if (onError === void 0) { onError = null; }
  33130. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  33131. if (invertY === void 0) { invertY = false; }
  33132. var gl = this._gl;
  33133. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  33134. scene._addPendingData(texture);
  33135. texture.url = url;
  33136. this._internalTexturesCache.push(texture);
  33137. var onerror = function (request, exception) {
  33138. scene._removePendingData(texture);
  33139. if (onError && request) {
  33140. onError(request.status + " " + request.statusText, exception);
  33141. }
  33142. };
  33143. var internalCallback = function (data) {
  33144. var width = texture.width;
  33145. var faceDataArrays = callback(data);
  33146. if (!faceDataArrays) {
  33147. return;
  33148. }
  33149. if (mipmapGenerator) {
  33150. var textureType = _this._getWebGLTextureType(type);
  33151. var internalFormat = _this._getInternalFormat(format);
  33152. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  33153. var needConversion = false;
  33154. if (internalFormat === gl.RGB) {
  33155. internalFormat = gl.RGBA;
  33156. needConversion = true;
  33157. }
  33158. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  33159. _this._unpackFlipY(false);
  33160. var mipData = mipmapGenerator(faceDataArrays);
  33161. for (var level = 0; level < mipData.length; level++) {
  33162. var mipSize = width >> level;
  33163. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  33164. var mipFaceData = mipData[level][faceIndex];
  33165. if (needConversion) {
  33166. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  33167. }
  33168. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  33169. }
  33170. }
  33171. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  33172. }
  33173. else {
  33174. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  33175. }
  33176. texture.isReady = true;
  33177. // this.resetTextureCache();
  33178. scene._removePendingData(texture);
  33179. if (onLoad) {
  33180. onLoad();
  33181. }
  33182. };
  33183. this._loadFile(url, function (data) {
  33184. internalCallback(data);
  33185. }, undefined, scene.offlineProvider, true, onerror);
  33186. return texture;
  33187. };
  33188. /**
  33189. * Update a raw 3D texture
  33190. * @param texture defines the texture to update
  33191. * @param data defines the data to store
  33192. * @param format defines the data format
  33193. * @param invertY defines if data must be stored with Y axis inverted
  33194. * @param compression defines the used compression (can be null)
  33195. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  33196. */
  33197. Engine.prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  33198. if (compression === void 0) { compression = null; }
  33199. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  33200. var internalType = this._getWebGLTextureType(textureType);
  33201. var internalFormat = this._getInternalFormat(format);
  33202. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  33203. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  33204. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  33205. if (!this._doNotHandleContextLost) {
  33206. texture._bufferView = data;
  33207. texture.format = format;
  33208. texture.invertY = invertY;
  33209. texture._compression = compression;
  33210. }
  33211. if (texture.width % 4 !== 0) {
  33212. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  33213. }
  33214. if (compression && data) {
  33215. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  33216. }
  33217. else {
  33218. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  33219. }
  33220. if (texture.generateMipMaps) {
  33221. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  33222. }
  33223. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33224. // this.resetTextureCache();
  33225. texture.isReady = true;
  33226. };
  33227. /**
  33228. * Creates a new raw 3D texture
  33229. * @param data defines the data used to create the texture
  33230. * @param width defines the width of the texture
  33231. * @param height defines the height of the texture
  33232. * @param depth defines the depth of the texture
  33233. * @param format defines the format of the texture
  33234. * @param generateMipMaps defines if the engine must generate mip levels
  33235. * @param invertY defines if data must be stored with Y axis inverted
  33236. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33237. * @param compression defines the compressed used (can be null)
  33238. * @param textureType defines the compressed used (can be null)
  33239. * @returns a new raw 3D texture (stored in an InternalTexture)
  33240. */
  33241. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  33242. if (compression === void 0) { compression = null; }
  33243. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  33244. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_10__["InternalTexture"].DATASOURCE_RAW3D);
  33245. texture.baseWidth = width;
  33246. texture.baseHeight = height;
  33247. texture.baseDepth = depth;
  33248. texture.width = width;
  33249. texture.height = height;
  33250. texture.depth = depth;
  33251. texture.format = format;
  33252. texture.type = textureType;
  33253. texture.generateMipMaps = generateMipMaps;
  33254. texture.samplingMode = samplingMode;
  33255. texture.is3D = true;
  33256. if (!this._doNotHandleContextLost) {
  33257. texture._bufferView = data;
  33258. }
  33259. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  33260. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  33261. // Filters
  33262. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  33263. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  33264. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  33265. if (generateMipMaps) {
  33266. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  33267. }
  33268. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33269. this._internalTexturesCache.push(texture);
  33270. return texture;
  33271. };
  33272. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  33273. var gl = this._gl;
  33274. if (!gl) {
  33275. return;
  33276. }
  33277. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  33278. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  33279. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  33280. if (!noMipmap && !isCompressed) {
  33281. gl.generateMipmap(gl.TEXTURE_2D);
  33282. }
  33283. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  33284. // this.resetTextureCache();
  33285. if (scene) {
  33286. scene._removePendingData(texture);
  33287. }
  33288. texture.onLoadedObservable.notifyObservers(texture);
  33289. texture.onLoadedObservable.clear();
  33290. };
  33291. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  33292. var _this = this;
  33293. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  33294. var maxTextureSize = this.getCaps().maxTextureSize;
  33295. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, maxTextureSize) : width);
  33296. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, maxTextureSize) : height);
  33297. var gl = this._gl;
  33298. if (!gl) {
  33299. return;
  33300. }
  33301. if (!texture._webGLTexture) {
  33302. // this.resetTextureCache();
  33303. if (scene) {
  33304. scene._removePendingData(texture);
  33305. }
  33306. return;
  33307. }
  33308. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  33309. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  33310. texture.baseWidth = width;
  33311. texture.baseHeight = height;
  33312. texture.width = potWidth;
  33313. texture.height = potHeight;
  33314. texture.isReady = true;
  33315. if (processFunction(potWidth, potHeight, function () {
  33316. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  33317. })) {
  33318. // Returning as texture needs extra async steps
  33319. return;
  33320. }
  33321. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  33322. };
  33323. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  33324. // Create new RGBA data container.
  33325. var rgbaData;
  33326. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  33327. rgbaData = new Float32Array(width * height * 4);
  33328. }
  33329. else {
  33330. rgbaData = new Uint32Array(width * height * 4);
  33331. }
  33332. // Convert each pixel.
  33333. for (var x = 0; x < width; x++) {
  33334. for (var y = 0; y < height; y++) {
  33335. var index = (y * width + x) * 3;
  33336. var newIndex = (y * width + x) * 4;
  33337. // Map Old Value to new value.
  33338. rgbaData[newIndex + 0] = rgbData[index + 0];
  33339. rgbaData[newIndex + 1] = rgbData[index + 1];
  33340. rgbaData[newIndex + 2] = rgbData[index + 2];
  33341. // Add fully opaque alpha channel.
  33342. rgbaData[newIndex + 3] = 1;
  33343. }
  33344. }
  33345. return rgbaData;
  33346. };
  33347. /** @hidden */
  33348. Engine.prototype._releaseFramebufferObjects = function (texture) {
  33349. var gl = this._gl;
  33350. if (texture._framebuffer) {
  33351. gl.deleteFramebuffer(texture._framebuffer);
  33352. texture._framebuffer = null;
  33353. }
  33354. if (texture._depthStencilBuffer) {
  33355. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  33356. texture._depthStencilBuffer = null;
  33357. }
  33358. if (texture._MSAAFramebuffer) {
  33359. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  33360. texture._MSAAFramebuffer = null;
  33361. }
  33362. if (texture._MSAARenderBuffer) {
  33363. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  33364. texture._MSAARenderBuffer = null;
  33365. }
  33366. };
  33367. /** @hidden */
  33368. Engine.prototype._releaseTexture = function (texture) {
  33369. var gl = this._gl;
  33370. this._releaseFramebufferObjects(texture);
  33371. gl.deleteTexture(texture._webGLTexture);
  33372. // Unbind channels
  33373. this.unbindAllTextures();
  33374. var index = this._internalTexturesCache.indexOf(texture);
  33375. if (index !== -1) {
  33376. this._internalTexturesCache.splice(index, 1);
  33377. }
  33378. // Integrated fixed lod samplers.
  33379. if (texture._lodTextureHigh) {
  33380. texture._lodTextureHigh.dispose();
  33381. }
  33382. if (texture._lodTextureMid) {
  33383. texture._lodTextureMid.dispose();
  33384. }
  33385. if (texture._lodTextureLow) {
  33386. texture._lodTextureLow.dispose();
  33387. }
  33388. // Set output texture of post process to null if the texture has been released/disposed
  33389. this.scenes.forEach(function (scene) {
  33390. scene.postProcesses.forEach(function (postProcess) {
  33391. if (postProcess._outputTexture == texture) {
  33392. postProcess._outputTexture = null;
  33393. }
  33394. });
  33395. scene.cameras.forEach(function (camera) {
  33396. camera._postProcesses.forEach(function (postProcess) {
  33397. if (postProcess) {
  33398. if (postProcess._outputTexture == texture) {
  33399. postProcess._outputTexture = null;
  33400. }
  33401. }
  33402. });
  33403. });
  33404. });
  33405. };
  33406. Engine.prototype.setProgram = function (program) {
  33407. if (this._currentProgram !== program) {
  33408. this._gl.useProgram(program);
  33409. this._currentProgram = program;
  33410. }
  33411. };
  33412. /**
  33413. * Binds an effect to the webGL context
  33414. * @param effect defines the effect to bind
  33415. */
  33416. Engine.prototype.bindSamplers = function (effect) {
  33417. this.setProgram(effect.getProgram());
  33418. var samplers = effect.getSamplers();
  33419. for (var index = 0; index < samplers.length; index++) {
  33420. var uniform = effect.getUniform(samplers[index]);
  33421. if (uniform) {
  33422. this._boundUniforms[index] = uniform;
  33423. }
  33424. }
  33425. this._currentEffect = null;
  33426. };
  33427. Engine.prototype._activateCurrentTexture = function () {
  33428. if (this._currentTextureChannel !== this._activeChannel) {
  33429. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  33430. this._currentTextureChannel = this._activeChannel;
  33431. }
  33432. };
  33433. /** @hidden */
  33434. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  33435. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  33436. if (force === void 0) { force = false; }
  33437. var wasPreviouslyBound = false;
  33438. var isTextureForRendering = texture && texture._associatedChannel > -1;
  33439. if (forTextureDataUpdate && isTextureForRendering) {
  33440. this._activeChannel = texture._associatedChannel;
  33441. }
  33442. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  33443. if (currentTextureBound !== texture || force) {
  33444. this._activateCurrentTexture();
  33445. if (texture && texture.isMultiview) {
  33446. this._gl.bindTexture(target, texture ? texture._colorTextureArray : null);
  33447. }
  33448. else {
  33449. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  33450. }
  33451. this._boundTexturesCache[this._activeChannel] = texture;
  33452. if (texture) {
  33453. texture._associatedChannel = this._activeChannel;
  33454. }
  33455. }
  33456. else if (forTextureDataUpdate) {
  33457. wasPreviouslyBound = true;
  33458. this._activateCurrentTexture();
  33459. }
  33460. if (isTextureForRendering && !forTextureDataUpdate) {
  33461. this._bindSamplerUniformToChannel(texture._associatedChannel, this._activeChannel);
  33462. }
  33463. return wasPreviouslyBound;
  33464. };
  33465. /** @hidden */
  33466. Engine.prototype._bindTexture = function (channel, texture) {
  33467. if (channel < 0) {
  33468. return;
  33469. }
  33470. if (texture) {
  33471. texture._associatedChannel = channel;
  33472. }
  33473. this._activeChannel = channel;
  33474. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  33475. };
  33476. /**
  33477. * Sets a texture to the webGL context from a postprocess
  33478. * @param channel defines the channel to use
  33479. * @param postProcess defines the source postprocess
  33480. */
  33481. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  33482. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  33483. };
  33484. /**
  33485. * Binds the output of the passed in post process to the texture channel specified
  33486. * @param channel The channel the texture should be bound to
  33487. * @param postProcess The post process which's output should be bound
  33488. */
  33489. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  33490. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  33491. };
  33492. /**
  33493. * Unbind all textures from the webGL context
  33494. */
  33495. Engine.prototype.unbindAllTextures = function () {
  33496. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  33497. this._activeChannel = channel;
  33498. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33499. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33500. if (this.webGLVersion > 1) {
  33501. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33502. }
  33503. }
  33504. };
  33505. /**
  33506. * Sets a texture to the according uniform.
  33507. * @param channel The texture channel
  33508. * @param uniform The uniform to set
  33509. * @param texture The texture to apply
  33510. */
  33511. Engine.prototype.setTexture = function (channel, uniform, texture) {
  33512. if (channel < 0) {
  33513. return;
  33514. }
  33515. if (uniform) {
  33516. this._boundUniforms[channel] = uniform;
  33517. }
  33518. this._setTexture(channel, texture);
  33519. };
  33520. /**
  33521. * Sets a depth stencil texture from a render target to the according uniform.
  33522. * @param channel The texture channel
  33523. * @param uniform The uniform to set
  33524. * @param texture The render target texture containing the depth stencil texture to apply
  33525. */
  33526. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  33527. if (channel < 0) {
  33528. return;
  33529. }
  33530. if (uniform) {
  33531. this._boundUniforms[channel] = uniform;
  33532. }
  33533. if (!texture || !texture.depthStencilTexture) {
  33534. this._setTexture(channel, null);
  33535. }
  33536. else {
  33537. this._setTexture(channel, texture, false, true);
  33538. }
  33539. };
  33540. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  33541. var uniform = this._boundUniforms[sourceSlot];
  33542. if (uniform._currentState === destination) {
  33543. return;
  33544. }
  33545. this._gl.uniform1i(uniform, destination);
  33546. uniform._currentState = destination;
  33547. };
  33548. Engine.prototype._getTextureWrapMode = function (mode) {
  33549. switch (mode) {
  33550. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  33551. return this._gl.REPEAT;
  33552. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  33553. return this._gl.CLAMP_TO_EDGE;
  33554. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  33555. return this._gl.MIRRORED_REPEAT;
  33556. }
  33557. return this._gl.REPEAT;
  33558. };
  33559. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  33560. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  33561. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  33562. // Not ready?
  33563. if (!texture) {
  33564. if (this._boundTexturesCache[channel] != null) {
  33565. this._activeChannel = channel;
  33566. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  33567. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  33568. if (this.webGLVersion > 1) {
  33569. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  33570. }
  33571. }
  33572. return false;
  33573. }
  33574. // Video
  33575. if (texture.video) {
  33576. this._activeChannel = channel;
  33577. texture.update();
  33578. }
  33579. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  33580. texture.delayLoad();
  33581. return false;
  33582. }
  33583. var internalTexture;
  33584. if (depthStencilTexture) {
  33585. internalTexture = texture.depthStencilTexture;
  33586. }
  33587. else if (texture.isReady()) {
  33588. internalTexture = texture.getInternalTexture();
  33589. }
  33590. else if (texture.isCube) {
  33591. internalTexture = this.emptyCubeTexture;
  33592. }
  33593. else if (texture.is3D) {
  33594. internalTexture = this.emptyTexture3D;
  33595. }
  33596. else {
  33597. internalTexture = this.emptyTexture;
  33598. }
  33599. if (!isPartOfTextureArray && internalTexture) {
  33600. internalTexture._associatedChannel = channel;
  33601. }
  33602. var needToBind = true;
  33603. if (this._boundTexturesCache[channel] === internalTexture) {
  33604. if (!isPartOfTextureArray) {
  33605. this._bindSamplerUniformToChannel(internalTexture._associatedChannel, channel);
  33606. }
  33607. needToBind = false;
  33608. }
  33609. this._activeChannel = channel;
  33610. if (internalTexture && internalTexture.isMultiview) {
  33611. if (needToBind) {
  33612. this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY, internalTexture, isPartOfTextureArray);
  33613. }
  33614. }
  33615. else if (internalTexture && internalTexture.is3D) {
  33616. if (needToBind) {
  33617. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  33618. }
  33619. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  33620. internalTexture._cachedWrapU = texture.wrapU;
  33621. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  33622. }
  33623. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  33624. internalTexture._cachedWrapV = texture.wrapV;
  33625. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  33626. }
  33627. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  33628. internalTexture._cachedWrapR = texture.wrapR;
  33629. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  33630. }
  33631. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  33632. }
  33633. else if (internalTexture && internalTexture.isCube) {
  33634. if (needToBind) {
  33635. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  33636. }
  33637. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  33638. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  33639. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  33640. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  33641. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  33642. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  33643. }
  33644. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  33645. }
  33646. else {
  33647. if (needToBind) {
  33648. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  33649. }
  33650. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  33651. internalTexture._cachedWrapU = texture.wrapU;
  33652. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  33653. }
  33654. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  33655. internalTexture._cachedWrapV = texture.wrapV;
  33656. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  33657. }
  33658. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  33659. }
  33660. return true;
  33661. };
  33662. /**
  33663. * Sets an array of texture to the webGL context
  33664. * @param channel defines the channel where the texture array must be set
  33665. * @param uniform defines the associated uniform location
  33666. * @param textures defines the array of textures to bind
  33667. */
  33668. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  33669. if (channel < 0 || !uniform) {
  33670. return;
  33671. }
  33672. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  33673. this._textureUnits = new Int32Array(textures.length);
  33674. }
  33675. for (var i = 0; i < textures.length; i++) {
  33676. var texture = textures[i].getInternalTexture();
  33677. if (texture) {
  33678. this._textureUnits[channel + i] = channel + i;
  33679. texture._associatedChannel = channel + i;
  33680. }
  33681. else {
  33682. this._textureUnits[channel + i] = -1;
  33683. }
  33684. }
  33685. this._gl.uniform1iv(uniform, this._textureUnits);
  33686. for (var index = 0; index < textures.length; index++) {
  33687. this._setTexture(this._textureUnits[index], textures[index], true);
  33688. }
  33689. };
  33690. /** @hidden */
  33691. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  33692. var internalTexture = texture.getInternalTexture();
  33693. if (!internalTexture) {
  33694. return;
  33695. }
  33696. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  33697. var value = texture.anisotropicFilteringLevel;
  33698. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  33699. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  33700. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  33701. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  33702. }
  33703. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  33704. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  33705. internalTexture._cachedAnisotropicFilteringLevel = value;
  33706. }
  33707. };
  33708. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  33709. this._bindTextureDirectly(target, texture, true, true);
  33710. this._gl.texParameterf(target, parameter, value);
  33711. };
  33712. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  33713. if (texture) {
  33714. this._bindTextureDirectly(target, texture, true, true);
  33715. }
  33716. this._gl.texParameteri(target, parameter, value);
  33717. };
  33718. /**
  33719. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33720. * @param x defines the x coordinate of the rectangle where pixels must be read
  33721. * @param y defines the y coordinate of the rectangle where pixels must be read
  33722. * @param width defines the width of the rectangle where pixels must be read
  33723. * @param height defines the height of the rectangle where pixels must be read
  33724. * @returns a Uint8Array containing RGBA colors
  33725. */
  33726. Engine.prototype.readPixels = function (x, y, width, height) {
  33727. var data = new Uint8Array(height * width * 4);
  33728. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  33729. return data;
  33730. };
  33731. /**
  33732. * Add an externaly attached data from its key.
  33733. * This method call will fail and return false, if such key already exists.
  33734. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33735. * @param key the unique key that identifies the data
  33736. * @param data the data object to associate to the key for this Engine instance
  33737. * @return true if no such key were already present and the data was added successfully, false otherwise
  33738. */
  33739. Engine.prototype.addExternalData = function (key, data) {
  33740. if (!this._externalData) {
  33741. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33742. }
  33743. return this._externalData.add(key, data);
  33744. };
  33745. /**
  33746. * Get an externaly attached data from its key
  33747. * @param key the unique key that identifies the data
  33748. * @return the associated data, if present (can be null), or undefined if not present
  33749. */
  33750. Engine.prototype.getExternalData = function (key) {
  33751. if (!this._externalData) {
  33752. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33753. }
  33754. return this._externalData.get(key);
  33755. };
  33756. /**
  33757. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33758. * @param key the unique key that identifies the data
  33759. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33760. * @return the associated data, can be null if the factory returned null.
  33761. */
  33762. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  33763. if (!this._externalData) {
  33764. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33765. }
  33766. return this._externalData.getOrAddWithFactory(key, factory);
  33767. };
  33768. /**
  33769. * Remove an externaly attached data from the Engine instance
  33770. * @param key the unique key that identifies the data
  33771. * @return true if the data was successfully removed, false if it doesn't exist
  33772. */
  33773. Engine.prototype.removeExternalData = function (key) {
  33774. if (!this._externalData) {
  33775. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  33776. }
  33777. return this._externalData.remove(key);
  33778. };
  33779. /**
  33780. * Unbind all vertex attributes from the webGL context
  33781. */
  33782. Engine.prototype.unbindAllAttributes = function () {
  33783. if (this._mustWipeVertexAttributes) {
  33784. this._mustWipeVertexAttributes = false;
  33785. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  33786. this._gl.disableVertexAttribArray(i);
  33787. this._vertexAttribArraysEnabled[i] = false;
  33788. this._currentBufferPointers[i].active = false;
  33789. }
  33790. return;
  33791. }
  33792. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  33793. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  33794. continue;
  33795. }
  33796. this._gl.disableVertexAttribArray(i);
  33797. this._vertexAttribArraysEnabled[i] = false;
  33798. this._currentBufferPointers[i].active = false;
  33799. }
  33800. };
  33801. /**
  33802. * 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
  33803. */
  33804. Engine.prototype.releaseEffects = function () {
  33805. for (var name in this._compiledEffects) {
  33806. this._deleteProgram(this._compiledEffects[name]._program);
  33807. }
  33808. this._compiledEffects = {};
  33809. };
  33810. /**
  33811. * Dispose and release all associated resources
  33812. */
  33813. Engine.prototype.dispose = function () {
  33814. this.hideLoadingUI();
  33815. this.stopRenderLoop();
  33816. this.onNewSceneAddedObservable.clear();
  33817. // Release postProcesses
  33818. while (this.postProcesses.length) {
  33819. this.postProcesses[0].dispose();
  33820. }
  33821. // Empty texture
  33822. if (this._emptyTexture) {
  33823. this._releaseTexture(this._emptyTexture);
  33824. this._emptyTexture = null;
  33825. }
  33826. if (this._emptyCubeTexture) {
  33827. this._releaseTexture(this._emptyCubeTexture);
  33828. this._emptyCubeTexture = null;
  33829. }
  33830. // Rescale PP
  33831. if (this._rescalePostProcess) {
  33832. this._rescalePostProcess.dispose();
  33833. }
  33834. // Release scenes
  33835. while (this.scenes.length) {
  33836. this.scenes[0].dispose();
  33837. }
  33838. // Release audio engine
  33839. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  33840. Engine.audioEngine.dispose();
  33841. }
  33842. // Release effects
  33843. this.releaseEffects();
  33844. // Unbind
  33845. this.unbindAllAttributes();
  33846. this._boundUniforms = [];
  33847. if (this._dummyFramebuffer) {
  33848. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  33849. }
  33850. //WebVR
  33851. this.disableVR();
  33852. // Events
  33853. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  33854. window.removeEventListener("blur", this._onBlur);
  33855. window.removeEventListener("focus", this._onFocus);
  33856. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  33857. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  33858. if (this._renderingCanvas) {
  33859. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  33860. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  33861. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  33862. if (!this._doNotHandleContextLost) {
  33863. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  33864. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  33865. }
  33866. }
  33867. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  33868. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  33869. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  33870. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  33871. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  33872. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  33873. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  33874. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  33875. if (this._onVrDisplayConnect) {
  33876. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  33877. if (this._onVrDisplayDisconnect) {
  33878. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  33879. }
  33880. if (this._onVrDisplayPresentChange) {
  33881. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  33882. }
  33883. this._onVrDisplayConnect = null;
  33884. this._onVrDisplayDisconnect = null;
  33885. }
  33886. }
  33887. // Remove from Instances
  33888. var index = Engine.Instances.indexOf(this);
  33889. if (index >= 0) {
  33890. Engine.Instances.splice(index, 1);
  33891. }
  33892. this._workingCanvas = null;
  33893. this._workingContext = null;
  33894. this._currentBufferPointers = [];
  33895. this._renderingCanvas = null;
  33896. this._currentProgram = null;
  33897. this._bindedRenderFunction = null;
  33898. this.onResizeObservable.clear();
  33899. this.onCanvasBlurObservable.clear();
  33900. this.onCanvasFocusObservable.clear();
  33901. this.onCanvasPointerOutObservable.clear();
  33902. this.onBeginFrameObservable.clear();
  33903. this.onEndFrameObservable.clear();
  33904. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  33905. // Abort active requests
  33906. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  33907. var request = _a[_i];
  33908. request.abort();
  33909. }
  33910. };
  33911. // Loading screen
  33912. /**
  33913. * Display the loading screen
  33914. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33915. */
  33916. Engine.prototype.displayLoadingUI = function () {
  33917. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  33918. return;
  33919. }
  33920. var loadingScreen = this.loadingScreen;
  33921. if (loadingScreen) {
  33922. loadingScreen.displayLoadingUI();
  33923. }
  33924. };
  33925. /**
  33926. * Hide the loading screen
  33927. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33928. */
  33929. Engine.prototype.hideLoadingUI = function () {
  33930. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_13__["DomManagement"].IsWindowObjectExist()) {
  33931. return;
  33932. }
  33933. var loadingScreen = this.loadingScreen;
  33934. if (loadingScreen) {
  33935. loadingScreen.hideLoadingUI();
  33936. }
  33937. };
  33938. Object.defineProperty(Engine.prototype, "loadingScreen", {
  33939. /**
  33940. * Gets the current loading screen object
  33941. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33942. */
  33943. get: function () {
  33944. if (!this._loadingScreen && this._renderingCanvas) {
  33945. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  33946. }
  33947. return this._loadingScreen;
  33948. },
  33949. /**
  33950. * Sets the current loading screen object
  33951. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33952. */
  33953. set: function (loadingScreen) {
  33954. this._loadingScreen = loadingScreen;
  33955. },
  33956. enumerable: true,
  33957. configurable: true
  33958. });
  33959. Object.defineProperty(Engine.prototype, "loadingUIText", {
  33960. /**
  33961. * Sets the current loading screen text
  33962. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33963. */
  33964. set: function (text) {
  33965. this.loadingScreen.loadingUIText = text;
  33966. },
  33967. enumerable: true,
  33968. configurable: true
  33969. });
  33970. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  33971. /**
  33972. * Sets the current loading screen background color
  33973. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33974. */
  33975. set: function (color) {
  33976. this.loadingScreen.loadingUIBackgroundColor = color;
  33977. },
  33978. enumerable: true,
  33979. configurable: true
  33980. });
  33981. /**
  33982. * Attach a new callback raised when context lost event is fired
  33983. * @param callback defines the callback to call
  33984. */
  33985. Engine.prototype.attachContextLostEvent = function (callback) {
  33986. if (this._renderingCanvas) {
  33987. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  33988. }
  33989. };
  33990. /**
  33991. * Attach a new callback raised when context restored event is fired
  33992. * @param callback defines the callback to call
  33993. */
  33994. Engine.prototype.attachContextRestoredEvent = function (callback) {
  33995. if (this._renderingCanvas) {
  33996. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  33997. }
  33998. };
  33999. /**
  34000. * Gets the source code of the vertex shader associated with a specific webGL program
  34001. * @param program defines the program to use
  34002. * @returns a string containing the source code of the vertex shader associated with the program
  34003. */
  34004. Engine.prototype.getVertexShaderSource = function (program) {
  34005. var shaders = this._gl.getAttachedShaders(program);
  34006. if (!shaders) {
  34007. return null;
  34008. }
  34009. return this._gl.getShaderSource(shaders[0]);
  34010. };
  34011. /**
  34012. * Gets the source code of the fragment shader associated with a specific webGL program
  34013. * @param program defines the program to use
  34014. * @returns a string containing the source code of the fragment shader associated with the program
  34015. */
  34016. Engine.prototype.getFragmentShaderSource = function (program) {
  34017. var shaders = this._gl.getAttachedShaders(program);
  34018. if (!shaders) {
  34019. return null;
  34020. }
  34021. return this._gl.getShaderSource(shaders[1]);
  34022. };
  34023. /**
  34024. * Get the current error code of the webGL context
  34025. * @returns the error code
  34026. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34027. */
  34028. Engine.prototype.getError = function () {
  34029. return this._gl.getError();
  34030. };
  34031. // FPS
  34032. /**
  34033. * Gets the current framerate
  34034. * @returns a number representing the framerate
  34035. */
  34036. Engine.prototype.getFps = function () {
  34037. return this._fps;
  34038. };
  34039. /**
  34040. * Gets the time spent between current and previous frame
  34041. * @returns a number representing the delta time in ms
  34042. */
  34043. Engine.prototype.getDeltaTime = function () {
  34044. return this._deltaTime;
  34045. };
  34046. Engine.prototype._measureFps = function () {
  34047. this._performanceMonitor.sampleFrame();
  34048. this._fps = this._performanceMonitor.averageFPS;
  34049. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  34050. };
  34051. /** @hidden */
  34052. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  34053. if (faceIndex === void 0) { faceIndex = -1; }
  34054. if (level === void 0) { level = 0; }
  34055. if (buffer === void 0) { buffer = null; }
  34056. var gl = this._gl;
  34057. if (!this._dummyFramebuffer) {
  34058. var dummy = gl.createFramebuffer();
  34059. if (!dummy) {
  34060. throw new Error("Unable to create dummy framebuffer");
  34061. }
  34062. this._dummyFramebuffer = dummy;
  34063. }
  34064. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  34065. if (faceIndex > -1) {
  34066. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  34067. }
  34068. else {
  34069. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  34070. }
  34071. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  34072. switch (readType) {
  34073. case gl.UNSIGNED_BYTE:
  34074. if (!buffer) {
  34075. buffer = new Uint8Array(4 * width * height);
  34076. }
  34077. readType = gl.UNSIGNED_BYTE;
  34078. break;
  34079. default:
  34080. if (!buffer) {
  34081. buffer = new Float32Array(4 * width * height);
  34082. }
  34083. readType = gl.FLOAT;
  34084. break;
  34085. }
  34086. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  34087. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  34088. return buffer;
  34089. };
  34090. Engine.prototype._canRenderToFloatFramebuffer = function () {
  34091. if (this._webGLVersion > 1) {
  34092. return this._caps.colorBufferFloat;
  34093. }
  34094. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  34095. };
  34096. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  34097. if (this._webGLVersion > 1) {
  34098. return this._caps.colorBufferFloat;
  34099. }
  34100. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  34101. };
  34102. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  34103. Engine.prototype._canRenderToFramebuffer = function (type) {
  34104. var gl = this._gl;
  34105. //clear existing errors
  34106. while (gl.getError() !== gl.NO_ERROR) { }
  34107. var successful = true;
  34108. var texture = gl.createTexture();
  34109. gl.bindTexture(gl.TEXTURE_2D, texture);
  34110. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  34111. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  34112. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  34113. var fb = gl.createFramebuffer();
  34114. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  34115. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  34116. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  34117. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  34118. successful = successful && (gl.getError() === gl.NO_ERROR);
  34119. //try render by clearing frame buffer's color buffer
  34120. if (successful) {
  34121. gl.clear(gl.COLOR_BUFFER_BIT);
  34122. successful = successful && (gl.getError() === gl.NO_ERROR);
  34123. }
  34124. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  34125. if (successful) {
  34126. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  34127. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  34128. var readFormat = gl.RGBA;
  34129. var readType = gl.UNSIGNED_BYTE;
  34130. var buffer = new Uint8Array(4);
  34131. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  34132. successful = successful && (gl.getError() === gl.NO_ERROR);
  34133. }
  34134. //clean up
  34135. gl.deleteTexture(texture);
  34136. gl.deleteFramebuffer(fb);
  34137. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  34138. //clear accumulated errors
  34139. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  34140. return successful;
  34141. };
  34142. /** @hidden */
  34143. Engine.prototype._getWebGLTextureType = function (type) {
  34144. if (this._webGLVersion === 1) {
  34145. switch (type) {
  34146. case Engine.TEXTURETYPE_FLOAT:
  34147. return this._gl.FLOAT;
  34148. case Engine.TEXTURETYPE_HALF_FLOAT:
  34149. return this._gl.HALF_FLOAT_OES;
  34150. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  34151. return this._gl.UNSIGNED_BYTE;
  34152. }
  34153. return this._gl.UNSIGNED_BYTE;
  34154. }
  34155. switch (type) {
  34156. case Engine.TEXTURETYPE_BYTE:
  34157. return this._gl.BYTE;
  34158. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  34159. return this._gl.UNSIGNED_BYTE;
  34160. case Engine.TEXTURETYPE_SHORT:
  34161. return this._gl.SHORT;
  34162. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  34163. return this._gl.UNSIGNED_SHORT;
  34164. case Engine.TEXTURETYPE_INT:
  34165. return this._gl.INT;
  34166. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  34167. return this._gl.UNSIGNED_INT;
  34168. case Engine.TEXTURETYPE_FLOAT:
  34169. return this._gl.FLOAT;
  34170. case Engine.TEXTURETYPE_HALF_FLOAT:
  34171. return this._gl.HALF_FLOAT;
  34172. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  34173. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  34174. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  34175. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  34176. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  34177. return this._gl.UNSIGNED_SHORT_5_6_5;
  34178. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  34179. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  34180. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  34181. return this._gl.UNSIGNED_INT_24_8;
  34182. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  34183. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  34184. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  34185. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  34186. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  34187. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  34188. }
  34189. return this._gl.UNSIGNED_BYTE;
  34190. };
  34191. Engine.prototype._getInternalFormat = function (format) {
  34192. var internalFormat = this._gl.RGBA;
  34193. switch (format) {
  34194. case Engine.TEXTUREFORMAT_ALPHA:
  34195. internalFormat = this._gl.ALPHA;
  34196. break;
  34197. case Engine.TEXTUREFORMAT_LUMINANCE:
  34198. internalFormat = this._gl.LUMINANCE;
  34199. break;
  34200. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  34201. internalFormat = this._gl.LUMINANCE_ALPHA;
  34202. break;
  34203. case Engine.TEXTUREFORMAT_RED:
  34204. internalFormat = this._gl.RED;
  34205. break;
  34206. case Engine.TEXTUREFORMAT_RG:
  34207. internalFormat = this._gl.RG;
  34208. break;
  34209. case Engine.TEXTUREFORMAT_RGB:
  34210. internalFormat = this._gl.RGB;
  34211. break;
  34212. case Engine.TEXTUREFORMAT_RGBA:
  34213. internalFormat = this._gl.RGBA;
  34214. break;
  34215. }
  34216. if (this._webGLVersion > 1) {
  34217. switch (format) {
  34218. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34219. internalFormat = this._gl.RED_INTEGER;
  34220. break;
  34221. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34222. internalFormat = this._gl.RG_INTEGER;
  34223. break;
  34224. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34225. internalFormat = this._gl.RGB_INTEGER;
  34226. break;
  34227. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34228. internalFormat = this._gl.RGBA_INTEGER;
  34229. break;
  34230. }
  34231. }
  34232. return internalFormat;
  34233. };
  34234. /** @hidden */
  34235. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  34236. if (this._webGLVersion === 1) {
  34237. if (format !== undefined) {
  34238. switch (format) {
  34239. case Engine.TEXTUREFORMAT_ALPHA:
  34240. return this._gl.ALPHA;
  34241. case Engine.TEXTUREFORMAT_LUMINANCE:
  34242. return this._gl.LUMINANCE;
  34243. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  34244. return this._gl.LUMINANCE_ALPHA;
  34245. }
  34246. }
  34247. return this._gl.RGBA;
  34248. }
  34249. switch (type) {
  34250. case Engine.TEXTURETYPE_BYTE:
  34251. switch (format) {
  34252. case Engine.TEXTUREFORMAT_RED:
  34253. return this._gl.R8_SNORM;
  34254. case Engine.TEXTUREFORMAT_RG:
  34255. return this._gl.RG8_SNORM;
  34256. case Engine.TEXTUREFORMAT_RGB:
  34257. return this._gl.RGB8_SNORM;
  34258. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34259. return this._gl.R8I;
  34260. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34261. return this._gl.RG8I;
  34262. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34263. return this._gl.RGB8I;
  34264. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34265. return this._gl.RGBA8I;
  34266. default:
  34267. return this._gl.RGBA8_SNORM;
  34268. }
  34269. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  34270. switch (format) {
  34271. case Engine.TEXTUREFORMAT_RED:
  34272. return this._gl.R8;
  34273. case Engine.TEXTUREFORMAT_RG:
  34274. return this._gl.RG8;
  34275. case Engine.TEXTUREFORMAT_RGB:
  34276. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  34277. case Engine.TEXTUREFORMAT_RGBA:
  34278. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  34279. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34280. return this._gl.R8UI;
  34281. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34282. return this._gl.RG8UI;
  34283. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34284. return this._gl.RGB8UI;
  34285. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34286. return this._gl.RGBA8UI;
  34287. default:
  34288. return this._gl.RGBA8;
  34289. }
  34290. case Engine.TEXTURETYPE_SHORT:
  34291. switch (format) {
  34292. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34293. return this._gl.R16I;
  34294. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34295. return this._gl.RG16I;
  34296. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34297. return this._gl.RGB16I;
  34298. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34299. return this._gl.RGBA16I;
  34300. default:
  34301. return this._gl.RGBA16I;
  34302. }
  34303. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  34304. switch (format) {
  34305. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34306. return this._gl.R16UI;
  34307. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34308. return this._gl.RG16UI;
  34309. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34310. return this._gl.RGB16UI;
  34311. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34312. return this._gl.RGBA16UI;
  34313. default:
  34314. return this._gl.RGBA16UI;
  34315. }
  34316. case Engine.TEXTURETYPE_INT:
  34317. switch (format) {
  34318. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34319. return this._gl.R32I;
  34320. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34321. return this._gl.RG32I;
  34322. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34323. return this._gl.RGB32I;
  34324. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34325. return this._gl.RGBA32I;
  34326. default:
  34327. return this._gl.RGBA32I;
  34328. }
  34329. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  34330. switch (format) {
  34331. case Engine.TEXTUREFORMAT_RED_INTEGER:
  34332. return this._gl.R32UI;
  34333. case Engine.TEXTUREFORMAT_RG_INTEGER:
  34334. return this._gl.RG32UI;
  34335. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  34336. return this._gl.RGB32UI;
  34337. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34338. return this._gl.RGBA32UI;
  34339. default:
  34340. return this._gl.RGBA32UI;
  34341. }
  34342. case Engine.TEXTURETYPE_FLOAT:
  34343. switch (format) {
  34344. case Engine.TEXTUREFORMAT_RED:
  34345. return this._gl.R32F; // By default. Other possibility is R16F.
  34346. case Engine.TEXTUREFORMAT_RG:
  34347. return this._gl.RG32F; // By default. Other possibility is RG16F.
  34348. case Engine.TEXTUREFORMAT_RGB:
  34349. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  34350. case Engine.TEXTUREFORMAT_RGBA:
  34351. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  34352. default:
  34353. return this._gl.RGBA32F;
  34354. }
  34355. case Engine.TEXTURETYPE_HALF_FLOAT:
  34356. switch (format) {
  34357. case Engine.TEXTUREFORMAT_RED:
  34358. return this._gl.R16F;
  34359. case Engine.TEXTUREFORMAT_RG:
  34360. return this._gl.RG16F;
  34361. case Engine.TEXTUREFORMAT_RGB:
  34362. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  34363. case Engine.TEXTUREFORMAT_RGBA:
  34364. return this._gl.RGBA16F;
  34365. default:
  34366. return this._gl.RGBA16F;
  34367. }
  34368. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  34369. return this._gl.RGB565;
  34370. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  34371. return this._gl.R11F_G11F_B10F;
  34372. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  34373. return this._gl.RGB9_E5;
  34374. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  34375. return this._gl.RGBA4;
  34376. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  34377. return this._gl.RGB5_A1;
  34378. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  34379. switch (format) {
  34380. case Engine.TEXTUREFORMAT_RGBA:
  34381. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  34382. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  34383. return this._gl.RGB10_A2UI;
  34384. default:
  34385. return this._gl.RGB10_A2;
  34386. }
  34387. }
  34388. return this._gl.RGBA8;
  34389. };
  34390. /** @hidden */
  34391. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  34392. if (type === Engine.TEXTURETYPE_FLOAT) {
  34393. return this._gl.RGBA32F;
  34394. }
  34395. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  34396. return this._gl.RGBA16F;
  34397. }
  34398. return this._gl.RGBA8;
  34399. };
  34400. /** @hidden */
  34401. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  34402. var _this = this;
  34403. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  34404. this._activeRequests.push(request);
  34405. request.onCompleteObservable.add(function (request) {
  34406. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  34407. });
  34408. return request;
  34409. };
  34410. /** @hidden */
  34411. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  34412. var _this = this;
  34413. return new Promise(function (resolve, reject) {
  34414. _this._loadFile(url, function (data) {
  34415. resolve(data);
  34416. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  34417. reject(exception);
  34418. });
  34419. });
  34420. };
  34421. Engine.prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  34422. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  34423. var onload = function (data) {
  34424. loadedFiles[index] = data;
  34425. loadedFiles._internalCount++;
  34426. if (loadedFiles._internalCount === 6) {
  34427. onfinish(loadedFiles);
  34428. }
  34429. };
  34430. var onerror = function (request, exception) {
  34431. if (onErrorCallBack && request) {
  34432. onErrorCallBack(request.status + " " + request.statusText, exception);
  34433. }
  34434. };
  34435. this._loadFile(url, onload, undefined, undefined, true, onerror);
  34436. };
  34437. Engine.prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  34438. if (onError === void 0) { onError = null; }
  34439. var loadedFiles = [];
  34440. loadedFiles._internalCount = 0;
  34441. for (var index = 0; index < 6; index++) {
  34442. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  34443. }
  34444. };
  34445. // Statics
  34446. /**
  34447. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  34448. * @returns true if the engine can be created
  34449. * @ignorenaming
  34450. */
  34451. Engine.isSupported = function () {
  34452. try {
  34453. var tempcanvas = document.createElement("canvas");
  34454. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  34455. return gl != null && !!window.WebGLRenderingContext;
  34456. }
  34457. catch (e) {
  34458. return false;
  34459. }
  34460. };
  34461. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34462. Engine.ExceptionList = [
  34463. { key: "Chrome\/63\.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  34464. { key: "Firefox\/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  34465. { key: "Firefox\/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  34466. { key: "Chrome\/72.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
  34467. { key: "Chrome\/73.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
  34468. { key: "Chrome\/74.+?Mobile", capture: null, captureConstraint: null, targets: ["vao"] },
  34469. { key: "Mac OS.+Chrome\/71", capture: null, captureConstraint: null, targets: ["vao"] },
  34470. { key: "Mac OS.+Chrome\/72", capture: null, captureConstraint: null, targets: ["vao"] }
  34471. ];
  34472. /**
  34473. * Hidden
  34474. */
  34475. Engine._TextureLoaders = [];
  34476. // Const statics
  34477. /** Defines that alpha blending is disabled */
  34478. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE;
  34479. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34480. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_ADD;
  34481. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34482. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE;
  34483. /** Defines that alpha blending to DEST - SRC * DEST */
  34484. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_SUBTRACT;
  34485. /** Defines that alpha blending to SRC * DEST */
  34486. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_MULTIPLY;
  34487. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34488. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_MAXIMIZED;
  34489. /** Defines that alpha blending to SRC + DEST */
  34490. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_ONEONE;
  34491. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34492. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_PREMULTIPLIED;
  34493. /**
  34494. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34495. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34496. */
  34497. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  34498. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34499. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_INTERPOLATE;
  34500. /**
  34501. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34502. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34503. */
  34504. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_SCREENMODE;
  34505. /** Defines that the ressource is not delayed*/
  34506. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DELAYLOADSTATE_NONE;
  34507. /** Defines that the ressource was successfully delay loaded */
  34508. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DELAYLOADSTATE_LOADED;
  34509. /** Defines that the ressource is currently delay loading */
  34510. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DELAYLOADSTATE_LOADING;
  34511. /** Defines that the ressource is delayed and has not started loading */
  34512. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DELAYLOADSTATE_NOTLOADED;
  34513. // Depht or Stencil test Constants.
  34514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34515. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].NEVER;
  34516. /** 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 */
  34517. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALWAYS;
  34518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34519. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].LESS;
  34520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34521. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].EQUAL;
  34522. /** 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 */
  34523. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].LEQUAL;
  34524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34525. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].GREATER;
  34526. /** 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 */
  34527. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].GEQUAL;
  34528. /** 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 */
  34529. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].NOTEQUAL;
  34530. // Stencil Actions Constants.
  34531. /** Passed to stencilOperation to specify that stencil value must be kept */
  34532. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].KEEP;
  34533. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34534. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].REPLACE;
  34535. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34536. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].INCR;
  34537. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34538. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DECR;
  34539. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34540. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].INVERT;
  34541. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34542. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].INCR_WRAP;
  34543. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34544. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].DECR_WRAP;
  34545. /** Texture is not repeating outside of 0..1 UVs */
  34546. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  34547. /** Texture is repeating outside of 0..1 UVs */
  34548. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  34549. /** Texture is repeating and mirrored */
  34550. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  34551. /** ALPHA */
  34552. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_ALPHA;
  34553. /** LUMINANCE */
  34554. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_LUMINANCE;
  34555. /** LUMINANCE_ALPHA */
  34556. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  34557. /** RGB */
  34558. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RGB;
  34559. /** RGBA */
  34560. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RGBA;
  34561. /** RED */
  34562. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RED;
  34563. /** RED (2nd reference) */
  34564. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_R;
  34565. /** RG */
  34566. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RG;
  34567. /** RED_INTEGER */
  34568. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  34569. /** RED_INTEGER (2nd reference) */
  34570. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_R_INTEGER;
  34571. /** RG_INTEGER */
  34572. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  34573. /** RGB_INTEGER */
  34574. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  34575. /** RGBA_INTEGER */
  34576. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  34577. /** UNSIGNED_BYTE */
  34578. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  34579. /** UNSIGNED_BYTE (2nd reference) */
  34580. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  34581. /** FLOAT */
  34582. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_FLOAT;
  34583. /** HALF_FLOAT */
  34584. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_HALF_FLOAT;
  34585. /** BYTE */
  34586. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_BYTE;
  34587. /** SHORT */
  34588. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_SHORT;
  34589. /** UNSIGNED_SHORT */
  34590. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  34591. /** INT */
  34592. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_INT;
  34593. /** UNSIGNED_INT */
  34594. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  34595. /** UNSIGNED_SHORT_4_4_4_4 */
  34596. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  34597. /** UNSIGNED_SHORT_5_5_5_1 */
  34598. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  34599. /** UNSIGNED_SHORT_5_6_5 */
  34600. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  34601. /** UNSIGNED_INT_2_10_10_10_REV */
  34602. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  34603. /** UNSIGNED_INT_24_8 */
  34604. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  34605. /** UNSIGNED_INT_10F_11F_11F_REV */
  34606. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  34607. /** UNSIGNED_INT_5_9_9_9_REV */
  34608. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  34609. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34610. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  34611. /** nearest is mag = nearest and min = nearest and mip = linear */
  34612. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  34613. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34614. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  34615. /** Trilinear is mag = linear and min = linear and mip = linear */
  34616. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  34617. /** nearest is mag = nearest and min = nearest and mip = linear */
  34618. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  34619. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34620. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  34621. /** Trilinear is mag = linear and min = linear and mip = linear */
  34622. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  34623. /** mag = nearest and min = nearest and mip = nearest */
  34624. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  34625. /** mag = nearest and min = linear and mip = nearest */
  34626. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  34627. /** mag = nearest and min = linear and mip = linear */
  34628. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  34629. /** mag = nearest and min = linear and mip = none */
  34630. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_LINEAR;
  34631. /** mag = nearest and min = nearest and mip = none */
  34632. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_NEAREST_NEAREST;
  34633. /** mag = linear and min = nearest and mip = nearest */
  34634. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  34635. /** mag = linear and min = nearest and mip = linear */
  34636. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  34637. /** mag = linear and min = linear and mip = none */
  34638. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_LINEAR;
  34639. /** mag = linear and min = nearest and mip = none */
  34640. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_LINEAR_NEAREST;
  34641. /** Explicit coordinates mode */
  34642. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_EXPLICIT_MODE;
  34643. /** Spherical coordinates mode */
  34644. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_SPHERICAL_MODE;
  34645. /** Planar coordinates mode */
  34646. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_PLANAR_MODE;
  34647. /** Cubic coordinates mode */
  34648. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_CUBIC_MODE;
  34649. /** Projection coordinates mode */
  34650. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_PROJECTION_MODE;
  34651. /** Skybox coordinates mode */
  34652. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_SKYBOX_MODE;
  34653. /** Inverse Cubic coordinates mode */
  34654. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_INVCUBIC_MODE;
  34655. /** Equirectangular coordinates mode */
  34656. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  34657. /** Equirectangular Fixed coordinates mode */
  34658. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  34659. /** Equirectangular Fixed Mirrored coordinates mode */
  34660. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  34661. // Texture rescaling mode
  34662. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34663. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].SCALEMODE_FLOOR;
  34664. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34665. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].SCALEMODE_NEAREST;
  34666. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34667. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].SCALEMODE_CEILING;
  34668. // Updatable statics so stick with vars here
  34669. /**
  34670. * Gets or sets the epsilon value used by collision engine
  34671. */
  34672. Engine.CollisionsEpsilon = 0.001;
  34673. /**
  34674. * Method called to create the default rescale post process on each engine.
  34675. */
  34676. Engine._RescalePostProcessFactory = null;
  34677. return Engine;
  34678. }());
  34679. /***/ }),
  34680. /***/ "./Engines/engineStore.ts":
  34681. /*!********************************!*\
  34682. !*** ./Engines/engineStore.ts ***!
  34683. \********************************/
  34684. /*! exports provided: EngineStore */
  34685. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34686. "use strict";
  34687. __webpack_require__.r(__webpack_exports__);
  34688. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  34689. /**
  34690. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34691. * during the life time of the application.
  34692. */
  34693. var EngineStore = /** @class */ (function () {
  34694. function EngineStore() {
  34695. }
  34696. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  34697. /**
  34698. * Gets the latest created engine
  34699. */
  34700. get: function () {
  34701. if (this.Instances.length === 0) {
  34702. return null;
  34703. }
  34704. return this.Instances[this.Instances.length - 1];
  34705. },
  34706. enumerable: true,
  34707. configurable: true
  34708. });
  34709. Object.defineProperty(EngineStore, "LastCreatedScene", {
  34710. /**
  34711. * Gets the latest created scene
  34712. */
  34713. get: function () {
  34714. var lastCreatedEngine = this.LastCreatedEngine;
  34715. if (!lastCreatedEngine) {
  34716. return null;
  34717. }
  34718. if (lastCreatedEngine.scenes.length === 0) {
  34719. return null;
  34720. }
  34721. return lastCreatedEngine.scenes[lastCreatedEngine.scenes.length - 1];
  34722. },
  34723. enumerable: true,
  34724. configurable: true
  34725. });
  34726. /** Gets the list of created engines */
  34727. EngineStore.Instances = new Array();
  34728. return EngineStore;
  34729. }());
  34730. /***/ }),
  34731. /***/ "./Engines/index.ts":
  34732. /*!**************************!*\
  34733. !*** ./Engines/index.ts ***!
  34734. \**************************/
  34735. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  34736. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34737. "use strict";
  34738. __webpack_require__.r(__webpack_exports__);
  34739. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  34740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  34741. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  34742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  34743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  34744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  34745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  34746. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  34747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  34748. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  34749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  34750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  34751. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  34752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  34753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  34754. /***/ }),
  34755. /***/ "./Engines/nullEngine.ts":
  34756. /*!*******************************!*\
  34757. !*** ./Engines/nullEngine.ts ***!
  34758. \*******************************/
  34759. /*! exports provided: NullEngineOptions, NullEngine */
  34760. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34761. "use strict";
  34762. __webpack_require__.r(__webpack_exports__);
  34763. /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  34764. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  34765. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34766. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  34767. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  34768. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  34769. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  34770. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  34771. /**
  34772. * Options to create the null engine
  34773. */
  34774. var NullEngineOptions = /** @class */ (function () {
  34775. function NullEngineOptions() {
  34776. /**
  34777. * Render width (Default: 512)
  34778. */
  34779. this.renderWidth = 512;
  34780. /**
  34781. * Render height (Default: 256)
  34782. */
  34783. this.renderHeight = 256;
  34784. /**
  34785. * Texture size (Default: 512)
  34786. */
  34787. this.textureSize = 512;
  34788. /**
  34789. * If delta time between frames should be constant
  34790. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34791. */
  34792. this.deterministicLockstep = false;
  34793. /**
  34794. * Maximum about of steps between frames (Default: 4)
  34795. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34796. */
  34797. this.lockstepMaxSteps = 4;
  34798. }
  34799. return NullEngineOptions;
  34800. }());
  34801. /**
  34802. * The null engine class provides support for headless version of babylon.js.
  34803. * This can be used in server side scenario or for testing purposes
  34804. */
  34805. var NullEngine = /** @class */ (function (_super) {
  34806. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  34807. function NullEngine(options) {
  34808. if (options === void 0) { options = new NullEngineOptions(); }
  34809. var _this = _super.call(this, null) || this;
  34810. if (options.deterministicLockstep === undefined) {
  34811. options.deterministicLockstep = false;
  34812. }
  34813. if (options.lockstepMaxSteps === undefined) {
  34814. options.lockstepMaxSteps = 4;
  34815. }
  34816. _this._options = options;
  34817. // Init caps
  34818. // We consider we are on a webgl1 capable device
  34819. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  34820. _this._caps.maxTexturesImageUnits = 16;
  34821. _this._caps.maxVertexTextureImageUnits = 16;
  34822. _this._caps.maxTextureSize = 512;
  34823. _this._caps.maxCubemapTextureSize = 512;
  34824. _this._caps.maxRenderTextureSize = 512;
  34825. _this._caps.maxVertexAttribs = 16;
  34826. _this._caps.maxVaryingVectors = 16;
  34827. _this._caps.maxFragmentUniformVectors = 16;
  34828. _this._caps.maxVertexUniformVectors = 16;
  34829. // Extensions
  34830. _this._caps.standardDerivatives = false;
  34831. _this._caps.astc = null;
  34832. _this._caps.s3tc = null;
  34833. _this._caps.pvrtc = null;
  34834. _this._caps.etc1 = null;
  34835. _this._caps.etc2 = null;
  34836. _this._caps.textureAnisotropicFilterExtension = null;
  34837. _this._caps.maxAnisotropy = 0;
  34838. _this._caps.uintIndices = false;
  34839. _this._caps.fragmentDepthSupported = false;
  34840. _this._caps.highPrecisionShaderSupported = true;
  34841. _this._caps.colorBufferFloat = false;
  34842. _this._caps.textureFloat = false;
  34843. _this._caps.textureFloatLinearFiltering = false;
  34844. _this._caps.textureFloatRender = false;
  34845. _this._caps.textureHalfFloat = false;
  34846. _this._caps.textureHalfFloatLinearFiltering = false;
  34847. _this._caps.textureHalfFloatRender = false;
  34848. _this._caps.textureLOD = false;
  34849. _this._caps.drawBuffersExtension = false;
  34850. _this._caps.depthTextureExtension = false;
  34851. _this._caps.vertexArrayObject = false;
  34852. _this._caps.instancedArrays = false;
  34853. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  34854. // Wrappers
  34855. var theCurrentGlobal = (typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : window);
  34856. if (typeof URL === "undefined") {
  34857. theCurrentGlobal.URL = {
  34858. createObjectURL: function () { },
  34859. revokeObjectURL: function () { }
  34860. };
  34861. }
  34862. if (typeof Blob === "undefined") {
  34863. theCurrentGlobal.Blob = function () { };
  34864. }
  34865. return _this;
  34866. }
  34867. /**
  34868. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34869. */
  34870. NullEngine.prototype.isDeterministicLockStep = function () {
  34871. return this._options.deterministicLockstep;
  34872. };
  34873. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  34874. NullEngine.prototype.getLockstepMaxSteps = function () {
  34875. return this._options.lockstepMaxSteps;
  34876. };
  34877. /**
  34878. * Sets hardware scaling, used to save performance if needed
  34879. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34880. */
  34881. NullEngine.prototype.getHardwareScalingLevel = function () {
  34882. return 1.0;
  34883. };
  34884. NullEngine.prototype.createVertexBuffer = function (vertices) {
  34885. return {
  34886. capacity: 0,
  34887. references: 1,
  34888. is32Bits: false
  34889. };
  34890. };
  34891. NullEngine.prototype.createIndexBuffer = function (indices) {
  34892. return {
  34893. capacity: 0,
  34894. references: 1,
  34895. is32Bits: false
  34896. };
  34897. };
  34898. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  34899. if (stencil === void 0) { stencil = false; }
  34900. };
  34901. NullEngine.prototype.getRenderWidth = function (useScreen) {
  34902. if (useScreen === void 0) { useScreen = false; }
  34903. if (!useScreen && this._currentRenderTarget) {
  34904. return this._currentRenderTarget.width;
  34905. }
  34906. return this._options.renderWidth;
  34907. };
  34908. NullEngine.prototype.getRenderHeight = function (useScreen) {
  34909. if (useScreen === void 0) { useScreen = false; }
  34910. if (!useScreen && this._currentRenderTarget) {
  34911. return this._currentRenderTarget.height;
  34912. }
  34913. return this._options.renderHeight;
  34914. };
  34915. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  34916. this._cachedViewport = viewport;
  34917. };
  34918. NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
  34919. return {
  34920. transformFeedback: null,
  34921. __SPECTOR_rebuildProgram: null,
  34922. isParallelCompiled: false
  34923. };
  34924. };
  34925. NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  34926. return [];
  34927. };
  34928. NullEngine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  34929. return [];
  34930. };
  34931. NullEngine.prototype.bindSamplers = function (effect) {
  34932. this._currentEffect = null;
  34933. };
  34934. NullEngine.prototype.enableEffect = function (effect) {
  34935. this._currentEffect = effect;
  34936. if (effect.onBind) {
  34937. effect.onBind(effect);
  34938. }
  34939. if (effect._onBindObservable) {
  34940. effect._onBindObservable.notifyObservers(effect);
  34941. }
  34942. };
  34943. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  34944. if (zOffset === void 0) { zOffset = 0; }
  34945. if (reverseSide === void 0) { reverseSide = false; }
  34946. };
  34947. NullEngine.prototype.setIntArray = function (uniform, array) {
  34948. };
  34949. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  34950. };
  34951. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  34952. };
  34953. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  34954. };
  34955. NullEngine.prototype.setFloatArray = function (uniform, array) {
  34956. };
  34957. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  34958. };
  34959. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  34960. };
  34961. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  34962. };
  34963. NullEngine.prototype.setArray = function (uniform, array) {
  34964. };
  34965. NullEngine.prototype.setArray2 = function (uniform, array) {
  34966. };
  34967. NullEngine.prototype.setArray3 = function (uniform, array) {
  34968. };
  34969. NullEngine.prototype.setArray4 = function (uniform, array) {
  34970. };
  34971. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  34972. };
  34973. NullEngine.prototype.setMatrix = function (uniform, matrix) {
  34974. };
  34975. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  34976. };
  34977. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  34978. };
  34979. NullEngine.prototype.setFloat = function (uniform, value) {
  34980. };
  34981. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  34982. };
  34983. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  34984. };
  34985. NullEngine.prototype.setBool = function (uniform, bool) {
  34986. };
  34987. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  34988. };
  34989. NullEngine.prototype.setColor3 = function (uniform, color3) {
  34990. };
  34991. NullEngine.prototype.setColor4 = function (uniform, color3, alpha) {
  34992. };
  34993. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  34994. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  34995. if (this._alphaMode === mode) {
  34996. return;
  34997. }
  34998. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34999. if (!noDepthWriteChange) {
  35000. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  35001. }
  35002. this._alphaMode = mode;
  35003. };
  35004. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  35005. };
  35006. NullEngine.prototype.wipeCaches = function (bruteForce) {
  35007. if (this.preventCacheWipeBetweenFrames) {
  35008. return;
  35009. }
  35010. this.resetTextureCache();
  35011. this._currentEffect = null;
  35012. if (bruteForce) {
  35013. this._currentProgram = null;
  35014. this._stencilState.reset();
  35015. this._depthCullingState.reset();
  35016. this._alphaState.reset();
  35017. }
  35018. this._cachedVertexBuffers = null;
  35019. this._cachedIndexBuffer = null;
  35020. this._cachedEffectForVertexBuffers = null;
  35021. };
  35022. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  35023. };
  35024. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  35025. };
  35026. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  35027. };
  35028. /** @hidden */
  35029. NullEngine.prototype._createTexture = function () {
  35030. return {};
  35031. };
  35032. /** @hidden */
  35033. NullEngine.prototype._releaseTexture = function (texture) {
  35034. };
  35035. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  35036. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  35037. if (onLoad === void 0) { onLoad = null; }
  35038. if (onError === void 0) { onError = null; }
  35039. if (buffer === void 0) { buffer = null; }
  35040. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  35041. var url = String(urlArg);
  35042. texture.url = url;
  35043. texture.generateMipMaps = !noMipmap;
  35044. texture.samplingMode = samplingMode;
  35045. texture.invertY = invertY;
  35046. texture.baseWidth = this._options.textureSize;
  35047. texture.baseHeight = this._options.textureSize;
  35048. texture.width = this._options.textureSize;
  35049. texture.height = this._options.textureSize;
  35050. if (format) {
  35051. texture.format = format;
  35052. }
  35053. texture.isReady = true;
  35054. if (onLoad) {
  35055. onLoad();
  35056. }
  35057. this._internalTexturesCache.push(texture);
  35058. return texture;
  35059. };
  35060. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  35061. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  35062. if (options !== undefined && typeof options === "object") {
  35063. fullOptions.generateMipMaps = options.generateMipMaps;
  35064. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  35065. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  35066. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  35067. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  35068. }
  35069. else {
  35070. fullOptions.generateMipMaps = options;
  35071. fullOptions.generateDepthBuffer = true;
  35072. fullOptions.generateStencilBuffer = false;
  35073. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  35074. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  35075. }
  35076. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  35077. var width = size.width || size;
  35078. var height = size.height || size;
  35079. texture._depthStencilBuffer = {};
  35080. texture._framebuffer = {};
  35081. texture.baseWidth = width;
  35082. texture.baseHeight = height;
  35083. texture.width = width;
  35084. texture.height = height;
  35085. texture.isReady = true;
  35086. texture.samples = 1;
  35087. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  35088. texture.samplingMode = fullOptions.samplingMode;
  35089. texture.type = fullOptions.type;
  35090. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  35091. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  35092. this._internalTexturesCache.push(texture);
  35093. return texture;
  35094. };
  35095. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  35096. texture.samplingMode = samplingMode;
  35097. };
  35098. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  35099. if (this._currentRenderTarget) {
  35100. this.unBindFramebuffer(this._currentRenderTarget);
  35101. }
  35102. this._currentRenderTarget = texture;
  35103. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  35104. if (this._cachedViewport && !forceFullscreenViewport) {
  35105. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  35106. }
  35107. };
  35108. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  35109. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  35110. this._currentRenderTarget = null;
  35111. if (onBeforeUnbind) {
  35112. if (texture._MSAAFramebuffer) {
  35113. this._currentFramebuffer = texture._framebuffer;
  35114. }
  35115. onBeforeUnbind();
  35116. }
  35117. this._currentFramebuffer = null;
  35118. };
  35119. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  35120. var vbo = {
  35121. capacity: 1,
  35122. references: 1,
  35123. is32Bits: false
  35124. };
  35125. return vbo;
  35126. };
  35127. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  35128. if (premulAlpha === void 0) { premulAlpha = false; }
  35129. };
  35130. NullEngine.prototype.areAllEffectsReady = function () {
  35131. return true;
  35132. };
  35133. /**
  35134. * @hidden
  35135. * Get the current error code of the webGL context
  35136. * @returns the error code
  35137. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35138. */
  35139. NullEngine.prototype.getError = function () {
  35140. return 0;
  35141. };
  35142. /** @hidden */
  35143. NullEngine.prototype._getUnpackAlignement = function () {
  35144. return 1;
  35145. };
  35146. /** @hidden */
  35147. NullEngine.prototype._unpackFlipY = function (value) {
  35148. };
  35149. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  35150. if (offset === void 0) { offset = 0; }
  35151. };
  35152. /**
  35153. * Updates a dynamic vertex buffer.
  35154. * @param vertexBuffer the vertex buffer to update
  35155. * @param data the data used to update the vertex buffer
  35156. * @param byteOffset the byte offset of the data (optional)
  35157. * @param byteLength the byte length of the data (optional)
  35158. */
  35159. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  35160. };
  35161. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  35162. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  35163. this._boundTexturesCache[this._activeChannel] = texture;
  35164. return true;
  35165. }
  35166. return false;
  35167. };
  35168. /** @hidden */
  35169. NullEngine.prototype._bindTexture = function (channel, texture) {
  35170. if (channel < 0) {
  35171. return;
  35172. }
  35173. this._bindTextureDirectly(0, texture);
  35174. };
  35175. /** @hidden */
  35176. NullEngine.prototype._releaseBuffer = function (buffer) {
  35177. buffer.references--;
  35178. if (buffer.references === 0) {
  35179. return true;
  35180. }
  35181. return false;
  35182. };
  35183. NullEngine.prototype.releaseEffects = function () {
  35184. };
  35185. NullEngine.prototype.displayLoadingUI = function () {
  35186. };
  35187. NullEngine.prototype.hideLoadingUI = function () {
  35188. };
  35189. /** @hidden */
  35190. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  35191. if (faceIndex === void 0) { faceIndex = 0; }
  35192. if (lod === void 0) { lod = 0; }
  35193. };
  35194. /** @hidden */
  35195. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  35196. if (faceIndex === void 0) { faceIndex = 0; }
  35197. if (lod === void 0) { lod = 0; }
  35198. };
  35199. /** @hidden */
  35200. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  35201. if (faceIndex === void 0) { faceIndex = 0; }
  35202. if (lod === void 0) { lod = 0; }
  35203. };
  35204. /** @hidden */
  35205. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  35206. if (faceIndex === void 0) { faceIndex = 0; }
  35207. if (lod === void 0) { lod = 0; }
  35208. };
  35209. return NullEngine;
  35210. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  35211. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  35212. /***/ }),
  35213. /***/ "./Events/clipboardEvents.ts":
  35214. /*!***********************************!*\
  35215. !*** ./Events/clipboardEvents.ts ***!
  35216. \***********************************/
  35217. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  35218. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35219. "use strict";
  35220. __webpack_require__.r(__webpack_exports__);
  35221. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  35222. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  35223. /**
  35224. * Gather the list of clipboard event types as constants.
  35225. */
  35226. var ClipboardEventTypes = /** @class */ (function () {
  35227. function ClipboardEventTypes() {
  35228. }
  35229. /**
  35230. * The clipboard event is fired when a copy command is active (pressed).
  35231. */
  35232. ClipboardEventTypes.COPY = 0x01; //
  35233. /**
  35234. * The clipboard event is fired when a cut command is active (pressed).
  35235. */
  35236. ClipboardEventTypes.CUT = 0x02;
  35237. /**
  35238. * The clipboard event is fired when a paste command is active (pressed).
  35239. */
  35240. ClipboardEventTypes.PASTE = 0x03;
  35241. return ClipboardEventTypes;
  35242. }());
  35243. /**
  35244. * This class is used to store clipboard related info for the onClipboardObservable event.
  35245. */
  35246. var ClipboardInfo = /** @class */ (function () {
  35247. /**
  35248. *Creates an instance of ClipboardInfo.
  35249. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  35250. * @param event Defines the related dom event
  35251. */
  35252. function ClipboardInfo(
  35253. /**
  35254. * Defines the type of event (BABYLON.ClipboardEventTypes)
  35255. */
  35256. type,
  35257. /**
  35258. * Defines the related dom event
  35259. */
  35260. event) {
  35261. this.type = type;
  35262. this.event = event;
  35263. }
  35264. /**
  35265. * Get the clipboard event's type from the keycode.
  35266. * @param keyCode Defines the keyCode for the current keyboard event.
  35267. * @return {number}
  35268. */
  35269. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  35270. var charCode = keyCode;
  35271. //TODO: add codes for extended ASCII
  35272. switch (charCode) {
  35273. case 67: return ClipboardEventTypes.COPY;
  35274. case 86: return ClipboardEventTypes.PASTE;
  35275. case 88: return ClipboardEventTypes.CUT;
  35276. default: return -1;
  35277. }
  35278. };
  35279. return ClipboardInfo;
  35280. }());
  35281. /***/ }),
  35282. /***/ "./Events/index.ts":
  35283. /*!*************************!*\
  35284. !*** ./Events/index.ts ***!
  35285. \*************************/
  35286. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  35287. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35288. "use strict";
  35289. __webpack_require__.r(__webpack_exports__);
  35290. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  35291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  35292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  35293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  35294. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  35295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  35296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  35297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  35298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  35299. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  35300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  35301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  35302. /***/ }),
  35303. /***/ "./Events/keyboardEvents.ts":
  35304. /*!**********************************!*\
  35305. !*** ./Events/keyboardEvents.ts ***!
  35306. \**********************************/
  35307. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  35308. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35309. "use strict";
  35310. __webpack_require__.r(__webpack_exports__);
  35311. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  35312. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  35313. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  35314. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35315. /**
  35316. * Gather the list of keyboard event types as constants.
  35317. */
  35318. var KeyboardEventTypes = /** @class */ (function () {
  35319. function KeyboardEventTypes() {
  35320. }
  35321. /**
  35322. * The keydown event is fired when a key becomes active (pressed).
  35323. */
  35324. KeyboardEventTypes.KEYDOWN = 0x01;
  35325. /**
  35326. * The keyup event is fired when a key has been released.
  35327. */
  35328. KeyboardEventTypes.KEYUP = 0x02;
  35329. return KeyboardEventTypes;
  35330. }());
  35331. /**
  35332. * This class is used to store keyboard related info for the onKeyboardObservable event.
  35333. */
  35334. var KeyboardInfo = /** @class */ (function () {
  35335. /**
  35336. * Instantiates a new keyboard info.
  35337. * This class is used to store keyboard related info for the onKeyboardObservable event.
  35338. * @param type Defines the type of event (KeyboardEventTypes)
  35339. * @param event Defines the related dom event
  35340. */
  35341. function KeyboardInfo(
  35342. /**
  35343. * Defines the type of event (KeyboardEventTypes)
  35344. */
  35345. type,
  35346. /**
  35347. * Defines the related dom event
  35348. */
  35349. event) {
  35350. this.type = type;
  35351. this.event = event;
  35352. }
  35353. return KeyboardInfo;
  35354. }());
  35355. /**
  35356. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  35357. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  35358. */
  35359. var KeyboardInfoPre = /** @class */ (function (_super) {
  35360. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  35361. /**
  35362. * Instantiates a new keyboard pre info.
  35363. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  35364. * @param type Defines the type of event (KeyboardEventTypes)
  35365. * @param event Defines the related dom event
  35366. */
  35367. function KeyboardInfoPre(
  35368. /**
  35369. * Defines the type of event (KeyboardEventTypes)
  35370. */
  35371. type,
  35372. /**
  35373. * Defines the related dom event
  35374. */
  35375. event) {
  35376. var _this = _super.call(this, type, event) || this;
  35377. _this.type = type;
  35378. _this.event = event;
  35379. _this.skipOnPointerObservable = false;
  35380. return _this;
  35381. }
  35382. return KeyboardInfoPre;
  35383. }(KeyboardInfo));
  35384. /***/ }),
  35385. /***/ "./Events/pointerEvents.ts":
  35386. /*!*********************************!*\
  35387. !*** ./Events/pointerEvents.ts ***!
  35388. \*********************************/
  35389. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  35390. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35391. "use strict";
  35392. __webpack_require__.r(__webpack_exports__);
  35393. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  35394. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  35395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  35396. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  35397. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35398. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  35399. /**
  35400. * Gather the list of pointer event types as constants.
  35401. */
  35402. var PointerEventTypes = /** @class */ (function () {
  35403. function PointerEventTypes() {
  35404. }
  35405. /**
  35406. * 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.
  35407. */
  35408. PointerEventTypes.POINTERDOWN = 0x01;
  35409. /**
  35410. * The pointerup event is fired when a pointer is no longer active.
  35411. */
  35412. PointerEventTypes.POINTERUP = 0x02;
  35413. /**
  35414. * The pointermove event is fired when a pointer changes coordinates.
  35415. */
  35416. PointerEventTypes.POINTERMOVE = 0x04;
  35417. /**
  35418. * The pointerwheel event is fired when a mouse wheel has been rotated.
  35419. */
  35420. PointerEventTypes.POINTERWHEEL = 0x08;
  35421. /**
  35422. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  35423. */
  35424. PointerEventTypes.POINTERPICK = 0x10;
  35425. /**
  35426. * The pointertap event is fired when a the object has been touched and released without drag.
  35427. */
  35428. PointerEventTypes.POINTERTAP = 0x20;
  35429. /**
  35430. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  35431. */
  35432. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  35433. return PointerEventTypes;
  35434. }());
  35435. /**
  35436. * Base class of pointer info types.
  35437. */
  35438. var PointerInfoBase = /** @class */ (function () {
  35439. /**
  35440. * Instantiates the base class of pointers info.
  35441. * @param type Defines the type of event (PointerEventTypes)
  35442. * @param event Defines the related dom event
  35443. */
  35444. function PointerInfoBase(
  35445. /**
  35446. * Defines the type of event (PointerEventTypes)
  35447. */
  35448. type,
  35449. /**
  35450. * Defines the related dom event
  35451. */
  35452. event) {
  35453. this.type = type;
  35454. this.event = event;
  35455. }
  35456. return PointerInfoBase;
  35457. }());
  35458. /**
  35459. * This class is used to store pointer related info for the onPrePointerObservable event.
  35460. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  35461. */
  35462. var PointerInfoPre = /** @class */ (function (_super) {
  35463. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  35464. /**
  35465. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  35466. * @param type Defines the type of event (PointerEventTypes)
  35467. * @param event Defines the related dom event
  35468. * @param localX Defines the local x coordinates of the pointer when the event occured
  35469. * @param localY Defines the local y coordinates of the pointer when the event occured
  35470. */
  35471. function PointerInfoPre(type, event, localX, localY) {
  35472. var _this = _super.call(this, type, event) || this;
  35473. /**
  35474. * Ray from a pointer if availible (eg. 6dof controller)
  35475. */
  35476. _this.ray = null;
  35477. _this.skipOnPointerObservable = false;
  35478. _this.localPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  35479. return _this;
  35480. }
  35481. return PointerInfoPre;
  35482. }(PointerInfoBase));
  35483. /**
  35484. * This type contains all the data related to a pointer event in Babylon.js.
  35485. * 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.
  35486. */
  35487. var PointerInfo = /** @class */ (function (_super) {
  35488. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  35489. /**
  35490. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  35491. * @param type Defines the type of event (PointerEventTypes)
  35492. * @param event Defines the related dom event
  35493. * @param pickInfo Defines the picking info associated to the info (if any)\
  35494. */
  35495. function PointerInfo(type, event,
  35496. /**
  35497. * Defines the picking info associated to the info (if any)\
  35498. */
  35499. pickInfo) {
  35500. var _this = _super.call(this, type, event) || this;
  35501. _this.pickInfo = pickInfo;
  35502. return _this;
  35503. }
  35504. return PointerInfo;
  35505. }(PointerInfoBase));
  35506. /***/ }),
  35507. /***/ "./Gamepads/Controllers/daydreamController.ts":
  35508. /*!****************************************************!*\
  35509. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  35510. \****************************************************/
  35511. /*! exports provided: DaydreamController */
  35512. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35513. "use strict";
  35514. __webpack_require__.r(__webpack_exports__);
  35515. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  35516. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35517. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  35518. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35519. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35520. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35521. /**
  35522. * Google Daydream controller
  35523. */
  35524. var DaydreamController = /** @class */ (function (_super) {
  35525. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  35526. /**
  35527. * Creates a new DaydreamController from a gamepad
  35528. * @param vrGamepad the gamepad that the controller should be created from
  35529. */
  35530. function DaydreamController(vrGamepad) {
  35531. var _this = _super.call(this, vrGamepad) || this;
  35532. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  35533. return _this;
  35534. }
  35535. /**
  35536. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35537. * @param scene scene in which to add meshes
  35538. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35539. */
  35540. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35541. var _this = this;
  35542. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  35543. _this._defaultModel = newMeshes[1];
  35544. _this.attachToMesh(_this._defaultModel);
  35545. if (meshLoaded) {
  35546. meshLoaded(_this._defaultModel);
  35547. }
  35548. });
  35549. };
  35550. /**
  35551. * Called once for each button that changed state since the last frame
  35552. * @param buttonIdx Which button index changed
  35553. * @param state New state of the button
  35554. * @param changes Which properties on the state changed since last frame
  35555. */
  35556. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35557. // Daydream controller only has 1 GamepadButton (on the trackpad).
  35558. if (buttonIdx === 0) {
  35559. var observable = this.onTriggerStateChangedObservable;
  35560. if (observable) {
  35561. observable.notifyObservers(state);
  35562. }
  35563. }
  35564. else {
  35565. // If the app or home buttons are ever made available
  35566. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  35567. }
  35568. };
  35569. /**
  35570. * Base Url for the controller model.
  35571. */
  35572. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35573. /**
  35574. * File name for the controller model.
  35575. */
  35576. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  35577. /**
  35578. * Gamepad Id prefix used to identify Daydream Controller.
  35579. */
  35580. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  35581. return DaydreamController;
  35582. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35583. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35584. canCreate: function (gamepadInfo) {
  35585. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  35586. },
  35587. create: function (gamepadInfo) {
  35588. return new DaydreamController(gamepadInfo);
  35589. }
  35590. });
  35591. /***/ }),
  35592. /***/ "./Gamepads/Controllers/gearVRController.ts":
  35593. /*!**************************************************!*\
  35594. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  35595. \**************************************************/
  35596. /*! exports provided: GearVRController */
  35597. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35598. "use strict";
  35599. __webpack_require__.r(__webpack_exports__);
  35600. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  35601. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35602. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35603. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  35604. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35605. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35606. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35607. /**
  35608. * Gear VR Controller
  35609. */
  35610. var GearVRController = /** @class */ (function (_super) {
  35611. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  35612. /**
  35613. * Creates a new GearVRController from a gamepad
  35614. * @param vrGamepad the gamepad that the controller should be created from
  35615. */
  35616. function GearVRController(vrGamepad) {
  35617. var _this = _super.call(this, vrGamepad) || this;
  35618. _this._buttonIndexToObservableNameMap = [
  35619. 'onPadStateChangedObservable',
  35620. 'onTriggerStateChangedObservable' // Trigger
  35621. ];
  35622. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  35623. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  35624. _this._calculatedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  35625. _this._disableTrackPosition(_this._calculatedPosition);
  35626. return _this;
  35627. }
  35628. /**
  35629. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35630. * @param scene scene in which to add meshes
  35631. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35632. */
  35633. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35634. var _this = this;
  35635. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  35636. // Offset the controller so it will rotate around the users wrist
  35637. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  35638. newMeshes[1].parent = mesh;
  35639. newMeshes[1].position.z = -0.15;
  35640. _this._defaultModel = mesh;
  35641. _this.attachToMesh(_this._defaultModel);
  35642. if (meshLoaded) {
  35643. meshLoaded(_this._defaultModel);
  35644. }
  35645. });
  35646. };
  35647. /**
  35648. * Called once for each button that changed state since the last frame
  35649. * @param buttonIdx Which button index changed
  35650. * @param state New state of the button
  35651. * @param changes Which properties on the state changed since last frame
  35652. */
  35653. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35654. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  35655. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  35656. // Only emit events for buttons that we know how to map from index to observable
  35657. var observable = this[observableName];
  35658. if (observable) {
  35659. observable.notifyObservers(state);
  35660. }
  35661. }
  35662. };
  35663. /**
  35664. * Base Url for the controller model.
  35665. */
  35666. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35667. /**
  35668. * File name for the controller model.
  35669. */
  35670. GearVRController.MODEL_FILENAME = 'generic.babylon';
  35671. /**
  35672. * Gamepad Id prefix used to identify this controller.
  35673. */
  35674. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  35675. return GearVRController;
  35676. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  35677. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35678. canCreate: function (gamepadInfo) {
  35679. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  35680. gamepadInfo.id.indexOf('Oculus Go') !== -1;
  35681. },
  35682. create: function (gamepadInfo) {
  35683. return new GearVRController(gamepadInfo);
  35684. }
  35685. });
  35686. /***/ }),
  35687. /***/ "./Gamepads/Controllers/genericController.ts":
  35688. /*!***************************************************!*\
  35689. !*** ./Gamepads/Controllers/genericController.ts ***!
  35690. \***************************************************/
  35691. /*! exports provided: GenericController */
  35692. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35693. "use strict";
  35694. __webpack_require__.r(__webpack_exports__);
  35695. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  35696. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35697. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35698. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35699. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35700. /**
  35701. * Generic Controller
  35702. */
  35703. var GenericController = /** @class */ (function (_super) {
  35704. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  35705. /**
  35706. * Creates a new GenericController from a gamepad
  35707. * @param vrGamepad the gamepad that the controller should be created from
  35708. */
  35709. function GenericController(vrGamepad) {
  35710. return _super.call(this, vrGamepad) || this;
  35711. }
  35712. /**
  35713. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35714. * @param scene scene in which to add meshes
  35715. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35716. */
  35717. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35718. var _this = this;
  35719. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  35720. _this._defaultModel = newMeshes[1];
  35721. _this.attachToMesh(_this._defaultModel);
  35722. if (meshLoaded) {
  35723. meshLoaded(_this._defaultModel);
  35724. }
  35725. });
  35726. };
  35727. /**
  35728. * Called once for each button that changed state since the last frame
  35729. * @param buttonIdx Which button index changed
  35730. * @param state New state of the button
  35731. * @param changes Which properties on the state changed since last frame
  35732. */
  35733. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35734. console.log("Button id: " + buttonIdx + "state: ");
  35735. console.dir(state);
  35736. };
  35737. /**
  35738. * Base Url for the controller model.
  35739. */
  35740. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  35741. /**
  35742. * File name for the controller model.
  35743. */
  35744. GenericController.MODEL_FILENAME = 'generic.babylon';
  35745. return GenericController;
  35746. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  35747. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  35748. /***/ }),
  35749. /***/ "./Gamepads/Controllers/index.ts":
  35750. /*!***************************************!*\
  35751. !*** ./Gamepads/Controllers/index.ts ***!
  35752. \***************************************/
  35753. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  35754. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35755. "use strict";
  35756. __webpack_require__.r(__webpack_exports__);
  35757. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  35758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  35759. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  35760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  35761. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  35762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  35763. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  35764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  35765. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  35767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  35768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  35769. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  35770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  35771. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  35773. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  35774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  35775. /***/ }),
  35776. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  35777. /*!*******************************************************!*\
  35778. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  35779. \*******************************************************/
  35780. /*! exports provided: OculusTouchController */
  35781. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35782. "use strict";
  35783. __webpack_require__.r(__webpack_exports__);
  35784. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  35785. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35786. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35787. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35788. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35789. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35790. /**
  35791. * Oculus Touch Controller
  35792. */
  35793. var OculusTouchController = /** @class */ (function (_super) {
  35794. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  35795. /**
  35796. * Creates a new OculusTouchController from a gamepad
  35797. * @param vrGamepad the gamepad that the controller should be created from
  35798. */
  35799. function OculusTouchController(vrGamepad) {
  35800. var _this = _super.call(this, vrGamepad) || this;
  35801. /**
  35802. * Fired when the secondary trigger on this controller is modified
  35803. */
  35804. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35805. /**
  35806. * Fired when the thumb rest on this controller is modified
  35807. */
  35808. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35809. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  35810. return _this;
  35811. }
  35812. /**
  35813. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35814. * @param scene scene in which to add meshes
  35815. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35816. */
  35817. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35818. var _this = this;
  35819. var meshName;
  35820. // Hand
  35821. if (this.hand === 'left') {
  35822. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  35823. }
  35824. else { // Right is the default if no hand is specified
  35825. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  35826. }
  35827. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  35828. /*
  35829. Parent Mesh name: oculus_touch_left
  35830. - body
  35831. - trigger
  35832. - thumbstick
  35833. - grip
  35834. - button_y
  35835. - button_x
  35836. - button_enter
  35837. */
  35838. _this._defaultModel = newMeshes[1];
  35839. _this.attachToMesh(_this._defaultModel);
  35840. if (meshLoaded) {
  35841. meshLoaded(_this._defaultModel);
  35842. }
  35843. });
  35844. };
  35845. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  35846. /**
  35847. * Fired when the A button on this controller is modified
  35848. */
  35849. get: function () {
  35850. if (this.hand === 'right') {
  35851. return this.onMainButtonStateChangedObservable;
  35852. }
  35853. else {
  35854. throw new Error('No A button on left hand');
  35855. }
  35856. },
  35857. enumerable: true,
  35858. configurable: true
  35859. });
  35860. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  35861. /**
  35862. * Fired when the B button on this controller is modified
  35863. */
  35864. get: function () {
  35865. if (this.hand === 'right') {
  35866. return this.onSecondaryButtonStateChangedObservable;
  35867. }
  35868. else {
  35869. throw new Error('No B button on left hand');
  35870. }
  35871. },
  35872. enumerable: true,
  35873. configurable: true
  35874. });
  35875. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  35876. /**
  35877. * Fired when the X button on this controller is modified
  35878. */
  35879. get: function () {
  35880. if (this.hand === 'left') {
  35881. return this.onMainButtonStateChangedObservable;
  35882. }
  35883. else {
  35884. throw new Error('No X button on right hand');
  35885. }
  35886. },
  35887. enumerable: true,
  35888. configurable: true
  35889. });
  35890. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  35891. /**
  35892. * Fired when the Y button on this controller is modified
  35893. */
  35894. get: function () {
  35895. if (this.hand === 'left') {
  35896. return this.onSecondaryButtonStateChangedObservable;
  35897. }
  35898. else {
  35899. throw new Error('No Y button on right hand');
  35900. }
  35901. },
  35902. enumerable: true,
  35903. configurable: true
  35904. });
  35905. /**
  35906. * Called once for each button that changed state since the last frame
  35907. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  35908. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  35909. * 2) secondary trigger (same)
  35910. * 3) A (right) X (left), touch, pressed = value
  35911. * 4) B / Y
  35912. * 5) thumb rest
  35913. * @param buttonIdx Which button index changed
  35914. * @param state New state of the button
  35915. * @param changes Which properties on the state changed since last frame
  35916. */
  35917. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35918. var notifyObject = state; //{ state: state, changes: changes };
  35919. var triggerDirection = this.hand === 'right' ? -1 : 1;
  35920. switch (buttonIdx) {
  35921. case 0:
  35922. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35923. return;
  35924. case 1: // index trigger
  35925. if (this._defaultModel) {
  35926. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  35927. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  35928. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  35929. }
  35930. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35931. return;
  35932. case 2: // secondary trigger
  35933. if (this._defaultModel) {
  35934. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  35935. }
  35936. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  35937. return;
  35938. case 3:
  35939. if (this._defaultModel) {
  35940. if (notifyObject.pressed) {
  35941. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  35942. }
  35943. else {
  35944. (this._defaultModel.getChildren()[1]).position.y = 0;
  35945. }
  35946. }
  35947. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35948. return;
  35949. case 4:
  35950. if (this._defaultModel) {
  35951. if (notifyObject.pressed) {
  35952. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35953. }
  35954. else {
  35955. (this._defaultModel.getChildren()[2]).position.y = 0;
  35956. }
  35957. }
  35958. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35959. return;
  35960. case 5:
  35961. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  35962. return;
  35963. }
  35964. };
  35965. /**
  35966. * Base Url for the controller model.
  35967. */
  35968. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  35969. /**
  35970. * File name for the left controller model.
  35971. */
  35972. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  35973. /**
  35974. * File name for the right controller model.
  35975. */
  35976. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  35977. return OculusTouchController;
  35978. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35979. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35980. canCreate: function (gamepadInfo) {
  35981. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  35982. },
  35983. create: function (gamepadInfo) {
  35984. return new OculusTouchController(gamepadInfo);
  35985. }
  35986. });
  35987. /***/ }),
  35988. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  35989. /*!*******************************************************!*\
  35990. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  35991. \*******************************************************/
  35992. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  35993. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35994. "use strict";
  35995. __webpack_require__.r(__webpack_exports__);
  35996. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  35997. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  35998. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  35999. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36000. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36001. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  36002. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  36003. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  36004. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  36005. /**
  36006. * Defines the types of pose enabled controllers that are supported
  36007. */
  36008. var PoseEnabledControllerType;
  36009. (function (PoseEnabledControllerType) {
  36010. /**
  36011. * HTC Vive
  36012. */
  36013. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  36014. /**
  36015. * Oculus Rift
  36016. */
  36017. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  36018. /**
  36019. * Windows mixed reality
  36020. */
  36021. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  36022. /**
  36023. * Samsung gear VR
  36024. */
  36025. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  36026. /**
  36027. * Google Daydream
  36028. */
  36029. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  36030. /**
  36031. * Generic
  36032. */
  36033. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  36034. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  36035. /**
  36036. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  36037. */
  36038. var PoseEnabledControllerHelper = /** @class */ (function () {
  36039. function PoseEnabledControllerHelper() {
  36040. }
  36041. /**
  36042. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  36043. * @param vrGamepad the gamepad to initialized
  36044. * @returns a vr controller of the type the gamepad identified as
  36045. */
  36046. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  36047. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  36048. var factory = _a[_i];
  36049. if (factory.canCreate(vrGamepad)) {
  36050. return factory.create(vrGamepad);
  36051. }
  36052. }
  36053. if (this._DefaultControllerFactory) {
  36054. return this._DefaultControllerFactory(vrGamepad);
  36055. }
  36056. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  36057. };
  36058. /** @hidden */
  36059. PoseEnabledControllerHelper._ControllerFactories = [];
  36060. /** @hidden */
  36061. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  36062. return PoseEnabledControllerHelper;
  36063. }());
  36064. /**
  36065. * Defines the PoseEnabledController object that contains state of a vr capable controller
  36066. */
  36067. var PoseEnabledController = /** @class */ (function (_super) {
  36068. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  36069. /**
  36070. * Creates a new PoseEnabledController from a gamepad
  36071. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  36072. */
  36073. function PoseEnabledController(browserGamepad) {
  36074. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  36075. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  36076. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36077. _this._deviceRoomRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36078. /**
  36079. * The device position in babylon space
  36080. */
  36081. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36082. /**
  36083. * The device rotation in babylon space
  36084. */
  36085. _this.deviceRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36086. /**
  36087. * The scale factor of the device in babylon space
  36088. */
  36089. _this.deviceScaleFactor = 1;
  36090. // Used to convert 6dof controllers to 3dof
  36091. _this._trackPosition = true;
  36092. _this._maxRotationDistFromHeadset = Math.PI / 5;
  36093. _this._draggedRoomRotation = 0;
  36094. _this._leftHandSystemQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36095. /**
  36096. * Internal, matrix used to convert room space to babylon space
  36097. * @hidden
  36098. */
  36099. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  36100. /**
  36101. * Node to be used when casting a ray from the controller
  36102. * @hidden
  36103. */
  36104. _this._pointingPoseNode = null;
  36105. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  36106. /**
  36107. * @hidden
  36108. */
  36109. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36110. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  36111. _this.controllerType = PoseEnabledControllerType.GENERIC;
  36112. _this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36113. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36114. _this._calculatedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  36115. _this._calculatedRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36116. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  36117. return _this;
  36118. }
  36119. /**
  36120. * @hidden
  36121. */
  36122. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  36123. if (this._trackPosition) {
  36124. this._calculatedPosition.copyFrom(fixedPosition);
  36125. this._trackPosition = false;
  36126. }
  36127. };
  36128. /**
  36129. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  36130. */
  36131. PoseEnabledController.prototype.update = function () {
  36132. _super.prototype.update.call(this);
  36133. this._updatePoseAndMesh();
  36134. };
  36135. /**
  36136. * Updates only the pose device and mesh without doing any button event checking
  36137. */
  36138. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  36139. var pose = this.browserGamepad.pose;
  36140. this.updateFromDevice(pose);
  36141. 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) {
  36142. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  36143. camera._computeDevicePosition();
  36144. this._deviceToWorld.setTranslation(camera.devicePosition);
  36145. if (camera.deviceRotationQuaternion) {
  36146. var camera = camera;
  36147. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0]);
  36148. // Find the radian distance away that the headset is from the controllers rotation
  36149. 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));
  36150. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  36151. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  36152. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  36153. this._draggedRoomRotation += rotationAmount;
  36154. // Rotate controller around headset
  36155. var sin = Math.sin(-rotationAmount);
  36156. var cos = Math.cos(-rotationAmount);
  36157. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  36158. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  36159. }
  36160. }
  36161. }
  36162. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  36163. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  36164. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  36165. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  36166. if (this._mesh) {
  36167. this._mesh.position.copyFrom(this.devicePosition);
  36168. if (this._mesh.rotationQuaternion) {
  36169. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  36170. }
  36171. }
  36172. };
  36173. /**
  36174. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  36175. * @param poseData raw pose fromthe device
  36176. */
  36177. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  36178. if (poseData) {
  36179. this.rawPose = poseData;
  36180. if (poseData.position) {
  36181. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  36182. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  36183. this._deviceRoomPosition.z *= -1;
  36184. }
  36185. if (this._trackPosition) {
  36186. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  36187. }
  36188. this._calculatedPosition.addInPlace(this.position);
  36189. }
  36190. var pose = this.rawPose;
  36191. if (poseData.orientation && pose.orientation) {
  36192. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  36193. if (this._mesh) {
  36194. if (this._mesh.getScene().useRightHandedSystem) {
  36195. this._deviceRoomRotationQuaternion.z *= -1;
  36196. this._deviceRoomRotationQuaternion.w *= -1;
  36197. }
  36198. else {
  36199. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  36200. }
  36201. }
  36202. // if the camera is set, rotate to the camera's rotation
  36203. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  36204. }
  36205. }
  36206. };
  36207. /**
  36208. * Attaches a mesh to the controller
  36209. * @param mesh the mesh to be attached
  36210. */
  36211. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  36212. if (this._mesh) {
  36213. this._mesh.parent = null;
  36214. }
  36215. this._mesh = mesh;
  36216. if (this._poseControlledCamera) {
  36217. this._mesh.parent = this._poseControlledCamera;
  36218. }
  36219. if (!this._mesh.rotationQuaternion) {
  36220. this._mesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  36221. }
  36222. // 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
  36223. this._updatePoseAndMesh();
  36224. if (this._pointingPoseNode) {
  36225. var parents = [];
  36226. var obj = this._pointingPoseNode;
  36227. while (obj.parent) {
  36228. parents.push(obj.parent);
  36229. obj = obj.parent;
  36230. }
  36231. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  36232. }
  36233. this._meshAttachedObservable.notifyObservers(mesh);
  36234. };
  36235. /**
  36236. * Attaches the controllers mesh to a camera
  36237. * @param camera the camera the mesh should be attached to
  36238. */
  36239. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  36240. this._poseControlledCamera = camera;
  36241. if (this._mesh) {
  36242. this._mesh.parent = this._poseControlledCamera;
  36243. }
  36244. };
  36245. /**
  36246. * Disposes of the controller
  36247. */
  36248. PoseEnabledController.prototype.dispose = function () {
  36249. if (this._mesh) {
  36250. this._mesh.dispose();
  36251. }
  36252. this._mesh = null;
  36253. _super.prototype.dispose.call(this);
  36254. };
  36255. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  36256. /**
  36257. * The mesh that is attached to the controller
  36258. */
  36259. get: function () {
  36260. return this._mesh;
  36261. },
  36262. enumerable: true,
  36263. configurable: true
  36264. });
  36265. /**
  36266. * Gets the ray of the controller in the direction the controller is pointing
  36267. * @param length the length the resulting ray should be
  36268. * @returns a ray in the direction the controller is pointing
  36269. */
  36270. PoseEnabledController.prototype.getForwardRay = function (length) {
  36271. if (length === void 0) { length = 100; }
  36272. if (!this.mesh) {
  36273. 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);
  36274. }
  36275. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  36276. var origin = m.getTranslation();
  36277. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  36278. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  36279. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  36280. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  36281. };
  36282. /**
  36283. * Name of the child mesh that can be used to cast a ray from the controller
  36284. */
  36285. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  36286. return PoseEnabledController;
  36287. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  36288. /***/ }),
  36289. /***/ "./Gamepads/Controllers/viveController.ts":
  36290. /*!************************************************!*\
  36291. !*** ./Gamepads/Controllers/viveController.ts ***!
  36292. \************************************************/
  36293. /*! exports provided: ViveController */
  36294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36295. "use strict";
  36296. __webpack_require__.r(__webpack_exports__);
  36297. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  36298. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36299. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  36300. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  36301. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36302. /**
  36303. * Vive Controller
  36304. */
  36305. var ViveController = /** @class */ (function (_super) {
  36306. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  36307. /**
  36308. * Creates a new ViveController from a gamepad
  36309. * @param vrGamepad the gamepad that the controller should be created from
  36310. */
  36311. function ViveController(vrGamepad) {
  36312. var _this = _super.call(this, vrGamepad) || this;
  36313. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  36314. _this._invertLeftStickY = true;
  36315. return _this;
  36316. }
  36317. /**
  36318. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  36319. * @param scene scene in which to add meshes
  36320. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  36321. */
  36322. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  36323. var _this = this;
  36324. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  36325. /*
  36326. Parent Mesh name: ViveWand
  36327. - body
  36328. - r_gripper
  36329. - l_gripper
  36330. - menu_button
  36331. - system_button
  36332. - trackpad
  36333. - trigger
  36334. - LED
  36335. */
  36336. _this._defaultModel = newMeshes[1];
  36337. _this.attachToMesh(_this._defaultModel);
  36338. if (meshLoaded) {
  36339. meshLoaded(_this._defaultModel);
  36340. }
  36341. });
  36342. };
  36343. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  36344. /**
  36345. * Fired when the left button on this controller is modified
  36346. */
  36347. get: function () {
  36348. return this.onMainButtonStateChangedObservable;
  36349. },
  36350. enumerable: true,
  36351. configurable: true
  36352. });
  36353. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  36354. /**
  36355. * Fired when the right button on this controller is modified
  36356. */
  36357. get: function () {
  36358. return this.onMainButtonStateChangedObservable;
  36359. },
  36360. enumerable: true,
  36361. configurable: true
  36362. });
  36363. Object.defineProperty(ViveController.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. /**
  36374. * Called once for each button that changed state since the last frame
  36375. * Vive mapping:
  36376. * 0: touchpad
  36377. * 1: trigger
  36378. * 2: left AND right buttons
  36379. * 3: menu button
  36380. * @param buttonIdx Which button index changed
  36381. * @param state New state of the button
  36382. * @param changes Which properties on the state changed since last frame
  36383. */
  36384. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  36385. var notifyObject = state; //{ state: state, changes: changes };
  36386. switch (buttonIdx) {
  36387. case 0:
  36388. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  36389. return;
  36390. case 1: // index trigger
  36391. if (this._defaultModel) {
  36392. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  36393. }
  36394. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  36395. return;
  36396. case 2: // left AND right button
  36397. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  36398. return;
  36399. case 3:
  36400. if (this._defaultModel) {
  36401. if (notifyObject.pressed) {
  36402. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  36403. }
  36404. else {
  36405. (this._defaultModel.getChildren()[2]).position.y = 0;
  36406. }
  36407. }
  36408. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  36409. return;
  36410. }
  36411. };
  36412. /**
  36413. * Base Url for the controller model.
  36414. */
  36415. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  36416. /**
  36417. * File name for the controller model.
  36418. */
  36419. ViveController.MODEL_FILENAME = 'wand.babylon';
  36420. return ViveController;
  36421. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  36422. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36423. canCreate: function (gamepadInfo) {
  36424. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  36425. },
  36426. create: function (gamepadInfo) {
  36427. return new ViveController(gamepadInfo);
  36428. }
  36429. });
  36430. /***/ }),
  36431. /***/ "./Gamepads/Controllers/webVRController.ts":
  36432. /*!*************************************************!*\
  36433. !*** ./Gamepads/Controllers/webVRController.ts ***!
  36434. \*************************************************/
  36435. /*! exports provided: WebVRController */
  36436. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36437. "use strict";
  36438. __webpack_require__.r(__webpack_exports__);
  36439. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  36440. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36441. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36442. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36443. /**
  36444. * Defines the WebVRController object that represents controllers tracked in 3D space
  36445. */
  36446. var WebVRController = /** @class */ (function (_super) {
  36447. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  36448. /**
  36449. * Creates a new WebVRController from a gamepad
  36450. * @param vrGamepad the gamepad that the WebVRController should be created from
  36451. */
  36452. function WebVRController(vrGamepad) {
  36453. var _this = _super.call(this, vrGamepad) || this;
  36454. // Observables
  36455. /**
  36456. * Fired when the trigger state has changed
  36457. */
  36458. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36459. /**
  36460. * Fired when the main button state has changed
  36461. */
  36462. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36463. /**
  36464. * Fired when the secondary button state has changed
  36465. */
  36466. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36467. /**
  36468. * Fired when the pad state has changed
  36469. */
  36470. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36471. /**
  36472. * Fired when controllers stick values have changed
  36473. */
  36474. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36475. /**
  36476. * X and Y axis corrisponding to the controllers joystick
  36477. */
  36478. _this.pad = { x: 0, y: 0 };
  36479. // avoid GC, store state in a tmp object
  36480. _this._changes = {
  36481. pressChanged: false,
  36482. touchChanged: false,
  36483. valueChanged: false,
  36484. changed: false
  36485. };
  36486. _this._buttons = new Array(vrGamepad.buttons.length);
  36487. _this.hand = vrGamepad.hand;
  36488. return _this;
  36489. }
  36490. /**
  36491. * Fired when a controller button's state has changed
  36492. * @param callback the callback containing the button that was modified
  36493. */
  36494. WebVRController.prototype.onButtonStateChange = function (callback) {
  36495. this._onButtonStateChange = callback;
  36496. };
  36497. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  36498. /**
  36499. * The default controller model for the controller
  36500. */
  36501. get: function () {
  36502. return this._defaultModel;
  36503. },
  36504. enumerable: true,
  36505. configurable: true
  36506. });
  36507. /**
  36508. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  36509. */
  36510. WebVRController.prototype.update = function () {
  36511. _super.prototype.update.call(this);
  36512. for (var index = 0; index < this._buttons.length; index++) {
  36513. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  36514. }
  36515. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  36516. this.pad.x = this.leftStick.x;
  36517. this.pad.y = this.leftStick.y;
  36518. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  36519. }
  36520. };
  36521. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  36522. if (!newState) {
  36523. newState = {
  36524. pressed: false,
  36525. touched: false,
  36526. value: 0
  36527. };
  36528. }
  36529. if (!currentState) {
  36530. this._buttons[buttonIndex] = {
  36531. pressed: newState.pressed,
  36532. touched: newState.touched,
  36533. value: newState.value
  36534. };
  36535. return;
  36536. }
  36537. this._checkChanges(newState, currentState);
  36538. if (this._changes.changed) {
  36539. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  36540. this._handleButtonChange(buttonIndex, newState, this._changes);
  36541. }
  36542. this._buttons[buttonIndex].pressed = newState.pressed;
  36543. this._buttons[buttonIndex].touched = newState.touched;
  36544. // oculus triggers are never 0, thou not touched.
  36545. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  36546. };
  36547. WebVRController.prototype._checkChanges = function (newState, currentState) {
  36548. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  36549. this._changes.touchChanged = newState.touched !== currentState.touched;
  36550. this._changes.valueChanged = newState.value !== currentState.value;
  36551. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  36552. return this._changes;
  36553. };
  36554. /**
  36555. * Disposes of th webVRCOntroller
  36556. */
  36557. WebVRController.prototype.dispose = function () {
  36558. _super.prototype.dispose.call(this);
  36559. this.onTriggerStateChangedObservable.clear();
  36560. this.onMainButtonStateChangedObservable.clear();
  36561. this.onSecondaryButtonStateChangedObservable.clear();
  36562. this.onPadStateChangedObservable.clear();
  36563. this.onPadValuesChangedObservable.clear();
  36564. };
  36565. return WebVRController;
  36566. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  36567. /***/ }),
  36568. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  36569. /*!*********************************************************!*\
  36570. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  36571. \*********************************************************/
  36572. /*! exports provided: WindowsMotionController */
  36573. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36574. "use strict";
  36575. __webpack_require__.r(__webpack_exports__);
  36576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  36577. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36578. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  36579. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  36580. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  36581. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  36582. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  36583. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  36584. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  36585. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  36586. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36587. /**
  36588. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  36589. */
  36590. var LoadedMeshInfo = /** @class */ (function () {
  36591. function LoadedMeshInfo() {
  36592. /**
  36593. * Map of the button meshes contained in the controller
  36594. */
  36595. this.buttonMeshes = {};
  36596. /**
  36597. * Map of the axis meshes contained in the controller
  36598. */
  36599. this.axisMeshes = {};
  36600. }
  36601. return LoadedMeshInfo;
  36602. }());
  36603. /**
  36604. * Defines the WindowsMotionController object that the state of the windows motion controller
  36605. */
  36606. var WindowsMotionController = /** @class */ (function (_super) {
  36607. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  36608. /**
  36609. * Creates a new WindowsMotionController from a gamepad
  36610. * @param vrGamepad the gamepad that the controller should be created from
  36611. */
  36612. function WindowsMotionController(vrGamepad) {
  36613. var _this = _super.call(this, vrGamepad) || this;
  36614. _this._mapping = {
  36615. // Semantic button names
  36616. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  36617. // A mapping of the button name to glTF model node name
  36618. // that should be transformed by button value.
  36619. buttonMeshNames: {
  36620. 'trigger': 'SELECT',
  36621. 'menu': 'MENU',
  36622. 'grip': 'GRASP',
  36623. 'thumbstick': 'THUMBSTICK_PRESS',
  36624. 'trackpad': 'TOUCHPAD_PRESS'
  36625. },
  36626. // This mapping is used to translate from the Motion Controller to Babylon semantics
  36627. buttonObservableNames: {
  36628. 'trigger': 'onTriggerStateChangedObservable',
  36629. 'menu': 'onSecondaryButtonStateChangedObservable',
  36630. 'grip': 'onMainButtonStateChangedObservable',
  36631. 'thumbstick': 'onPadStateChangedObservable',
  36632. 'trackpad': 'onTrackpadChangedObservable'
  36633. },
  36634. // A mapping of the axis name to glTF model node name
  36635. // that should be transformed by axis value.
  36636. // This array mirrors the browserGamepad.axes array, such that
  36637. // the mesh corresponding to axis 0 is in this array index 0.
  36638. axisMeshNames: [
  36639. 'THUMBSTICK_X',
  36640. 'THUMBSTICK_Y',
  36641. 'TOUCHPAD_TOUCH_X',
  36642. 'TOUCHPAD_TOUCH_Y'
  36643. ],
  36644. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  36645. };
  36646. /**
  36647. * Fired when the trackpad on this controller is clicked
  36648. */
  36649. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  36650. /**
  36651. * Fired when the trackpad on this controller is modified
  36652. */
  36653. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  36654. /**
  36655. * The current x and y values of this controller's trackpad
  36656. */
  36657. _this.trackpad = { x: 0, y: 0 };
  36658. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  36659. _this._loadedMeshInfo = null;
  36660. return _this;
  36661. }
  36662. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  36663. /**
  36664. * Fired when the trigger on this controller is modified
  36665. */
  36666. get: function () {
  36667. return this.onTriggerStateChangedObservable;
  36668. },
  36669. enumerable: true,
  36670. configurable: true
  36671. });
  36672. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  36673. /**
  36674. * Fired when the menu button on this controller is modified
  36675. */
  36676. get: function () {
  36677. return this.onSecondaryButtonStateChangedObservable;
  36678. },
  36679. enumerable: true,
  36680. configurable: true
  36681. });
  36682. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  36683. /**
  36684. * Fired when the grip button on this controller is modified
  36685. */
  36686. get: function () {
  36687. return this.onMainButtonStateChangedObservable;
  36688. },
  36689. enumerable: true,
  36690. configurable: true
  36691. });
  36692. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  36693. /**
  36694. * Fired when the thumbstick button on this controller is modified
  36695. */
  36696. get: function () {
  36697. return this.onPadStateChangedObservable;
  36698. },
  36699. enumerable: true,
  36700. configurable: true
  36701. });
  36702. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  36703. /**
  36704. * Fired when the touchpad button on this controller is modified
  36705. */
  36706. get: function () {
  36707. return this.onTrackpadChangedObservable;
  36708. },
  36709. enumerable: true,
  36710. configurable: true
  36711. });
  36712. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  36713. /**
  36714. * Fired when the touchpad values on this controller are modified
  36715. */
  36716. get: function () {
  36717. return this.onTrackpadValuesChangedObservable;
  36718. },
  36719. enumerable: true,
  36720. configurable: true
  36721. });
  36722. WindowsMotionController.prototype._updateTrackpad = function () {
  36723. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  36724. this.trackpad.x = this.browserGamepad["axes"][2];
  36725. this.trackpad.y = this.browserGamepad["axes"][3];
  36726. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  36727. }
  36728. };
  36729. /**
  36730. * Called once per frame by the engine.
  36731. */
  36732. WindowsMotionController.prototype.update = function () {
  36733. _super.prototype.update.call(this);
  36734. if (this.browserGamepad.axes) {
  36735. this._updateTrackpad();
  36736. // Only need to animate axes if there is a loaded mesh
  36737. if (this._loadedMeshInfo) {
  36738. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  36739. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  36740. }
  36741. }
  36742. }
  36743. };
  36744. /**
  36745. * Called once for each button that changed state since the last frame
  36746. * @param buttonIdx Which button index changed
  36747. * @param state New state of the button
  36748. * @param changes Which properties on the state changed since last frame
  36749. */
  36750. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  36751. var buttonName = this._mapping.buttons[buttonIdx];
  36752. if (!buttonName) {
  36753. return;
  36754. }
  36755. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  36756. this._updateTrackpad();
  36757. // Only emit events for buttons that we know how to map from index to name
  36758. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  36759. if (observable) {
  36760. observable.notifyObservers(state);
  36761. }
  36762. this._lerpButtonTransform(buttonName, state.value);
  36763. };
  36764. /**
  36765. * Moves the buttons on the controller mesh based on their current state
  36766. * @param buttonName the name of the button to move
  36767. * @param buttonValue the value of the button which determines the buttons new position
  36768. */
  36769. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  36770. // If there is no loaded mesh, there is nothing to transform.
  36771. if (!this._loadedMeshInfo) {
  36772. return;
  36773. }
  36774. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  36775. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  36776. return;
  36777. }
  36778. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  36779. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  36780. };
  36781. /**
  36782. * Moves the axis on the controller mesh based on its current state
  36783. * @param axis the index of the axis
  36784. * @param axisValue the value of the axis which determines the meshes new position
  36785. * @hidden
  36786. */
  36787. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  36788. if (!this._loadedMeshInfo) {
  36789. return;
  36790. }
  36791. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  36792. if (!meshInfo) {
  36793. return;
  36794. }
  36795. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  36796. return;
  36797. }
  36798. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  36799. var lerpValue = axisValue * 0.5 + 0.5;
  36800. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  36801. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  36802. };
  36803. /**
  36804. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  36805. * @param scene scene in which to add meshes
  36806. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  36807. */
  36808. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  36809. var _this = this;
  36810. if (forceDefault === void 0) { forceDefault = false; }
  36811. var path;
  36812. var filename;
  36813. // Checking if GLB loader is present
  36814. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  36815. // Determine the device specific folder based on the ID suffix
  36816. var device = 'default';
  36817. if (this.id && !forceDefault) {
  36818. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  36819. device = ((match && match[0]) || device);
  36820. }
  36821. // Hand
  36822. if (this.hand === 'left') {
  36823. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  36824. }
  36825. else { // Right is the default if no hand is specified
  36826. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  36827. }
  36828. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  36829. }
  36830. else {
  36831. _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");
  36832. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  36833. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  36834. }
  36835. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  36836. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  36837. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  36838. if (!_this._loadedMeshInfo) {
  36839. return;
  36840. }
  36841. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  36842. _this.attachToMesh(_this._defaultModel);
  36843. if (meshLoaded) {
  36844. meshLoaded(_this._defaultModel);
  36845. }
  36846. }, null, function (scene, message) {
  36847. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  36848. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  36849. if (!forceDefault) {
  36850. _this.initControllerMesh(scene, meshLoaded, true);
  36851. }
  36852. });
  36853. };
  36854. /**
  36855. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  36856. * can be transformed by button presses and axes values, based on this._mapping.
  36857. *
  36858. * @param scene scene in which the meshes exist
  36859. * @param meshes list of meshes that make up the controller model to process
  36860. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  36861. */
  36862. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  36863. var loadedMeshInfo = null;
  36864. // Create a new mesh to contain the glTF hierarchy
  36865. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  36866. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  36867. var childMesh = null;
  36868. for (var i = 0; i < meshes.length; i++) {
  36869. var mesh = meshes[i];
  36870. if (!mesh.parent) {
  36871. // Exclude controller meshes from picking results
  36872. mesh.isPickable = false;
  36873. // Handle root node, attach to the new parentMesh
  36874. childMesh = mesh;
  36875. break;
  36876. }
  36877. }
  36878. if (childMesh) {
  36879. childMesh.setParent(parentMesh);
  36880. // Create our mesh info. Note that this method will always return non-null.
  36881. loadedMeshInfo = this.createMeshInfo(parentMesh);
  36882. }
  36883. else {
  36884. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  36885. }
  36886. return loadedMeshInfo;
  36887. };
  36888. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  36889. var loadedMeshInfo = new LoadedMeshInfo();
  36890. var i;
  36891. loadedMeshInfo.rootNode = rootNode;
  36892. // Reset the caches
  36893. loadedMeshInfo.buttonMeshes = {};
  36894. loadedMeshInfo.axisMeshes = {};
  36895. // Button Meshes
  36896. for (i = 0; i < this._mapping.buttons.length; i++) {
  36897. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  36898. if (!buttonMeshName) {
  36899. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  36900. continue;
  36901. }
  36902. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  36903. if (!buttonMesh) {
  36904. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  36905. continue;
  36906. }
  36907. var buttonMeshInfo = {
  36908. index: i,
  36909. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  36910. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  36911. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  36912. };
  36913. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  36914. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  36915. }
  36916. else {
  36917. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  36918. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  36919. '(VALUE: ' + !!buttonMeshInfo.value +
  36920. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  36921. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  36922. ')');
  36923. }
  36924. }
  36925. // Axis Meshes
  36926. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  36927. var axisMeshName = this._mapping.axisMeshNames[i];
  36928. if (!axisMeshName) {
  36929. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  36930. continue;
  36931. }
  36932. var axisMesh = getChildByName(rootNode, axisMeshName);
  36933. if (!axisMesh) {
  36934. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  36935. continue;
  36936. }
  36937. var axisMeshInfo = {
  36938. index: i,
  36939. value: getImmediateChildByName(axisMesh, 'VALUE'),
  36940. min: getImmediateChildByName(axisMesh, 'MIN'),
  36941. max: getImmediateChildByName(axisMesh, 'MAX')
  36942. };
  36943. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  36944. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  36945. }
  36946. else {
  36947. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  36948. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  36949. '(VALUE: ' + !!axisMeshInfo.value +
  36950. ', MIN: ' + !!axisMeshInfo.min +
  36951. ', MAX:' + !!axisMeshInfo.max +
  36952. ')');
  36953. }
  36954. }
  36955. // Pointing Ray
  36956. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  36957. if (!loadedMeshInfo.pointingPoseNode) {
  36958. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  36959. }
  36960. else {
  36961. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  36962. }
  36963. return loadedMeshInfo;
  36964. // Look through all children recursively. This will return null if no mesh exists with the given name.
  36965. function getChildByName(node, name) {
  36966. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  36967. }
  36968. // Look through only immediate children. This will return null if no mesh exists with the given name.
  36969. function getImmediateChildByName(node, name) {
  36970. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  36971. }
  36972. };
  36973. /**
  36974. * Gets the ray of the controller in the direction the controller is pointing
  36975. * @param length the length the resulting ray should be
  36976. * @returns a ray in the direction the controller is pointing
  36977. */
  36978. WindowsMotionController.prototype.getForwardRay = function (length) {
  36979. if (length === void 0) { length = 100; }
  36980. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  36981. return _super.prototype.getForwardRay.call(this, length);
  36982. }
  36983. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  36984. var origin = m.getTranslation();
  36985. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  36986. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  36987. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  36988. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  36989. };
  36990. /**
  36991. * Disposes of the controller
  36992. */
  36993. WindowsMotionController.prototype.dispose = function () {
  36994. _super.prototype.dispose.call(this);
  36995. this.onTrackpadChangedObservable.clear();
  36996. };
  36997. /**
  36998. * The base url used to load the left and right controller models
  36999. */
  37000. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  37001. /**
  37002. * The name of the left controller model file
  37003. */
  37004. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  37005. /**
  37006. * The name of the right controller model file
  37007. */
  37008. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  37009. /**
  37010. * The controller name prefix for this controller type
  37011. */
  37012. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  37013. /**
  37014. * The controller id pattern for this controller type
  37015. */
  37016. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  37017. return WindowsMotionController;
  37018. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  37019. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  37020. canCreate: function (gamepadInfo) {
  37021. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  37022. },
  37023. create: function (gamepadInfo) {
  37024. return new WindowsMotionController(gamepadInfo);
  37025. }
  37026. });
  37027. /***/ }),
  37028. /***/ "./Gamepads/gamepad.ts":
  37029. /*!*****************************!*\
  37030. !*** ./Gamepads/gamepad.ts ***!
  37031. \*****************************/
  37032. /*! exports provided: StickValues, Gamepad, GenericPad */
  37033. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37034. "use strict";
  37035. __webpack_require__.r(__webpack_exports__);
  37036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  37037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  37038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  37039. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37040. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37041. /**
  37042. * Represents a gamepad control stick position
  37043. */
  37044. var StickValues = /** @class */ (function () {
  37045. /**
  37046. * Initializes the gamepad x and y control stick values
  37047. * @param x The x component of the gamepad control stick value
  37048. * @param y The y component of the gamepad control stick value
  37049. */
  37050. function StickValues(
  37051. /**
  37052. * The x component of the control stick
  37053. */
  37054. x,
  37055. /**
  37056. * The y component of the control stick
  37057. */
  37058. y) {
  37059. this.x = x;
  37060. this.y = y;
  37061. }
  37062. return StickValues;
  37063. }());
  37064. /**
  37065. * Represents a gamepad
  37066. */
  37067. var Gamepad = /** @class */ (function () {
  37068. /**
  37069. * Initializes the gamepad
  37070. * @param id The id of the gamepad
  37071. * @param index The index of the gamepad
  37072. * @param browserGamepad The browser gamepad
  37073. * @param leftStickX The x component of the left joystick
  37074. * @param leftStickY The y component of the left joystick
  37075. * @param rightStickX The x component of the right joystick
  37076. * @param rightStickY The y component of the right joystick
  37077. */
  37078. function Gamepad(
  37079. /**
  37080. * The id of the gamepad
  37081. */
  37082. id,
  37083. /**
  37084. * The index of the gamepad
  37085. */
  37086. index,
  37087. /**
  37088. * The browser gamepad
  37089. */
  37090. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  37091. if (leftStickX === void 0) { leftStickX = 0; }
  37092. if (leftStickY === void 0) { leftStickY = 1; }
  37093. if (rightStickX === void 0) { rightStickX = 2; }
  37094. if (rightStickY === void 0) { rightStickY = 3; }
  37095. this.id = id;
  37096. this.index = index;
  37097. this.browserGamepad = browserGamepad;
  37098. this._leftStick = { x: 0, y: 0 };
  37099. this._rightStick = { x: 0, y: 0 };
  37100. /** @hidden */
  37101. this._isConnected = true;
  37102. /**
  37103. * Specifies whether the left control stick should be Y-inverted
  37104. */
  37105. this._invertLeftStickY = false;
  37106. this.type = Gamepad.GAMEPAD;
  37107. this._leftStickAxisX = leftStickX;
  37108. this._leftStickAxisY = leftStickY;
  37109. this._rightStickAxisX = rightStickX;
  37110. this._rightStickAxisY = rightStickY;
  37111. if (this.browserGamepad.axes.length >= 2) {
  37112. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  37113. }
  37114. if (this.browserGamepad.axes.length >= 4) {
  37115. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  37116. }
  37117. }
  37118. Object.defineProperty(Gamepad.prototype, "isConnected", {
  37119. /**
  37120. * Specifies if the gamepad has been connected
  37121. */
  37122. get: function () {
  37123. return this._isConnected;
  37124. },
  37125. enumerable: true,
  37126. configurable: true
  37127. });
  37128. /**
  37129. * Callback triggered when the left joystick has changed
  37130. * @param callback
  37131. */
  37132. Gamepad.prototype.onleftstickchanged = function (callback) {
  37133. this._onleftstickchanged = callback;
  37134. };
  37135. /**
  37136. * Callback triggered when the right joystick has changed
  37137. * @param callback
  37138. */
  37139. Gamepad.prototype.onrightstickchanged = function (callback) {
  37140. this._onrightstickchanged = callback;
  37141. };
  37142. Object.defineProperty(Gamepad.prototype, "leftStick", {
  37143. /**
  37144. * Gets the left joystick
  37145. */
  37146. get: function () {
  37147. return this._leftStick;
  37148. },
  37149. /**
  37150. * Sets the left joystick values
  37151. */
  37152. set: function (newValues) {
  37153. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  37154. this._onleftstickchanged(newValues);
  37155. }
  37156. this._leftStick = newValues;
  37157. },
  37158. enumerable: true,
  37159. configurable: true
  37160. });
  37161. Object.defineProperty(Gamepad.prototype, "rightStick", {
  37162. /**
  37163. * Gets the right joystick
  37164. */
  37165. get: function () {
  37166. return this._rightStick;
  37167. },
  37168. /**
  37169. * Sets the right joystick value
  37170. */
  37171. set: function (newValues) {
  37172. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  37173. this._onrightstickchanged(newValues);
  37174. }
  37175. this._rightStick = newValues;
  37176. },
  37177. enumerable: true,
  37178. configurable: true
  37179. });
  37180. /**
  37181. * Updates the gamepad joystick positions
  37182. */
  37183. Gamepad.prototype.update = function () {
  37184. if (this._leftStick) {
  37185. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  37186. if (this._invertLeftStickY) {
  37187. this.leftStick.y *= -1;
  37188. }
  37189. }
  37190. if (this._rightStick) {
  37191. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  37192. }
  37193. };
  37194. /**
  37195. * Disposes the gamepad
  37196. */
  37197. Gamepad.prototype.dispose = function () {
  37198. };
  37199. /**
  37200. * Represents a gamepad controller
  37201. */
  37202. Gamepad.GAMEPAD = 0;
  37203. /**
  37204. * Represents a generic controller
  37205. */
  37206. Gamepad.GENERIC = 1;
  37207. /**
  37208. * Represents an XBox controller
  37209. */
  37210. Gamepad.XBOX = 2;
  37211. /**
  37212. * Represents a pose-enabled controller
  37213. */
  37214. Gamepad.POSE_ENABLED = 3;
  37215. return Gamepad;
  37216. }());
  37217. /**
  37218. * Represents a generic gamepad
  37219. */
  37220. var GenericPad = /** @class */ (function (_super) {
  37221. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  37222. /**
  37223. * Initializes the generic gamepad
  37224. * @param id The id of the generic gamepad
  37225. * @param index The index of the generic gamepad
  37226. * @param browserGamepad The browser gamepad
  37227. */
  37228. function GenericPad(id, index, browserGamepad) {
  37229. var _this = _super.call(this, id, index, browserGamepad) || this;
  37230. /**
  37231. * Observable triggered when a button has been pressed
  37232. */
  37233. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37234. /**
  37235. * Observable triggered when a button has been released
  37236. */
  37237. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37238. _this.type = Gamepad.GENERIC;
  37239. _this._buttons = new Array(browserGamepad.buttons.length);
  37240. return _this;
  37241. }
  37242. /**
  37243. * Callback triggered when a button has been pressed
  37244. * @param callback Called when a button has been pressed
  37245. */
  37246. GenericPad.prototype.onbuttondown = function (callback) {
  37247. this._onbuttondown = callback;
  37248. };
  37249. /**
  37250. * Callback triggered when a button has been released
  37251. * @param callback Called when a button has been released
  37252. */
  37253. GenericPad.prototype.onbuttonup = function (callback) {
  37254. this._onbuttonup = callback;
  37255. };
  37256. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  37257. if (newValue !== currentValue) {
  37258. if (newValue === 1) {
  37259. if (this._onbuttondown) {
  37260. this._onbuttondown(buttonIndex);
  37261. }
  37262. this.onButtonDownObservable.notifyObservers(buttonIndex);
  37263. }
  37264. if (newValue === 0) {
  37265. if (this._onbuttonup) {
  37266. this._onbuttonup(buttonIndex);
  37267. }
  37268. this.onButtonUpObservable.notifyObservers(buttonIndex);
  37269. }
  37270. }
  37271. return newValue;
  37272. };
  37273. /**
  37274. * Updates the generic gamepad
  37275. */
  37276. GenericPad.prototype.update = function () {
  37277. _super.prototype.update.call(this);
  37278. for (var index = 0; index < this._buttons.length; index++) {
  37279. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  37280. }
  37281. };
  37282. /**
  37283. * Disposes the generic gamepad
  37284. */
  37285. GenericPad.prototype.dispose = function () {
  37286. _super.prototype.dispose.call(this);
  37287. this.onButtonDownObservable.clear();
  37288. this.onButtonUpObservable.clear();
  37289. };
  37290. return GenericPad;
  37291. }(Gamepad));
  37292. /***/ }),
  37293. /***/ "./Gamepads/gamepadManager.ts":
  37294. /*!************************************!*\
  37295. !*** ./Gamepads/gamepadManager.ts ***!
  37296. \************************************/
  37297. /*! exports provided: GamepadManager */
  37298. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37299. "use strict";
  37300. __webpack_require__.r(__webpack_exports__);
  37301. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  37302. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  37303. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37304. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  37305. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  37306. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  37307. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  37308. /**
  37309. * Manager for handling gamepads
  37310. */
  37311. var GamepadManager = /** @class */ (function () {
  37312. /**
  37313. * Initializes the gamepad manager
  37314. * @param _scene BabylonJS scene
  37315. */
  37316. function GamepadManager(_scene) {
  37317. var _this = this;
  37318. this._scene = _scene;
  37319. this._babylonGamepads = [];
  37320. this._oneGamepadConnected = false;
  37321. /** @hidden */
  37322. this._isMonitoring = false;
  37323. /**
  37324. * observable to be triggered when the gamepad controller has been disconnected
  37325. */
  37326. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37327. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  37328. this._gamepadEventSupported = false;
  37329. }
  37330. else {
  37331. this._gamepadEventSupported = 'GamepadEvent' in window;
  37332. this._gamepadSupport = (navigator.getGamepads ||
  37333. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  37334. }
  37335. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"](function (observer) {
  37336. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  37337. for (var i in _this._babylonGamepads) {
  37338. var gamepad = _this._babylonGamepads[i];
  37339. if (gamepad && gamepad._isConnected) {
  37340. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  37341. }
  37342. }
  37343. });
  37344. this._onGamepadConnectedEvent = function (evt) {
  37345. var gamepad = evt.gamepad;
  37346. if (gamepad.index in _this._babylonGamepads) {
  37347. if (_this._babylonGamepads[gamepad.index].isConnected) {
  37348. return;
  37349. }
  37350. }
  37351. var newGamepad;
  37352. if (_this._babylonGamepads[gamepad.index]) {
  37353. newGamepad = _this._babylonGamepads[gamepad.index];
  37354. newGamepad.browserGamepad = gamepad;
  37355. newGamepad._isConnected = true;
  37356. }
  37357. else {
  37358. newGamepad = _this._addNewGamepad(gamepad);
  37359. }
  37360. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  37361. _this._startMonitoringGamepads();
  37362. };
  37363. this._onGamepadDisconnectedEvent = function (evt) {
  37364. var gamepad = evt.gamepad;
  37365. // Remove the gamepad from the list of gamepads to monitor.
  37366. for (var i in _this._babylonGamepads) {
  37367. if (_this._babylonGamepads[i].index === gamepad.index) {
  37368. var disconnectedGamepad = _this._babylonGamepads[i];
  37369. disconnectedGamepad._isConnected = false;
  37370. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  37371. break;
  37372. }
  37373. }
  37374. };
  37375. if (this._gamepadSupport) {
  37376. //first add already-connected gamepads
  37377. this._updateGamepadObjects();
  37378. if (this._babylonGamepads.length) {
  37379. this._startMonitoringGamepads();
  37380. }
  37381. // Checking if the gamepad connected event is supported (like in Firefox)
  37382. if (this._gamepadEventSupported) {
  37383. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  37384. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  37385. }
  37386. else {
  37387. this._startMonitoringGamepads();
  37388. }
  37389. }
  37390. }
  37391. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  37392. /**
  37393. * The gamepads in the game pad manager
  37394. */
  37395. get: function () {
  37396. return this._babylonGamepads;
  37397. },
  37398. enumerable: true,
  37399. configurable: true
  37400. });
  37401. /**
  37402. * Get the gamepad controllers based on type
  37403. * @param type The type of gamepad controller
  37404. * @returns Nullable gamepad
  37405. */
  37406. GamepadManager.prototype.getGamepadByType = function (type) {
  37407. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].XBOX; }
  37408. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  37409. var gamepad = _a[_i];
  37410. if (gamepad && gamepad.type === type) {
  37411. return gamepad;
  37412. }
  37413. }
  37414. return null;
  37415. };
  37416. /**
  37417. * Disposes the gamepad manager
  37418. */
  37419. GamepadManager.prototype.dispose = function () {
  37420. if (this._gamepadEventSupported) {
  37421. if (this._onGamepadConnectedEvent) {
  37422. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  37423. }
  37424. if (this._onGamepadDisconnectedEvent) {
  37425. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  37426. }
  37427. this._onGamepadConnectedEvent = null;
  37428. this._onGamepadDisconnectedEvent = null;
  37429. }
  37430. this._babylonGamepads.forEach(function (gamepad) {
  37431. gamepad.dispose();
  37432. });
  37433. this.onGamepadConnectedObservable.clear();
  37434. this.onGamepadDisconnectedObservable.clear();
  37435. this._oneGamepadConnected = false;
  37436. this._stopMonitoringGamepads();
  37437. this._babylonGamepads = [];
  37438. };
  37439. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  37440. if (!this._oneGamepadConnected) {
  37441. this._oneGamepadConnected = true;
  37442. }
  37443. var newGamepad;
  37444. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  37445. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  37446. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  37447. }
  37448. // if pose is supported, use the (WebVR) pose enabled controller
  37449. else if (gamepad.pose) {
  37450. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  37451. }
  37452. else {
  37453. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_5__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  37454. }
  37455. this._babylonGamepads[newGamepad.index] = newGamepad;
  37456. return newGamepad;
  37457. };
  37458. GamepadManager.prototype._startMonitoringGamepads = function () {
  37459. if (!this._isMonitoring) {
  37460. this._isMonitoring = true;
  37461. //back-comp
  37462. if (!this._scene) {
  37463. this._checkGamepadsStatus();
  37464. }
  37465. }
  37466. };
  37467. GamepadManager.prototype._stopMonitoringGamepads = function () {
  37468. this._isMonitoring = false;
  37469. };
  37470. /** @hidden */
  37471. GamepadManager.prototype._checkGamepadsStatus = function () {
  37472. var _this = this;
  37473. // Hack to be compatible Chrome
  37474. this._updateGamepadObjects();
  37475. for (var i in this._babylonGamepads) {
  37476. var gamepad = this._babylonGamepads[i];
  37477. if (!gamepad || !gamepad.isConnected) {
  37478. continue;
  37479. }
  37480. gamepad.update();
  37481. }
  37482. if (this._isMonitoring && !this._scene) {
  37483. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  37484. }
  37485. };
  37486. // This function is called only on Chrome, which does not properly support
  37487. // connection/disconnection events and forces you to recopy again the gamepad object
  37488. GamepadManager.prototype._updateGamepadObjects = function () {
  37489. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  37490. for (var i = 0; i < gamepads.length; i++) {
  37491. var gamepad = gamepads[i];
  37492. if (gamepad) {
  37493. if (!this._babylonGamepads[gamepad.index]) {
  37494. var newGamepad = this._addNewGamepad(gamepad);
  37495. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  37496. }
  37497. else {
  37498. // Forced to copy again this object for Chrome for unknown reason
  37499. this._babylonGamepads[i].browserGamepad = gamepad;
  37500. if (!this._babylonGamepads[i].isConnected) {
  37501. this._babylonGamepads[i]._isConnected = true;
  37502. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  37503. }
  37504. }
  37505. }
  37506. }
  37507. };
  37508. return GamepadManager;
  37509. }());
  37510. /***/ }),
  37511. /***/ "./Gamepads/gamepadSceneComponent.ts":
  37512. /*!*******************************************!*\
  37513. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  37514. \*******************************************/
  37515. /*! exports provided: GamepadSystemSceneComponent */
  37516. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37517. "use strict";
  37518. __webpack_require__.r(__webpack_exports__);
  37519. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  37520. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  37521. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  37522. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  37523. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  37524. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  37525. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  37526. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  37527. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  37528. get: function () {
  37529. if (!this._gamepadManager) {
  37530. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  37531. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  37532. if (!component) {
  37533. component = new GamepadSystemSceneComponent(this);
  37534. this._addComponent(component);
  37535. }
  37536. }
  37537. return this._gamepadManager;
  37538. },
  37539. enumerable: true,
  37540. configurable: true
  37541. });
  37542. /**
  37543. * Adds a gamepad to the free camera inputs manager
  37544. */
  37545. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  37546. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  37547. return this;
  37548. };
  37549. /**
  37550. * Adds a gamepad to the arc rotate camera inputs manager
  37551. */
  37552. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  37553. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  37554. return this;
  37555. };
  37556. /**
  37557. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37558. */
  37559. var GamepadSystemSceneComponent = /** @class */ (function () {
  37560. /**
  37561. * Creates a new instance of the component for the given scene
  37562. * @param scene Defines the scene to register the component in
  37563. */
  37564. function GamepadSystemSceneComponent(scene) {
  37565. /**
  37566. * The component name helpfull to identify the component in the list of scene components.
  37567. */
  37568. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  37569. this.scene = scene;
  37570. }
  37571. /**
  37572. * Registers the component in a given scene
  37573. */
  37574. GamepadSystemSceneComponent.prototype.register = function () {
  37575. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  37576. };
  37577. /**
  37578. * Rebuilds the elements related to this component in case of
  37579. * context lost for instance.
  37580. */
  37581. GamepadSystemSceneComponent.prototype.rebuild = function () {
  37582. // Nothing to do for gamepads
  37583. };
  37584. /**
  37585. * Disposes the component and the associated ressources
  37586. */
  37587. GamepadSystemSceneComponent.prototype.dispose = function () {
  37588. var gamepadManager = this.scene._gamepadManager;
  37589. if (gamepadManager) {
  37590. gamepadManager.dispose();
  37591. this.scene._gamepadManager = null;
  37592. }
  37593. };
  37594. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  37595. var gamepadManager = this.scene._gamepadManager;
  37596. if (gamepadManager && gamepadManager._isMonitoring) {
  37597. gamepadManager._checkGamepadsStatus();
  37598. }
  37599. };
  37600. return GamepadSystemSceneComponent;
  37601. }());
  37602. /***/ }),
  37603. /***/ "./Gamepads/index.ts":
  37604. /*!***************************!*\
  37605. !*** ./Gamepads/index.ts ***!
  37606. \***************************/
  37607. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad */
  37608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37609. "use strict";
  37610. __webpack_require__.r(__webpack_exports__);
  37611. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  37612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  37613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  37614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  37615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  37616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  37617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  37618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  37619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  37620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  37621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  37622. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  37623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  37624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  37625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  37626. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  37627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  37628. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  37629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  37630. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  37631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  37632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  37633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  37634. /***/ }),
  37635. /***/ "./Gamepads/xboxGamepad.ts":
  37636. /*!*********************************!*\
  37637. !*** ./Gamepads/xboxGamepad.ts ***!
  37638. \*********************************/
  37639. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  37640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37641. "use strict";
  37642. __webpack_require__.r(__webpack_exports__);
  37643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  37644. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  37645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  37646. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37647. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37648. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  37649. /**
  37650. * Defines supported buttons for XBox360 compatible gamepads
  37651. */
  37652. var Xbox360Button;
  37653. (function (Xbox360Button) {
  37654. /** A */
  37655. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  37656. /** B */
  37657. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  37658. /** X */
  37659. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  37660. /** Y */
  37661. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  37662. /** Start */
  37663. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  37664. /** Back */
  37665. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  37666. /** Left button */
  37667. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  37668. /** Right button */
  37669. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  37670. /** Left stick */
  37671. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  37672. /** Right stick */
  37673. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  37674. })(Xbox360Button || (Xbox360Button = {}));
  37675. /** Defines values for XBox360 DPad */
  37676. var Xbox360Dpad;
  37677. (function (Xbox360Dpad) {
  37678. /** Up */
  37679. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  37680. /** Down */
  37681. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  37682. /** Left */
  37683. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  37684. /** Right */
  37685. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  37686. })(Xbox360Dpad || (Xbox360Dpad = {}));
  37687. /**
  37688. * Defines a XBox360 gamepad
  37689. */
  37690. var Xbox360Pad = /** @class */ (function (_super) {
  37691. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  37692. /**
  37693. * Creates a new XBox360 gamepad object
  37694. * @param id defines the id of this gamepad
  37695. * @param index defines its index
  37696. * @param gamepad defines the internal HTML gamepad object
  37697. * @param xboxOne defines if it is a XBox One gamepad
  37698. */
  37699. function Xbox360Pad(id, index, gamepad, xboxOne) {
  37700. if (xboxOne === void 0) { xboxOne = false; }
  37701. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  37702. _this._leftTrigger = 0;
  37703. _this._rightTrigger = 0;
  37704. /** Observable raised when a button is pressed */
  37705. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37706. /** Observable raised when a button is released */
  37707. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37708. /** Observable raised when a pad is pressed */
  37709. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37710. /** Observable raised when a pad is released */
  37711. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37712. _this._buttonA = 0;
  37713. _this._buttonB = 0;
  37714. _this._buttonX = 0;
  37715. _this._buttonY = 0;
  37716. _this._buttonBack = 0;
  37717. _this._buttonStart = 0;
  37718. _this._buttonLB = 0;
  37719. _this._buttonRB = 0;
  37720. _this._buttonLeftStick = 0;
  37721. _this._buttonRightStick = 0;
  37722. _this._dPadUp = 0;
  37723. _this._dPadDown = 0;
  37724. _this._dPadLeft = 0;
  37725. _this._dPadRight = 0;
  37726. _this._isXboxOnePad = false;
  37727. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  37728. _this._isXboxOnePad = xboxOne;
  37729. return _this;
  37730. }
  37731. /**
  37732. * Defines the callback to call when left trigger is pressed
  37733. * @param callback defines the callback to use
  37734. */
  37735. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  37736. this._onlefttriggerchanged = callback;
  37737. };
  37738. /**
  37739. * Defines the callback to call when right trigger is pressed
  37740. * @param callback defines the callback to use
  37741. */
  37742. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  37743. this._onrighttriggerchanged = callback;
  37744. };
  37745. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  37746. /**
  37747. * Gets the left trigger value
  37748. */
  37749. get: function () {
  37750. return this._leftTrigger;
  37751. },
  37752. /**
  37753. * Sets the left trigger value
  37754. */
  37755. set: function (newValue) {
  37756. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  37757. this._onlefttriggerchanged(newValue);
  37758. }
  37759. this._leftTrigger = newValue;
  37760. },
  37761. enumerable: true,
  37762. configurable: true
  37763. });
  37764. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  37765. /**
  37766. * Gets the right trigger value
  37767. */
  37768. get: function () {
  37769. return this._rightTrigger;
  37770. },
  37771. /**
  37772. * Sets the right trigger value
  37773. */
  37774. set: function (newValue) {
  37775. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  37776. this._onrighttriggerchanged(newValue);
  37777. }
  37778. this._rightTrigger = newValue;
  37779. },
  37780. enumerable: true,
  37781. configurable: true
  37782. });
  37783. /**
  37784. * Defines the callback to call when a button is pressed
  37785. * @param callback defines the callback to use
  37786. */
  37787. Xbox360Pad.prototype.onbuttondown = function (callback) {
  37788. this._onbuttondown = callback;
  37789. };
  37790. /**
  37791. * Defines the callback to call when a button is released
  37792. * @param callback defines the callback to use
  37793. */
  37794. Xbox360Pad.prototype.onbuttonup = function (callback) {
  37795. this._onbuttonup = callback;
  37796. };
  37797. /**
  37798. * Defines the callback to call when a pad is pressed
  37799. * @param callback defines the callback to use
  37800. */
  37801. Xbox360Pad.prototype.ondpaddown = function (callback) {
  37802. this._ondpaddown = callback;
  37803. };
  37804. /**
  37805. * Defines the callback to call when a pad is released
  37806. * @param callback defines the callback to use
  37807. */
  37808. Xbox360Pad.prototype.ondpadup = function (callback) {
  37809. this._ondpadup = callback;
  37810. };
  37811. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  37812. if (newValue !== currentValue) {
  37813. if (newValue === 1) {
  37814. if (this._onbuttondown) {
  37815. this._onbuttondown(buttonType);
  37816. }
  37817. this.onButtonDownObservable.notifyObservers(buttonType);
  37818. }
  37819. if (newValue === 0) {
  37820. if (this._onbuttonup) {
  37821. this._onbuttonup(buttonType);
  37822. }
  37823. this.onButtonUpObservable.notifyObservers(buttonType);
  37824. }
  37825. }
  37826. return newValue;
  37827. };
  37828. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  37829. if (newValue !== currentValue) {
  37830. if (newValue === 1) {
  37831. if (this._ondpaddown) {
  37832. this._ondpaddown(buttonType);
  37833. }
  37834. this.onPadDownObservable.notifyObservers(buttonType);
  37835. }
  37836. if (newValue === 0) {
  37837. if (this._ondpadup) {
  37838. this._ondpadup(buttonType);
  37839. }
  37840. this.onPadUpObservable.notifyObservers(buttonType);
  37841. }
  37842. }
  37843. return newValue;
  37844. };
  37845. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  37846. /**
  37847. * Gets the value of the `A` button
  37848. */
  37849. get: function () {
  37850. return this._buttonA;
  37851. },
  37852. /**
  37853. * Sets the value of the `A` button
  37854. */
  37855. set: function (value) {
  37856. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  37857. },
  37858. enumerable: true,
  37859. configurable: true
  37860. });
  37861. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  37862. /**
  37863. * Gets the value of the `B` button
  37864. */
  37865. get: function () {
  37866. return this._buttonB;
  37867. },
  37868. /**
  37869. * Sets the value of the `B` button
  37870. */
  37871. set: function (value) {
  37872. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  37873. },
  37874. enumerable: true,
  37875. configurable: true
  37876. });
  37877. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  37878. /**
  37879. * Gets the value of the `X` button
  37880. */
  37881. get: function () {
  37882. return this._buttonX;
  37883. },
  37884. /**
  37885. * Sets the value of the `X` button
  37886. */
  37887. set: function (value) {
  37888. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  37889. },
  37890. enumerable: true,
  37891. configurable: true
  37892. });
  37893. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  37894. /**
  37895. * Gets the value of the `Y` button
  37896. */
  37897. get: function () {
  37898. return this._buttonY;
  37899. },
  37900. /**
  37901. * Sets the value of the `Y` button
  37902. */
  37903. set: function (value) {
  37904. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  37905. },
  37906. enumerable: true,
  37907. configurable: true
  37908. });
  37909. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  37910. /**
  37911. * Gets the value of the `Start` button
  37912. */
  37913. get: function () {
  37914. return this._buttonStart;
  37915. },
  37916. /**
  37917. * Sets the value of the `Start` button
  37918. */
  37919. set: function (value) {
  37920. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  37921. },
  37922. enumerable: true,
  37923. configurable: true
  37924. });
  37925. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  37926. /**
  37927. * Gets the value of the `Back` button
  37928. */
  37929. get: function () {
  37930. return this._buttonBack;
  37931. },
  37932. /**
  37933. * Sets the value of the `Back` button
  37934. */
  37935. set: function (value) {
  37936. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  37937. },
  37938. enumerable: true,
  37939. configurable: true
  37940. });
  37941. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  37942. /**
  37943. * Gets the value of the `Left` button
  37944. */
  37945. get: function () {
  37946. return this._buttonLB;
  37947. },
  37948. /**
  37949. * Sets the value of the `Left` button
  37950. */
  37951. set: function (value) {
  37952. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  37953. },
  37954. enumerable: true,
  37955. configurable: true
  37956. });
  37957. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  37958. /**
  37959. * Gets the value of the `Right` button
  37960. */
  37961. get: function () {
  37962. return this._buttonRB;
  37963. },
  37964. /**
  37965. * Sets the value of the `Right` button
  37966. */
  37967. set: function (value) {
  37968. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  37969. },
  37970. enumerable: true,
  37971. configurable: true
  37972. });
  37973. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  37974. /**
  37975. * Gets the value of the Left joystick
  37976. */
  37977. get: function () {
  37978. return this._buttonLeftStick;
  37979. },
  37980. /**
  37981. * Sets the value of the Left joystick
  37982. */
  37983. set: function (value) {
  37984. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  37985. },
  37986. enumerable: true,
  37987. configurable: true
  37988. });
  37989. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  37990. /**
  37991. * Gets the value of the Right joystick
  37992. */
  37993. get: function () {
  37994. return this._buttonRightStick;
  37995. },
  37996. /**
  37997. * Sets the value of the Right joystick
  37998. */
  37999. set: function (value) {
  38000. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  38001. },
  38002. enumerable: true,
  38003. configurable: true
  38004. });
  38005. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  38006. /**
  38007. * Gets the value of D-pad up
  38008. */
  38009. get: function () {
  38010. return this._dPadUp;
  38011. },
  38012. /**
  38013. * Sets the value of D-pad up
  38014. */
  38015. set: function (value) {
  38016. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  38017. },
  38018. enumerable: true,
  38019. configurable: true
  38020. });
  38021. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  38022. /**
  38023. * Gets the value of D-pad down
  38024. */
  38025. get: function () {
  38026. return this._dPadDown;
  38027. },
  38028. /**
  38029. * Sets the value of D-pad down
  38030. */
  38031. set: function (value) {
  38032. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  38033. },
  38034. enumerable: true,
  38035. configurable: true
  38036. });
  38037. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  38038. /**
  38039. * Gets the value of D-pad left
  38040. */
  38041. get: function () {
  38042. return this._dPadLeft;
  38043. },
  38044. /**
  38045. * Sets the value of D-pad left
  38046. */
  38047. set: function (value) {
  38048. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  38049. },
  38050. enumerable: true,
  38051. configurable: true
  38052. });
  38053. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  38054. /**
  38055. * Gets the value of D-pad right
  38056. */
  38057. get: function () {
  38058. return this._dPadRight;
  38059. },
  38060. /**
  38061. * Sets the value of D-pad right
  38062. */
  38063. set: function (value) {
  38064. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  38065. },
  38066. enumerable: true,
  38067. configurable: true
  38068. });
  38069. /**
  38070. * Force the gamepad to synchronize with device values
  38071. */
  38072. Xbox360Pad.prototype.update = function () {
  38073. _super.prototype.update.call(this);
  38074. if (this._isXboxOnePad) {
  38075. this.buttonA = this.browserGamepad.buttons[0].value;
  38076. this.buttonB = this.browserGamepad.buttons[1].value;
  38077. this.buttonX = this.browserGamepad.buttons[2].value;
  38078. this.buttonY = this.browserGamepad.buttons[3].value;
  38079. this.buttonLB = this.browserGamepad.buttons[4].value;
  38080. this.buttonRB = this.browserGamepad.buttons[5].value;
  38081. this.leftTrigger = this.browserGamepad.axes[2];
  38082. this.rightTrigger = this.browserGamepad.axes[5];
  38083. this.buttonBack = this.browserGamepad.buttons[9].value;
  38084. this.buttonStart = this.browserGamepad.buttons[8].value;
  38085. this.buttonLeftStick = this.browserGamepad.buttons[6].value;
  38086. this.buttonRightStick = this.browserGamepad.buttons[7].value;
  38087. this.dPadUp = this.browserGamepad.buttons[11].value;
  38088. this.dPadDown = this.browserGamepad.buttons[12].value;
  38089. this.dPadLeft = this.browserGamepad.buttons[13].value;
  38090. this.dPadRight = this.browserGamepad.buttons[14].value;
  38091. }
  38092. else {
  38093. this.buttonA = this.browserGamepad.buttons[0].value;
  38094. this.buttonB = this.browserGamepad.buttons[1].value;
  38095. this.buttonX = this.browserGamepad.buttons[2].value;
  38096. this.buttonY = this.browserGamepad.buttons[3].value;
  38097. this.buttonLB = this.browserGamepad.buttons[4].value;
  38098. this.buttonRB = this.browserGamepad.buttons[5].value;
  38099. this.leftTrigger = this.browserGamepad.buttons[6].value;
  38100. this.rightTrigger = this.browserGamepad.buttons[7].value;
  38101. this.buttonBack = this.browserGamepad.buttons[8].value;
  38102. this.buttonStart = this.browserGamepad.buttons[9].value;
  38103. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  38104. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  38105. this.dPadUp = this.browserGamepad.buttons[12].value;
  38106. this.dPadDown = this.browserGamepad.buttons[13].value;
  38107. this.dPadLeft = this.browserGamepad.buttons[14].value;
  38108. this.dPadRight = this.browserGamepad.buttons[15].value;
  38109. }
  38110. };
  38111. /**
  38112. * Disposes the gamepad
  38113. */
  38114. Xbox360Pad.prototype.dispose = function () {
  38115. _super.prototype.dispose.call(this);
  38116. this.onButtonDownObservable.clear();
  38117. this.onButtonUpObservable.clear();
  38118. this.onPadDownObservable.clear();
  38119. this.onPadUpObservable.clear();
  38120. };
  38121. return Xbox360Pad;
  38122. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  38123. /***/ }),
  38124. /***/ "./Gizmos/axisDragGizmo.ts":
  38125. /*!*********************************!*\
  38126. !*** ./Gizmos/axisDragGizmo.ts ***!
  38127. \*********************************/
  38128. /*! exports provided: AxisDragGizmo */
  38129. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38130. "use strict";
  38131. __webpack_require__.r(__webpack_exports__);
  38132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  38133. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38134. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38135. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38136. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  38137. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  38138. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38139. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38140. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38141. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38142. /**
  38143. * Single axis drag gizmo
  38144. */
  38145. var AxisDragGizmo = /** @class */ (function (_super) {
  38146. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  38147. /**
  38148. * Creates an AxisDragGizmo
  38149. * @param gizmoLayer The utility layer the gizmo will be added to
  38150. * @param dragAxis The axis which the gizmo will be able to drag on
  38151. * @param color The color of the gizmo
  38152. */
  38153. function AxisDragGizmo(dragAxis, color, gizmoLayer) {
  38154. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  38155. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38156. var _this = _super.call(this, gizmoLayer) || this;
  38157. _this._pointerObserver = null;
  38158. /**
  38159. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38160. */
  38161. _this.snapDistance = 0;
  38162. /**
  38163. * Event that fires each time the gizmo snaps to a new location.
  38164. * * snapDistance is the the change in distance
  38165. */
  38166. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38167. // Create Material
  38168. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38169. coloredMaterial.diffuseColor = color;
  38170. coloredMaterial.specularColor = color.subtract(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1));
  38171. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38172. hoverMaterial.diffuseColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38173. // Build mesh on root node
  38174. var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
  38175. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  38176. arrow.scaling.scaleInPlace(1 / 3);
  38177. arrow.parent = _this._rootMesh;
  38178. var currentSnapDragDistance = 0;
  38179. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38180. var tmpSnapEvent = { snapDistance: 0 };
  38181. // Add drag behavior to handle events when the gizmo is dragged
  38182. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38183. _this.dragBehavior.moveAttached = false;
  38184. _this._rootMesh.addBehavior(_this.dragBehavior);
  38185. var localDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38186. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  38187. _this.dragBehavior.onDragObservable.add(function (event) {
  38188. if (_this.attachedMesh) {
  38189. // Convert delta to local translation if it has a parent
  38190. if (_this.attachedMesh.parent) {
  38191. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  38192. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  38193. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  38194. }
  38195. else {
  38196. localDelta.copyFrom(event.delta);
  38197. }
  38198. // Snapping logic
  38199. if (_this.snapDistance == 0) {
  38200. _this.attachedMesh.position.addInPlace(localDelta);
  38201. }
  38202. else {
  38203. currentSnapDragDistance += event.dragDistance;
  38204. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38205. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38206. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38207. localDelta.normalizeToRef(tmpVector);
  38208. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  38209. _this.attachedMesh.position.addInPlace(tmpVector);
  38210. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  38211. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38212. }
  38213. }
  38214. }
  38215. });
  38216. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38217. if (_this._customMeshSet) {
  38218. return;
  38219. }
  38220. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38221. var material = isHovered ? hoverMaterial : coloredMaterial;
  38222. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38223. m.material = material;
  38224. if (m.color) {
  38225. m.color = material.diffuseColor;
  38226. }
  38227. });
  38228. });
  38229. var light = gizmoLayer._getSharedGizmoLight();
  38230. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes(false));
  38231. return _this;
  38232. }
  38233. /** @hidden */
  38234. AxisDragGizmo._CreateArrow = function (scene, material) {
  38235. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  38236. var cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 0.075, diameterBottom: 0.0375, tessellation: 96 }, scene);
  38237. var line = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0.005, height: 0.275, diameterBottom: 0.005, tessellation: 96 }, scene);
  38238. line.material = material;
  38239. cylinder.parent = arrow;
  38240. line.parent = arrow;
  38241. // Position arrow pointing in its drag axis
  38242. cylinder.material = material;
  38243. cylinder.rotation.x = Math.PI / 2;
  38244. cylinder.position.z += 0.3;
  38245. line.position.z += 0.275 / 2;
  38246. line.rotation.x = Math.PI / 2;
  38247. return arrow;
  38248. };
  38249. /** @hidden */
  38250. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  38251. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  38252. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  38253. var mesh = _a[_i];
  38254. var childInstance = mesh.createInstance(mesh.name);
  38255. childInstance.parent = instance;
  38256. }
  38257. return instance;
  38258. };
  38259. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  38260. if (this.dragBehavior) {
  38261. this.dragBehavior.enabled = value ? true : false;
  38262. }
  38263. };
  38264. /**
  38265. * Disposes of the gizmo
  38266. */
  38267. AxisDragGizmo.prototype.dispose = function () {
  38268. this.onSnapObservable.clear();
  38269. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38270. this.dragBehavior.detach();
  38271. _super.prototype.dispose.call(this);
  38272. };
  38273. return AxisDragGizmo;
  38274. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  38275. /***/ }),
  38276. /***/ "./Gizmos/axisScaleGizmo.ts":
  38277. /*!**********************************!*\
  38278. !*** ./Gizmos/axisScaleGizmo.ts ***!
  38279. \**********************************/
  38280. /*! exports provided: AxisScaleGizmo */
  38281. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38282. "use strict";
  38283. __webpack_require__.r(__webpack_exports__);
  38284. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  38285. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38286. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38287. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38288. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38289. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  38290. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  38291. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38292. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38293. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38294. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38295. /**
  38296. * Single axis scale gizmo
  38297. */
  38298. var AxisScaleGizmo = /** @class */ (function (_super) {
  38299. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  38300. /**
  38301. * Creates an AxisScaleGizmo
  38302. * @param gizmoLayer The utility layer the gizmo will be added to
  38303. * @param dragAxis The axis which the gizmo will be able to scale on
  38304. * @param color The color of the gizmo
  38305. */
  38306. function AxisScaleGizmo(dragAxis, color, gizmoLayer) {
  38307. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  38308. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38309. var _this = _super.call(this, gizmoLayer) || this;
  38310. _this._pointerObserver = null;
  38311. /**
  38312. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38313. */
  38314. _this.snapDistance = 0;
  38315. /**
  38316. * Event that fires each time the gizmo snaps to a new location.
  38317. * * snapDistance is the the change in distance
  38318. */
  38319. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38320. /**
  38321. * If the scaling operation should be done on all axis (default: false)
  38322. */
  38323. _this.uniformScaling = false;
  38324. // Create Material
  38325. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38326. _this._coloredMaterial.diffuseColor = color;
  38327. _this._coloredMaterial.specularColor = color.subtract(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1));
  38328. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38329. hoverMaterial.diffuseColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38330. // Build mesh on root node
  38331. var arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38332. var arrowMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__["BoxBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  38333. var arrowTail = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0.005, height: 0.275, diameterBottom: 0.005, tessellation: 96 }, gizmoLayer.utilityLayerScene);
  38334. arrowTail.material = _this._coloredMaterial;
  38335. arrow.addChild(arrowMesh);
  38336. arrow.addChild(arrowTail);
  38337. // Position arrow pointing in its drag axis
  38338. arrowMesh.scaling.scaleInPlace(0.1);
  38339. arrowMesh.material = _this._coloredMaterial;
  38340. arrowMesh.rotation.x = Math.PI / 2;
  38341. arrowMesh.position.z += 0.3;
  38342. arrowTail.position.z += 0.275 / 2;
  38343. arrowTail.rotation.x = Math.PI / 2;
  38344. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  38345. _this._rootMesh.addChild(arrow);
  38346. arrow.scaling.scaleInPlace(1 / 3);
  38347. // Add drag behavior to handle events when the gizmo is dragged
  38348. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38349. _this.dragBehavior.moveAttached = false;
  38350. _this._rootMesh.addBehavior(_this.dragBehavior);
  38351. var currentSnapDragDistance = 0;
  38352. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38353. var tmpSnapEvent = { snapDistance: 0 };
  38354. _this.dragBehavior.onDragObservable.add(function (event) {
  38355. if (_this.attachedMesh) {
  38356. // Snapping logic
  38357. var snapped = false;
  38358. var dragSteps = 0;
  38359. if (_this.uniformScaling) {
  38360. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  38361. if (tmpVector.y < 0) {
  38362. tmpVector.scaleInPlace(-1);
  38363. }
  38364. }
  38365. else {
  38366. tmpVector.copyFrom(dragAxis);
  38367. }
  38368. if (_this.snapDistance == 0) {
  38369. tmpVector.scaleToRef(event.dragDistance, tmpVector);
  38370. }
  38371. else {
  38372. currentSnapDragDistance += event.dragDistance;
  38373. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38374. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38375. if (currentSnapDragDistance < 0) {
  38376. dragSteps *= -1;
  38377. }
  38378. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38379. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  38380. snapped = true;
  38381. }
  38382. else {
  38383. tmpVector.scaleInPlace(0);
  38384. }
  38385. }
  38386. _this.attachedMesh.scaling.addInPlace(tmpVector);
  38387. if (snapped) {
  38388. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  38389. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38390. }
  38391. }
  38392. });
  38393. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38394. if (_this._customMeshSet) {
  38395. return;
  38396. }
  38397. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38398. var material = isHovered ? hoverMaterial : _this._coloredMaterial;
  38399. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38400. m.material = material;
  38401. if (m.color) {
  38402. m.color = material.diffuseColor;
  38403. }
  38404. });
  38405. });
  38406. var light = gizmoLayer._getSharedGizmoLight();
  38407. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes());
  38408. return _this;
  38409. }
  38410. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  38411. if (this.dragBehavior) {
  38412. this.dragBehavior.enabled = value ? true : false;
  38413. }
  38414. };
  38415. /**
  38416. * Disposes of the gizmo
  38417. */
  38418. AxisScaleGizmo.prototype.dispose = function () {
  38419. this.onSnapObservable.clear();
  38420. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38421. this.dragBehavior.detach();
  38422. _super.prototype.dispose.call(this);
  38423. };
  38424. /**
  38425. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38426. * @param mesh The mesh to replace the default mesh of the gizmo
  38427. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  38428. */
  38429. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  38430. var _this = this;
  38431. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  38432. _super.prototype.setCustomMesh.call(this, mesh);
  38433. if (useGizmoMaterial) {
  38434. this._rootMesh.getChildMeshes().forEach(function (m) {
  38435. m.material = _this._coloredMaterial;
  38436. if (m.color) {
  38437. m.color = _this._coloredMaterial.diffuseColor;
  38438. }
  38439. });
  38440. this._customMeshSet = false;
  38441. }
  38442. };
  38443. return AxisScaleGizmo;
  38444. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  38445. /***/ }),
  38446. /***/ "./Gizmos/boundingBoxGizmo.ts":
  38447. /*!************************************!*\
  38448. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  38449. \************************************/
  38450. /*! exports provided: BoundingBoxGizmo */
  38451. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38452. "use strict";
  38453. __webpack_require__.r(__webpack_exports__);
  38454. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  38455. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38456. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38457. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38458. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38459. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38460. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38461. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  38462. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  38463. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  38464. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38465. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38466. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38467. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38468. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  38469. /**
  38470. * Bounding box gizmo
  38471. */
  38472. var BoundingBoxGizmo = /** @class */ (function (_super) {
  38473. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  38474. /**
  38475. * Creates an BoundingBoxGizmo
  38476. * @param gizmoLayer The utility layer the gizmo will be added to
  38477. * @param color The color of the gizmo
  38478. */
  38479. function BoundingBoxGizmo(color, gizmoLayer) {
  38480. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  38481. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  38482. var _this = _super.call(this, gizmoLayer) || this;
  38483. _this._boundingDimensions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  38484. _this._renderObserver = null;
  38485. _this._pointerObserver = null;
  38486. _this._scaleDragSpeed = 0.2;
  38487. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38488. _this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  38489. _this._tmpRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  38490. /**
  38491. * 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)
  38492. */
  38493. _this.ignoreChildren = false;
  38494. /**
  38495. * 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)
  38496. */
  38497. _this.includeChildPredicate = null;
  38498. /**
  38499. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  38500. */
  38501. _this.rotationSphereSize = 0.1;
  38502. /**
  38503. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  38504. */
  38505. _this.scaleBoxSize = 0.1;
  38506. /**
  38507. * 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)
  38508. */
  38509. _this.fixedDragMeshScreenSize = false;
  38510. /**
  38511. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  38512. */
  38513. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  38514. /**
  38515. * Fired when a rotation sphere or scale box is dragged
  38516. */
  38517. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38518. /**
  38519. * Fired when a scale box is dragged
  38520. */
  38521. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38522. /**
  38523. * Fired when a scale box drag is ended
  38524. */
  38525. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38526. /**
  38527. * Fired when a rotation sphere is dragged
  38528. */
  38529. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38530. /**
  38531. * Fired when a rotation sphere drag is ended
  38532. */
  38533. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38534. /**
  38535. * 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)
  38536. */
  38537. _this.scalePivot = null;
  38538. _this._existingMeshScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  38539. // Dragging
  38540. _this._dragMesh = null;
  38541. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]();
  38542. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  38543. _this._updateScale = false;
  38544. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  38545. // Create Materials
  38546. _this.coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38547. _this.coloredMaterial.disableLighting = true;
  38548. _this.hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38549. _this.hoverColoredMaterial.disableLighting = true;
  38550. // Build bounding box out of lines
  38551. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38552. _this._lineBoundingBox.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38553. var lines = [];
  38554. 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));
  38555. 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));
  38556. 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));
  38557. 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));
  38558. 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));
  38559. 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));
  38560. 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));
  38561. 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));
  38562. 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));
  38563. 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));
  38564. 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));
  38565. 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));
  38566. lines.forEach(function (l) {
  38567. l.color = color;
  38568. l.position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  38569. l.isPickable = false;
  38570. _this._lineBoundingBox.addChild(l);
  38571. });
  38572. _this._rootMesh.addChild(_this._lineBoundingBox);
  38573. _this.setColor(color);
  38574. // Create rotation spheres
  38575. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38576. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38577. var _loop_1 = function (i_1) {
  38578. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__["SphereBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  38579. sphere.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38580. sphere.material = this_1.coloredMaterial;
  38581. // Drag behavior
  38582. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({});
  38583. _dragBehavior.moveAttached = false;
  38584. _dragBehavior.updateDragPlane = false;
  38585. sphere.addBehavior(_dragBehavior);
  38586. var startingTurnDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  38587. var totalTurnAmountOfDrag = 0;
  38588. _dragBehavior.onDragStartObservable.add(function () {
  38589. startingTurnDirection.copyFrom(sphere.forward);
  38590. totalTurnAmountOfDrag = 0;
  38591. });
  38592. _dragBehavior.onDragObservable.add(function (event) {
  38593. _this.onRotationSphereDragObservable.notifyObservers({});
  38594. if (_this.attachedMesh) {
  38595. var originalParent = _this.attachedMesh.parent;
  38596. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  38597. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  38598. return;
  38599. }
  38600. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  38601. var worldDragDirection = startingTurnDirection;
  38602. // Project the world right on to the drag plane
  38603. var toSub = event.dragPlaneNormal.scale(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  38604. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  38605. // project drag delta on to the resulting drag axis and rotate based on that
  38606. var projectDist = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  38607. // Make rotation relative to size of mesh.
  38608. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  38609. // Rotate based on axis
  38610. if (!_this.attachedMesh.rotationQuaternion) {
  38611. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  38612. }
  38613. if (!_this._anchorMesh.rotationQuaternion) {
  38614. _this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  38615. }
  38616. // Do not allow the object to turn more than a full circle
  38617. totalTurnAmountOfDrag += projectDist;
  38618. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  38619. if (i_1 >= 8) {
  38620. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  38621. }
  38622. else if (i_1 >= 4) {
  38623. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  38624. }
  38625. else {
  38626. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  38627. }
  38628. // Rotate around center of bounding box
  38629. _this._anchorMesh.addChild(_this.attachedMesh);
  38630. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  38631. _this._anchorMesh.removeChild(_this.attachedMesh);
  38632. _this.attachedMesh.setParent(originalParent);
  38633. }
  38634. _this.updateBoundingBox();
  38635. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  38636. }
  38637. _this._updateDummy();
  38638. });
  38639. // Selection/deselection
  38640. _dragBehavior.onDragStartObservable.add(function () {
  38641. _this.onDragStartObservable.notifyObservers({});
  38642. _this._selectNode(sphere);
  38643. });
  38644. _dragBehavior.onDragEndObservable.add(function () {
  38645. _this.onRotationSphereDragEndObservable.notifyObservers({});
  38646. _this._selectNode(null);
  38647. _this._updateDummy();
  38648. });
  38649. this_1._rotateSpheresParent.addChild(sphere);
  38650. };
  38651. var this_1 = this, _dragBehavior;
  38652. for (var i_1 = 0; i_1 < 12; i_1++) {
  38653. _loop_1(i_1);
  38654. }
  38655. _this._rootMesh.addChild(_this._rotateSpheresParent);
  38656. // Create scale cubes
  38657. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38658. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38659. for (var i = 0; i < 2; i++) {
  38660. for (var j = 0; j < 2; j++) {
  38661. var _loop_2 = function () {
  38662. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  38663. box.material = this_2.coloredMaterial;
  38664. // Dragging logic
  38665. var dragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  38666. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({ dragAxis: dragAxis });
  38667. _dragBehavior.moveAttached = false;
  38668. box.addBehavior(_dragBehavior);
  38669. _dragBehavior.onDragObservable.add(function (event) {
  38670. _this.onScaleBoxDragObservable.notifyObservers({});
  38671. if (_this.attachedMesh) {
  38672. var originalParent = _this.attachedMesh.parent;
  38673. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  38674. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  38675. return;
  38676. }
  38677. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  38678. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  38679. var deltaScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  38680. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  38681. _this.updateBoundingBox();
  38682. if (_this.scalePivot) {
  38683. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  38684. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  38685. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  38686. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  38687. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  38688. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  38689. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  38690. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  38691. }
  38692. else {
  38693. // Scale from the position of the opposite corner
  38694. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  38695. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  38696. }
  38697. _this._anchorMesh.addChild(_this.attachedMesh);
  38698. _this._anchorMesh.scaling.addInPlace(deltaScale);
  38699. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  38700. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  38701. }
  38702. _this._anchorMesh.removeChild(_this.attachedMesh);
  38703. _this.attachedMesh.setParent(originalParent);
  38704. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  38705. }
  38706. _this._updateDummy();
  38707. });
  38708. // Selection/deselection
  38709. _dragBehavior.onDragStartObservable.add(function () {
  38710. _this.onDragStartObservable.notifyObservers({});
  38711. _this._selectNode(box);
  38712. });
  38713. _dragBehavior.onDragEndObservable.add(function () {
  38714. _this.onScaleBoxDragEndObservable.notifyObservers({});
  38715. _this._selectNode(null);
  38716. _this._updateDummy();
  38717. });
  38718. this_2._scaleBoxesParent.addChild(box);
  38719. };
  38720. var this_2 = this, _dragBehavior;
  38721. for (var k = 0; k < 2; k++) {
  38722. _loop_2();
  38723. }
  38724. }
  38725. }
  38726. _this._rootMesh.addChild(_this._scaleBoxesParent);
  38727. // Hover color change
  38728. var pointerIds = new Array();
  38729. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38730. if (!pointerIds[pointerInfo.event.pointerId]) {
  38731. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  38732. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  38733. pointerIds[pointerInfo.event.pointerId] = mesh;
  38734. mesh.material = _this.hoverColoredMaterial;
  38735. }
  38736. });
  38737. }
  38738. else {
  38739. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  38740. pointerIds[pointerInfo.event.pointerId].material = _this.coloredMaterial;
  38741. delete pointerIds[pointerInfo.event.pointerId];
  38742. }
  38743. }
  38744. });
  38745. // Update bounding box positions
  38746. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  38747. // Only update the bouding box if scaling has changed
  38748. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  38749. _this.updateBoundingBox();
  38750. }
  38751. else if (_this.fixedDragMeshScreenSize) {
  38752. _this._updateRotationSpheres();
  38753. _this._updateScaleBoxes();
  38754. }
  38755. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  38756. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  38757. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  38758. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  38759. }
  38760. });
  38761. _this.updateBoundingBox();
  38762. return _this;
  38763. }
  38764. /**
  38765. * Sets the color of the bounding box gizmo
  38766. * @param color the color to set
  38767. */
  38768. BoundingBoxGizmo.prototype.setColor = function (color) {
  38769. this.coloredMaterial.emissiveColor = color;
  38770. this.hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  38771. this._lineBoundingBox.getChildren().forEach(function (l) {
  38772. if (l.color) {
  38773. l.color = color;
  38774. }
  38775. });
  38776. };
  38777. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  38778. var _this = this;
  38779. if (value) {
  38780. // Reset anchor mesh to match attached mesh's scale
  38781. // This is needed to avoid invalid box/sphere position on first drag
  38782. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(value);
  38783. var originalParent = value.parent;
  38784. this._anchorMesh.addChild(value);
  38785. this._anchorMesh.removeChild(value);
  38786. value.setParent(originalParent);
  38787. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(value);
  38788. this.updateBoundingBox();
  38789. value.getChildMeshes(false).forEach(function (m) {
  38790. m.markAsDirty("scaling");
  38791. });
  38792. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  38793. _this._updateDummy();
  38794. });
  38795. }
  38796. };
  38797. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  38798. this._rotateSpheresParent.getChildMeshes()
  38799. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  38800. m.isVisible = (!selectedMesh || m == selectedMesh);
  38801. });
  38802. };
  38803. /**
  38804. * Updates the bounding box information for the Gizmo
  38805. */
  38806. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  38807. if (this.attachedMesh) {
  38808. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  38809. var originalParent = this.attachedMesh.parent;
  38810. this.attachedMesh.setParent(null);
  38811. this._update();
  38812. // Rotate based on axis
  38813. if (!this.attachedMesh.rotationQuaternion) {
  38814. this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  38815. }
  38816. if (!this._anchorMesh.rotationQuaternion) {
  38817. this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  38818. }
  38819. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  38820. // Store original position and reset mesh to origin before computing the bounding box
  38821. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  38822. this._tmpVector.copyFrom(this.attachedMesh.position);
  38823. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  38824. this.attachedMesh.position.set(0, 0, 0);
  38825. // Update bounding dimensions/positions
  38826. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  38827. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  38828. // Update gizmo to match bounding box scaling and rotation
  38829. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  38830. 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);
  38831. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  38832. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  38833. this._lineBoundingBox.computeWorldMatrix();
  38834. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  38835. // restore position/rotation values
  38836. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  38837. this.attachedMesh.position.copyFrom(this._tmpVector);
  38838. this.attachedMesh.setParent(originalParent);
  38839. }
  38840. this._updateRotationSpheres();
  38841. this._updateScaleBoxes();
  38842. if (this.attachedMesh) {
  38843. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  38844. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  38845. }
  38846. };
  38847. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  38848. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  38849. for (var i = 0; i < 3; i++) {
  38850. for (var j = 0; j < 2; j++) {
  38851. for (var k = 0; k < 2; k++) {
  38852. var index = ((i * 4) + (j * 2)) + k;
  38853. if (i == 0) {
  38854. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  38855. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38856. 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));
  38857. }
  38858. if (i == 1) {
  38859. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  38860. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38861. 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));
  38862. }
  38863. if (i == 2) {
  38864. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  38865. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38866. 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));
  38867. }
  38868. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  38869. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  38870. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  38871. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  38872. }
  38873. else {
  38874. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  38875. }
  38876. }
  38877. }
  38878. }
  38879. };
  38880. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  38881. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  38882. for (var i = 0; i < 2; i++) {
  38883. for (var j = 0; j < 2; j++) {
  38884. for (var k = 0; k < 2; k++) {
  38885. var index = ((i * 4) + (j * 2)) + k;
  38886. if (scaleBoxes[index]) {
  38887. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  38888. scaleBoxes[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38889. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  38890. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  38891. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  38892. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  38893. }
  38894. else {
  38895. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  38896. }
  38897. }
  38898. }
  38899. }
  38900. }
  38901. };
  38902. /**
  38903. * Enables rotation on the specified axis and disables rotation on the others
  38904. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  38905. */
  38906. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  38907. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  38908. if (i < 4) {
  38909. m.setEnabled(axis.indexOf("x") != -1);
  38910. }
  38911. else if (i < 8) {
  38912. m.setEnabled(axis.indexOf("y") != -1);
  38913. }
  38914. else {
  38915. m.setEnabled(axis.indexOf("z") != -1);
  38916. }
  38917. });
  38918. };
  38919. /**
  38920. * Enables/disables scaling
  38921. * @param enable if scaling should be enabled
  38922. */
  38923. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  38924. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  38925. m.setEnabled(enable);
  38926. });
  38927. };
  38928. BoundingBoxGizmo.prototype._updateDummy = function () {
  38929. if (this._dragMesh) {
  38930. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  38931. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  38932. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  38933. }
  38934. };
  38935. /**
  38936. * Enables a pointer drag behavior on the bounding box of the gizmo
  38937. */
  38938. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  38939. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  38940. this._dragMesh.visibility = 0;
  38941. this._dragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38942. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  38943. this._dragMesh.addBehavior(this.pointerDragBehavior);
  38944. };
  38945. /**
  38946. * Disposes of the gizmo
  38947. */
  38948. BoundingBoxGizmo.prototype.dispose = function () {
  38949. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38950. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  38951. this._lineBoundingBox.dispose();
  38952. this._rotateSpheresParent.dispose();
  38953. this._scaleBoxesParent.dispose();
  38954. if (this._dragMesh) {
  38955. this._dragMesh.dispose();
  38956. }
  38957. _super.prototype.dispose.call(this);
  38958. };
  38959. /**
  38960. * 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)
  38961. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  38962. * @returns the bounding box mesh with the passed in mesh as a child
  38963. */
  38964. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  38965. var makeNotPickable = function (root) {
  38966. root.isPickable = false;
  38967. root.getChildMeshes().forEach(function (c) {
  38968. makeNotPickable(c);
  38969. });
  38970. };
  38971. makeNotPickable(mesh);
  38972. // Reset position to get boudning box from origin with no rotation
  38973. if (!mesh.rotationQuaternion) {
  38974. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  38975. }
  38976. var oldPos = mesh.position.clone();
  38977. var oldRot = mesh.rotationQuaternion.clone();
  38978. mesh.rotationQuaternion.set(0, 0, 0, 1);
  38979. mesh.position.set(0, 0, 0);
  38980. // Update bounding dimensions/positions
  38981. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  38982. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  38983. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  38984. // Adjust scale to avoid undefined behavior when adding child
  38985. if (box.scaling.y === 0) {
  38986. box.scaling.y = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38987. }
  38988. if (box.scaling.x === 0) {
  38989. box.scaling.x = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38990. }
  38991. if (box.scaling.z === 0) {
  38992. box.scaling.z = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38993. }
  38994. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  38995. // Restore original positions
  38996. mesh.addChild(box);
  38997. mesh.rotationQuaternion.copyFrom(oldRot);
  38998. mesh.position.copyFrom(oldPos);
  38999. // Reverse parenting
  39000. mesh.removeChild(box);
  39001. box.addChild(mesh);
  39002. box.visibility = 0;
  39003. return box;
  39004. };
  39005. /**
  39006. * CustomMeshes are not supported by this gizmo
  39007. * @param mesh The mesh to replace the default mesh of the gizmo
  39008. */
  39009. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  39010. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  39011. };
  39012. return BoundingBoxGizmo;
  39013. }(_gizmo__WEBPACK_IMPORTED_MODULE_10__["Gizmo"]));
  39014. /***/ }),
  39015. /***/ "./Gizmos/gizmo.ts":
  39016. /*!*************************!*\
  39017. !*** ./Gizmos/gizmo.ts ***!
  39018. \*************************/
  39019. /*! exports provided: Gizmo */
  39020. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39021. "use strict";
  39022. __webpack_require__.r(__webpack_exports__);
  39023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  39024. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39025. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39026. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39027. /**
  39028. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39029. */
  39030. var Gizmo = /** @class */ (function () {
  39031. /**
  39032. * Creates a gizmo
  39033. * @param gizmoLayer The utility layer the gizmo will be added to
  39034. */
  39035. function Gizmo(
  39036. /** The utility layer the gizmo will be added to */
  39037. gizmoLayer) {
  39038. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39039. var _this = this;
  39040. this.gizmoLayer = gizmoLayer;
  39041. /**
  39042. * Ratio for the scale of the gizmo (Default: 1)
  39043. */
  39044. this.scaleRatio = 1;
  39045. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  39046. /**
  39047. * If a custom mesh has been set (Default: false)
  39048. */
  39049. this._customMeshSet = false;
  39050. /**
  39051. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39052. */
  39053. this.updateGizmoRotationToMatchAttachedMesh = true;
  39054. /**
  39055. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  39056. */
  39057. this.updateGizmoPositionToMatchAttachedMesh = true;
  39058. /**
  39059. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  39060. */
  39061. this._updateScale = true;
  39062. this._interactionsEnabled = true;
  39063. this._tempVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  39064. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  39065. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  39066. _this._update();
  39067. });
  39068. this.attachedMesh = null;
  39069. }
  39070. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  39071. /**
  39072. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39073. * * When set, interactions will be enabled
  39074. */
  39075. get: function () {
  39076. return this._attachedMesh;
  39077. },
  39078. set: function (value) {
  39079. this._attachedMesh = value;
  39080. this._rootMesh.setEnabled(value ? true : false);
  39081. this._attachedMeshChanged(value);
  39082. },
  39083. enumerable: true,
  39084. configurable: true
  39085. });
  39086. /**
  39087. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39088. * @param mesh The mesh to replace the default mesh of the gizmo
  39089. */
  39090. Gizmo.prototype.setCustomMesh = function (mesh) {
  39091. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  39092. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  39093. }
  39094. this._rootMesh.getChildMeshes().forEach(function (c) {
  39095. c.dispose();
  39096. });
  39097. mesh.parent = this._rootMesh;
  39098. this._customMeshSet = true;
  39099. };
  39100. Gizmo.prototype._attachedMeshChanged = function (value) {
  39101. };
  39102. /**
  39103. * @hidden
  39104. * Updates the gizmo to match the attached mesh's position/rotation
  39105. */
  39106. Gizmo.prototype._update = function () {
  39107. if (this.attachedMesh) {
  39108. var effectiveMesh = this.attachedMesh._effectiveMesh || this.attachedMesh;
  39109. if (this.updateGizmoRotationToMatchAttachedMesh) {
  39110. if (!this._rootMesh.rotationQuaternion) {
  39111. this._rootMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(this._rootMesh.rotation.y, this._rootMesh.rotation.x, this._rootMesh.rotation.z);
  39112. }
  39113. // Remove scaling before getting rotation matrix to get rotation matrix unmodified by scale
  39114. this._tempVector.copyFrom(effectiveMesh.scaling);
  39115. if (effectiveMesh.scaling.x < 0) {
  39116. effectiveMesh.scaling.x *= -1;
  39117. }
  39118. if (effectiveMesh.scaling.y < 0) {
  39119. effectiveMesh.scaling.y *= -1;
  39120. }
  39121. if (effectiveMesh.scaling.z < 0) {
  39122. effectiveMesh.scaling.z *= -1;
  39123. }
  39124. effectiveMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);
  39125. effectiveMesh.scaling.copyFrom(this._tempVector);
  39126. effectiveMesh.computeWorldMatrix();
  39127. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._tmpMatrix, this._rootMesh.rotationQuaternion);
  39128. }
  39129. else if (this._rootMesh.rotationQuaternion) {
  39130. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  39131. }
  39132. if (this.updateGizmoPositionToMatchAttachedMesh) {
  39133. this._rootMesh.position.copyFrom(effectiveMesh.absolutePosition);
  39134. }
  39135. if (this._updateScale && this.gizmoLayer.utilityLayerScene.activeCamera && this.attachedMesh) {
  39136. var cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition;
  39137. if (this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition) {
  39138. cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition;
  39139. }
  39140. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  39141. var dist = this._tempVector.length() * this.scaleRatio;
  39142. this._rootMesh.scaling.set(dist, dist, dist);
  39143. }
  39144. }
  39145. };
  39146. /**
  39147. * Disposes of the gizmo
  39148. */
  39149. Gizmo.prototype.dispose = function () {
  39150. this._rootMesh.dispose();
  39151. if (this._beforeRenderObserver) {
  39152. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  39153. }
  39154. };
  39155. return Gizmo;
  39156. }());
  39157. /***/ }),
  39158. /***/ "./Gizmos/gizmoManager.ts":
  39159. /*!********************************!*\
  39160. !*** ./Gizmos/gizmoManager.ts ***!
  39161. \********************************/
  39162. /*! exports provided: GizmoManager */
  39163. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39164. "use strict";
  39165. __webpack_require__.r(__webpack_exports__);
  39166. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return GizmoManager; });
  39167. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39168. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  39169. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39170. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39171. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39172. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  39173. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  39174. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  39175. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  39176. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  39177. /**
  39178. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  39179. */
  39180. var GizmoManager = /** @class */ (function () {
  39181. /**
  39182. * Instatiates a gizmo manager
  39183. * @param scene the scene to overlay the gizmos on top of
  39184. */
  39185. function GizmoManager(scene) {
  39186. var _this = this;
  39187. this.scene = scene;
  39188. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  39189. this.clearGizmoOnEmptyPointerEvent = false;
  39190. /** Fires an event when the manager is attached to a mesh */
  39191. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  39192. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  39193. this._pointerObserver = null;
  39194. this._attachedMesh = null;
  39195. this._boundingBoxColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  39196. /**
  39197. * When bounding box gizmo is enabled, this can be used to track drag/end events
  39198. */
  39199. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  39200. /**
  39201. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  39202. */
  39203. this.attachableMeshes = null;
  39204. /**
  39205. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  39206. */
  39207. this.usePointerToAttachGizmos = true;
  39208. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  39209. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  39210. this._defaultUtilityLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"].DefaultUtilityLayer;
  39211. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  39212. // Instatiate/dispose gizmos based on pointer actions
  39213. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  39214. if (!_this.usePointerToAttachGizmos) {
  39215. return;
  39216. }
  39217. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  39218. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  39219. var node = pointerInfo.pickInfo.pickedMesh;
  39220. if (_this.attachableMeshes == null) {
  39221. // Attach to the most parent node
  39222. while (node && node.parent != null) {
  39223. node = node.parent;
  39224. }
  39225. }
  39226. else {
  39227. // Attach to the parent node that is an attachableMesh
  39228. var found = false;
  39229. _this.attachableMeshes.forEach(function (mesh) {
  39230. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  39231. node = mesh;
  39232. found = true;
  39233. }
  39234. });
  39235. if (!found) {
  39236. node = null;
  39237. }
  39238. }
  39239. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  39240. if (_this._attachedMesh != node) {
  39241. _this.attachToMesh(node);
  39242. }
  39243. }
  39244. else {
  39245. if (_this.clearGizmoOnEmptyPointerEvent) {
  39246. _this.attachToMesh(null);
  39247. }
  39248. }
  39249. }
  39250. else {
  39251. if (_this.clearGizmoOnEmptyPointerEvent) {
  39252. _this.attachToMesh(null);
  39253. }
  39254. }
  39255. }
  39256. });
  39257. }
  39258. /**
  39259. * Attaches a set of gizmos to the specified mesh
  39260. * @param mesh The mesh the gizmo's should be attached to
  39261. */
  39262. GizmoManager.prototype.attachToMesh = function (mesh) {
  39263. if (this._attachedMesh) {
  39264. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39265. }
  39266. this._attachedMesh = mesh;
  39267. for (var key in this.gizmos) {
  39268. var gizmo = (this.gizmos[key]);
  39269. if (gizmo && this._gizmosEnabled[key]) {
  39270. gizmo.attachedMesh = mesh;
  39271. }
  39272. }
  39273. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  39274. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  39275. }
  39276. this.onAttachedToMeshObservable.notifyObservers(mesh);
  39277. };
  39278. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  39279. get: function () {
  39280. return this._gizmosEnabled.positionGizmo;
  39281. },
  39282. /**
  39283. * If the position gizmo is enabled
  39284. */
  39285. set: function (value) {
  39286. if (value) {
  39287. if (!this.gizmos.positionGizmo) {
  39288. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  39289. }
  39290. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  39291. }
  39292. else if (this.gizmos.positionGizmo) {
  39293. this.gizmos.positionGizmo.attachedMesh = null;
  39294. }
  39295. this._gizmosEnabled.positionGizmo = value;
  39296. },
  39297. enumerable: true,
  39298. configurable: true
  39299. });
  39300. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  39301. get: function () {
  39302. return this._gizmosEnabled.rotationGizmo;
  39303. },
  39304. /**
  39305. * If the rotation gizmo is enabled
  39306. */
  39307. set: function (value) {
  39308. if (value) {
  39309. if (!this.gizmos.rotationGizmo) {
  39310. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  39311. }
  39312. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  39313. }
  39314. else if (this.gizmos.rotationGizmo) {
  39315. this.gizmos.rotationGizmo.attachedMesh = null;
  39316. }
  39317. this._gizmosEnabled.rotationGizmo = value;
  39318. },
  39319. enumerable: true,
  39320. configurable: true
  39321. });
  39322. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  39323. get: function () {
  39324. return this._gizmosEnabled.scaleGizmo;
  39325. },
  39326. /**
  39327. * If the scale gizmo is enabled
  39328. */
  39329. set: function (value) {
  39330. if (value) {
  39331. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  39332. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  39333. }
  39334. else if (this.gizmos.scaleGizmo) {
  39335. this.gizmos.scaleGizmo.attachedMesh = null;
  39336. }
  39337. this._gizmosEnabled.scaleGizmo = value;
  39338. },
  39339. enumerable: true,
  39340. configurable: true
  39341. });
  39342. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  39343. get: function () {
  39344. return this._gizmosEnabled.boundingBoxGizmo;
  39345. },
  39346. /**
  39347. * If the boundingBox gizmo is enabled
  39348. */
  39349. set: function (value) {
  39350. if (value) {
  39351. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  39352. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  39353. if (this._attachedMesh) {
  39354. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39355. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  39356. }
  39357. }
  39358. else if (this.gizmos.boundingBoxGizmo) {
  39359. if (this._attachedMesh) {
  39360. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  39361. }
  39362. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  39363. }
  39364. this._gizmosEnabled.boundingBoxGizmo = value;
  39365. },
  39366. enumerable: true,
  39367. configurable: true
  39368. });
  39369. /**
  39370. * Disposes of the gizmo manager
  39371. */
  39372. GizmoManager.prototype.dispose = function () {
  39373. this.scene.onPointerObservable.remove(this._pointerObserver);
  39374. for (var key in this.gizmos) {
  39375. var gizmo = (this.gizmos[key]);
  39376. if (gizmo) {
  39377. gizmo.dispose();
  39378. }
  39379. }
  39380. this._defaultKeepDepthUtilityLayer.dispose();
  39381. this.boundingBoxDragBehavior.detach();
  39382. this.onAttachedToMeshObservable.clear();
  39383. };
  39384. return GizmoManager;
  39385. }());
  39386. /***/ }),
  39387. /***/ "./Gizmos/index.ts":
  39388. /*!*************************!*\
  39389. !*** ./Gizmos/index.ts ***!
  39390. \*************************/
  39391. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo */
  39392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39393. "use strict";
  39394. __webpack_require__.r(__webpack_exports__);
  39395. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  39396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  39397. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  39398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  39399. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  39400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  39401. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  39403. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  39404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  39405. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  39406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  39407. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  39408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  39409. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  39410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  39411. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  39412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  39413. /* harmony import */ var _lightGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lightGizmo */ "./Gizmos/lightGizmo.ts");
  39414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _lightGizmo__WEBPACK_IMPORTED_MODULE_9__["LightGizmo"]; });
  39415. /***/ }),
  39416. /***/ "./Gizmos/lightGizmo.ts":
  39417. /*!******************************!*\
  39418. !*** ./Gizmos/lightGizmo.ts ***!
  39419. \******************************/
  39420. /*! exports provided: LightGizmo */
  39421. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39422. "use strict";
  39423. __webpack_require__.r(__webpack_exports__);
  39424. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return LightGizmo; });
  39425. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39426. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39427. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39428. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39429. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39430. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39431. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  39432. /* harmony import */ var _Lights_directionalLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/directionalLight */ "./Lights/directionalLight.ts");
  39433. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  39434. /* harmony import */ var _Meshes_Builders_hemisphereBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/hemisphereBuilder */ "./Meshes/Builders/hemisphereBuilder.ts");
  39435. /* harmony import */ var _Lights_spotLight__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Lights/spotLight */ "./Lights/spotLight.ts");
  39436. /**
  39437. * Gizmo that enables viewing a light
  39438. */
  39439. var LightGizmo = /** @class */ (function (_super) {
  39440. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LightGizmo, _super);
  39441. /**
  39442. * Creates a LightGizmo
  39443. * @param gizmoLayer The utility layer the gizmo will be added to
  39444. */
  39445. function LightGizmo(gizmoLayer) {
  39446. var _this = _super.call(this, gizmoLayer) || this;
  39447. _this._light = null;
  39448. _this.attachedMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", _this.gizmoLayer.utilityLayerScene);
  39449. _this._material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("light", _this.gizmoLayer.originalScene);
  39450. _this._material.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.5, 0.5, 0.5);
  39451. _this._material.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.1, 0.1, 0.1);
  39452. return _this;
  39453. }
  39454. Object.defineProperty(LightGizmo.prototype, "light", {
  39455. get: function () {
  39456. return this._light;
  39457. },
  39458. /**
  39459. * The light that the gizmo is attached to
  39460. */
  39461. set: function (light) {
  39462. var _this = this;
  39463. this._light = light;
  39464. if (light) {
  39465. // Create the mesh for the given light type
  39466. if (this._lightMesh) {
  39467. this._lightMesh.dispose();
  39468. }
  39469. if (light instanceof _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_6__["HemisphericLight"]) {
  39470. this._lightMesh = LightGizmo._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene);
  39471. }
  39472. else if (light instanceof _Lights_directionalLight__WEBPACK_IMPORTED_MODULE_7__["DirectionalLight"]) {
  39473. this._lightMesh = LightGizmo._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene);
  39474. }
  39475. else if (light instanceof _Lights_spotLight__WEBPACK_IMPORTED_MODULE_10__["SpotLight"]) {
  39476. this._lightMesh = LightGizmo._CreateSpotLightMesh(this.gizmoLayer.utilityLayerScene);
  39477. }
  39478. else {
  39479. this._lightMesh = LightGizmo._CreatePointLightMesh(this.gizmoLayer.utilityLayerScene);
  39480. }
  39481. this._lightMesh.getChildMeshes(false).forEach(function (m) {
  39482. m.material = _this._material;
  39483. });
  39484. this._lightMesh.parent = this._rootMesh;
  39485. // Add lighting to the light gizmo
  39486. var gizmoLight = this.gizmoLayer._getSharedGizmoLight();
  39487. gizmoLight.includedOnlyMeshes = gizmoLight.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(false));
  39488. // Get update position and direction if the light has it
  39489. if (light.position) {
  39490. this.attachedMesh.position.copyFrom(light.position);
  39491. }
  39492. if (light.direction) {
  39493. this._lightMesh.setDirection(light.direction);
  39494. }
  39495. }
  39496. },
  39497. enumerable: true,
  39498. configurable: true
  39499. });
  39500. /**
  39501. * @hidden
  39502. * Updates the gizmo to match the attached mesh's position/rotation
  39503. */
  39504. LightGizmo.prototype._update = function () {
  39505. _super.prototype._update.call(this);
  39506. if (!this._light) {
  39507. return;
  39508. }
  39509. if (this._light.position) {
  39510. this._light.position.copyFrom(this.attachedMesh.position);
  39511. }
  39512. if (this._light.direction) {
  39513. this._light.direction.copyFrom(this._lightMesh.forward);
  39514. }
  39515. if (!this._light.isEnabled()) {
  39516. this._material.diffuseColor.set(0, 0, 0);
  39517. }
  39518. else {
  39519. this._material.diffuseColor.set(this._light.diffuse.r / 3, this._light.diffuse.g / 3, this._light.diffuse.b / 3);
  39520. }
  39521. };
  39522. LightGizmo._CreateHemisphericLightMesh = function (scene) {
  39523. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("hemisphereLight", scene);
  39524. var hemisphere = _Meshes_Builders_hemisphereBuilder__WEBPACK_IMPORTED_MODULE_9__["HemisphereBuilder"].CreateHemisphere(root.name, { segments: 10, diameter: 1 }, scene);
  39525. hemisphere.position.z = -0.15;
  39526. hemisphere.rotation.x = Math.PI / 2;
  39527. hemisphere.parent = root;
  39528. var lines = this._createLightLines(3, scene);
  39529. lines.parent = root;
  39530. lines.position.z - 0.15;
  39531. root.scaling.scaleInPlace(LightGizmo._Scale);
  39532. root.rotation.x = Math.PI / 2;
  39533. return root;
  39534. };
  39535. LightGizmo._CreatePointLightMesh = function (scene) {
  39536. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("pointLight", scene);
  39537. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__["SphereBuilder"].CreateSphere(root.name, { segments: 10, diameter: 1 }, scene);
  39538. sphere.rotation.x = Math.PI / 2;
  39539. sphere.parent = root;
  39540. var lines = this._createLightLines(5, scene);
  39541. lines.parent = root;
  39542. root.scaling.scaleInPlace(LightGizmo._Scale);
  39543. root.rotation.x = Math.PI / 2;
  39544. return root;
  39545. };
  39546. LightGizmo._CreateSpotLightMesh = function (scene) {
  39547. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("spotLight", scene);
  39548. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__["SphereBuilder"].CreateSphere(root.name, { segments: 10, diameter: 1 }, scene);
  39549. sphere.parent = root;
  39550. var hemisphere = _Meshes_Builders_hemisphereBuilder__WEBPACK_IMPORTED_MODULE_9__["HemisphereBuilder"].CreateHemisphere(root.name, { segments: 10, diameter: 2 }, scene);
  39551. hemisphere.parent = root;
  39552. hemisphere.rotation.x = -Math.PI / 2;
  39553. var lines = this._createLightLines(2, scene);
  39554. lines.parent = root;
  39555. root.scaling.scaleInPlace(LightGizmo._Scale);
  39556. root.rotation.x = Math.PI / 2;
  39557. return root;
  39558. };
  39559. LightGizmo._CreateDirectionalLightMesh = function (scene) {
  39560. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("directionalLight", scene);
  39561. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](root.name, scene);
  39562. mesh.parent = root;
  39563. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_8__["SphereBuilder"].CreateSphere(root.name, { diameter: 1.2, segments: 10 }, scene);
  39564. sphere.parent = mesh;
  39565. var line = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder(root.name, 6, 0.3, 0.3, 6, 1, scene);
  39566. line.parent = mesh;
  39567. var left = line.clone(root.name);
  39568. left.scaling.y = 0.5;
  39569. left.position.x += 1.25;
  39570. var right = line.clone(root.name);
  39571. right.scaling.y = 0.5;
  39572. right.position.x += -1.25;
  39573. var arrowHead = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder(root.name, 1, 0, 0.6, 6, 1, scene);
  39574. arrowHead.position.y += 3;
  39575. arrowHead.parent = mesh;
  39576. var left = arrowHead.clone(root.name);
  39577. left.position.y = 1.5;
  39578. left.position.x += 1.25;
  39579. var right = arrowHead.clone(root.name);
  39580. right.position.y = 1.5;
  39581. right.position.x += -1.25;
  39582. mesh.scaling.scaleInPlace(LightGizmo._Scale);
  39583. mesh.rotation.z = Math.PI / 2;
  39584. mesh.rotation.y = Math.PI / 2;
  39585. return root;
  39586. };
  39587. // Static helper methods
  39588. LightGizmo._Scale = 0.007;
  39589. /**
  39590. * Creates the lines for a light mesh
  39591. */
  39592. LightGizmo._createLightLines = function (levels, scene) {
  39593. var distFromSphere = 1.2;
  39594. var root = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("root", scene);
  39595. root.rotation.x = Math.PI / 2;
  39596. // Create the top line, this will be cloned for all other lines
  39597. var linePivot = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]("linePivot", scene);
  39598. linePivot.parent = root;
  39599. var line = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder("line", 2, 0.2, 0.3, 6, 1, scene);
  39600. line.position.y = line.scaling.y / 2 + distFromSphere;
  39601. line.parent = linePivot;
  39602. if (levels < 2) {
  39603. return linePivot;
  39604. }
  39605. for (var i = 0; i < 4; i++) {
  39606. var l = linePivot.clone("lineParentClone");
  39607. l.rotation.z = Math.PI / 4;
  39608. l.rotation.y = (Math.PI / 2) + (Math.PI / 2 * i);
  39609. l.getChildMeshes()[0].scaling.y = 0.5;
  39610. l.getChildMeshes()[0].scaling.x = l.getChildMeshes()[0].scaling.z = 0.8;
  39611. l.getChildMeshes()[0].position.y = l.getChildMeshes()[0].scaling.y / 2 + distFromSphere;
  39612. }
  39613. if (levels < 3) {
  39614. return root;
  39615. }
  39616. for (var i = 0; i < 4; i++) {
  39617. var l = linePivot.clone("linePivotClone");
  39618. l.rotation.z = Math.PI / 2;
  39619. l.rotation.y = (Math.PI / 2 * i);
  39620. }
  39621. if (levels < 4) {
  39622. return root;
  39623. }
  39624. for (var i = 0; i < 4; i++) {
  39625. var l = linePivot.clone("linePivotClone");
  39626. l.rotation.z = Math.PI + (Math.PI / 4);
  39627. l.rotation.y = (Math.PI / 2) + (Math.PI / 2 * i);
  39628. l.getChildMeshes()[0].scaling.y = 0.5;
  39629. l.getChildMeshes()[0].scaling.x = l.getChildMeshes()[0].scaling.z = 0.8;
  39630. l.getChildMeshes()[0].position.y = l.getChildMeshes()[0].scaling.y / 2 + distFromSphere;
  39631. }
  39632. if (levels < 5) {
  39633. return root;
  39634. }
  39635. var l = linePivot.clone("linePivotClone");
  39636. l.rotation.z = Math.PI;
  39637. return root;
  39638. };
  39639. return LightGizmo;
  39640. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39641. /***/ }),
  39642. /***/ "./Gizmos/planeRotationGizmo.ts":
  39643. /*!**************************************!*\
  39644. !*** ./Gizmos/planeRotationGizmo.ts ***!
  39645. \**************************************/
  39646. /*! exports provided: PlaneRotationGizmo */
  39647. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39648. "use strict";
  39649. __webpack_require__.r(__webpack_exports__);
  39650. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  39651. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39652. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39653. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39654. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  39655. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39656. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  39657. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39658. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39659. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39660. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  39661. /**
  39662. * Single plane rotation gizmo
  39663. */
  39664. var PlaneRotationGizmo = /** @class */ (function (_super) {
  39665. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  39666. /**
  39667. * Creates a PlaneRotationGizmo
  39668. * @param gizmoLayer The utility layer the gizmo will be added to
  39669. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  39670. * @param color The color of the gizmo
  39671. * @param tessellation Amount of tessellation to be used when creating rotation circles
  39672. */
  39673. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation) {
  39674. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  39675. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39676. if (tessellation === void 0) { tessellation = 32; }
  39677. var _this = _super.call(this, gizmoLayer) || this;
  39678. _this._pointerObserver = null;
  39679. /**
  39680. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  39681. */
  39682. _this.snapDistance = 0;
  39683. /**
  39684. * Event that fires each time the gizmo snaps to a new location.
  39685. * * snapDistance is the the change in distance
  39686. */
  39687. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39688. // Create Material
  39689. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  39690. coloredMaterial.diffuseColor = color;
  39691. coloredMaterial.specularColor = color.subtract(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.1, 0.1, 0.1));
  39692. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  39693. hoverMaterial.diffuseColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  39694. // Build mesh on root node
  39695. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  39696. var drag = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateTorus("", 0.6, 0.03, tessellation, gizmoLayer.utilityLayerScene);
  39697. drag.visibility = 0;
  39698. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateTorus("", 0.6, 0.005, tessellation, gizmoLayer.utilityLayerScene);
  39699. rotationMesh.material = coloredMaterial;
  39700. // Position arrow pointing in its drag axis
  39701. rotationMesh.rotation.x = Math.PI / 2;
  39702. drag.rotation.x = Math.PI / 2;
  39703. parentMesh.addChild(rotationMesh);
  39704. parentMesh.addChild(drag);
  39705. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  39706. _this._rootMesh.addChild(parentMesh);
  39707. parentMesh.scaling.scaleInPlace(1 / 3);
  39708. // Add drag behavior to handle events when the gizmo is dragged
  39709. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  39710. _this.dragBehavior.moveAttached = false;
  39711. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  39712. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  39713. _this._rootMesh.addBehavior(_this.dragBehavior);
  39714. var lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39715. _this.dragBehavior.onDragStartObservable.add(function (e) {
  39716. if (_this.attachedMesh) {
  39717. lastDragPosition.copyFrom(e.dragPlanePoint);
  39718. }
  39719. });
  39720. var rotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  39721. var planeNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39722. var localPlaneNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39723. var tmpSnapEvent = { snapDistance: 0 };
  39724. var currentSnapDragDistance = 0;
  39725. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  39726. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  39727. var amountToRotate = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  39728. _this.dragBehavior.onDragObservable.add(function (event) {
  39729. if (_this.attachedMesh) {
  39730. if (!_this.attachedMesh.rotationQuaternion) {
  39731. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  39732. }
  39733. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  39734. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  39735. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  39736. var cross = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  39737. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  39738. var angle = Math.atan2(cross.length(), dot);
  39739. planeNormalTowardsCamera.copyFrom(planeNormal);
  39740. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  39741. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  39742. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  39743. localPlaneNormalTowardsCamera = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  39744. }
  39745. // Flip up vector depending on which side the camera is on
  39746. if (gizmoLayer.utilityLayerScene.activeCamera) {
  39747. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  39748. if (_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  39749. planeNormalTowardsCamera.scaleInPlace(-1);
  39750. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  39751. }
  39752. }
  39753. var halfCircleSide = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  39754. if (halfCircleSide) {
  39755. angle = -angle;
  39756. }
  39757. // Snapping logic
  39758. var snapped = false;
  39759. if (_this.snapDistance != 0) {
  39760. currentSnapDragDistance += angle;
  39761. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  39762. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  39763. if (currentSnapDragDistance < 0) {
  39764. dragSteps *= -1;
  39765. }
  39766. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  39767. angle = _this.snapDistance * dragSteps;
  39768. snapped = true;
  39769. }
  39770. else {
  39771. angle = 0;
  39772. }
  39773. }
  39774. // If the mesh has a parent, convert needed world rotation to local rotation
  39775. tmpMatrix.reset();
  39776. if (_this.attachedMesh.parent) {
  39777. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  39778. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  39779. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  39780. }
  39781. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  39782. var quaternionCoefficient = Math.sin(angle / 2);
  39783. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  39784. // 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
  39785. if (tmpMatrix.determinant() > 0) {
  39786. amountToRotate.toEulerAnglesToRef(tmpVector);
  39787. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  39788. }
  39789. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  39790. // Rotate selected mesh quaternion over fixed axis
  39791. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  39792. }
  39793. else {
  39794. // Rotate selected mesh quaternion over rotated axis
  39795. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  39796. }
  39797. lastDragPosition.copyFrom(event.dragPlanePoint);
  39798. if (snapped) {
  39799. tmpSnapEvent.snapDistance = angle;
  39800. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  39801. }
  39802. }
  39803. });
  39804. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  39805. if (_this._customMeshSet) {
  39806. return;
  39807. }
  39808. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  39809. var material = isHovered ? hoverMaterial : coloredMaterial;
  39810. _this._rootMesh.getChildMeshes().forEach(function (m) {
  39811. m.material = material;
  39812. if (m.color) {
  39813. m.color = material.diffuseColor;
  39814. }
  39815. });
  39816. });
  39817. var light = gizmoLayer._getSharedGizmoLight();
  39818. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(_this._rootMesh.getChildMeshes(false));
  39819. return _this;
  39820. }
  39821. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  39822. if (this.dragBehavior) {
  39823. this.dragBehavior.enabled = value ? true : false;
  39824. }
  39825. };
  39826. /**
  39827. * Disposes of the gizmo
  39828. */
  39829. PlaneRotationGizmo.prototype.dispose = function () {
  39830. this.onSnapObservable.clear();
  39831. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  39832. this.dragBehavior.detach();
  39833. _super.prototype.dispose.call(this);
  39834. };
  39835. return PlaneRotationGizmo;
  39836. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  39837. /***/ }),
  39838. /***/ "./Gizmos/positionGizmo.ts":
  39839. /*!*********************************!*\
  39840. !*** ./Gizmos/positionGizmo.ts ***!
  39841. \*********************************/
  39842. /*! exports provided: PositionGizmo */
  39843. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39844. "use strict";
  39845. __webpack_require__.r(__webpack_exports__);
  39846. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return PositionGizmo; });
  39847. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39848. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39849. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39850. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39851. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39852. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  39853. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39854. /**
  39855. * Gizmo that enables dragging a mesh along 3 axis
  39856. */
  39857. var PositionGizmo = /** @class */ (function (_super) {
  39858. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  39859. /**
  39860. * Creates a PositionGizmo
  39861. * @param gizmoLayer The utility layer the gizmo will be added to
  39862. */
  39863. function PositionGizmo(gizmoLayer) {
  39864. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39865. var _this = _super.call(this, gizmoLayer) || this;
  39866. /** Fires an event when any of it's sub gizmos are dragged */
  39867. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39868. /** Fires an event when any of it's sub gizmos are released from dragging */
  39869. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39870. _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);
  39871. _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);
  39872. _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);
  39873. // Relay drag events
  39874. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  39875. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39876. _this.onDragStartObservable.notifyObservers({});
  39877. });
  39878. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39879. _this.onDragEndObservable.notifyObservers({});
  39880. });
  39881. });
  39882. _this.attachedMesh = null;
  39883. return _this;
  39884. }
  39885. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  39886. get: function () {
  39887. return this.xGizmo.attachedMesh;
  39888. },
  39889. set: function (mesh) {
  39890. if (this.xGizmo) {
  39891. this.xGizmo.attachedMesh = mesh;
  39892. this.yGizmo.attachedMesh = mesh;
  39893. this.zGizmo.attachedMesh = mesh;
  39894. }
  39895. },
  39896. enumerable: true,
  39897. configurable: true
  39898. });
  39899. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39900. get: function () {
  39901. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39902. },
  39903. set: function (value) {
  39904. if (this.xGizmo) {
  39905. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39906. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39907. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39908. }
  39909. },
  39910. enumerable: true,
  39911. configurable: true
  39912. });
  39913. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  39914. get: function () {
  39915. return this.xGizmo.snapDistance;
  39916. },
  39917. /**
  39918. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39919. */
  39920. set: function (value) {
  39921. if (this.xGizmo) {
  39922. this.xGizmo.snapDistance = value;
  39923. this.yGizmo.snapDistance = value;
  39924. this.zGizmo.snapDistance = value;
  39925. }
  39926. },
  39927. enumerable: true,
  39928. configurable: true
  39929. });
  39930. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  39931. get: function () {
  39932. return this.xGizmo.scaleRatio;
  39933. },
  39934. /**
  39935. * Ratio for the scale of the gizmo (Default: 1)
  39936. */
  39937. set: function (value) {
  39938. if (this.xGizmo) {
  39939. this.xGizmo.scaleRatio = value;
  39940. this.yGizmo.scaleRatio = value;
  39941. this.zGizmo.scaleRatio = value;
  39942. }
  39943. },
  39944. enumerable: true,
  39945. configurable: true
  39946. });
  39947. /**
  39948. * Disposes of the gizmo
  39949. */
  39950. PositionGizmo.prototype.dispose = function () {
  39951. this.xGizmo.dispose();
  39952. this.yGizmo.dispose();
  39953. this.zGizmo.dispose();
  39954. this.onDragStartObservable.clear();
  39955. this.onDragEndObservable.clear();
  39956. };
  39957. /**
  39958. * CustomMeshes are not supported by this gizmo
  39959. * @param mesh The mesh to replace the default mesh of the gizmo
  39960. */
  39961. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  39962. _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)");
  39963. };
  39964. return PositionGizmo;
  39965. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39966. /***/ }),
  39967. /***/ "./Gizmos/rotationGizmo.ts":
  39968. /*!*********************************!*\
  39969. !*** ./Gizmos/rotationGizmo.ts ***!
  39970. \*********************************/
  39971. /*! exports provided: RotationGizmo */
  39972. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39973. "use strict";
  39974. __webpack_require__.r(__webpack_exports__);
  39975. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  39976. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39977. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39978. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39979. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39980. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39981. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  39982. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39983. /**
  39984. * Gizmo that enables rotating a mesh along 3 axis
  39985. */
  39986. var RotationGizmo = /** @class */ (function (_super) {
  39987. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  39988. /**
  39989. * Creates a RotationGizmo
  39990. * @param gizmoLayer The utility layer the gizmo will be added to
  39991. * @param tessellation Amount of tessellation to be used when creating rotation circles
  39992. */
  39993. function RotationGizmo(gizmoLayer, tessellation) {
  39994. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39995. if (tessellation === void 0) { tessellation = 32; }
  39996. var _this = _super.call(this, gizmoLayer) || this;
  39997. /** Fires an event when any of it's sub gizmos are dragged */
  39998. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39999. /** Fires an event when any of it's sub gizmos are released from dragging */
  40000. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40001. _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);
  40002. _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);
  40003. _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);
  40004. // Relay drag events
  40005. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  40006. gizmo.dragBehavior.onDragStartObservable.add(function () {
  40007. _this.onDragStartObservable.notifyObservers({});
  40008. });
  40009. gizmo.dragBehavior.onDragEndObservable.add(function () {
  40010. _this.onDragEndObservable.notifyObservers({});
  40011. });
  40012. });
  40013. _this.attachedMesh = null;
  40014. return _this;
  40015. }
  40016. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  40017. get: function () {
  40018. return this.xGizmo.attachedMesh;
  40019. },
  40020. set: function (mesh) {
  40021. if (this.xGizmo) {
  40022. this.xGizmo.attachedMesh = mesh;
  40023. this.yGizmo.attachedMesh = mesh;
  40024. this.zGizmo.attachedMesh = mesh;
  40025. }
  40026. },
  40027. enumerable: true,
  40028. configurable: true
  40029. });
  40030. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  40031. get: function () {
  40032. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  40033. },
  40034. set: function (value) {
  40035. if (this.xGizmo) {
  40036. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40037. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40038. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40039. }
  40040. },
  40041. enumerable: true,
  40042. configurable: true
  40043. });
  40044. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  40045. get: function () {
  40046. return this.xGizmo.snapDistance;
  40047. },
  40048. /**
  40049. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40050. */
  40051. set: function (value) {
  40052. if (this.xGizmo) {
  40053. this.xGizmo.snapDistance = value;
  40054. this.yGizmo.snapDistance = value;
  40055. this.zGizmo.snapDistance = value;
  40056. }
  40057. },
  40058. enumerable: true,
  40059. configurable: true
  40060. });
  40061. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  40062. get: function () {
  40063. return this.xGizmo.scaleRatio;
  40064. },
  40065. /**
  40066. * Ratio for the scale of the gizmo (Default: 1)
  40067. */
  40068. set: function (value) {
  40069. if (this.xGizmo) {
  40070. this.xGizmo.scaleRatio = value;
  40071. this.yGizmo.scaleRatio = value;
  40072. this.zGizmo.scaleRatio = value;
  40073. }
  40074. },
  40075. enumerable: true,
  40076. configurable: true
  40077. });
  40078. /**
  40079. * Disposes of the gizmo
  40080. */
  40081. RotationGizmo.prototype.dispose = function () {
  40082. this.xGizmo.dispose();
  40083. this.yGizmo.dispose();
  40084. this.zGizmo.dispose();
  40085. this.onDragStartObservable.clear();
  40086. this.onDragEndObservable.clear();
  40087. };
  40088. /**
  40089. * CustomMeshes are not supported by this gizmo
  40090. * @param mesh The mesh to replace the default mesh of the gizmo
  40091. */
  40092. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  40093. _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)");
  40094. };
  40095. return RotationGizmo;
  40096. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  40097. /***/ }),
  40098. /***/ "./Gizmos/scaleGizmo.ts":
  40099. /*!******************************!*\
  40100. !*** ./Gizmos/scaleGizmo.ts ***!
  40101. \******************************/
  40102. /*! exports provided: ScaleGizmo */
  40103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40104. "use strict";
  40105. __webpack_require__.r(__webpack_exports__);
  40106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  40107. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40108. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  40109. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40110. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40111. /* harmony import */ var _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  40112. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  40113. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  40114. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  40115. /**
  40116. * Gizmo that enables scaling a mesh along 3 axis
  40117. */
  40118. var ScaleGizmo = /** @class */ (function (_super) {
  40119. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  40120. /**
  40121. * Creates a ScaleGizmo
  40122. * @param gizmoLayer The utility layer the gizmo will be added to
  40123. */
  40124. function ScaleGizmo(gizmoLayer) {
  40125. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  40126. var _this = _super.call(this, gizmoLayer) || this;
  40127. /** Fires an event when any of it's sub gizmos are dragged */
  40128. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40129. /** Fires an event when any of it's sub gizmos are released from dragging */
  40130. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  40131. _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);
  40132. _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);
  40133. _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);
  40134. // Create uniform scale gizmo
  40135. _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);
  40136. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  40137. _this.uniformScaleGizmo.uniformScaling = true;
  40138. var uniformScalingMesh = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  40139. uniformScalingMesh.scaling.scaleInPlace(0.02);
  40140. uniformScalingMesh.visibility = 0;
  40141. var octahedron = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  40142. octahedron.scaling.scaleInPlace(0.007);
  40143. uniformScalingMesh.addChild(octahedron);
  40144. _this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
  40145. var light = gizmoLayer._getSharedGizmoLight();
  40146. light.includedOnlyMeshes = light.includedOnlyMeshes.concat(octahedron);
  40147. // Relay drag events
  40148. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  40149. gizmo.dragBehavior.onDragStartObservable.add(function () {
  40150. _this.onDragStartObservable.notifyObservers({});
  40151. });
  40152. gizmo.dragBehavior.onDragEndObservable.add(function () {
  40153. _this.onDragEndObservable.notifyObservers({});
  40154. });
  40155. });
  40156. _this.attachedMesh = null;
  40157. return _this;
  40158. }
  40159. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  40160. get: function () {
  40161. return this.xGizmo.attachedMesh;
  40162. },
  40163. set: function (mesh) {
  40164. if (this.xGizmo) {
  40165. this.xGizmo.attachedMesh = mesh;
  40166. this.yGizmo.attachedMesh = mesh;
  40167. this.zGizmo.attachedMesh = mesh;
  40168. this.uniformScaleGizmo.attachedMesh = mesh;
  40169. }
  40170. },
  40171. enumerable: true,
  40172. configurable: true
  40173. });
  40174. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  40175. get: function () {
  40176. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  40177. },
  40178. set: function (value) {
  40179. if (!value) {
  40180. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  40181. }
  40182. if (this.xGizmo) {
  40183. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40184. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40185. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  40186. }
  40187. },
  40188. enumerable: true,
  40189. configurable: true
  40190. });
  40191. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  40192. get: function () {
  40193. return this.xGizmo.snapDistance;
  40194. },
  40195. /**
  40196. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40197. */
  40198. set: function (value) {
  40199. if (this.xGizmo) {
  40200. this.xGizmo.snapDistance = value;
  40201. this.yGizmo.snapDistance = value;
  40202. this.zGizmo.snapDistance = value;
  40203. this.uniformScaleGizmo.snapDistance = value;
  40204. }
  40205. },
  40206. enumerable: true,
  40207. configurable: true
  40208. });
  40209. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  40210. get: function () {
  40211. return this.xGizmo.scaleRatio;
  40212. },
  40213. /**
  40214. * Ratio for the scale of the gizmo (Default: 1)
  40215. */
  40216. set: function (value) {
  40217. if (this.xGizmo) {
  40218. this.xGizmo.scaleRatio = value;
  40219. this.yGizmo.scaleRatio = value;
  40220. this.zGizmo.scaleRatio = value;
  40221. this.uniformScaleGizmo.scaleRatio = value;
  40222. }
  40223. },
  40224. enumerable: true,
  40225. configurable: true
  40226. });
  40227. /**
  40228. * Disposes of the gizmo
  40229. */
  40230. ScaleGizmo.prototype.dispose = function () {
  40231. this.xGizmo.dispose();
  40232. this.yGizmo.dispose();
  40233. this.zGizmo.dispose();
  40234. this.uniformScaleGizmo.dispose();
  40235. this.onDragStartObservable.clear();
  40236. this.onDragEndObservable.clear();
  40237. };
  40238. return ScaleGizmo;
  40239. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  40240. /***/ }),
  40241. /***/ "./Helpers/environmentHelper.ts":
  40242. /*!**************************************!*\
  40243. !*** ./Helpers/environmentHelper.ts ***!
  40244. \**************************************/
  40245. /*! exports provided: EnvironmentHelper */
  40246. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40247. "use strict";
  40248. __webpack_require__.r(__webpack_exports__);
  40249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  40250. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40251. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40252. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  40253. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40254. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40255. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  40256. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40257. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  40258. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  40259. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  40260. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  40261. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  40262. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  40263. /**
  40264. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  40265. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  40266. * It also helps with the default setup of your imageProcessing configuration.
  40267. */
  40268. var EnvironmentHelper = /** @class */ (function () {
  40269. /**
  40270. * constructor
  40271. * @param options Defines the options we want to customize the helper
  40272. * @param scene The scene to add the material to
  40273. */
  40274. function EnvironmentHelper(options, scene) {
  40275. var _this = this;
  40276. this._errorHandler = function (message, exception) {
  40277. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  40278. };
  40279. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  40280. this._scene = scene;
  40281. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40282. this._setupBackground();
  40283. this._setupImageProcessing();
  40284. }
  40285. /**
  40286. * Creates the default options for the helper.
  40287. */
  40288. EnvironmentHelper._getDefaultOptions = function () {
  40289. return {
  40290. createGround: true,
  40291. groundSize: 15,
  40292. groundTexture: this._groundTextureCDNUrl,
  40293. groundColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  40294. groundOpacity: 0.9,
  40295. enableGroundShadow: true,
  40296. groundShadowLevel: 0.5,
  40297. enableGroundMirror: false,
  40298. groundMirrorSizeRatio: 0.3,
  40299. groundMirrorBlurKernel: 64,
  40300. groundMirrorAmount: 1,
  40301. groundMirrorFresnelWeight: 1,
  40302. groundMirrorFallOffDistance: 0,
  40303. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  40304. groundYBias: 0.00001,
  40305. createSkybox: true,
  40306. skyboxSize: 20,
  40307. skyboxTexture: this._skyboxTextureCDNUrl,
  40308. skyboxColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  40309. backgroundYRotation: 0,
  40310. sizeAuto: true,
  40311. rootPosition: _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  40312. setupImageProcessing: true,
  40313. environmentTexture: this._environmentTextureCDNUrl,
  40314. cameraExposure: 0.8,
  40315. cameraContrast: 1.2,
  40316. toneMappingEnabled: true,
  40317. };
  40318. };
  40319. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  40320. /**
  40321. * Gets the root mesh created by the helper.
  40322. */
  40323. get: function () {
  40324. return this._rootMesh;
  40325. },
  40326. enumerable: true,
  40327. configurable: true
  40328. });
  40329. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  40330. /**
  40331. * Gets the skybox created by the helper.
  40332. */
  40333. get: function () {
  40334. return this._skybox;
  40335. },
  40336. enumerable: true,
  40337. configurable: true
  40338. });
  40339. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  40340. /**
  40341. * Gets the skybox texture created by the helper.
  40342. */
  40343. get: function () {
  40344. return this._skyboxTexture;
  40345. },
  40346. enumerable: true,
  40347. configurable: true
  40348. });
  40349. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  40350. /**
  40351. * Gets the skybox material created by the helper.
  40352. */
  40353. get: function () {
  40354. return this._skyboxMaterial;
  40355. },
  40356. enumerable: true,
  40357. configurable: true
  40358. });
  40359. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  40360. /**
  40361. * Gets the ground mesh created by the helper.
  40362. */
  40363. get: function () {
  40364. return this._ground;
  40365. },
  40366. enumerable: true,
  40367. configurable: true
  40368. });
  40369. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  40370. /**
  40371. * Gets the ground texture created by the helper.
  40372. */
  40373. get: function () {
  40374. return this._groundTexture;
  40375. },
  40376. enumerable: true,
  40377. configurable: true
  40378. });
  40379. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  40380. /**
  40381. * Gets the ground mirror created by the helper.
  40382. */
  40383. get: function () {
  40384. return this._groundMirror;
  40385. },
  40386. enumerable: true,
  40387. configurable: true
  40388. });
  40389. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  40390. /**
  40391. * Gets the ground mirror render list to helps pushing the meshes
  40392. * you wish in the ground reflection.
  40393. */
  40394. get: function () {
  40395. if (this._groundMirror) {
  40396. return this._groundMirror.renderList;
  40397. }
  40398. return null;
  40399. },
  40400. enumerable: true,
  40401. configurable: true
  40402. });
  40403. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  40404. /**
  40405. * Gets the ground material created by the helper.
  40406. */
  40407. get: function () {
  40408. return this._groundMaterial;
  40409. },
  40410. enumerable: true,
  40411. configurable: true
  40412. });
  40413. /**
  40414. * Updates the background according to the new options
  40415. * @param options
  40416. */
  40417. EnvironmentHelper.prototype.updateOptions = function (options) {
  40418. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  40419. if (this._ground && !newOptions.createGround) {
  40420. this._ground.dispose();
  40421. this._ground = null;
  40422. }
  40423. if (this._groundMaterial && !newOptions.createGround) {
  40424. this._groundMaterial.dispose();
  40425. this._groundMaterial = null;
  40426. }
  40427. if (this._groundTexture) {
  40428. if (this._options.groundTexture != newOptions.groundTexture) {
  40429. this._groundTexture.dispose();
  40430. this._groundTexture = null;
  40431. }
  40432. }
  40433. if (this._skybox && !newOptions.createSkybox) {
  40434. this._skybox.dispose();
  40435. this._skybox = null;
  40436. }
  40437. if (this._skyboxMaterial && !newOptions.createSkybox) {
  40438. this._skyboxMaterial.dispose();
  40439. this._skyboxMaterial = null;
  40440. }
  40441. if (this._skyboxTexture) {
  40442. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  40443. this._skyboxTexture.dispose();
  40444. this._skyboxTexture = null;
  40445. }
  40446. }
  40447. if (this._groundMirror && !newOptions.enableGroundMirror) {
  40448. this._groundMirror.dispose();
  40449. this._groundMirror = null;
  40450. }
  40451. if (this._scene.environmentTexture) {
  40452. if (this._options.environmentTexture != newOptions.environmentTexture) {
  40453. this._scene.environmentTexture.dispose();
  40454. }
  40455. }
  40456. this._options = newOptions;
  40457. this._setupBackground();
  40458. this._setupImageProcessing();
  40459. };
  40460. /**
  40461. * Sets the primary color of all the available elements.
  40462. * @param color the main color to affect to the ground and the background
  40463. */
  40464. EnvironmentHelper.prototype.setMainColor = function (color) {
  40465. if (this.groundMaterial) {
  40466. this.groundMaterial.primaryColor = color;
  40467. }
  40468. if (this.skyboxMaterial) {
  40469. this.skyboxMaterial.primaryColor = color;
  40470. }
  40471. if (this.groundMirror) {
  40472. this.groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](color.r, color.g, color.b, 1.0);
  40473. }
  40474. };
  40475. /**
  40476. * Setup the image processing according to the specified options.
  40477. */
  40478. EnvironmentHelper.prototype._setupImageProcessing = function () {
  40479. if (this._options.setupImageProcessing) {
  40480. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  40481. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  40482. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  40483. this._setupEnvironmentTexture();
  40484. }
  40485. };
  40486. /**
  40487. * Setup the environment texture according to the specified options.
  40488. */
  40489. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  40490. if (this._scene.environmentTexture) {
  40491. return;
  40492. }
  40493. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40494. this._scene.environmentTexture = this._options.environmentTexture;
  40495. return;
  40496. }
  40497. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  40498. this._scene.environmentTexture = environmentTexture;
  40499. };
  40500. /**
  40501. * Setup the background according to the specified options.
  40502. */
  40503. EnvironmentHelper.prototype._setupBackground = function () {
  40504. if (!this._rootMesh) {
  40505. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("BackgroundHelper", this._scene);
  40506. }
  40507. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  40508. var sceneSize = this._getSceneSize();
  40509. if (this._options.createGround) {
  40510. this._setupGround(sceneSize);
  40511. this._setupGroundMaterial();
  40512. this._setupGroundDiffuseTexture();
  40513. if (this._options.enableGroundMirror) {
  40514. this._setupGroundMirrorTexture(sceneSize);
  40515. }
  40516. this._setupMirrorInGroundMaterial();
  40517. }
  40518. if (this._options.createSkybox) {
  40519. this._setupSkybox(sceneSize);
  40520. this._setupSkyboxMaterial();
  40521. this._setupSkyboxReflectionTexture();
  40522. }
  40523. this._rootMesh.position.x = sceneSize.rootPosition.x;
  40524. this._rootMesh.position.z = sceneSize.rootPosition.z;
  40525. this._rootMesh.position.y = sceneSize.rootPosition.y;
  40526. };
  40527. /**
  40528. * Get the scene sizes according to the setup.
  40529. */
  40530. EnvironmentHelper.prototype._getSceneSize = function () {
  40531. var _this = this;
  40532. var groundSize = this._options.groundSize;
  40533. var skyboxSize = this._options.skyboxSize;
  40534. var rootPosition = this._options.rootPosition;
  40535. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  40536. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  40537. }
  40538. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  40539. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  40540. });
  40541. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  40542. if (this._options.sizeAuto) {
  40543. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  40544. this._scene.activeCamera.upperRadiusLimit) {
  40545. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  40546. skyboxSize = groundSize;
  40547. }
  40548. var sceneDiagonalLenght = sceneDiagonal.length();
  40549. if (sceneDiagonalLenght > groundSize) {
  40550. groundSize = sceneDiagonalLenght * 2;
  40551. skyboxSize = groundSize;
  40552. }
  40553. // 10 % bigger.
  40554. groundSize *= 1.1;
  40555. skyboxSize *= 1.5;
  40556. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  40557. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  40558. }
  40559. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  40560. };
  40561. /**
  40562. * Setup the ground according to the specified options.
  40563. */
  40564. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  40565. var _this = this;
  40566. if (!this._ground || this._ground.isDisposed()) {
  40567. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  40568. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  40569. this._ground.parent = this._rootMesh;
  40570. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  40571. }
  40572. this._ground.receiveShadows = this._options.enableGroundShadow;
  40573. };
  40574. /**
  40575. * Setup the ground material according to the specified options.
  40576. */
  40577. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  40578. if (!this._groundMaterial) {
  40579. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  40580. }
  40581. this._groundMaterial.alpha = this._options.groundOpacity;
  40582. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  40583. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  40584. this._groundMaterial.primaryColor = this._options.groundColor;
  40585. this._groundMaterial.useRGBColor = false;
  40586. this._groundMaterial.enableNoise = true;
  40587. if (this._ground) {
  40588. this._ground.material = this._groundMaterial;
  40589. }
  40590. };
  40591. /**
  40592. * Setup the ground diffuse texture according to the specified options.
  40593. */
  40594. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  40595. if (!this._groundMaterial) {
  40596. return;
  40597. }
  40598. if (this._groundTexture) {
  40599. return;
  40600. }
  40601. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40602. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  40603. return;
  40604. }
  40605. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  40606. diffuseTexture.gammaSpace = false;
  40607. diffuseTexture.hasAlpha = true;
  40608. this._groundMaterial.diffuseTexture = diffuseTexture;
  40609. };
  40610. /**
  40611. * Setup the ground mirror texture according to the specified options.
  40612. */
  40613. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  40614. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  40615. if (!this._groundMirror) {
  40616. 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);
  40617. this._groundMirror.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  40618. this._groundMirror.anisotropicFilteringLevel = 1;
  40619. this._groundMirror.wrapU = wrapping;
  40620. this._groundMirror.wrapV = wrapping;
  40621. this._groundMirror.gammaSpace = false;
  40622. if (this._groundMirror.renderList) {
  40623. for (var i = 0; i < this._scene.meshes.length; i++) {
  40624. var mesh = this._scene.meshes[i];
  40625. if (mesh !== this._ground &&
  40626. mesh !== this._skybox &&
  40627. mesh !== this._rootMesh) {
  40628. this._groundMirror.renderList.push(mesh);
  40629. }
  40630. }
  40631. }
  40632. }
  40633. this._groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  40634. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  40635. };
  40636. /**
  40637. * Setup the ground to receive the mirror texture.
  40638. */
  40639. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  40640. if (this._groundMaterial) {
  40641. this._groundMaterial.reflectionTexture = this._groundMirror;
  40642. this._groundMaterial.reflectionFresnel = true;
  40643. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  40644. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  40645. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  40646. }
  40647. };
  40648. /**
  40649. * Setup the skybox according to the specified options.
  40650. */
  40651. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  40652. var _this = this;
  40653. if (!this._skybox || this._skybox.isDisposed()) {
  40654. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].BACKSIDE);
  40655. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  40656. }
  40657. this._skybox.parent = this._rootMesh;
  40658. };
  40659. /**
  40660. * Setup the skybox material according to the specified options.
  40661. */
  40662. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  40663. if (!this._skybox) {
  40664. return;
  40665. }
  40666. if (!this._skyboxMaterial) {
  40667. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  40668. }
  40669. this._skyboxMaterial.useRGBColor = false;
  40670. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  40671. this._skyboxMaterial.enableNoise = true;
  40672. this._skybox.material = this._skyboxMaterial;
  40673. };
  40674. /**
  40675. * Setup the skybox reflection texture according to the specified options.
  40676. */
  40677. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  40678. if (!this._skyboxMaterial) {
  40679. return;
  40680. }
  40681. if (this._skyboxTexture) {
  40682. return;
  40683. }
  40684. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  40685. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  40686. return;
  40687. }
  40688. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  40689. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].SKYBOX_MODE;
  40690. this._skyboxTexture.gammaSpace = false;
  40691. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  40692. };
  40693. /**
  40694. * Dispose all the elements created by the Helper.
  40695. */
  40696. EnvironmentHelper.prototype.dispose = function () {
  40697. if (this._groundMaterial) {
  40698. this._groundMaterial.dispose(true, true);
  40699. }
  40700. if (this._skyboxMaterial) {
  40701. this._skyboxMaterial.dispose(true, true);
  40702. }
  40703. this._rootMesh.dispose(false);
  40704. };
  40705. /**
  40706. * Default ground texture URL.
  40707. */
  40708. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  40709. /**
  40710. * Default skybox texture URL.
  40711. */
  40712. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  40713. /**
  40714. * Default environment texture URL.
  40715. */
  40716. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  40717. return EnvironmentHelper;
  40718. }());
  40719. /***/ }),
  40720. /***/ "./Helpers/index.ts":
  40721. /*!**************************!*\
  40722. !*** ./Helpers/index.ts ***!
  40723. \**************************/
  40724. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  40725. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40726. "use strict";
  40727. __webpack_require__.r(__webpack_exports__);
  40728. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  40729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  40730. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  40731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  40732. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  40733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  40734. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  40735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  40736. /***/ }),
  40737. /***/ "./Helpers/photoDome.ts":
  40738. /*!******************************!*\
  40739. !*** ./Helpers/photoDome.ts ***!
  40740. \******************************/
  40741. /*! exports provided: PhotoDome */
  40742. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40743. "use strict";
  40744. __webpack_require__.r(__webpack_exports__);
  40745. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  40746. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40747. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40748. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  40749. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40750. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40751. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  40752. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  40753. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40754. /**
  40755. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  40756. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  40757. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  40758. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  40759. */
  40760. var PhotoDome = /** @class */ (function (_super) {
  40761. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  40762. /**
  40763. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  40764. * @param name Element's name, child elements will append suffixes for their own names.
  40765. * @param urlsOfPhoto defines the url of the photo to display
  40766. * @param options defines an object containing optional or exposed sub element properties
  40767. * @param onError defines a callback called when an error occured while loading the texture
  40768. */
  40769. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  40770. if (onError === void 0) { onError = null; }
  40771. var _this = _super.call(this, name, scene) || this;
  40772. _this._useDirectMapping = false;
  40773. /**
  40774. * Observable raised when an error occured while loading the 360 image
  40775. */
  40776. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  40777. // set defaults and manage values
  40778. name = name || "photoDome";
  40779. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  40780. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  40781. if (options.useDirectMapping === undefined) {
  40782. _this._useDirectMapping = true;
  40783. }
  40784. else {
  40785. _this._useDirectMapping = options.useDirectMapping;
  40786. }
  40787. if (options.faceForward === undefined) {
  40788. options.faceForward = true;
  40789. }
  40790. _this._setReady(false);
  40791. // create
  40792. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  40793. _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);
  40794. // configure material
  40795. material.opacityFresnel = false;
  40796. material.useEquirectangularFOV = true;
  40797. material.fovMultiplier = 1.0;
  40798. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  40799. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  40800. if (onError) {
  40801. onError(message, exception);
  40802. }
  40803. });
  40804. _this.photoTexture.onLoadObservable.addOnce(function () {
  40805. _this._setReady(true);
  40806. });
  40807. // configure mesh
  40808. _this._mesh.material = material;
  40809. _this._mesh.parent = _this;
  40810. // Initial rotation
  40811. if (options.faceForward && scene.activeCamera) {
  40812. var camera = scene.activeCamera;
  40813. var forward = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Forward();
  40814. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].TransformNormal(forward, camera.getViewMatrix());
  40815. direction.normalize();
  40816. _this.rotation.y = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Dot(forward, direction));
  40817. }
  40818. return _this;
  40819. }
  40820. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  40821. /**
  40822. * Gets or sets the texture being displayed on the sphere
  40823. */
  40824. get: function () {
  40825. return this._photoTexture;
  40826. },
  40827. set: function (value) {
  40828. if (this._photoTexture === value) {
  40829. return;
  40830. }
  40831. this._photoTexture = value;
  40832. if (this._useDirectMapping) {
  40833. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40834. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40835. this._material.diffuseTexture = this._photoTexture;
  40836. }
  40837. else {
  40838. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  40839. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  40840. this._material.reflectionTexture = this._photoTexture;
  40841. }
  40842. },
  40843. enumerable: true,
  40844. configurable: true
  40845. });
  40846. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  40847. /**
  40848. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  40849. * Also see the options.resolution property.
  40850. */
  40851. get: function () {
  40852. return this._material.fovMultiplier;
  40853. },
  40854. set: function (value) {
  40855. this._material.fovMultiplier = value;
  40856. },
  40857. enumerable: true,
  40858. configurable: true
  40859. });
  40860. /**
  40861. * Releases resources associated with this node.
  40862. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  40863. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  40864. */
  40865. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  40866. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  40867. this._photoTexture.dispose();
  40868. this._mesh.dispose();
  40869. this._material.dispose();
  40870. this.onLoadErrorObservable.clear();
  40871. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  40872. };
  40873. return PhotoDome;
  40874. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  40875. /***/ }),
  40876. /***/ "./Helpers/sceneHelpers.ts":
  40877. /*!*********************************!*\
  40878. !*** ./Helpers/sceneHelpers.ts ***!
  40879. \*********************************/
  40880. /*! exports provided: _forceSceneHelpersToBundle */
  40881. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40882. "use strict";
  40883. __webpack_require__.r(__webpack_exports__);
  40884. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  40885. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  40886. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  40887. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40888. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  40889. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40890. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  40891. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  40892. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  40893. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  40894. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  40895. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  40896. /* harmony import */ var _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/XR/webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  40897. /* harmony import */ var _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/XR/webXRInput */ "./Cameras/XR/webXRInput.ts");
  40898. /* harmony import */ var _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/XR/webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  40899. /* harmony import */ var _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Cameras/XR/webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  40900. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  40901. /* harmony import */ var _Materials_Textures_Loaders_ddsTextureLoader__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Materials/Textures/Loaders/ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  40902. /* harmony import */ var _Materials_Textures_Loaders_envTextureLoader__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/Loaders/envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  40903. /* harmony import */ var _Materials_Textures_Loaders_ktxTextureLoader__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Materials/Textures/Loaders/ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  40904. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  40905. /** @hidden */
  40906. var _forceSceneHelpersToBundle = true;
  40907. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  40908. if (replace === void 0) { replace = false; }
  40909. // Dispose existing light in replace mode.
  40910. if (replace) {
  40911. if (this.lights) {
  40912. for (var i = 0; i < this.lights.length; i++) {
  40913. this.lights[i].dispose();
  40914. }
  40915. }
  40916. }
  40917. // Light
  40918. if (this.lights.length === 0) {
  40919. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  40920. }
  40921. };
  40922. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  40923. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  40924. if (replace === void 0) { replace = false; }
  40925. if (attachCameraControls === void 0) { attachCameraControls = false; }
  40926. // Dispose existing camera in replace mode.
  40927. if (replace) {
  40928. if (this.activeCamera) {
  40929. this.activeCamera.dispose();
  40930. this.activeCamera = null;
  40931. }
  40932. }
  40933. // Camera
  40934. if (!this.activeCamera) {
  40935. var worldExtends = this.getWorldExtends();
  40936. var worldSize = worldExtends.max.subtract(worldExtends.min);
  40937. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  40938. var camera;
  40939. var radius = worldSize.length() * 1.5;
  40940. // empty scene scenario!
  40941. if (!isFinite(radius)) {
  40942. radius = 1;
  40943. worldCenter.copyFromFloats(0, 0, 0);
  40944. }
  40945. if (createArcRotateCamera) {
  40946. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  40947. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  40948. arcRotateCamera.wheelPrecision = 100 / radius;
  40949. camera = arcRotateCamera;
  40950. }
  40951. else {
  40952. 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);
  40953. freeCamera.setTarget(worldCenter);
  40954. camera = freeCamera;
  40955. }
  40956. camera.minZ = radius * 0.01;
  40957. camera.maxZ = radius * 1000;
  40958. camera.speed = radius * 0.2;
  40959. this.activeCamera = camera;
  40960. var canvas = this.getEngine().getRenderingCanvas();
  40961. if (attachCameraControls && canvas) {
  40962. camera.attachControl(canvas);
  40963. }
  40964. }
  40965. };
  40966. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  40967. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  40968. if (replace === void 0) { replace = false; }
  40969. if (attachCameraControls === void 0) { attachCameraControls = false; }
  40970. this.createDefaultLight(replace);
  40971. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  40972. };
  40973. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  40974. if (pbr === void 0) { pbr = false; }
  40975. if (scale === void 0) { scale = 1000; }
  40976. if (blur === void 0) { blur = 0; }
  40977. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  40978. if (!environmentTexture) {
  40979. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  40980. return null;
  40981. }
  40982. if (setGlobalEnvTexture) {
  40983. if (environmentTexture) {
  40984. this.environmentTexture = environmentTexture;
  40985. }
  40986. }
  40987. // Skybox
  40988. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  40989. if (pbr) {
  40990. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  40991. hdrSkyboxMaterial.backFaceCulling = false;
  40992. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  40993. if (hdrSkyboxMaterial.reflectionTexture) {
  40994. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  40995. }
  40996. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  40997. hdrSkyboxMaterial.disableLighting = true;
  40998. hdrSkyboxMaterial.twoSidedLighting = true;
  40999. hdrSkybox.infiniteDistance = true;
  41000. hdrSkybox.material = hdrSkyboxMaterial;
  41001. }
  41002. else {
  41003. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  41004. skyboxMaterial.backFaceCulling = false;
  41005. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  41006. if (skyboxMaterial.reflectionTexture) {
  41007. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  41008. }
  41009. skyboxMaterial.disableLighting = true;
  41010. hdrSkybox.infiniteDistance = true;
  41011. hdrSkybox.material = skyboxMaterial;
  41012. }
  41013. hdrSkybox.isPickable = false;
  41014. return hdrSkybox;
  41015. };
  41016. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  41017. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  41018. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  41019. }
  41020. return null;
  41021. };
  41022. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  41023. if (webVROptions === void 0) { webVROptions = {}; }
  41024. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__["VRExperienceHelper"](this, webVROptions);
  41025. };
  41026. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function () {
  41027. var _this = this;
  41028. return _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__["WebXRExperienceHelper"].CreateAsync(this).then(function (helper) {
  41029. var outputCanvas = new _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__["WebXRManagedOutputCanvas"](helper);
  41030. return _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__["WebXREnterExitUI"].CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
  41031. .then(function (ui) {
  41032. new _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__["WebXRInput"](helper);
  41033. return helper;
  41034. });
  41035. });
  41036. };
  41037. /***/ }),
  41038. /***/ "./Helpers/videoDome.ts":
  41039. /*!******************************!*\
  41040. !*** ./Helpers/videoDome.ts ***!
  41041. \******************************/
  41042. /*! exports provided: VideoDome */
  41043. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41044. "use strict";
  41045. __webpack_require__.r(__webpack_exports__);
  41046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  41047. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41048. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  41049. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  41050. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41051. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  41052. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  41053. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  41054. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41055. /**
  41056. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  41057. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  41058. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  41059. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  41060. */
  41061. var VideoDome = /** @class */ (function (_super) {
  41062. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  41063. /**
  41064. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  41065. * @param name Element's name, child elements will append suffixes for their own names.
  41066. * @param urlsOrVideo defines the url(s) or the video element to use
  41067. * @param options An object containing optional or exposed sub element properties
  41068. */
  41069. function VideoDome(name, urlsOrVideo, options, scene) {
  41070. var _this = _super.call(this, name, scene) || this;
  41071. _this._useDirectMapping = false;
  41072. _this._videoMode = VideoDome.MODE_MONOSCOPIC;
  41073. /**
  41074. * Oberserver used in Stereoscopic VR Mode.
  41075. */
  41076. _this._onBeforeCameraRenderObserver = null;
  41077. scene = _this.getScene();
  41078. // set defaults and manage values
  41079. name = name || "videoDome";
  41080. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  41081. options.clickToPlay = Boolean(options.clickToPlay);
  41082. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  41083. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  41084. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  41085. if (options.useDirectMapping === undefined) {
  41086. _this._useDirectMapping = true;
  41087. }
  41088. else {
  41089. _this._useDirectMapping = options.useDirectMapping;
  41090. }
  41091. if (options.faceForward === undefined) {
  41092. options.faceForward = true;
  41093. }
  41094. _this._setReady(false);
  41095. // create
  41096. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  41097. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  41098. 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);
  41099. _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);
  41100. texture.onLoadObservable.addOnce(function () {
  41101. _this._setReady(true);
  41102. });
  41103. // configure material
  41104. material.useEquirectangularFOV = true;
  41105. material.fovMultiplier = 1.0;
  41106. material.opacityFresnel = false;
  41107. if (_this._useDirectMapping) {
  41108. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  41109. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  41110. material.diffuseTexture = texture;
  41111. }
  41112. else {
  41113. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  41114. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  41115. material.reflectionTexture = texture;
  41116. }
  41117. // configure mesh
  41118. _this._mesh.material = material;
  41119. _this._mesh.parent = _this;
  41120. // optional configuration
  41121. if (options.clickToPlay) {
  41122. scene.onPointerUp = function () {
  41123. _this._videoTexture.video.play();
  41124. };
  41125. }
  41126. // Initial rotation
  41127. if (options.faceForward && scene.activeCamera) {
  41128. var camera = scene.activeCamera;
  41129. var forward = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Forward();
  41130. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].TransformNormal(forward, camera.getViewMatrix());
  41131. direction.normalize();
  41132. _this.rotation.y = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"].Dot(forward, direction));
  41133. }
  41134. return _this;
  41135. }
  41136. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  41137. /**
  41138. * Gets the video texture being displayed on the sphere
  41139. */
  41140. get: function () {
  41141. return this._videoTexture;
  41142. },
  41143. enumerable: true,
  41144. configurable: true
  41145. });
  41146. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  41147. /**
  41148. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  41149. * Also see the options.resolution property.
  41150. */
  41151. get: function () {
  41152. return this._material.fovMultiplier;
  41153. },
  41154. set: function (value) {
  41155. this._material.fovMultiplier = value;
  41156. },
  41157. enumerable: true,
  41158. configurable: true
  41159. });
  41160. Object.defineProperty(VideoDome.prototype, "videoMode", {
  41161. /**
  41162. * Gets or set the current video mode for the video. It can be:
  41163. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  41164. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  41165. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  41166. */
  41167. get: function () {
  41168. return this._videoMode;
  41169. },
  41170. set: function (value) {
  41171. if (this._videoMode === value) {
  41172. return;
  41173. }
  41174. this._changeVideoMode(value);
  41175. },
  41176. enumerable: true,
  41177. configurable: true
  41178. });
  41179. VideoDome.prototype._changeVideoMode = function (value) {
  41180. var _this = this;
  41181. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41182. this._videoMode = value;
  41183. // Default Setup and Reset.
  41184. this._videoTexture.uScale = 1;
  41185. this._videoTexture.vScale = 1;
  41186. this._videoTexture.uOffset = 0;
  41187. this._videoTexture.vOffset = 0;
  41188. switch (value) {
  41189. case VideoDome.MODE_SIDEBYSIDE:
  41190. this._videoTexture.uScale = 0.5;
  41191. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  41192. _this._videoTexture.uOffset = camera.isRightCamera ? 0.5 : 0.0;
  41193. });
  41194. break;
  41195. case VideoDome.MODE_TOPBOTTOM:
  41196. this._videoTexture.vScale = 0.5;
  41197. this._onBeforeCameraRenderObserver = this._scene.onBeforeCameraRenderObservable.add(function (camera) {
  41198. _this._videoTexture.vOffset = camera.isRightCamera ? 0.5 : 0.0;
  41199. });
  41200. break;
  41201. }
  41202. };
  41203. /**
  41204. * Releases resources associated with this node.
  41205. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  41206. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  41207. */
  41208. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  41209. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  41210. this._videoTexture.dispose();
  41211. this._mesh.dispose();
  41212. this._material.dispose();
  41213. this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41214. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  41215. };
  41216. /**
  41217. * Define the video source as a Monoscopic panoramic 360 video.
  41218. */
  41219. VideoDome.MODE_MONOSCOPIC = 0;
  41220. /**
  41221. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  41222. */
  41223. VideoDome.MODE_TOPBOTTOM = 1;
  41224. /**
  41225. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  41226. */
  41227. VideoDome.MODE_SIDEBYSIDE = 2;
  41228. return VideoDome;
  41229. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  41230. /***/ }),
  41231. /***/ "./Instrumentation/engineInstrumentation.ts":
  41232. /*!**************************************************!*\
  41233. !*** ./Instrumentation/engineInstrumentation.ts ***!
  41234. \**************************************************/
  41235. /*! exports provided: EngineInstrumentation */
  41236. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41237. "use strict";
  41238. __webpack_require__.r(__webpack_exports__);
  41239. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  41240. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41241. /**
  41242. * This class can be used to get instrumentation data from a Babylon engine
  41243. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41244. */
  41245. var EngineInstrumentation = /** @class */ (function () {
  41246. /**
  41247. * Instantiates a new engine instrumentation.
  41248. * This class can be used to get instrumentation data from a Babylon engine
  41249. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41250. * @param engine Defines the engine to instrument
  41251. */
  41252. function EngineInstrumentation(
  41253. /**
  41254. * Define the instrumented engine.
  41255. */
  41256. engine) {
  41257. this.engine = engine;
  41258. this._captureGPUFrameTime = false;
  41259. this._gpuFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41260. this._captureShaderCompilationTime = false;
  41261. this._shaderCompilationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41262. // Observers
  41263. this._onBeginFrameObserver = null;
  41264. this._onEndFrameObserver = null;
  41265. this._onBeforeShaderCompilationObserver = null;
  41266. this._onAfterShaderCompilationObserver = null;
  41267. }
  41268. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  41269. // Properties
  41270. /**
  41271. * Gets the perf counter used for GPU frame time
  41272. */
  41273. get: function () {
  41274. return this._gpuFrameTime;
  41275. },
  41276. enumerable: true,
  41277. configurable: true
  41278. });
  41279. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  41280. /**
  41281. * Gets the GPU frame time capture status
  41282. */
  41283. get: function () {
  41284. return this._captureGPUFrameTime;
  41285. },
  41286. /**
  41287. * Enable or disable the GPU frame time capture
  41288. */
  41289. set: function (value) {
  41290. var _this = this;
  41291. if (value === this._captureGPUFrameTime) {
  41292. return;
  41293. }
  41294. this._captureGPUFrameTime = value;
  41295. if (value) {
  41296. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  41297. if (!_this._gpuFrameTimeToken) {
  41298. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  41299. }
  41300. });
  41301. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  41302. if (!_this._gpuFrameTimeToken) {
  41303. return;
  41304. }
  41305. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  41306. if (time > -1) {
  41307. _this._gpuFrameTimeToken = null;
  41308. _this._gpuFrameTime.fetchNewFrame();
  41309. _this._gpuFrameTime.addCount(time, true);
  41310. }
  41311. });
  41312. }
  41313. else {
  41314. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  41315. this._onBeginFrameObserver = null;
  41316. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  41317. this._onEndFrameObserver = null;
  41318. }
  41319. },
  41320. enumerable: true,
  41321. configurable: true
  41322. });
  41323. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  41324. /**
  41325. * Gets the perf counter used for shader compilation time
  41326. */
  41327. get: function () {
  41328. return this._shaderCompilationTime;
  41329. },
  41330. enumerable: true,
  41331. configurable: true
  41332. });
  41333. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  41334. /**
  41335. * Gets the shader compilation time capture status
  41336. */
  41337. get: function () {
  41338. return this._captureShaderCompilationTime;
  41339. },
  41340. /**
  41341. * Enable or disable the shader compilation time capture
  41342. */
  41343. set: function (value) {
  41344. var _this = this;
  41345. if (value === this._captureShaderCompilationTime) {
  41346. return;
  41347. }
  41348. this._captureShaderCompilationTime = value;
  41349. if (value) {
  41350. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  41351. _this._shaderCompilationTime.fetchNewFrame();
  41352. _this._shaderCompilationTime.beginMonitoring();
  41353. });
  41354. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  41355. _this._shaderCompilationTime.endMonitoring();
  41356. });
  41357. }
  41358. else {
  41359. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  41360. this._onBeforeShaderCompilationObserver = null;
  41361. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  41362. this._onAfterShaderCompilationObserver = null;
  41363. }
  41364. },
  41365. enumerable: true,
  41366. configurable: true
  41367. });
  41368. /**
  41369. * Dispose and release associated resources.
  41370. */
  41371. EngineInstrumentation.prototype.dispose = function () {
  41372. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  41373. this._onBeginFrameObserver = null;
  41374. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  41375. this._onEndFrameObserver = null;
  41376. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  41377. this._onBeforeShaderCompilationObserver = null;
  41378. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  41379. this._onAfterShaderCompilationObserver = null;
  41380. this.engine = null;
  41381. };
  41382. return EngineInstrumentation;
  41383. }());
  41384. /***/ }),
  41385. /***/ "./Instrumentation/index.ts":
  41386. /*!**********************************!*\
  41387. !*** ./Instrumentation/index.ts ***!
  41388. \**********************************/
  41389. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  41390. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41391. "use strict";
  41392. __webpack_require__.r(__webpack_exports__);
  41393. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  41394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  41395. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  41396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  41397. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  41398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  41399. /***/ }),
  41400. /***/ "./Instrumentation/sceneInstrumentation.ts":
  41401. /*!*************************************************!*\
  41402. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  41403. \*************************************************/
  41404. /*! exports provided: SceneInstrumentation */
  41405. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41406. "use strict";
  41407. __webpack_require__.r(__webpack_exports__);
  41408. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  41409. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41410. /**
  41411. * This class can be used to get instrumentation data from a Babylon engine
  41412. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  41413. */
  41414. var SceneInstrumentation = /** @class */ (function () {
  41415. /**
  41416. * Instantiates a new scene instrumentation.
  41417. * This class can be used to get instrumentation data from a Babylon engine
  41418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  41419. * @param scene Defines the scene to instrument
  41420. */
  41421. function SceneInstrumentation(
  41422. /**
  41423. * Defines the scene to instrument
  41424. */
  41425. scene) {
  41426. var _this = this;
  41427. this.scene = scene;
  41428. this._captureActiveMeshesEvaluationTime = false;
  41429. this._activeMeshesEvaluationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41430. this._captureRenderTargetsRenderTime = false;
  41431. this._renderTargetsRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41432. this._captureFrameTime = false;
  41433. this._frameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41434. this._captureRenderTime = false;
  41435. this._renderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41436. this._captureInterFrameTime = false;
  41437. this._interFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41438. this._captureParticlesRenderTime = false;
  41439. this._particlesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41440. this._captureSpritesRenderTime = false;
  41441. this._spritesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41442. this._capturePhysicsTime = false;
  41443. this._physicsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41444. this._captureAnimationsTime = false;
  41445. this._animationsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41446. this._captureCameraRenderTime = false;
  41447. this._cameraRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  41448. // Observers
  41449. this._onBeforeActiveMeshesEvaluationObserver = null;
  41450. this._onAfterActiveMeshesEvaluationObserver = null;
  41451. this._onBeforeRenderTargetsRenderObserver = null;
  41452. this._onAfterRenderTargetsRenderObserver = null;
  41453. this._onAfterRenderObserver = null;
  41454. this._onBeforeDrawPhaseObserver = null;
  41455. this._onAfterDrawPhaseObserver = null;
  41456. this._onBeforeAnimationsObserver = null;
  41457. this._onBeforeParticlesRenderingObserver = null;
  41458. this._onAfterParticlesRenderingObserver = null;
  41459. this._onBeforeSpritesRenderingObserver = null;
  41460. this._onAfterSpritesRenderingObserver = null;
  41461. this._onBeforePhysicsObserver = null;
  41462. this._onAfterPhysicsObserver = null;
  41463. this._onAfterAnimationsObserver = null;
  41464. this._onBeforeCameraRenderObserver = null;
  41465. this._onAfterCameraRenderObserver = null;
  41466. // Before render
  41467. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  41468. if (_this._captureActiveMeshesEvaluationTime) {
  41469. _this._activeMeshesEvaluationTime.fetchNewFrame();
  41470. }
  41471. if (_this._captureRenderTargetsRenderTime) {
  41472. _this._renderTargetsRenderTime.fetchNewFrame();
  41473. }
  41474. if (_this._captureFrameTime) {
  41475. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  41476. _this._frameTime.beginMonitoring();
  41477. }
  41478. if (_this._captureInterFrameTime) {
  41479. _this._interFrameTime.endMonitoring();
  41480. }
  41481. if (_this._captureParticlesRenderTime) {
  41482. _this._particlesRenderTime.fetchNewFrame();
  41483. }
  41484. if (_this._captureSpritesRenderTime) {
  41485. _this._spritesRenderTime.fetchNewFrame();
  41486. }
  41487. if (_this._captureAnimationsTime) {
  41488. _this._animationsTime.beginMonitoring();
  41489. }
  41490. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  41491. });
  41492. // After render
  41493. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  41494. if (_this._captureFrameTime) {
  41495. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  41496. _this._frameTime.endMonitoring();
  41497. }
  41498. if (_this._captureRenderTime) {
  41499. _this._renderTime.endMonitoring(false);
  41500. }
  41501. if (_this._captureInterFrameTime) {
  41502. _this._interFrameTime.beginMonitoring();
  41503. }
  41504. });
  41505. }
  41506. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  41507. // Properties
  41508. /**
  41509. * Gets the perf counter used for active meshes evaluation time
  41510. */
  41511. get: function () {
  41512. return this._activeMeshesEvaluationTime;
  41513. },
  41514. enumerable: true,
  41515. configurable: true
  41516. });
  41517. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  41518. /**
  41519. * Gets the active meshes evaluation time capture status
  41520. */
  41521. get: function () {
  41522. return this._captureActiveMeshesEvaluationTime;
  41523. },
  41524. /**
  41525. * Enable or disable the active meshes evaluation time capture
  41526. */
  41527. set: function (value) {
  41528. var _this = this;
  41529. if (value === this._captureActiveMeshesEvaluationTime) {
  41530. return;
  41531. }
  41532. this._captureActiveMeshesEvaluationTime = value;
  41533. if (value) {
  41534. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  41535. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  41536. _this._activeMeshesEvaluationTime.beginMonitoring();
  41537. });
  41538. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  41539. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  41540. _this._activeMeshesEvaluationTime.endMonitoring();
  41541. });
  41542. }
  41543. else {
  41544. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  41545. this._onBeforeActiveMeshesEvaluationObserver = null;
  41546. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  41547. this._onAfterActiveMeshesEvaluationObserver = null;
  41548. }
  41549. },
  41550. enumerable: true,
  41551. configurable: true
  41552. });
  41553. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  41554. /**
  41555. * Gets the perf counter used for render targets render time
  41556. */
  41557. get: function () {
  41558. return this._renderTargetsRenderTime;
  41559. },
  41560. enumerable: true,
  41561. configurable: true
  41562. });
  41563. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  41564. /**
  41565. * Gets the render targets render time capture status
  41566. */
  41567. get: function () {
  41568. return this._captureRenderTargetsRenderTime;
  41569. },
  41570. /**
  41571. * Enable or disable the render targets render time capture
  41572. */
  41573. set: function (value) {
  41574. var _this = this;
  41575. if (value === this._captureRenderTargetsRenderTime) {
  41576. return;
  41577. }
  41578. this._captureRenderTargetsRenderTime = value;
  41579. if (value) {
  41580. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  41581. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  41582. _this._renderTargetsRenderTime.beginMonitoring();
  41583. });
  41584. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  41585. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  41586. _this._renderTargetsRenderTime.endMonitoring(false);
  41587. });
  41588. }
  41589. else {
  41590. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  41591. this._onBeforeRenderTargetsRenderObserver = null;
  41592. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  41593. this._onAfterRenderTargetsRenderObserver = null;
  41594. }
  41595. },
  41596. enumerable: true,
  41597. configurable: true
  41598. });
  41599. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  41600. /**
  41601. * Gets the perf counter used for particles render time
  41602. */
  41603. get: function () {
  41604. return this._particlesRenderTime;
  41605. },
  41606. enumerable: true,
  41607. configurable: true
  41608. });
  41609. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  41610. /**
  41611. * Gets the particles render time capture status
  41612. */
  41613. get: function () {
  41614. return this._captureParticlesRenderTime;
  41615. },
  41616. /**
  41617. * Enable or disable the particles render time capture
  41618. */
  41619. set: function (value) {
  41620. var _this = this;
  41621. if (value === this._captureParticlesRenderTime) {
  41622. return;
  41623. }
  41624. this._captureParticlesRenderTime = value;
  41625. if (value) {
  41626. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  41627. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  41628. _this._particlesRenderTime.beginMonitoring();
  41629. });
  41630. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  41631. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  41632. _this._particlesRenderTime.endMonitoring(false);
  41633. });
  41634. }
  41635. else {
  41636. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  41637. this._onBeforeParticlesRenderingObserver = null;
  41638. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  41639. this._onAfterParticlesRenderingObserver = null;
  41640. }
  41641. },
  41642. enumerable: true,
  41643. configurable: true
  41644. });
  41645. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  41646. /**
  41647. * Gets the perf counter used for sprites render time
  41648. */
  41649. get: function () {
  41650. return this._spritesRenderTime;
  41651. },
  41652. enumerable: true,
  41653. configurable: true
  41654. });
  41655. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  41656. /**
  41657. * Gets the sprites render time capture status
  41658. */
  41659. get: function () {
  41660. return this._captureSpritesRenderTime;
  41661. },
  41662. /**
  41663. * Enable or disable the sprites render time capture
  41664. */
  41665. set: function (value) {
  41666. var _this = this;
  41667. if (value === this._captureSpritesRenderTime) {
  41668. return;
  41669. }
  41670. this._captureSpritesRenderTime = value;
  41671. if (!this.scene.spriteManagers) {
  41672. return;
  41673. }
  41674. if (value) {
  41675. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  41676. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  41677. _this._spritesRenderTime.beginMonitoring();
  41678. });
  41679. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  41680. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  41681. _this._spritesRenderTime.endMonitoring(false);
  41682. });
  41683. }
  41684. else {
  41685. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  41686. this._onBeforeSpritesRenderingObserver = null;
  41687. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  41688. this._onAfterSpritesRenderingObserver = null;
  41689. }
  41690. },
  41691. enumerable: true,
  41692. configurable: true
  41693. });
  41694. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  41695. /**
  41696. * Gets the perf counter used for physics time
  41697. */
  41698. get: function () {
  41699. return this._physicsTime;
  41700. },
  41701. enumerable: true,
  41702. configurable: true
  41703. });
  41704. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  41705. /**
  41706. * Gets the physics time capture status
  41707. */
  41708. get: function () {
  41709. return this._capturePhysicsTime;
  41710. },
  41711. /**
  41712. * Enable or disable the physics time capture
  41713. */
  41714. set: function (value) {
  41715. var _this = this;
  41716. if (value === this._capturePhysicsTime) {
  41717. return;
  41718. }
  41719. if (!this.scene.onBeforePhysicsObservable) {
  41720. return;
  41721. }
  41722. this._capturePhysicsTime = value;
  41723. if (value) {
  41724. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  41725. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  41726. _this._physicsTime.beginMonitoring();
  41727. });
  41728. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  41729. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  41730. _this._physicsTime.endMonitoring();
  41731. });
  41732. }
  41733. else {
  41734. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  41735. this._onBeforePhysicsObserver = null;
  41736. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  41737. this._onAfterPhysicsObserver = null;
  41738. }
  41739. },
  41740. enumerable: true,
  41741. configurable: true
  41742. });
  41743. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  41744. /**
  41745. * Gets the perf counter used for animations time
  41746. */
  41747. get: function () {
  41748. return this._animationsTime;
  41749. },
  41750. enumerable: true,
  41751. configurable: true
  41752. });
  41753. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  41754. /**
  41755. * Gets the animations time capture status
  41756. */
  41757. get: function () {
  41758. return this._captureAnimationsTime;
  41759. },
  41760. /**
  41761. * Enable or disable the animations time capture
  41762. */
  41763. set: function (value) {
  41764. var _this = this;
  41765. if (value === this._captureAnimationsTime) {
  41766. return;
  41767. }
  41768. this._captureAnimationsTime = value;
  41769. if (value) {
  41770. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  41771. _this._animationsTime.endMonitoring();
  41772. });
  41773. }
  41774. else {
  41775. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  41776. this._onAfterAnimationsObserver = null;
  41777. }
  41778. },
  41779. enumerable: true,
  41780. configurable: true
  41781. });
  41782. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  41783. /**
  41784. * Gets the perf counter used for frame time capture
  41785. */
  41786. get: function () {
  41787. return this._frameTime;
  41788. },
  41789. enumerable: true,
  41790. configurable: true
  41791. });
  41792. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  41793. /**
  41794. * Gets the frame time capture status
  41795. */
  41796. get: function () {
  41797. return this._captureFrameTime;
  41798. },
  41799. /**
  41800. * Enable or disable the frame time capture
  41801. */
  41802. set: function (value) {
  41803. this._captureFrameTime = value;
  41804. },
  41805. enumerable: true,
  41806. configurable: true
  41807. });
  41808. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  41809. /**
  41810. * Gets the perf counter used for inter-frames time capture
  41811. */
  41812. get: function () {
  41813. return this._interFrameTime;
  41814. },
  41815. enumerable: true,
  41816. configurable: true
  41817. });
  41818. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  41819. /**
  41820. * Gets the inter-frames time capture status
  41821. */
  41822. get: function () {
  41823. return this._captureInterFrameTime;
  41824. },
  41825. /**
  41826. * Enable or disable the inter-frames time capture
  41827. */
  41828. set: function (value) {
  41829. this._captureInterFrameTime = value;
  41830. },
  41831. enumerable: true,
  41832. configurable: true
  41833. });
  41834. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  41835. /**
  41836. * Gets the perf counter used for render time capture
  41837. */
  41838. get: function () {
  41839. return this._renderTime;
  41840. },
  41841. enumerable: true,
  41842. configurable: true
  41843. });
  41844. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  41845. /**
  41846. * Gets the render time capture status
  41847. */
  41848. get: function () {
  41849. return this._captureRenderTime;
  41850. },
  41851. /**
  41852. * Enable or disable the render time capture
  41853. */
  41854. set: function (value) {
  41855. var _this = this;
  41856. if (value === this._captureRenderTime) {
  41857. return;
  41858. }
  41859. this._captureRenderTime = value;
  41860. if (value) {
  41861. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  41862. _this._renderTime.beginMonitoring();
  41863. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  41864. });
  41865. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  41866. _this._renderTime.endMonitoring(false);
  41867. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  41868. });
  41869. }
  41870. else {
  41871. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  41872. this._onBeforeDrawPhaseObserver = null;
  41873. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  41874. this._onAfterDrawPhaseObserver = null;
  41875. }
  41876. },
  41877. enumerable: true,
  41878. configurable: true
  41879. });
  41880. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  41881. /**
  41882. * Gets the perf counter used for camera render time capture
  41883. */
  41884. get: function () {
  41885. return this._cameraRenderTime;
  41886. },
  41887. enumerable: true,
  41888. configurable: true
  41889. });
  41890. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  41891. /**
  41892. * Gets the camera render time capture status
  41893. */
  41894. get: function () {
  41895. return this._captureCameraRenderTime;
  41896. },
  41897. /**
  41898. * Enable or disable the camera render time capture
  41899. */
  41900. set: function (value) {
  41901. var _this = this;
  41902. if (value === this._captureCameraRenderTime) {
  41903. return;
  41904. }
  41905. this._captureCameraRenderTime = value;
  41906. if (value) {
  41907. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  41908. _this._cameraRenderTime.beginMonitoring();
  41909. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  41910. });
  41911. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  41912. _this._cameraRenderTime.endMonitoring(false);
  41913. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  41914. });
  41915. }
  41916. else {
  41917. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41918. this._onBeforeCameraRenderObserver = null;
  41919. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  41920. this._onAfterCameraRenderObserver = null;
  41921. }
  41922. },
  41923. enumerable: true,
  41924. configurable: true
  41925. });
  41926. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  41927. /**
  41928. * Gets the perf counter used for draw calls
  41929. */
  41930. get: function () {
  41931. return this.scene.getEngine()._drawCalls;
  41932. },
  41933. enumerable: true,
  41934. configurable: true
  41935. });
  41936. /**
  41937. * Dispose and release associated resources.
  41938. */
  41939. SceneInstrumentation.prototype.dispose = function () {
  41940. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  41941. this._onAfterRenderObserver = null;
  41942. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  41943. this._onBeforeActiveMeshesEvaluationObserver = null;
  41944. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  41945. this._onAfterActiveMeshesEvaluationObserver = null;
  41946. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  41947. this._onBeforeRenderTargetsRenderObserver = null;
  41948. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  41949. this._onAfterRenderTargetsRenderObserver = null;
  41950. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  41951. this._onBeforeAnimationsObserver = null;
  41952. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  41953. this._onBeforeParticlesRenderingObserver = null;
  41954. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  41955. this._onAfterParticlesRenderingObserver = null;
  41956. if (this._onBeforeSpritesRenderingObserver) {
  41957. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  41958. this._onBeforeSpritesRenderingObserver = null;
  41959. }
  41960. if (this._onAfterSpritesRenderingObserver) {
  41961. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  41962. this._onAfterSpritesRenderingObserver = null;
  41963. }
  41964. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  41965. this._onBeforeDrawPhaseObserver = null;
  41966. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  41967. this._onAfterDrawPhaseObserver = null;
  41968. if (this._onBeforePhysicsObserver) {
  41969. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  41970. this._onBeforePhysicsObserver = null;
  41971. }
  41972. if (this._onAfterPhysicsObserver) {
  41973. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  41974. this._onAfterPhysicsObserver = null;
  41975. }
  41976. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  41977. this._onAfterAnimationsObserver = null;
  41978. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  41979. this._onBeforeCameraRenderObserver = null;
  41980. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  41981. this._onAfterCameraRenderObserver = null;
  41982. this.scene = null;
  41983. };
  41984. return SceneInstrumentation;
  41985. }());
  41986. /***/ }),
  41987. /***/ "./Instrumentation/timeToken.ts":
  41988. /*!**************************************!*\
  41989. !*** ./Instrumentation/timeToken.ts ***!
  41990. \**************************************/
  41991. /*! exports provided: _TimeToken */
  41992. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41993. "use strict";
  41994. __webpack_require__.r(__webpack_exports__);
  41995. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  41996. /**
  41997. * @hidden
  41998. **/
  41999. var _TimeToken = /** @class */ (function () {
  42000. function _TimeToken() {
  42001. this._timeElapsedQueryEnded = false;
  42002. }
  42003. return _TimeToken;
  42004. }());
  42005. /***/ }),
  42006. /***/ "./Layers/effectLayer.ts":
  42007. /*!*******************************!*\
  42008. !*** ./Layers/effectLayer.ts ***!
  42009. \*******************************/
  42010. /*! exports provided: EffectLayer */
  42011. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42012. "use strict";
  42013. __webpack_require__.r(__webpack_exports__);
  42014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  42015. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42016. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42017. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42018. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42019. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42020. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  42021. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42022. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42023. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42024. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42025. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  42026. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42027. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  42028. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  42029. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  42030. /**
  42031. * The effect layer Helps adding post process effect blended with the main pass.
  42032. *
  42033. * This can be for instance use to generate glow or higlight effects on the scene.
  42034. *
  42035. * The effect layer class can not be used directly and is intented to inherited from to be
  42036. * customized per effects.
  42037. */
  42038. var EffectLayer = /** @class */ (function () {
  42039. /**
  42040. * Instantiates a new effect Layer and references it in the scene.
  42041. * @param name The name of the layer
  42042. * @param scene The scene to use the layer in
  42043. */
  42044. function EffectLayer(
  42045. /** The Friendly of the effect in the scene */
  42046. name, scene) {
  42047. this._vertexBuffers = {};
  42048. this._maxSize = 0;
  42049. this._mainTextureDesiredSize = { width: 0, height: 0 };
  42050. this._shouldRender = true;
  42051. this._postProcesses = [];
  42052. this._textures = [];
  42053. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  42054. /**
  42055. * The clear color of the texture used to generate the glow map.
  42056. */
  42057. this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  42058. /**
  42059. * Specifies wether the highlight layer is enabled or not.
  42060. */
  42061. this.isEnabled = true;
  42062. /**
  42063. * An event triggered when the effect layer has been disposed.
  42064. */
  42065. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42066. /**
  42067. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  42068. */
  42069. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42070. /**
  42071. * An event triggered when the generated texture is being merged in the scene.
  42072. */
  42073. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42074. /**
  42075. * An event triggered when the generated texture has been merged in the scene.
  42076. */
  42077. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42078. /**
  42079. * An event triggered when the efffect layer changes its size.
  42080. */
  42081. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  42082. this.name = name;
  42083. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  42084. EffectLayer._SceneComponentInitialization(this._scene);
  42085. this._engine = this._scene.getEngine();
  42086. this._maxSize = this._engine.getCaps().maxTextureSize;
  42087. this._scene.effectLayers.push(this);
  42088. // Generate Buffers
  42089. this._generateIndexBuffer();
  42090. this._genrateVertexBuffer();
  42091. }
  42092. Object.defineProperty(EffectLayer.prototype, "camera", {
  42093. /**
  42094. * Gets the camera attached to the layer.
  42095. */
  42096. get: function () {
  42097. return this._effectLayerOptions.camera;
  42098. },
  42099. enumerable: true,
  42100. configurable: true
  42101. });
  42102. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  42103. /**
  42104. * Gets the rendering group id the layer should render in.
  42105. */
  42106. get: function () {
  42107. return this._effectLayerOptions.renderingGroupId;
  42108. },
  42109. enumerable: true,
  42110. configurable: true
  42111. });
  42112. /**
  42113. * Initializes the effect layer with the required options.
  42114. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  42115. */
  42116. EffectLayer.prototype._init = function (options) {
  42117. // Adapt options
  42118. 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);
  42119. this._setMainTextureSize();
  42120. this._createMainTexture();
  42121. this._createTextureAndPostProcesses();
  42122. this._mergeEffect = this._createMergeEffect();
  42123. };
  42124. /**
  42125. * Generates the index buffer of the full screen quad blending to the main canvas.
  42126. */
  42127. EffectLayer.prototype._generateIndexBuffer = function () {
  42128. // Indices
  42129. var indices = [];
  42130. indices.push(0);
  42131. indices.push(1);
  42132. indices.push(2);
  42133. indices.push(0);
  42134. indices.push(2);
  42135. indices.push(3);
  42136. this._indexBuffer = this._engine.createIndexBuffer(indices);
  42137. };
  42138. /**
  42139. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  42140. */
  42141. EffectLayer.prototype._genrateVertexBuffer = function () {
  42142. // VBO
  42143. var vertices = [];
  42144. vertices.push(1, 1);
  42145. vertices.push(-1, 1);
  42146. vertices.push(-1, -1);
  42147. vertices.push(1, -1);
  42148. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind, false, false, 2);
  42149. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = vertexBuffer;
  42150. };
  42151. /**
  42152. * Sets the main texture desired size which is the closest power of two
  42153. * of the engine canvas size.
  42154. */
  42155. EffectLayer.prototype._setMainTextureSize = function () {
  42156. if (this._effectLayerOptions.mainTextureFixedSize) {
  42157. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  42158. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  42159. }
  42160. else {
  42161. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  42162. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  42163. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  42164. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  42165. }
  42166. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  42167. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  42168. };
  42169. /**
  42170. * Creates the main texture for the effect layer.
  42171. */
  42172. EffectLayer.prototype._createMainTexture = function () {
  42173. var _this = this;
  42174. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  42175. width: this._mainTextureDesiredSize.width,
  42176. height: this._mainTextureDesiredSize.height
  42177. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  42178. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  42179. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42180. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42181. this._mainTexture.anisotropicFilteringLevel = 1;
  42182. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE);
  42183. this._mainTexture.renderParticles = false;
  42184. this._mainTexture.renderList = null;
  42185. this._mainTexture.ignoreCameraViewport = true;
  42186. // Custom render function
  42187. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  42188. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  42189. var index;
  42190. var engine = _this._scene.getEngine();
  42191. if (depthOnlySubMeshes.length) {
  42192. engine.setColorWrite(false);
  42193. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  42194. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  42195. }
  42196. engine.setColorWrite(true);
  42197. }
  42198. for (index = 0; index < opaqueSubMeshes.length; index++) {
  42199. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  42200. }
  42201. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  42202. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  42203. }
  42204. for (index = 0; index < transparentSubMeshes.length; index++) {
  42205. _this._renderSubMesh(transparentSubMeshes.data[index]);
  42206. }
  42207. };
  42208. this._mainTexture.onClearObservable.add(function (engine) {
  42209. engine.clear(_this.neutralColor, true, true, true);
  42210. });
  42211. };
  42212. /**
  42213. * Adds specific effects defines.
  42214. * @param defines The defines to add specifics to.
  42215. */
  42216. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  42217. // Nothing to add by default.
  42218. };
  42219. /**
  42220. * Checks for the readiness of the element composing the layer.
  42221. * @param subMesh the mesh to check for
  42222. * @param useInstances specify wether or not to use instances to render the mesh
  42223. * @param emissiveTexture the associated emissive texture used to generate the glow
  42224. * @return true if ready otherwise, false
  42225. */
  42226. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  42227. var material = subMesh.getMaterial();
  42228. if (!material) {
  42229. return false;
  42230. }
  42231. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  42232. return false;
  42233. }
  42234. var defines = [];
  42235. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  42236. var mesh = subMesh.getMesh();
  42237. var uv1 = false;
  42238. var uv2 = false;
  42239. // Diffuse
  42240. if (material) {
  42241. var needAlphaTest = material.needAlphaTesting();
  42242. var diffuseTexture = material.getAlphaTestTexture();
  42243. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  42244. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  42245. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  42246. defines.push("#define DIFFUSE");
  42247. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  42248. diffuseTexture.coordinatesIndex === 1) {
  42249. defines.push("#define DIFFUSEUV2");
  42250. uv2 = true;
  42251. }
  42252. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  42253. defines.push("#define DIFFUSEUV1");
  42254. uv1 = true;
  42255. }
  42256. if (needAlphaTest) {
  42257. defines.push("#define ALPHATEST");
  42258. defines.push("#define ALPHATESTVALUE 0.4");
  42259. }
  42260. }
  42261. var opacityTexture = material.opacityTexture;
  42262. if (opacityTexture) {
  42263. defines.push("#define OPACITY");
  42264. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  42265. opacityTexture.coordinatesIndex === 1) {
  42266. defines.push("#define OPACITYUV2");
  42267. uv2 = true;
  42268. }
  42269. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  42270. defines.push("#define OPACITYUV1");
  42271. uv1 = true;
  42272. }
  42273. }
  42274. }
  42275. // Emissive
  42276. if (emissiveTexture) {
  42277. defines.push("#define EMISSIVE");
  42278. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  42279. emissiveTexture.coordinatesIndex === 1) {
  42280. defines.push("#define EMISSIVEUV2");
  42281. uv2 = true;
  42282. }
  42283. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  42284. defines.push("#define EMISSIVEUV1");
  42285. uv1 = true;
  42286. }
  42287. }
  42288. // Vertex
  42289. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  42290. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  42291. defines.push("#define VERTEXALPHA");
  42292. }
  42293. if (uv1) {
  42294. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  42295. defines.push("#define UV1");
  42296. }
  42297. if (uv2) {
  42298. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  42299. defines.push("#define UV2");
  42300. }
  42301. // Bones
  42302. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  42303. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesKind);
  42304. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsKind);
  42305. if (mesh.numBoneInfluencers > 4) {
  42306. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesExtraKind);
  42307. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsExtraKind);
  42308. }
  42309. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  42310. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  42311. }
  42312. else {
  42313. defines.push("#define NUM_BONE_INFLUENCERS 0");
  42314. }
  42315. // Morph targets
  42316. var manager = mesh.morphTargetManager;
  42317. var morphInfluencers = 0;
  42318. if (manager) {
  42319. if (manager.numInfluencers > 0) {
  42320. defines.push("#define MORPHTARGETS");
  42321. morphInfluencers = manager.numInfluencers;
  42322. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  42323. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  42324. }
  42325. }
  42326. // Instances
  42327. if (useInstances) {
  42328. defines.push("#define INSTANCES");
  42329. attribs.push("world0");
  42330. attribs.push("world1");
  42331. attribs.push("world2");
  42332. attribs.push("world3");
  42333. }
  42334. this._addCustomEffectDefines(defines);
  42335. // Get correct effect
  42336. var join = defines.join("\n");
  42337. if (this._cachedDefines !== join) {
  42338. this._cachedDefines = join;
  42339. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  42340. "color", "morphTargetInfluences",
  42341. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  42342. }
  42343. return this._effectLayerMapGenerationEffect.isReady();
  42344. };
  42345. /**
  42346. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  42347. */
  42348. EffectLayer.prototype.render = function () {
  42349. var currentEffect = this._mergeEffect;
  42350. // Check
  42351. if (!currentEffect.isReady()) {
  42352. return;
  42353. }
  42354. for (var i = 0; i < this._postProcesses.length; i++) {
  42355. if (!this._postProcesses[i].isReady()) {
  42356. return;
  42357. }
  42358. }
  42359. var engine = this._scene.getEngine();
  42360. this.onBeforeComposeObservable.notifyObservers(this);
  42361. // Render
  42362. engine.enableEffect(currentEffect);
  42363. engine.setState(false);
  42364. // VBOs
  42365. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  42366. // Cache
  42367. var previousAlphaMode = engine.getAlphaMode();
  42368. // Go Blend.
  42369. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  42370. // Blends the map on the main canvas.
  42371. this._internalRender(currentEffect);
  42372. // Restore Alpha
  42373. engine.setAlphaMode(previousAlphaMode);
  42374. this.onAfterComposeObservable.notifyObservers(this);
  42375. // Handle size changes.
  42376. var size = this._mainTexture.getSize();
  42377. this._setMainTextureSize();
  42378. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  42379. // Recreate RTT and post processes on size change.
  42380. this.onSizeChangedObservable.notifyObservers(this);
  42381. this._disposeTextureAndPostProcesses();
  42382. this._createMainTexture();
  42383. this._createTextureAndPostProcesses();
  42384. }
  42385. };
  42386. /**
  42387. * Determine if a given mesh will be used in the current effect.
  42388. * @param mesh mesh to test
  42389. * @returns true if the mesh will be used
  42390. */
  42391. EffectLayer.prototype.hasMesh = function (mesh) {
  42392. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  42393. return true;
  42394. }
  42395. return false;
  42396. };
  42397. /**
  42398. * Returns true if the layer contains information to display, otherwise false.
  42399. * @returns true if the glow layer should be rendered
  42400. */
  42401. EffectLayer.prototype.shouldRender = function () {
  42402. return this.isEnabled && this._shouldRender;
  42403. };
  42404. /**
  42405. * Returns true if the mesh should render, otherwise false.
  42406. * @param mesh The mesh to render
  42407. * @returns true if it should render otherwise false
  42408. */
  42409. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  42410. return true;
  42411. };
  42412. /**
  42413. * Returns true if the mesh can be rendered, otherwise false.
  42414. * @param mesh The mesh to render
  42415. * @param material The material used on the mesh
  42416. * @returns true if it can be rendered otherwise false
  42417. */
  42418. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  42419. return !material.needAlphaBlendingForMesh(mesh);
  42420. };
  42421. /**
  42422. * Returns true if the mesh should render, otherwise false.
  42423. * @param mesh The mesh to render
  42424. * @returns true if it should render otherwise false
  42425. */
  42426. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  42427. return true;
  42428. };
  42429. /**
  42430. * Renders the submesh passed in parameter to the generation map.
  42431. */
  42432. EffectLayer.prototype._renderSubMesh = function (subMesh) {
  42433. var _this = this;
  42434. if (!this.shouldRender()) {
  42435. return;
  42436. }
  42437. var material = subMesh.getMaterial();
  42438. var mesh = subMesh.getRenderingMesh();
  42439. var scene = this._scene;
  42440. var engine = scene.getEngine();
  42441. if (!material) {
  42442. return;
  42443. }
  42444. // Do not block in blend mode.
  42445. if (!this._canRenderMesh(mesh, material)) {
  42446. return;
  42447. }
  42448. // Culling
  42449. engine.setState(material.backFaceCulling);
  42450. // Managing instances
  42451. var batch = mesh._getInstancesRenderList(subMesh._id);
  42452. if (batch.mustReturn) {
  42453. return;
  42454. }
  42455. // Early Exit per mesh
  42456. if (!this._shouldRenderMesh(mesh)) {
  42457. return;
  42458. }
  42459. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  42460. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  42461. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  42462. engine.enableEffect(this._effectLayerMapGenerationEffect);
  42463. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode);
  42464. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  42465. this._effectLayerMapGenerationEffect.setFloat4("color", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  42466. var needAlphaTest = material.needAlphaTesting();
  42467. var diffuseTexture = material.getAlphaTestTexture();
  42468. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  42469. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  42470. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  42471. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  42472. var textureMatrix = diffuseTexture.getTextureMatrix();
  42473. if (textureMatrix) {
  42474. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  42475. }
  42476. }
  42477. var opacityTexture = material.opacityTexture;
  42478. if (opacityTexture) {
  42479. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  42480. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  42481. var textureMatrix = opacityTexture.getTextureMatrix();
  42482. if (textureMatrix) {
  42483. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  42484. }
  42485. }
  42486. // Glow emissive only
  42487. if (this._emissiveTextureAndColor.texture) {
  42488. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  42489. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  42490. }
  42491. // Bones
  42492. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  42493. this._effectLayerMapGenerationEffect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  42494. }
  42495. // Morph targets
  42496. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  42497. // Draw
  42498. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  42499. }
  42500. else {
  42501. // Need to reset refresh rate of the main map
  42502. this._mainTexture.resetRefreshCounter();
  42503. }
  42504. };
  42505. /**
  42506. * Rebuild the required buffers.
  42507. * @hidden Internal use only.
  42508. */
  42509. EffectLayer.prototype._rebuild = function () {
  42510. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  42511. if (vb) {
  42512. vb._rebuild();
  42513. }
  42514. this._generateIndexBuffer();
  42515. };
  42516. /**
  42517. * Dispose only the render target textures and post process.
  42518. */
  42519. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  42520. this._mainTexture.dispose();
  42521. for (var i = 0; i < this._postProcesses.length; i++) {
  42522. if (this._postProcesses[i]) {
  42523. this._postProcesses[i].dispose();
  42524. }
  42525. }
  42526. this._postProcesses = [];
  42527. for (var i = 0; i < this._textures.length; i++) {
  42528. if (this._textures[i]) {
  42529. this._textures[i].dispose();
  42530. }
  42531. }
  42532. this._textures = [];
  42533. };
  42534. /**
  42535. * Dispose the highlight layer and free resources.
  42536. */
  42537. EffectLayer.prototype.dispose = function () {
  42538. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  42539. if (vertexBuffer) {
  42540. vertexBuffer.dispose();
  42541. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = null;
  42542. }
  42543. if (this._indexBuffer) {
  42544. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  42545. this._indexBuffer = null;
  42546. }
  42547. // Clean textures and post processes
  42548. this._disposeTextureAndPostProcesses();
  42549. // Remove from scene
  42550. var index = this._scene.effectLayers.indexOf(this, 0);
  42551. if (index > -1) {
  42552. this._scene.effectLayers.splice(index, 1);
  42553. }
  42554. // Callback
  42555. this.onDisposeObservable.notifyObservers(this);
  42556. this.onDisposeObservable.clear();
  42557. this.onBeforeRenderMainTextureObservable.clear();
  42558. this.onBeforeComposeObservable.clear();
  42559. this.onAfterComposeObservable.clear();
  42560. this.onSizeChangedObservable.clear();
  42561. };
  42562. /**
  42563. * Gets the class name of the effect layer
  42564. * @returns the string with the class name of the effect layer
  42565. */
  42566. EffectLayer.prototype.getClassName = function () {
  42567. return "EffectLayer";
  42568. };
  42569. /**
  42570. * Creates an effect layer from parsed effect layer data
  42571. * @param parsedEffectLayer defines effect layer data
  42572. * @param scene defines the current scene
  42573. * @param rootUrl defines the root URL containing the effect layer information
  42574. * @returns a parsed effect Layer
  42575. */
  42576. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  42577. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  42578. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  42579. };
  42580. /** @hidden */
  42581. EffectLayer._SceneComponentInitialization = function (_) {
  42582. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__["_DevTools"].WarnImport("EffectLayerSceneComponent");
  42583. };
  42584. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42585. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42586. ], EffectLayer.prototype, "name", void 0);
  42587. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42588. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  42589. ], EffectLayer.prototype, "neutralColor", void 0);
  42590. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42591. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42592. ], EffectLayer.prototype, "isEnabled", void 0);
  42593. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42594. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  42595. ], EffectLayer.prototype, "camera", null);
  42596. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42597. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42598. ], EffectLayer.prototype, "renderingGroupId", null);
  42599. return EffectLayer;
  42600. }());
  42601. /***/ }),
  42602. /***/ "./Layers/effectLayerSceneComponent.ts":
  42603. /*!*********************************************!*\
  42604. !*** ./Layers/effectLayerSceneComponent.ts ***!
  42605. \*********************************************/
  42606. /*! exports provided: EffectLayerSceneComponent */
  42607. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42608. "use strict";
  42609. __webpack_require__.r(__webpack_exports__);
  42610. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  42611. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  42612. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42613. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42614. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42615. // Adds the parser to the scene parsers.
  42616. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  42617. if (parsedData.effectLayers) {
  42618. if (!container.effectLayers) {
  42619. container.effectLayers = new Array();
  42620. }
  42621. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  42622. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  42623. container.effectLayers.push(effectLayer);
  42624. }
  42625. }
  42626. });
  42627. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  42628. var index = this.effectLayers.indexOf(toRemove);
  42629. if (index !== -1) {
  42630. this.effectLayers.splice(index, 1);
  42631. }
  42632. return index;
  42633. };
  42634. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  42635. this.effectLayers.push(newEffectLayer);
  42636. };
  42637. /**
  42638. * Defines the layer scene component responsible to manage any effect layers
  42639. * in a given scene.
  42640. */
  42641. var EffectLayerSceneComponent = /** @class */ (function () {
  42642. /**
  42643. * Creates a new instance of the component for the given scene
  42644. * @param scene Defines the scene to register the component in
  42645. */
  42646. function EffectLayerSceneComponent(scene) {
  42647. /**
  42648. * The component name helpfull to identify the component in the list of scene components.
  42649. */
  42650. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  42651. this._renderEffects = false;
  42652. this._needStencil = false;
  42653. this._previousStencilState = false;
  42654. this.scene = scene;
  42655. this._engine = scene.getEngine();
  42656. scene.effectLayers = new Array();
  42657. }
  42658. /**
  42659. * Registers the component in a given scene
  42660. */
  42661. EffectLayerSceneComponent.prototype.register = function () {
  42662. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  42663. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  42664. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  42665. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  42666. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  42667. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  42668. };
  42669. /**
  42670. * Rebuilds the elements related to this component in case of
  42671. * context lost for instance.
  42672. */
  42673. EffectLayerSceneComponent.prototype.rebuild = function () {
  42674. var layers = this.scene.effectLayers;
  42675. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  42676. var effectLayer = layers_1[_i];
  42677. effectLayer._rebuild();
  42678. }
  42679. };
  42680. /**
  42681. * Serializes the component data to the specified json object
  42682. * @param serializationObject The object to serialize to
  42683. */
  42684. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  42685. // Effect layers
  42686. serializationObject.effectLayers = [];
  42687. var layers = this.scene.effectLayers;
  42688. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  42689. var effectLayer = layers_2[_i];
  42690. if (effectLayer.serialize) {
  42691. serializationObject.effectLayers.push(effectLayer.serialize());
  42692. }
  42693. }
  42694. };
  42695. /**
  42696. * Adds all the element from the container to the scene
  42697. * @param container the container holding the elements
  42698. */
  42699. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  42700. var _this = this;
  42701. if (!container.effectLayers) {
  42702. return;
  42703. }
  42704. container.effectLayers.forEach(function (o) {
  42705. _this.scene.addEffectLayer(o);
  42706. });
  42707. };
  42708. /**
  42709. * Removes all the elements in the container from the scene
  42710. * @param container contains the elements to remove
  42711. * @param dispose if the removed element should be disposed (default: false)
  42712. */
  42713. EffectLayerSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  42714. var _this = this;
  42715. if (!container.effectLayers) {
  42716. return;
  42717. }
  42718. container.effectLayers.forEach(function (o) {
  42719. _this.scene.removeEffectLayer(o);
  42720. if (dispose) {
  42721. o.dispose();
  42722. }
  42723. });
  42724. };
  42725. /**
  42726. * Disposes the component and the associated ressources.
  42727. */
  42728. EffectLayerSceneComponent.prototype.dispose = function () {
  42729. var layers = this.scene.effectLayers;
  42730. while (layers.length) {
  42731. layers[0].dispose();
  42732. }
  42733. };
  42734. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  42735. var layers = this.scene.effectLayers;
  42736. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  42737. var layer = layers_3[_i];
  42738. if (!layer.hasMesh(mesh)) {
  42739. continue;
  42740. }
  42741. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  42742. var subMesh = _b[_a];
  42743. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  42744. return false;
  42745. }
  42746. }
  42747. }
  42748. return true;
  42749. };
  42750. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  42751. this._renderEffects = false;
  42752. this._needStencil = false;
  42753. var layers = this.scene.effectLayers;
  42754. if (layers && layers.length > 0) {
  42755. this._previousStencilState = this._engine.getStencilBuffer();
  42756. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  42757. var effectLayer = layers_4[_i];
  42758. if (effectLayer.shouldRender() &&
  42759. (!effectLayer.camera ||
  42760. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  42761. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  42762. this._renderEffects = true;
  42763. this._needStencil = this._needStencil || effectLayer.needStencil();
  42764. var renderTarget = effectLayer._mainTexture;
  42765. if (renderTarget._shouldRender()) {
  42766. this.scene.incrementRenderId();
  42767. renderTarget.render(false, false);
  42768. }
  42769. }
  42770. }
  42771. this.scene.incrementRenderId();
  42772. }
  42773. };
  42774. EffectLayerSceneComponent.prototype._setStencil = function () {
  42775. // Activate effect Layer stencil
  42776. if (this._needStencil) {
  42777. this._engine.setStencilBuffer(true);
  42778. }
  42779. };
  42780. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  42781. // Restore effect Layer stencil
  42782. if (this._needStencil) {
  42783. this._engine.setStencilBuffer(this._previousStencilState);
  42784. }
  42785. };
  42786. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  42787. if (this._renderEffects) {
  42788. this._engine.setDepthBuffer(false);
  42789. var layers = this.scene.effectLayers;
  42790. for (var i = 0; i < layers.length; i++) {
  42791. var effectLayer = layers[i];
  42792. if (effectLayer.renderingGroupId === renderingGroupId) {
  42793. if (effectLayer.shouldRender()) {
  42794. effectLayer.render();
  42795. }
  42796. }
  42797. }
  42798. this._engine.setDepthBuffer(true);
  42799. }
  42800. };
  42801. EffectLayerSceneComponent.prototype._drawCamera = function () {
  42802. if (this._renderEffects) {
  42803. this._draw(-1);
  42804. }
  42805. };
  42806. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  42807. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  42808. this._draw(index);
  42809. }
  42810. };
  42811. return EffectLayerSceneComponent;
  42812. }());
  42813. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  42814. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  42815. if (!component) {
  42816. component = new EffectLayerSceneComponent(scene);
  42817. scene._addComponent(component);
  42818. }
  42819. };
  42820. /***/ }),
  42821. /***/ "./Layers/glowLayer.ts":
  42822. /*!*****************************!*\
  42823. !*** ./Layers/glowLayer.ts ***!
  42824. \*****************************/
  42825. /*! exports provided: GlowLayer */
  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__, "GlowLayer", function() { return GlowLayer; });
  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_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42833. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42834. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42835. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42836. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42837. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42838. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  42839. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42840. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42841. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42842. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  42843. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  42844. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  42845. /* harmony import */ var _Layers_effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Layers/effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  42846. _abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  42847. for (var index = 0; index < this.effectLayers.length; index++) {
  42848. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  42849. return this.effectLayers[index];
  42850. }
  42851. }
  42852. return null;
  42853. };
  42854. /**
  42855. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  42856. *
  42857. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  42858. * glowy meshes to your scene.
  42859. *
  42860. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  42861. */
  42862. var GlowLayer = /** @class */ (function (_super) {
  42863. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  42864. /**
  42865. * Instantiates a new glow Layer and references it to the scene.
  42866. * @param name The name of the layer
  42867. * @param scene The scene to use the layer in
  42868. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  42869. */
  42870. function GlowLayer(name, scene, options) {
  42871. var _this = _super.call(this, name, scene) || this;
  42872. _this._intensity = 1.0;
  42873. _this._includedOnlyMeshes = [];
  42874. _this._excludedMeshes = [];
  42875. _this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 1);
  42876. // Adapt options
  42877. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  42878. // Initialize the layer
  42879. _this._init({
  42880. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_ADD,
  42881. camera: _this._options.camera,
  42882. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  42883. mainTextureRatio: _this._options.mainTextureRatio,
  42884. renderingGroupId: _this._options.renderingGroupId
  42885. });
  42886. return _this;
  42887. }
  42888. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  42889. /**
  42890. * Gets the kernel size of the blur.
  42891. */
  42892. get: function () {
  42893. return this._horizontalBlurPostprocess1.kernel;
  42894. },
  42895. /**
  42896. * Sets the kernel size of the blur.
  42897. */
  42898. set: function (value) {
  42899. this._horizontalBlurPostprocess1.kernel = value;
  42900. this._verticalBlurPostprocess1.kernel = value;
  42901. this._horizontalBlurPostprocess2.kernel = value;
  42902. this._verticalBlurPostprocess2.kernel = value;
  42903. },
  42904. enumerable: true,
  42905. configurable: true
  42906. });
  42907. Object.defineProperty(GlowLayer.prototype, "intensity", {
  42908. /**
  42909. * Gets the glow intensity.
  42910. */
  42911. get: function () {
  42912. return this._intensity;
  42913. },
  42914. /**
  42915. * Sets the glow intensity.
  42916. */
  42917. set: function (value) {
  42918. this._intensity = value;
  42919. },
  42920. enumerable: true,
  42921. configurable: true
  42922. });
  42923. /**
  42924. * Get the effect name of the layer.
  42925. * @return The effect name
  42926. */
  42927. GlowLayer.prototype.getEffectName = function () {
  42928. return GlowLayer.EffectName;
  42929. };
  42930. /**
  42931. * Create the merge effect. This is the shader use to blit the information back
  42932. * to the main canvas at the end of the scene rendering.
  42933. */
  42934. GlowLayer.prototype._createMergeEffect = function () {
  42935. // Effect
  42936. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  42937. };
  42938. /**
  42939. * Creates the render target textures and post processes used in the glow layer.
  42940. */
  42941. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  42942. var _this = this;
  42943. var blurTextureWidth = this._mainTextureDesiredSize.width;
  42944. var blurTextureHeight = this._mainTextureDesiredSize.height;
  42945. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  42946. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  42947. var textureType = 0;
  42948. if (this._engine.getCaps().textureHalfFloatRender) {
  42949. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  42950. }
  42951. else {
  42952. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  42953. }
  42954. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  42955. width: blurTextureWidth,
  42956. height: blurTextureHeight
  42957. }, this._scene, false, true, textureType);
  42958. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42959. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42960. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  42961. this._blurTexture1.renderParticles = false;
  42962. this._blurTexture1.ignoreCameraViewport = true;
  42963. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  42964. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  42965. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  42966. width: blurTextureWidth2,
  42967. height: blurTextureHeight2
  42968. }, this._scene, false, true, textureType);
  42969. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42970. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  42971. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  42972. this._blurTexture2.renderParticles = false;
  42973. this._blurTexture2.ignoreCameraViewport = true;
  42974. this._textures = [this._blurTexture1, this._blurTexture2];
  42975. 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, {
  42976. width: blurTextureWidth,
  42977. height: blurTextureHeight
  42978. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42979. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  42980. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  42981. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  42982. effect.setTexture("textureSampler", _this._mainTexture);
  42983. });
  42984. 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, {
  42985. width: blurTextureWidth,
  42986. height: blurTextureHeight
  42987. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42988. 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, {
  42989. width: blurTextureWidth2,
  42990. height: blurTextureHeight2
  42991. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42992. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  42993. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  42994. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  42995. effect.setTexture("textureSampler", _this._blurTexture1);
  42996. });
  42997. 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, {
  42998. width: blurTextureWidth2,
  42999. height: blurTextureHeight2
  43000. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43001. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  43002. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  43003. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  43004. this._mainTexture.samples = this._options.mainTextureSamples;
  43005. this._mainTexture.onAfterUnbindObservable.add(function () {
  43006. var internalTexture = _this._blurTexture1.getInternalTexture();
  43007. if (internalTexture) {
  43008. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  43009. internalTexture = _this._blurTexture2.getInternalTexture();
  43010. if (internalTexture) {
  43011. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  43012. }
  43013. }
  43014. });
  43015. // Prevent autoClear.
  43016. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  43017. };
  43018. /**
  43019. * Checks for the readiness of the element composing the layer.
  43020. * @param subMesh the mesh to check for
  43021. * @param useInstances specify wether or not to use instances to render the mesh
  43022. * @param emissiveTexture the associated emissive texture used to generate the glow
  43023. * @return true if ready otherwise, false
  43024. */
  43025. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  43026. var material = subMesh.getMaterial();
  43027. var mesh = subMesh.getRenderingMesh();
  43028. if (!material || !mesh) {
  43029. return false;
  43030. }
  43031. var emissiveTexture = material.emissiveTexture;
  43032. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  43033. };
  43034. /**
  43035. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43036. */
  43037. GlowLayer.prototype.needStencil = function () {
  43038. return false;
  43039. };
  43040. /**
  43041. * Returns true if the mesh can be rendered, otherwise false.
  43042. * @param mesh The mesh to render
  43043. * @param material The material used on the mesh
  43044. * @returns true if it can be rendered otherwise false
  43045. */
  43046. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  43047. return true;
  43048. };
  43049. /**
  43050. * Implementation specific of rendering the generating effect on the main canvas.
  43051. * @param effect The effect used to render through
  43052. */
  43053. GlowLayer.prototype._internalRender = function (effect) {
  43054. // Texture
  43055. effect.setTexture("textureSampler", this._blurTexture1);
  43056. effect.setTexture("textureSampler2", this._blurTexture2);
  43057. effect.setFloat("offset", this._intensity);
  43058. // Cache
  43059. var engine = this._engine;
  43060. var previousStencilBuffer = engine.getStencilBuffer();
  43061. // Draw order
  43062. engine.setStencilBuffer(false);
  43063. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 6);
  43064. // Draw order
  43065. engine.setStencilBuffer(previousStencilBuffer);
  43066. };
  43067. /**
  43068. * Sets the required values for both the emissive texture and and the main color.
  43069. */
  43070. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  43071. var textureLevel = 1.0;
  43072. if (this.customEmissiveTextureSelector) {
  43073. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  43074. }
  43075. else {
  43076. if (material) {
  43077. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  43078. if (this._emissiveTextureAndColor.texture) {
  43079. textureLevel = this._emissiveTextureAndColor.texture.level;
  43080. }
  43081. }
  43082. else {
  43083. this._emissiveTextureAndColor.texture = null;
  43084. }
  43085. }
  43086. if (this.customEmissiveColorSelector) {
  43087. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  43088. }
  43089. else {
  43090. if (material.emissiveColor) {
  43091. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  43092. }
  43093. else {
  43094. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  43095. }
  43096. }
  43097. };
  43098. /**
  43099. * Returns true if the mesh should render, otherwise false.
  43100. * @param mesh The mesh to render
  43101. * @returns true if it should render otherwise false
  43102. */
  43103. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  43104. return this.hasMesh(mesh);
  43105. };
  43106. /**
  43107. * Adds specific effects defines.
  43108. * @param defines The defines to add specifics to.
  43109. */
  43110. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  43111. defines.push("#define GLOW");
  43112. };
  43113. /**
  43114. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  43115. * @param mesh The mesh to exclude from the glow layer
  43116. */
  43117. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  43118. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  43119. this._excludedMeshes.push(mesh.uniqueId);
  43120. }
  43121. };
  43122. /**
  43123. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  43124. * @param mesh The mesh to remove
  43125. */
  43126. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  43127. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  43128. if (index !== -1) {
  43129. this._excludedMeshes.splice(index, 1);
  43130. }
  43131. };
  43132. /**
  43133. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  43134. * @param mesh The mesh to include in the glow layer
  43135. */
  43136. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  43137. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  43138. this._includedOnlyMeshes.push(mesh.uniqueId);
  43139. }
  43140. };
  43141. /**
  43142. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  43143. * @param mesh The mesh to remove
  43144. */
  43145. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  43146. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  43147. if (index !== -1) {
  43148. this._includedOnlyMeshes.splice(index, 1);
  43149. }
  43150. };
  43151. /**
  43152. * Determine if a given mesh will be used in the glow layer
  43153. * @param mesh The mesh to test
  43154. * @returns true if the mesh will be highlighted by the current glow layer
  43155. */
  43156. GlowLayer.prototype.hasMesh = function (mesh) {
  43157. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43158. return false;
  43159. }
  43160. // Included Mesh
  43161. if (this._includedOnlyMeshes.length) {
  43162. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  43163. }
  43164. // Excluded Mesh
  43165. if (this._excludedMeshes.length) {
  43166. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  43167. }
  43168. return true;
  43169. };
  43170. /**
  43171. * Free any resources and references associated to a mesh.
  43172. * Internal use
  43173. * @param mesh The mesh to free.
  43174. * @hidden
  43175. */
  43176. GlowLayer.prototype._disposeMesh = function (mesh) {
  43177. this.removeIncludedOnlyMesh(mesh);
  43178. this.removeExcludedMesh(mesh);
  43179. };
  43180. /**
  43181. * Gets the class name of the effect layer
  43182. * @returns the string with the class name of the effect layer
  43183. */
  43184. GlowLayer.prototype.getClassName = function () {
  43185. return "GlowLayer";
  43186. };
  43187. /**
  43188. * Serializes this glow layer
  43189. * @returns a serialized glow layer object
  43190. */
  43191. GlowLayer.prototype.serialize = function () {
  43192. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  43193. serializationObject.customType = "BABYLON.GlowLayer";
  43194. var index;
  43195. // Included meshes
  43196. serializationObject.includedMeshes = [];
  43197. if (this._includedOnlyMeshes.length) {
  43198. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  43199. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  43200. if (mesh) {
  43201. serializationObject.includedMeshes.push(mesh.id);
  43202. }
  43203. }
  43204. }
  43205. // Excluded meshes
  43206. serializationObject.excludedMeshes = [];
  43207. if (this._excludedMeshes.length) {
  43208. for (index = 0; index < this._excludedMeshes.length; index++) {
  43209. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  43210. if (mesh) {
  43211. serializationObject.excludedMeshes.push(mesh.id);
  43212. }
  43213. }
  43214. }
  43215. return serializationObject;
  43216. };
  43217. /**
  43218. * Creates a Glow Layer from parsed glow layer data
  43219. * @param parsedGlowLayer defines glow layer data
  43220. * @param scene defines the current scene
  43221. * @param rootUrl defines the root URL containing the glow layer information
  43222. * @returns a parsed Glow Layer
  43223. */
  43224. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  43225. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  43226. var index;
  43227. // Excluded meshes
  43228. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  43229. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  43230. if (mesh) {
  43231. gl.addExcludedMesh(mesh);
  43232. }
  43233. }
  43234. // Included meshes
  43235. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  43236. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  43237. if (mesh) {
  43238. gl.addIncludedOnlyMesh(mesh);
  43239. }
  43240. }
  43241. return gl;
  43242. };
  43243. /**
  43244. * Effect Name of the layer.
  43245. */
  43246. GlowLayer.EffectName = "GlowLayer";
  43247. /**
  43248. * The default blur kernel size used for the glow.
  43249. */
  43250. GlowLayer.DefaultBlurKernelSize = 32;
  43251. /**
  43252. * The default texture size ratio used for the glow.
  43253. */
  43254. GlowLayer.DefaultTextureRatio = 0.5;
  43255. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43256. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43257. ], GlowLayer.prototype, "blurKernelSize", null);
  43258. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43259. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43260. ], GlowLayer.prototype, "intensity", null);
  43261. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43262. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  43263. ], GlowLayer.prototype, "_options", void 0);
  43264. return GlowLayer;
  43265. }(_effectLayer__WEBPACK_IMPORTED_MODULE_9__["EffectLayer"]));
  43266. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  43267. /***/ }),
  43268. /***/ "./Layers/highlightLayer.ts":
  43269. /*!**********************************!*\
  43270. !*** ./Layers/highlightLayer.ts ***!
  43271. \**********************************/
  43272. /*! exports provided: HighlightLayer */
  43273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43274. "use strict";
  43275. __webpack_require__.r(__webpack_exports__);
  43276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  43277. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  43278. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  43279. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  43280. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43281. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43282. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43283. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43284. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43285. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  43286. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  43287. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  43288. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  43289. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  43290. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  43291. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43292. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  43293. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  43294. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  43295. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  43296. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  43297. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  43298. for (var index = 0; index < this.effectLayers.length; index++) {
  43299. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  43300. return this.effectLayers[index];
  43301. }
  43302. }
  43303. return null;
  43304. };
  43305. /**
  43306. * Special Glow Blur post process only blurring the alpha channel
  43307. * It enforces keeping the most luminous color in the color channel.
  43308. */
  43309. var GlowBlurPostProcess = /** @class */ (function (_super) {
  43310. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  43311. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  43312. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  43313. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  43314. _this.direction = direction;
  43315. _this.kernel = kernel;
  43316. _this.onApplyObservable.add(function (effect) {
  43317. effect.setFloat2("screenSize", _this.width, _this.height);
  43318. effect.setVector2("direction", _this.direction);
  43319. effect.setFloat("blurWidth", _this.kernel);
  43320. });
  43321. return _this;
  43322. }
  43323. return GlowBlurPostProcess;
  43324. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  43325. /**
  43326. * The highlight layer Helps adding a glow effect around a mesh.
  43327. *
  43328. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  43329. * glowy meshes to your scene.
  43330. *
  43331. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  43332. */
  43333. var HighlightLayer = /** @class */ (function (_super) {
  43334. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  43335. /**
  43336. * Instantiates a new highlight Layer and references it to the scene..
  43337. * @param name The name of the layer
  43338. * @param scene The scene to use the layer in
  43339. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  43340. */
  43341. function HighlightLayer(name, scene, options) {
  43342. var _this = _super.call(this, name, scene) || this;
  43343. _this.name = name;
  43344. /**
  43345. * Specifies whether or not the inner glow is ACTIVE in the layer.
  43346. */
  43347. _this.innerGlow = true;
  43348. /**
  43349. * Specifies whether or not the outer glow is ACTIVE in the layer.
  43350. */
  43351. _this.outerGlow = true;
  43352. /**
  43353. * An event triggered when the highlight layer is being blurred.
  43354. */
  43355. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  43356. /**
  43357. * An event triggered when the highlight layer has been blurred.
  43358. */
  43359. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  43360. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  43361. _this._meshes = {};
  43362. _this._excludedMeshes = {};
  43363. _this.neutralColor = HighlightLayer.NeutralColor;
  43364. // Warn on stencil
  43365. if (!_this._engine.isStencilEnable) {
  43366. _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 }");
  43367. }
  43368. // Adapt options
  43369. _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);
  43370. // Initialize the layer
  43371. _this._init({
  43372. alphaBlendingMode: _this._options.alphaBlendingMode,
  43373. camera: _this._options.camera,
  43374. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  43375. mainTextureRatio: _this._options.mainTextureRatio,
  43376. renderingGroupId: _this._options.renderingGroupId
  43377. });
  43378. // Do not render as long as no meshes have been added
  43379. _this._shouldRender = false;
  43380. return _this;
  43381. }
  43382. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  43383. /**
  43384. * Gets the horizontal size of the blur.
  43385. */
  43386. get: function () {
  43387. return this._horizontalBlurPostprocess.kernel;
  43388. },
  43389. /**
  43390. * Specifies the horizontal size of the blur.
  43391. */
  43392. set: function (value) {
  43393. this._horizontalBlurPostprocess.kernel = value;
  43394. },
  43395. enumerable: true,
  43396. configurable: true
  43397. });
  43398. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  43399. /**
  43400. * Gets the vertical size of the blur.
  43401. */
  43402. get: function () {
  43403. return this._verticalBlurPostprocess.kernel;
  43404. },
  43405. /**
  43406. * Specifies the vertical size of the blur.
  43407. */
  43408. set: function (value) {
  43409. this._verticalBlurPostprocess.kernel = value;
  43410. },
  43411. enumerable: true,
  43412. configurable: true
  43413. });
  43414. /**
  43415. * Get the effect name of the layer.
  43416. * @return The effect name
  43417. */
  43418. HighlightLayer.prototype.getEffectName = function () {
  43419. return HighlightLayer.EffectName;
  43420. };
  43421. /**
  43422. * Create the merge effect. This is the shader use to blit the information back
  43423. * to the main canvas at the end of the scene rendering.
  43424. */
  43425. HighlightLayer.prototype._createMergeEffect = function () {
  43426. // Effect
  43427. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  43428. };
  43429. /**
  43430. * Creates the render target textures and post processes used in the highlight layer.
  43431. */
  43432. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  43433. var _this = this;
  43434. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  43435. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  43436. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  43437. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  43438. var textureType = 0;
  43439. if (this._engine.getCaps().textureHalfFloatRender) {
  43440. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  43441. }
  43442. else {
  43443. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  43444. }
  43445. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  43446. width: blurTextureWidth,
  43447. height: blurTextureHeight
  43448. }, this._scene, false, true, textureType);
  43449. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  43450. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  43451. this._blurTexture.anisotropicFilteringLevel = 16;
  43452. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  43453. this._blurTexture.renderParticles = false;
  43454. this._blurTexture.ignoreCameraViewport = true;
  43455. this._textures = [this._blurTexture];
  43456. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  43457. 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());
  43458. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  43459. effect.setTexture("textureSampler", _this._mainTexture);
  43460. });
  43461. 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());
  43462. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  43463. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  43464. });
  43465. 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());
  43466. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  43467. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  43468. });
  43469. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  43470. }
  43471. else {
  43472. 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, {
  43473. width: blurTextureWidth,
  43474. height: blurTextureHeight
  43475. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43476. this._horizontalBlurPostprocess.width = blurTextureWidth;
  43477. this._horizontalBlurPostprocess.height = blurTextureHeight;
  43478. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  43479. effect.setTexture("textureSampler", _this._mainTexture);
  43480. });
  43481. 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, {
  43482. width: blurTextureWidth,
  43483. height: blurTextureHeight
  43484. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  43485. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  43486. }
  43487. this._mainTexture.onAfterUnbindObservable.add(function () {
  43488. _this.onBeforeBlurObservable.notifyObservers(_this);
  43489. var internalTexture = _this._blurTexture.getInternalTexture();
  43490. if (internalTexture) {
  43491. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  43492. }
  43493. _this.onAfterBlurObservable.notifyObservers(_this);
  43494. });
  43495. // Prevent autoClear.
  43496. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  43497. };
  43498. /**
  43499. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43500. */
  43501. HighlightLayer.prototype.needStencil = function () {
  43502. return true;
  43503. };
  43504. /**
  43505. * Checks for the readiness of the element composing the layer.
  43506. * @param subMesh the mesh to check for
  43507. * @param useInstances specify wether or not to use instances to render the mesh
  43508. * @param emissiveTexture the associated emissive texture used to generate the glow
  43509. * @return true if ready otherwise, false
  43510. */
  43511. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  43512. var material = subMesh.getMaterial();
  43513. var mesh = subMesh.getRenderingMesh();
  43514. if (!material || !mesh || !this._meshes) {
  43515. return false;
  43516. }
  43517. var emissiveTexture = null;
  43518. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  43519. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  43520. emissiveTexture = material.emissiveTexture;
  43521. }
  43522. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  43523. };
  43524. /**
  43525. * Implementation specific of rendering the generating effect on the main canvas.
  43526. * @param effect The effect used to render through
  43527. */
  43528. HighlightLayer.prototype._internalRender = function (effect) {
  43529. // Texture
  43530. effect.setTexture("textureSampler", this._blurTexture);
  43531. // Cache
  43532. var engine = this._engine;
  43533. engine.cacheStencilState();
  43534. // Stencil operations
  43535. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  43536. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  43537. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  43538. // Draw order
  43539. engine.setStencilMask(0x00);
  43540. engine.setStencilBuffer(true);
  43541. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  43542. // 2 passes inner outer
  43543. if (this.outerGlow) {
  43544. effect.setFloat("offset", 0);
  43545. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  43546. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  43547. }
  43548. if (this.innerGlow) {
  43549. effect.setFloat("offset", 1);
  43550. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  43551. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  43552. }
  43553. // Restore Cache
  43554. engine.restoreStencilState();
  43555. };
  43556. /**
  43557. * Returns true if the layer contains information to display, otherwise false.
  43558. */
  43559. HighlightLayer.prototype.shouldRender = function () {
  43560. if (_super.prototype.shouldRender.call(this)) {
  43561. return this._meshes ? true : false;
  43562. }
  43563. return false;
  43564. };
  43565. /**
  43566. * Returns true if the mesh should render, otherwise false.
  43567. * @param mesh The mesh to render
  43568. * @returns true if it should render otherwise false
  43569. */
  43570. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  43571. // Excluded Mesh
  43572. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  43573. return false;
  43574. }
  43575. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43576. return false;
  43577. }
  43578. return true;
  43579. };
  43580. /**
  43581. * Sets the required values for both the emissive texture and and the main color.
  43582. */
  43583. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  43584. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  43585. if (highlightLayerMesh) {
  43586. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  43587. }
  43588. else {
  43589. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  43590. }
  43591. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  43592. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  43593. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  43594. }
  43595. else {
  43596. this._emissiveTextureAndColor.texture = null;
  43597. }
  43598. };
  43599. /**
  43600. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  43601. * @param mesh The mesh to exclude from the highlight layer
  43602. */
  43603. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  43604. if (!this._excludedMeshes) {
  43605. return;
  43606. }
  43607. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  43608. if (!meshExcluded) {
  43609. this._excludedMeshes[mesh.uniqueId] = {
  43610. mesh: mesh,
  43611. beforeBind: mesh.onBeforeBindObservable.add(function (mesh) {
  43612. mesh.getEngine().setStencilBuffer(false);
  43613. }),
  43614. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  43615. mesh.getEngine().setStencilBuffer(true);
  43616. }),
  43617. };
  43618. }
  43619. };
  43620. /**
  43621. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  43622. * @param mesh The mesh to highlight
  43623. */
  43624. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  43625. if (!this._excludedMeshes) {
  43626. return;
  43627. }
  43628. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  43629. if (meshExcluded) {
  43630. if (meshExcluded.beforeBind) {
  43631. mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
  43632. }
  43633. if (meshExcluded.afterRender) {
  43634. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  43635. }
  43636. }
  43637. this._excludedMeshes[mesh.uniqueId] = null;
  43638. };
  43639. /**
  43640. * Determine if a given mesh will be highlighted by the current HighlightLayer
  43641. * @param mesh mesh to test
  43642. * @returns true if the mesh will be highlighted by the current HighlightLayer
  43643. */
  43644. HighlightLayer.prototype.hasMesh = function (mesh) {
  43645. if (!this._meshes) {
  43646. return false;
  43647. }
  43648. if (!_super.prototype.hasMesh.call(this, mesh)) {
  43649. return false;
  43650. }
  43651. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  43652. };
  43653. /**
  43654. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  43655. * @param mesh The mesh to highlight
  43656. * @param color The color of the highlight
  43657. * @param glowEmissiveOnly Extract the glow from the emissive texture
  43658. */
  43659. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  43660. var _this = this;
  43661. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  43662. if (!this._meshes) {
  43663. return;
  43664. }
  43665. var meshHighlight = this._meshes[mesh.uniqueId];
  43666. if (meshHighlight) {
  43667. meshHighlight.color = color;
  43668. }
  43669. else {
  43670. this._meshes[mesh.uniqueId] = {
  43671. mesh: mesh,
  43672. color: color,
  43673. // Lambda required for capture due to Observable this context
  43674. observerHighlight: mesh.onBeforeBindObservable.add(function (mesh) {
  43675. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  43676. _this._defaultStencilReference(mesh);
  43677. }
  43678. else {
  43679. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  43680. }
  43681. }),
  43682. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  43683. glowEmissiveOnly: glowEmissiveOnly
  43684. };
  43685. mesh.onDisposeObservable.add(function () {
  43686. _this._disposeMesh(mesh);
  43687. });
  43688. }
  43689. this._shouldRender = true;
  43690. };
  43691. /**
  43692. * Remove a mesh from the highlight layer in order to make it stop glowing.
  43693. * @param mesh The mesh to highlight
  43694. */
  43695. HighlightLayer.prototype.removeMesh = function (mesh) {
  43696. if (!this._meshes) {
  43697. return;
  43698. }
  43699. var meshHighlight = this._meshes[mesh.uniqueId];
  43700. if (meshHighlight) {
  43701. if (meshHighlight.observerHighlight) {
  43702. mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  43703. }
  43704. if (meshHighlight.observerDefault) {
  43705. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  43706. }
  43707. delete this._meshes[mesh.uniqueId];
  43708. }
  43709. this._shouldRender = false;
  43710. for (var meshHighlightToCheck in this._meshes) {
  43711. if (this._meshes[meshHighlightToCheck]) {
  43712. this._shouldRender = true;
  43713. break;
  43714. }
  43715. }
  43716. };
  43717. /**
  43718. * Force the stencil to the normal expected value for none glowing parts
  43719. */
  43720. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  43721. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  43722. };
  43723. /**
  43724. * Free any resources and references associated to a mesh.
  43725. * Internal use
  43726. * @param mesh The mesh to free.
  43727. * @hidden
  43728. */
  43729. HighlightLayer.prototype._disposeMesh = function (mesh) {
  43730. this.removeMesh(mesh);
  43731. this.removeExcludedMesh(mesh);
  43732. };
  43733. /**
  43734. * Dispose the highlight layer and free resources.
  43735. */
  43736. HighlightLayer.prototype.dispose = function () {
  43737. if (this._meshes) {
  43738. // Clean mesh references
  43739. for (var id in this._meshes) {
  43740. var meshHighlight = this._meshes[id];
  43741. if (meshHighlight && meshHighlight.mesh) {
  43742. if (meshHighlight.observerHighlight) {
  43743. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  43744. }
  43745. if (meshHighlight.observerDefault) {
  43746. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  43747. }
  43748. }
  43749. }
  43750. this._meshes = null;
  43751. }
  43752. if (this._excludedMeshes) {
  43753. for (var id in this._excludedMeshes) {
  43754. var meshHighlight = this._excludedMeshes[id];
  43755. if (meshHighlight) {
  43756. if (meshHighlight.beforeBind) {
  43757. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
  43758. }
  43759. if (meshHighlight.afterRender) {
  43760. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  43761. }
  43762. }
  43763. }
  43764. this._excludedMeshes = null;
  43765. }
  43766. _super.prototype.dispose.call(this);
  43767. };
  43768. /**
  43769. * Gets the class name of the effect layer
  43770. * @returns the string with the class name of the effect layer
  43771. */
  43772. HighlightLayer.prototype.getClassName = function () {
  43773. return "HighlightLayer";
  43774. };
  43775. /**
  43776. * Serializes this Highlight layer
  43777. * @returns a serialized Highlight layer object
  43778. */
  43779. HighlightLayer.prototype.serialize = function () {
  43780. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  43781. serializationObject.customType = "BABYLON.HighlightLayer";
  43782. // Highlighted meshes
  43783. serializationObject.meshes = [];
  43784. if (this._meshes) {
  43785. for (var m in this._meshes) {
  43786. var mesh = this._meshes[m];
  43787. if (mesh) {
  43788. serializationObject.meshes.push({
  43789. glowEmissiveOnly: mesh.glowEmissiveOnly,
  43790. color: mesh.color.asArray(),
  43791. meshId: mesh.mesh.id
  43792. });
  43793. }
  43794. }
  43795. }
  43796. // Excluded meshes
  43797. serializationObject.excludedMeshes = [];
  43798. if (this._excludedMeshes) {
  43799. for (var e in this._excludedMeshes) {
  43800. var excludedMesh = this._excludedMeshes[e];
  43801. if (excludedMesh) {
  43802. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  43803. }
  43804. }
  43805. }
  43806. return serializationObject;
  43807. };
  43808. /**
  43809. * Creates a Highlight layer from parsed Highlight layer data
  43810. * @param parsedHightlightLayer defines the Highlight layer data
  43811. * @param scene defines the current scene
  43812. * @param rootUrl defines the root URL containing the Highlight layer information
  43813. * @returns a parsed Highlight layer
  43814. */
  43815. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  43816. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  43817. var index;
  43818. // Excluded meshes
  43819. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  43820. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  43821. if (mesh) {
  43822. hl.addExcludedMesh(mesh);
  43823. }
  43824. }
  43825. // Included meshes
  43826. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  43827. var highlightedMesh = parsedHightlightLayer.meshes[index];
  43828. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  43829. if (mesh) {
  43830. hl.addMesh(mesh, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  43831. }
  43832. }
  43833. return hl;
  43834. };
  43835. /**
  43836. * Effect Name of the highlight layer.
  43837. */
  43838. HighlightLayer.EffectName = "HighlightLayer";
  43839. /**
  43840. * The neutral color used during the preparation of the glow effect.
  43841. * This is black by default as the blend operation is a blend operation.
  43842. */
  43843. HighlightLayer.NeutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  43844. /**
  43845. * Stencil value used for glowing meshes.
  43846. */
  43847. HighlightLayer.GlowingMeshStencilReference = 0x02;
  43848. /**
  43849. * Stencil value used for the other meshes in the scene.
  43850. */
  43851. HighlightLayer.NormalMeshStencilReference = 0x01;
  43852. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43853. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43854. ], HighlightLayer.prototype, "innerGlow", void 0);
  43855. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43856. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43857. ], HighlightLayer.prototype, "outerGlow", void 0);
  43858. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43859. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43860. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  43861. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43862. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  43863. ], HighlightLayer.prototype, "blurVerticalSize", null);
  43864. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  43865. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  43866. ], HighlightLayer.prototype, "_options", void 0);
  43867. return HighlightLayer;
  43868. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  43869. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  43870. /***/ }),
  43871. /***/ "./Layers/index.ts":
  43872. /*!*************************!*\
  43873. !*** ./Layers/index.ts ***!
  43874. \*************************/
  43875. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  43876. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43877. "use strict";
  43878. __webpack_require__.r(__webpack_exports__);
  43879. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  43880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  43881. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  43882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  43883. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  43884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  43885. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  43886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  43887. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  43888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  43889. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  43890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  43891. /***/ }),
  43892. /***/ "./Layers/layer.ts":
  43893. /*!*************************!*\
  43894. !*** ./Layers/layer.ts ***!
  43895. \*************************/
  43896. /*! exports provided: Layer */
  43897. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43898. "use strict";
  43899. __webpack_require__.r(__webpack_exports__);
  43900. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  43901. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  43902. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43903. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  43904. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43905. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43906. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43907. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43908. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  43909. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43910. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  43911. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  43912. /**
  43913. * This represents a full screen 2d layer.
  43914. * This can be useful to display a picture in the background of your scene for instance.
  43915. * @see https://www.babylonjs-playground.com/#08A2BS#1
  43916. */
  43917. var Layer = /** @class */ (function () {
  43918. /**
  43919. * Instantiates a new layer.
  43920. * This represents a full screen 2d layer.
  43921. * This can be useful to display a picture in the background of your scene for instance.
  43922. * @see https://www.babylonjs-playground.com/#08A2BS#1
  43923. * @param name Define the name of the layer in the scene
  43924. * @param imgUrl Define the url of the texture to display in the layer
  43925. * @param scene Define the scene the layer belongs to
  43926. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  43927. * @param color Defines a color for the layer
  43928. */
  43929. function Layer(
  43930. /**
  43931. * Define the name of the layer.
  43932. */
  43933. name, imgUrl, scene, isBackground, color) {
  43934. this.name = name;
  43935. /**
  43936. * Define the scale of the layer in order to zoom in out of the texture.
  43937. */
  43938. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  43939. /**
  43940. * Define an offset for the layer in order to shift the texture.
  43941. */
  43942. this.offset = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  43943. /**
  43944. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  43945. */
  43946. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  43947. /**
  43948. * Define a mask to restrict the layer to only some of the scene cameras.
  43949. */
  43950. this.layerMask = 0x0FFFFFFF;
  43951. /**
  43952. * Define the list of render target the layer is visible into.
  43953. */
  43954. this.renderTargetTextures = [];
  43955. /**
  43956. * Define if the layer is only used in renderTarget or if it also
  43957. * renders in the main frame buffer of the canvas.
  43958. */
  43959. this.renderOnlyInRenderTargetTextures = false;
  43960. this._vertexBuffers = {};
  43961. /**
  43962. * An event triggered when the layer is disposed.
  43963. */
  43964. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43965. /**
  43966. * An event triggered before rendering the scene
  43967. */
  43968. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43969. /**
  43970. * An event triggered after rendering the scene
  43971. */
  43972. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  43973. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"](imgUrl, scene, true) : null;
  43974. this.isBackground = isBackground === undefined ? true : isBackground;
  43975. this.color = color === undefined ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1) : color;
  43976. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene);
  43977. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_LAYER);
  43978. if (!layerComponent) {
  43979. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__["LayerSceneComponent"](this._scene);
  43980. this._scene._addComponent(layerComponent);
  43981. }
  43982. this._scene.layers.push(this);
  43983. var engine = this._scene.getEngine();
  43984. // VBO
  43985. var vertices = [];
  43986. vertices.push(1, 1);
  43987. vertices.push(-1, 1);
  43988. vertices.push(-1, -1);
  43989. vertices.push(1, -1);
  43990. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  43991. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = vertexBuffer;
  43992. this._createIndexBuffer();
  43993. // Effects
  43994. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  43995. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  43996. }
  43997. Object.defineProperty(Layer.prototype, "onDispose", {
  43998. /**
  43999. * Back compatibility with callback before the onDisposeObservable existed.
  44000. * The set callback will be triggered when the layer has been disposed.
  44001. */
  44002. set: function (callback) {
  44003. if (this._onDisposeObserver) {
  44004. this.onDisposeObservable.remove(this._onDisposeObserver);
  44005. }
  44006. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  44007. },
  44008. enumerable: true,
  44009. configurable: true
  44010. });
  44011. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  44012. /**
  44013. * Back compatibility with callback before the onBeforeRenderObservable existed.
  44014. * The set callback will be triggered just before rendering the layer.
  44015. */
  44016. set: function (callback) {
  44017. if (this._onBeforeRenderObserver) {
  44018. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  44019. }
  44020. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  44021. },
  44022. enumerable: true,
  44023. configurable: true
  44024. });
  44025. Object.defineProperty(Layer.prototype, "onAfterRender", {
  44026. /**
  44027. * Back compatibility with callback before the onAfterRenderObservable existed.
  44028. * The set callback will be triggered just after rendering the layer.
  44029. */
  44030. set: function (callback) {
  44031. if (this._onAfterRenderObserver) {
  44032. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  44033. }
  44034. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  44035. },
  44036. enumerable: true,
  44037. configurable: true
  44038. });
  44039. Layer.prototype._createIndexBuffer = function () {
  44040. var engine = this._scene.getEngine();
  44041. // Indices
  44042. var indices = [];
  44043. indices.push(0);
  44044. indices.push(1);
  44045. indices.push(2);
  44046. indices.push(0);
  44047. indices.push(2);
  44048. indices.push(3);
  44049. this._indexBuffer = engine.createIndexBuffer(indices);
  44050. };
  44051. /** @hidden */
  44052. Layer.prototype._rebuild = function () {
  44053. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  44054. if (vb) {
  44055. vb._rebuild();
  44056. }
  44057. this._createIndexBuffer();
  44058. };
  44059. /**
  44060. * Renders the layer in the scene.
  44061. */
  44062. Layer.prototype.render = function () {
  44063. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  44064. // Check
  44065. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  44066. return;
  44067. }
  44068. var engine = this._scene.getEngine();
  44069. this.onBeforeRenderObservable.notifyObservers(this);
  44070. // Render
  44071. engine.enableEffect(currentEffect);
  44072. engine.setState(false);
  44073. // Texture
  44074. currentEffect.setTexture("textureSampler", this.texture);
  44075. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  44076. // Color
  44077. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  44078. // Scale / offset
  44079. currentEffect.setVector2("offset", this.offset);
  44080. currentEffect.setVector2("scale", this.scale);
  44081. // VBOs
  44082. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  44083. // Draw order
  44084. if (!this.alphaTest) {
  44085. engine.setAlphaMode(this.alphaBlendingMode);
  44086. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  44087. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  44088. }
  44089. else {
  44090. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  44091. }
  44092. this.onAfterRenderObservable.notifyObservers(this);
  44093. };
  44094. /**
  44095. * Disposes and releases the associated ressources.
  44096. */
  44097. Layer.prototype.dispose = function () {
  44098. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  44099. if (vertexBuffer) {
  44100. vertexBuffer.dispose();
  44101. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  44102. }
  44103. if (this._indexBuffer) {
  44104. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  44105. this._indexBuffer = null;
  44106. }
  44107. if (this.texture) {
  44108. this.texture.dispose();
  44109. this.texture = null;
  44110. }
  44111. // Clean RTT list
  44112. this.renderTargetTextures = [];
  44113. // Remove from scene
  44114. var index = this._scene.layers.indexOf(this);
  44115. this._scene.layers.splice(index, 1);
  44116. // Callback
  44117. this.onDisposeObservable.notifyObservers(this);
  44118. this.onDisposeObservable.clear();
  44119. this.onAfterRenderObservable.clear();
  44120. this.onBeforeRenderObservable.clear();
  44121. };
  44122. return Layer;
  44123. }());
  44124. /***/ }),
  44125. /***/ "./Layers/layerSceneComponent.ts":
  44126. /*!***************************************!*\
  44127. !*** ./Layers/layerSceneComponent.ts ***!
  44128. \***************************************/
  44129. /*! exports provided: LayerSceneComponent */
  44130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44131. "use strict";
  44132. __webpack_require__.r(__webpack_exports__);
  44133. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  44134. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  44135. /**
  44136. * Defines the layer scene component responsible to manage any layers
  44137. * in a given scene.
  44138. */
  44139. var LayerSceneComponent = /** @class */ (function () {
  44140. /**
  44141. * Creates a new instance of the component for the given scene
  44142. * @param scene Defines the scene to register the component in
  44143. */
  44144. function LayerSceneComponent(scene) {
  44145. /**
  44146. * The component name helpfull to identify the component in the list of scene components.
  44147. */
  44148. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  44149. this.scene = scene;
  44150. this._engine = scene.getEngine();
  44151. scene.layers = new Array();
  44152. }
  44153. /**
  44154. * Registers the component in a given scene
  44155. */
  44156. LayerSceneComponent.prototype.register = function () {
  44157. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  44158. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  44159. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  44160. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  44161. };
  44162. /**
  44163. * Rebuilds the elements related to this component in case of
  44164. * context lost for instance.
  44165. */
  44166. LayerSceneComponent.prototype.rebuild = function () {
  44167. var layers = this.scene.layers;
  44168. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  44169. var layer = layers_1[_i];
  44170. layer._rebuild();
  44171. }
  44172. };
  44173. /**
  44174. * Disposes the component and the associated ressources.
  44175. */
  44176. LayerSceneComponent.prototype.dispose = function () {
  44177. var layers = this.scene.layers;
  44178. while (layers.length) {
  44179. layers[0].dispose();
  44180. }
  44181. };
  44182. LayerSceneComponent.prototype._draw = function (predicate) {
  44183. var layers = this.scene.layers;
  44184. if (layers.length) {
  44185. this._engine.setDepthBuffer(false);
  44186. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  44187. var layer = layers_2[_i];
  44188. if (predicate(layer)) {
  44189. layer.render();
  44190. }
  44191. }
  44192. this._engine.setDepthBuffer(true);
  44193. }
  44194. };
  44195. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  44196. return !layer.renderOnlyInRenderTargetTextures &&
  44197. layer.isBackground === isBackground &&
  44198. ((layer.layerMask & cameraLayerMask) !== 0);
  44199. };
  44200. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  44201. var _this = this;
  44202. this._draw(function (layer) {
  44203. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  44204. });
  44205. };
  44206. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  44207. var _this = this;
  44208. this._draw(function (layer) {
  44209. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  44210. });
  44211. };
  44212. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  44213. return (layer.renderTargetTextures.length > 0) &&
  44214. layer.isBackground === isBackground &&
  44215. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  44216. ((layer.layerMask & cameraLayerMask) !== 0);
  44217. };
  44218. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  44219. var _this = this;
  44220. this._draw(function (layer) {
  44221. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  44222. });
  44223. };
  44224. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  44225. var _this = this;
  44226. this._draw(function (layer) {
  44227. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  44228. });
  44229. };
  44230. return LayerSceneComponent;
  44231. }());
  44232. /***/ }),
  44233. /***/ "./Legacy/legacy.ts":
  44234. /*!**************************!*\
  44235. !*** ./Legacy/legacy.ts ***!
  44236. \**************************/
  44237. /*! 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, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, MirrorTexture, MultiRenderTarget, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, 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, LinesBuilder, PlaneBuilder, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, VRMultiviewToSingleviewPostProcess, ReflectionProbe, BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer, Sprite, SpriteManager, SpriteSceneComponent, _AlphaState, _DepthCullingState, _StencilState, AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, EquiRectangularCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsMatrix, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, MeshExploder, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, WebRequest, InspectableType, 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, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  44238. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44239. "use strict";
  44240. __webpack_require__.r(__webpack_exports__);
  44241. /* WEBPACK VAR INJECTION */(function(global) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Debug", function() { return Debug; });
  44242. /* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  44243. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  44244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  44245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  44246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  44247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  44248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  44249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  44250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  44251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  44252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  44253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  44254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  44255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  44256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  44257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  44258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  44259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  44260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  44261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  44262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  44263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  44264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  44265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  44266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  44267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  44268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  44269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  44270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  44271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  44272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  44273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  44274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  44275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  44276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  44277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  44278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  44279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  44280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  44281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  44282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  44283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  44284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  44285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  44286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  44287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  44288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  44289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  44290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  44291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  44292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  44293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  44294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  44295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  44296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  44297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  44298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  44299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  44300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  44301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  44302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  44303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  44304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  44305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  44306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  44307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  44308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  44309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  44310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  44311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  44312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  44313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  44314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  44315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  44316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  44317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  44318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  44319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  44320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  44321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultCollisionCoordinator"]; });
  44322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  44323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  44324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  44325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  44326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  44327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  44328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  44329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  44330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  44331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  44332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  44333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  44334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  44335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  44336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  44337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  44338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  44339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  44340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  44341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  44342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  44343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  44344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  44345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  44346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  44347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  44348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  44349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  44350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  44351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  44352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  44353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  44354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  44355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  44356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  44357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  44358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  44359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  44360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  44361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  44362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  44363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  44364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  44365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  44366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  44367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  44368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  44369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  44370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  44371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  44372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  44373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  44374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  44375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  44376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  44377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  44378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LightGizmo"]; });
  44379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  44380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  44381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  44382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  44383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  44384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  44385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  44386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  44387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  44388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  44389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  44390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  44391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  44392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  44393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  44394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  44395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  44396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  44397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  44398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  44399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  44400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  44401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  44402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  44403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  44404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  44405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  44406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  44407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  44408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  44409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  44410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  44411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  44412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  44413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  44414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  44415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  44416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  44417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  44418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  44419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  44420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  44421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  44422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EquiRectangularCubeTexture"]; });
  44423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  44424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  44425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  44426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  44427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  44428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  44429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  44430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  44431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  44432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  44433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  44434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  44435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  44436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  44437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  44438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  44439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  44440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  44441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  44442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  44443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  44444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  44445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  44446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  44447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  44448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  44449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  44450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  44451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  44452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  44453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  44454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  44455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  44456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  44457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tmp"]; });
  44458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  44459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  44460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  44461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  44462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  44463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  44464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  44465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  44466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TrailMesh"]; });
  44467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  44468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  44469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  44470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  44471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  44472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  44473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  44474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  44475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  44476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  44477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  44478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  44479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  44480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  44481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  44482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  44483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  44484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  44485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  44486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereBuilder"]; });
  44487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderBuilder"]; });
  44488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesBuilder"]; });
  44489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneBuilder"]; });
  44490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  44491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  44492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  44493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  44494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  44495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  44496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  44497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  44498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  44499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  44500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  44501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  44502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  44503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  44504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  44505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  44506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  44507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  44508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  44509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEventOptions"]; });
  44510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEventOptions"]; });
  44511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEventOptions"]; });
  44512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  44513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  44514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  44515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  44516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  44517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  44518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  44519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  44520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  44521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  44522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  44523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  44524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  44525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  44526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  44527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  44528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  44529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  44530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  44531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  44532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  44533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  44534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  44535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  44536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  44537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  44538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  44539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  44540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  44541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  44542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  44543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  44544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  44545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  44546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  44547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  44548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  44549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  44550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  44551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  44552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  44553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRMultiviewToSingleviewPostProcess"]; });
  44554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  44555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  44556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  44557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  44558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  44559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  44560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  44561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  44562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  44563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  44564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  44565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  44566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  44567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  44568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  44569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  44570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  44571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  44572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  44573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  44574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  44575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  44576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  44577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  44578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  44579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  44580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  44581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  44582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  44583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  44584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EquiRectangularCubeTextureAssetTask"]; });
  44585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  44586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  44587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  44588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  44589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  44590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  44591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  44592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  44593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  44594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  44595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  44596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  44597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  44598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  44599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMatrix"]; });
  44600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  44601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  44602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  44603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  44604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshExploder"]; });
  44605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  44606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  44607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  44608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  44609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  44610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  44611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  44612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  44613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  44614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  44615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  44616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  44617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  44618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  44619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  44620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  44621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  44622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  44623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  44624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  44625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  44626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  44627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  44628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  44629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  44630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  44631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  44632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  44633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  44634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  44635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  44636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  44637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  44638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  44639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  44640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  44641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  44642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  44643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  44644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  44645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  44646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  44647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  44648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  44649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  44650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  44651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  44652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  44653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebRequest"]; });
  44654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InspectableType"]; });
  44655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  44656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  44657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  44658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  44659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  44660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  44661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  44662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  44663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  44664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  44665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  44666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  44667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  44668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  44669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  44670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraKeyboardMoveInput"]; });
  44671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraMouseWheelInput"]; });
  44672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCameraPointersInput"]; });
  44673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  44674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  44675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  44676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  44677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  44678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  44679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  44680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  44681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  44682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  44683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  44684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  44685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  44686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  44687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  44688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  44689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  44690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  44691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OnAfterEnteringVRObservableEvent"]; });
  44692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  44693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  44694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  44695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  44696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  44697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  44698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  44699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  44700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  44701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  44702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  44703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  44704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  44705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  44706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  44707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  44708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  44709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  44710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  44711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  44712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  44713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterialDefines"]; });
  44714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  44715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  44716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  44717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  44718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  44719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  44720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  44721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  44722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  44723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  44724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  44725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  44726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  44727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  44728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscBuilder"]; });
  44729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"]; });
  44730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphereBuilder"]; });
  44731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusBuilder"]; });
  44732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotBuilder"]; });
  44733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonBuilder"]; });
  44734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShapeBuilder"]; });
  44735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LatheBuilder"]; });
  44736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundBuilder"]; });
  44737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TubeBuilder"]; });
  44738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolyhedronBuilder"]; });
  44739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IcoSphereBuilder"]; });
  44740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DecalBuilder"]; });
  44741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  44742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  44743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  44744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  44745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  44746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  44747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  44748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  44749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  44750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  44751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  44752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  44753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  44754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  44755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  44756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  44757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  44758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  44759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  44760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  44761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  44762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  44763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  44764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  44765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  44766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  44767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  44768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  44769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  44770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  44771. /**
  44772. * Legacy support, defining window.BABYLON (global variable).
  44773. *
  44774. * This is the entry point for the UMD module.
  44775. * The entry point for a future ESM package should be index.ts
  44776. */
  44777. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  44778. if (typeof globalObject !== "undefined") {
  44779. globalObject.BABYLON = BABYLON;
  44780. globalObject.BABYLON = globalObject.BABYLON || {};
  44781. var BABYLON = globalObject.BABYLON;
  44782. BABYLON.Debug = BABYLON.Debug || {};
  44783. var keys = [];
  44784. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  44785. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  44786. keys.push(key);
  44787. }
  44788. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  44789. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  44790. }
  44791. }
  44792. var Debug = {
  44793. AxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"],
  44794. BoneAxesViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"],
  44795. PhysicsViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["PhysicsViewer"],
  44796. SkeletonViewer: _Debug_index__WEBPACK_IMPORTED_MODULE_1__["SkeletonViewer"],
  44797. };
  44798. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  44799. /***/ }),
  44800. /***/ "./LensFlares/index.ts":
  44801. /*!*****************************!*\
  44802. !*** ./LensFlares/index.ts ***!
  44803. \*****************************/
  44804. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  44805. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44806. "use strict";
  44807. __webpack_require__.r(__webpack_exports__);
  44808. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  44809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  44810. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  44811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  44812. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  44813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  44814. /***/ }),
  44815. /***/ "./LensFlares/lensFlare.ts":
  44816. /*!*********************************!*\
  44817. !*** ./LensFlares/lensFlare.ts ***!
  44818. \*********************************/
  44819. /*! exports provided: LensFlare */
  44820. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44821. "use strict";
  44822. __webpack_require__.r(__webpack_exports__);
  44823. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  44824. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44825. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  44826. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  44827. /**
  44828. * This represents one of the lens effect in a `lensFlareSystem`.
  44829. * It controls one of the indiviual texture used in the effect.
  44830. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44831. */
  44832. var LensFlare = /** @class */ (function () {
  44833. /**
  44834. * Instantiates a new Lens Flare.
  44835. * This represents one of the lens effect in a `lensFlareSystem`.
  44836. * It controls one of the indiviual texture used in the effect.
  44837. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44838. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  44839. * @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.
  44840. * @param color Define the lens color
  44841. * @param imgUrl Define the lens texture url
  44842. * @param system Define the `lensFlareSystem` this flare is part of
  44843. */
  44844. function LensFlare(
  44845. /**
  44846. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  44847. */
  44848. size,
  44849. /**
  44850. * 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.
  44851. */
  44852. position, color, imgUrl, system) {
  44853. this.size = size;
  44854. this.position = position;
  44855. /**
  44856. * Define the alpha mode to render this particular lens.
  44857. */
  44858. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  44859. this.color = color || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  44860. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  44861. this._system = system;
  44862. system.lensFlares.push(this);
  44863. }
  44864. /**
  44865. * Creates a new Lens Flare.
  44866. * This represents one of the lens effect in a `lensFlareSystem`.
  44867. * It controls one of the indiviual texture used in the effect.
  44868. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44869. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  44870. * @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.
  44871. * @param color Define the lens color
  44872. * @param imgUrl Define the lens texture url
  44873. * @param system Define the `lensFlareSystem` this flare is part of
  44874. * @returns The newly created Lens Flare
  44875. */
  44876. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  44877. return new LensFlare(size, position, color, imgUrl, system);
  44878. };
  44879. /**
  44880. * Dispose and release the lens flare with its associated resources.
  44881. */
  44882. LensFlare.prototype.dispose = function () {
  44883. if (this.texture) {
  44884. this.texture.dispose();
  44885. }
  44886. // Remove from scene
  44887. var index = this._system.lensFlares.indexOf(this);
  44888. this._system.lensFlares.splice(index, 1);
  44889. };
  44890. return LensFlare;
  44891. }());
  44892. /***/ }),
  44893. /***/ "./LensFlares/lensFlareSystem.ts":
  44894. /*!***************************************!*\
  44895. !*** ./LensFlares/lensFlareSystem.ts ***!
  44896. \***************************************/
  44897. /*! exports provided: LensFlareSystem */
  44898. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44899. "use strict";
  44900. __webpack_require__.r(__webpack_exports__);
  44901. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  44902. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  44903. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  44904. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  44905. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  44906. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  44907. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  44908. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  44909. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  44910. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  44911. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  44912. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  44913. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  44914. /**
  44915. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44916. * It is usually composed of several `lensFlare`.
  44917. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44918. */
  44919. var LensFlareSystem = /** @class */ (function () {
  44920. /**
  44921. * Instantiates a lens flare system.
  44922. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44923. * It is usually composed of several `lensFlare`.
  44924. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44925. * @param name Define the name of the lens flare system in the scene
  44926. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  44927. * @param scene Define the scene the lens flare system belongs to
  44928. */
  44929. function LensFlareSystem(
  44930. /**
  44931. * Define the name of the lens flare system
  44932. */
  44933. name, emitter, scene) {
  44934. this.name = name;
  44935. /**
  44936. * List of lens flares used in this system.
  44937. */
  44938. this.lensFlares = new Array();
  44939. /**
  44940. * Define a limit from the border the lens flare can be visible.
  44941. */
  44942. this.borderLimit = 300;
  44943. /**
  44944. * Define a viewport border we do not want to see the lens flare in.
  44945. */
  44946. this.viewportBorder = 0;
  44947. /**
  44948. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  44949. */
  44950. this.layerMask = 0x0FFFFFFF;
  44951. this._vertexBuffers = {};
  44952. this._isEnabled = true;
  44953. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  44954. LensFlareSystem._SceneComponentInitialization(this._scene);
  44955. this._emitter = emitter;
  44956. this.id = name;
  44957. scene.lensFlareSystems.push(this);
  44958. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  44959. var engine = scene.getEngine();
  44960. // VBO
  44961. var vertices = [];
  44962. vertices.push(1, 1);
  44963. vertices.push(-1, 1);
  44964. vertices.push(-1, -1);
  44965. vertices.push(1, -1);
  44966. 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);
  44967. // Indices
  44968. var indices = [];
  44969. indices.push(0);
  44970. indices.push(1);
  44971. indices.push(2);
  44972. indices.push(0);
  44973. indices.push(2);
  44974. indices.push(3);
  44975. this._indexBuffer = engine.createIndexBuffer(indices);
  44976. // Effects
  44977. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  44978. }
  44979. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  44980. /**
  44981. * Define if the lens flare system is enabled.
  44982. */
  44983. get: function () {
  44984. return this._isEnabled;
  44985. },
  44986. set: function (value) {
  44987. this._isEnabled = value;
  44988. },
  44989. enumerable: true,
  44990. configurable: true
  44991. });
  44992. /**
  44993. * Get the scene the effects belongs to.
  44994. * @returns the scene holding the lens flare system
  44995. */
  44996. LensFlareSystem.prototype.getScene = function () {
  44997. return this._scene;
  44998. };
  44999. /**
  45000. * Get the emitter of the lens flare system.
  45001. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  45002. * @returns the emitter of the lens flare system
  45003. */
  45004. LensFlareSystem.prototype.getEmitter = function () {
  45005. return this._emitter;
  45006. };
  45007. /**
  45008. * Set the emitter of the lens flare system.
  45009. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  45010. * @param newEmitter Define the new emitter of the system
  45011. */
  45012. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  45013. this._emitter = newEmitter;
  45014. };
  45015. /**
  45016. * Get the lens flare system emitter position.
  45017. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  45018. * @returns the position
  45019. */
  45020. LensFlareSystem.prototype.getEmitterPosition = function () {
  45021. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  45022. };
  45023. /**
  45024. * @hidden
  45025. */
  45026. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  45027. var position = this.getEmitterPosition();
  45028. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  45029. this._positionX = position.x;
  45030. this._positionY = position.y;
  45031. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  45032. if (this.viewportBorder > 0) {
  45033. globalViewport.x -= this.viewportBorder;
  45034. globalViewport.y -= this.viewportBorder;
  45035. globalViewport.width += this.viewportBorder * 2;
  45036. globalViewport.height += this.viewportBorder * 2;
  45037. position.x += this.viewportBorder;
  45038. position.y += this.viewportBorder;
  45039. this._positionX += this.viewportBorder;
  45040. this._positionY += this.viewportBorder;
  45041. }
  45042. if (position.z > 0) {
  45043. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  45044. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  45045. return true;
  45046. }
  45047. }
  45048. return true;
  45049. }
  45050. return false;
  45051. };
  45052. /** @hidden */
  45053. LensFlareSystem.prototype._isVisible = function () {
  45054. if (!this._isEnabled || !this._scene.activeCamera) {
  45055. return false;
  45056. }
  45057. var emitterPosition = this.getEmitterPosition();
  45058. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  45059. var distance = direction.length();
  45060. direction.normalize();
  45061. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  45062. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  45063. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  45064. };
  45065. /**
  45066. * @hidden
  45067. */
  45068. LensFlareSystem.prototype.render = function () {
  45069. if (!this._effect.isReady() || !this._scene.activeCamera) {
  45070. return false;
  45071. }
  45072. var engine = this._scene.getEngine();
  45073. var viewport = this._scene.activeCamera.viewport;
  45074. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  45075. // Position
  45076. if (!this.computeEffectivePosition(globalViewport)) {
  45077. return false;
  45078. }
  45079. // Visibility
  45080. if (!this._isVisible()) {
  45081. return false;
  45082. }
  45083. // Intensity
  45084. var awayX;
  45085. var awayY;
  45086. if (this._positionX < this.borderLimit + globalViewport.x) {
  45087. awayX = this.borderLimit + globalViewport.x - this._positionX;
  45088. }
  45089. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  45090. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  45091. }
  45092. else {
  45093. awayX = 0;
  45094. }
  45095. if (this._positionY < this.borderLimit + globalViewport.y) {
  45096. awayY = this.borderLimit + globalViewport.y - this._positionY;
  45097. }
  45098. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  45099. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  45100. }
  45101. else {
  45102. awayY = 0;
  45103. }
  45104. var away = (awayX > awayY) ? awayX : awayY;
  45105. away -= this.viewportBorder;
  45106. if (away > this.borderLimit) {
  45107. away = this.borderLimit;
  45108. }
  45109. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  45110. if (intensity < 0) {
  45111. return false;
  45112. }
  45113. if (intensity > 1.0) {
  45114. intensity = 1.0;
  45115. }
  45116. if (this.viewportBorder > 0) {
  45117. globalViewport.x += this.viewportBorder;
  45118. globalViewport.y += this.viewportBorder;
  45119. globalViewport.width -= this.viewportBorder * 2;
  45120. globalViewport.height -= this.viewportBorder * 2;
  45121. this._positionX -= this.viewportBorder;
  45122. this._positionY -= this.viewportBorder;
  45123. }
  45124. // Position
  45125. var centerX = globalViewport.x + globalViewport.width / 2;
  45126. var centerY = globalViewport.y + globalViewport.height / 2;
  45127. var distX = centerX - this._positionX;
  45128. var distY = centerY - this._positionY;
  45129. // Effects
  45130. engine.enableEffect(this._effect);
  45131. engine.setState(false);
  45132. engine.setDepthBuffer(false);
  45133. // VBOs
  45134. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  45135. // Flares
  45136. for (var index = 0; index < this.lensFlares.length; index++) {
  45137. var flare = this.lensFlares[index];
  45138. engine.setAlphaMode(flare.alphaMode);
  45139. var x = centerX - (distX * flare.position);
  45140. var y = centerY - (distY * flare.position);
  45141. var cw = flare.size;
  45142. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  45143. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  45144. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  45145. 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);
  45146. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  45147. // Texture
  45148. this._effect.setTexture("textureSampler", flare.texture);
  45149. // Color
  45150. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  45151. // Draw order
  45152. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  45153. }
  45154. engine.setDepthBuffer(true);
  45155. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  45156. return true;
  45157. };
  45158. /**
  45159. * Dispose and release the lens flare with its associated resources.
  45160. */
  45161. LensFlareSystem.prototype.dispose = function () {
  45162. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  45163. if (vertexBuffer) {
  45164. vertexBuffer.dispose();
  45165. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  45166. }
  45167. if (this._indexBuffer) {
  45168. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  45169. this._indexBuffer = null;
  45170. }
  45171. while (this.lensFlares.length) {
  45172. this.lensFlares[0].dispose();
  45173. }
  45174. // Remove from scene
  45175. var index = this._scene.lensFlareSystems.indexOf(this);
  45176. this._scene.lensFlareSystems.splice(index, 1);
  45177. };
  45178. /**
  45179. * Parse a lens flare system from a JSON repressentation
  45180. * @param parsedLensFlareSystem Define the JSON to parse
  45181. * @param scene Define the scene the parsed system should be instantiated in
  45182. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  45183. * @returns the parsed system
  45184. */
  45185. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  45186. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  45187. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  45188. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  45189. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  45190. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  45191. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  45192. var parsedFlare = parsedLensFlareSystem.flares[index];
  45193. _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);
  45194. }
  45195. return lensFlareSystem;
  45196. };
  45197. /**
  45198. * Serialize the current Lens Flare System into a JSON representation.
  45199. * @returns the serialized JSON
  45200. */
  45201. LensFlareSystem.prototype.serialize = function () {
  45202. var serializationObject = {};
  45203. serializationObject.id = this.id;
  45204. serializationObject.name = this.name;
  45205. serializationObject.emitterId = this.getEmitter().id;
  45206. serializationObject.borderLimit = this.borderLimit;
  45207. serializationObject.flares = [];
  45208. for (var index = 0; index < this.lensFlares.length; index++) {
  45209. var flare = this.lensFlares[index];
  45210. serializationObject.flares.push({
  45211. size: flare.size,
  45212. position: flare.position,
  45213. color: flare.color.asArray(),
  45214. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  45215. });
  45216. }
  45217. return serializationObject;
  45218. };
  45219. /** @hidden */
  45220. LensFlareSystem._SceneComponentInitialization = function (_) {
  45221. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("LensFlareSystemSceneComponent");
  45222. };
  45223. return LensFlareSystem;
  45224. }());
  45225. /***/ }),
  45226. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  45227. /*!*****************************************************!*\
  45228. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  45229. \*****************************************************/
  45230. /*! exports provided: LensFlareSystemSceneComponent */
  45231. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45232. "use strict";
  45233. __webpack_require__.r(__webpack_exports__);
  45234. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  45235. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  45236. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  45237. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  45238. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  45239. // Adds the parser to the scene parsers.
  45240. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  45241. // Lens flares
  45242. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  45243. if (!container.lensFlareSystems) {
  45244. container.lensFlareSystems = new Array();
  45245. }
  45246. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  45247. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  45248. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  45249. container.lensFlareSystems.push(lf);
  45250. }
  45251. }
  45252. });
  45253. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  45254. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  45255. if (this.lensFlareSystems[index].name === name) {
  45256. return this.lensFlareSystems[index];
  45257. }
  45258. }
  45259. return null;
  45260. };
  45261. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  45262. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  45263. if (this.lensFlareSystems[index].id === id) {
  45264. return this.lensFlareSystems[index];
  45265. }
  45266. }
  45267. return null;
  45268. };
  45269. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  45270. var index = this.lensFlareSystems.indexOf(toRemove);
  45271. if (index !== -1) {
  45272. this.lensFlareSystems.splice(index, 1);
  45273. }
  45274. return index;
  45275. };
  45276. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  45277. this.lensFlareSystems.push(newLensFlareSystem);
  45278. };
  45279. /**
  45280. * Defines the lens flare scene component responsible to manage any lens flares
  45281. * in a given scene.
  45282. */
  45283. var LensFlareSystemSceneComponent = /** @class */ (function () {
  45284. /**
  45285. * Creates a new instance of the component for the given scene
  45286. * @param scene Defines the scene to register the component in
  45287. */
  45288. function LensFlareSystemSceneComponent(scene) {
  45289. /**
  45290. * The component name helpfull to identify the component in the list of scene components.
  45291. */
  45292. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  45293. this.scene = scene;
  45294. scene.lensFlareSystems = new Array();
  45295. }
  45296. /**
  45297. * Registers the component in a given scene
  45298. */
  45299. LensFlareSystemSceneComponent.prototype.register = function () {
  45300. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  45301. };
  45302. /**
  45303. * Rebuilds the elements related to this component in case of
  45304. * context lost for instance.
  45305. */
  45306. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  45307. // Nothing to do for lens flare
  45308. };
  45309. /**
  45310. * Adds all the element from the container to the scene
  45311. * @param container the container holding the elements
  45312. */
  45313. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  45314. var _this = this;
  45315. if (!container.lensFlareSystems) {
  45316. return;
  45317. }
  45318. container.lensFlareSystems.forEach(function (o) {
  45319. _this.scene.addLensFlareSystem(o);
  45320. });
  45321. };
  45322. /**
  45323. * Removes all the elements in the container from the scene
  45324. * @param container contains the elements to remove
  45325. * @param dispose if the removed element should be disposed (default: false)
  45326. */
  45327. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  45328. var _this = this;
  45329. if (!container.lensFlareSystems) {
  45330. return;
  45331. }
  45332. container.lensFlareSystems.forEach(function (o) {
  45333. _this.scene.removeLensFlareSystem(o);
  45334. if (dispose) {
  45335. o.dispose();
  45336. }
  45337. });
  45338. };
  45339. /**
  45340. * Serializes the component data to the specified json object
  45341. * @param serializationObject The object to serialize to
  45342. */
  45343. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  45344. // Lens flares
  45345. serializationObject.lensFlareSystems = [];
  45346. var lensFlareSystems = this.scene.lensFlareSystems;
  45347. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  45348. var lensFlareSystem = lensFlareSystems_1[_i];
  45349. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  45350. }
  45351. };
  45352. /**
  45353. * Disposes the component and the associated ressources.
  45354. */
  45355. LensFlareSystemSceneComponent.prototype.dispose = function () {
  45356. var lensFlareSystems = this.scene.lensFlareSystems;
  45357. while (lensFlareSystems.length) {
  45358. lensFlareSystems[0].dispose();
  45359. }
  45360. };
  45361. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  45362. // Lens flares
  45363. if (this.scene.lensFlaresEnabled) {
  45364. var lensFlareSystems = this.scene.lensFlareSystems;
  45365. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  45366. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  45367. var lensFlareSystem = lensFlareSystems_2[_i];
  45368. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  45369. lensFlareSystem.render();
  45370. }
  45371. }
  45372. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  45373. }
  45374. };
  45375. return LensFlareSystemSceneComponent;
  45376. }());
  45377. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  45378. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  45379. if (!component) {
  45380. component = new LensFlareSystemSceneComponent(scene);
  45381. scene._addComponent(component);
  45382. }
  45383. };
  45384. /***/ }),
  45385. /***/ "./Lights/Shadows/index.ts":
  45386. /*!*********************************!*\
  45387. !*** ./Lights/Shadows/index.ts ***!
  45388. \*********************************/
  45389. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  45390. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45391. "use strict";
  45392. __webpack_require__.r(__webpack_exports__);
  45393. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  45394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  45395. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  45396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  45397. /***/ }),
  45398. /***/ "./Lights/Shadows/shadowGenerator.ts":
  45399. /*!*******************************************!*\
  45400. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  45401. \*******************************************/
  45402. /*! exports provided: ShadowGenerator */
  45403. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45404. "use strict";
  45405. __webpack_require__.r(__webpack_exports__);
  45406. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  45407. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45408. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  45409. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  45410. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  45411. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  45412. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  45413. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  45414. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  45415. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  45416. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  45417. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  45418. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  45419. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  45420. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  45421. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  45422. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  45423. /**
  45424. * Default implementation IShadowGenerator.
  45425. * This is the main object responsible of generating shadows in the framework.
  45426. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  45427. */
  45428. var ShadowGenerator = /** @class */ (function () {
  45429. /**
  45430. * Creates a ShadowGenerator object.
  45431. * A ShadowGenerator is the required tool to use the shadows.
  45432. * Each light casting shadows needs to use its own ShadowGenerator.
  45433. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  45434. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  45435. * @param light The light object generating the shadows.
  45436. * @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.
  45437. */
  45438. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  45439. /**
  45440. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  45441. */
  45442. this.onBeforeShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  45443. /**
  45444. * Observable triggered before a mesh is rendered in the shadow map.
  45445. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  45446. */
  45447. this.onBeforeShadowMapRenderMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  45448. this._bias = 0.00005;
  45449. this._normalBias = 0;
  45450. this._blurBoxOffset = 1;
  45451. this._blurScale = 2;
  45452. this._blurKernel = 1;
  45453. this._useKernelBlur = false;
  45454. this._filter = ShadowGenerator.FILTER_NONE;
  45455. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  45456. this._contactHardeningLightSizeUVRatio = 0.1;
  45457. this._darkness = 0;
  45458. this._transparencyShadow = false;
  45459. /**
  45460. * Controls the extent to which the shadows fade out at the edge of the frustum
  45461. * Used only by directionals and spots
  45462. */
  45463. this.frustumEdgeFalloff = 0;
  45464. /**
  45465. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  45466. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  45467. * It might on the other hand introduce peter panning.
  45468. */
  45469. this.forceBackFacesOnly = false;
  45470. this._lightDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  45471. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  45472. this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  45473. this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  45474. this._cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  45475. this._cachedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  45476. this._currentFaceIndex = 0;
  45477. this._currentFaceIndexCache = 0;
  45478. this._defaultTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  45479. this._mapSize = mapSize;
  45480. this._light = light;
  45481. this._scene = light.getScene();
  45482. light._shadowGenerator = this;
  45483. ShadowGenerator._SceneComponentInitialization(this._scene);
  45484. // Texture type fallback from float to int if not supported.
  45485. var caps = this._scene.getEngine().getCaps();
  45486. if (!usefulFloatFirst) {
  45487. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  45488. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  45489. }
  45490. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  45491. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  45492. }
  45493. else {
  45494. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  45495. }
  45496. }
  45497. else {
  45498. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  45499. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  45500. }
  45501. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  45502. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  45503. }
  45504. else {
  45505. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  45506. }
  45507. }
  45508. this._initializeGenerator();
  45509. this._applyFilterValues();
  45510. }
  45511. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  45512. /**
  45513. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  45514. */
  45515. get: function () {
  45516. return this._bias;
  45517. },
  45518. /**
  45519. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  45520. */
  45521. set: function (bias) {
  45522. this._bias = bias;
  45523. },
  45524. enumerable: true,
  45525. configurable: true
  45526. });
  45527. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  45528. /**
  45529. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  45530. */
  45531. get: function () {
  45532. return this._normalBias;
  45533. },
  45534. /**
  45535. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  45536. */
  45537. set: function (normalBias) {
  45538. this._normalBias = normalBias;
  45539. },
  45540. enumerable: true,
  45541. configurable: true
  45542. });
  45543. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  45544. /**
  45545. * Gets the blur box offset: offset applied during the blur pass.
  45546. * Only useful if useKernelBlur = false
  45547. */
  45548. get: function () {
  45549. return this._blurBoxOffset;
  45550. },
  45551. /**
  45552. * Sets the blur box offset: offset applied during the blur pass.
  45553. * Only useful if useKernelBlur = false
  45554. */
  45555. set: function (value) {
  45556. if (this._blurBoxOffset === value) {
  45557. return;
  45558. }
  45559. this._blurBoxOffset = value;
  45560. this._disposeBlurPostProcesses();
  45561. },
  45562. enumerable: true,
  45563. configurable: true
  45564. });
  45565. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  45566. /**
  45567. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  45568. * 2 means half of the size.
  45569. */
  45570. get: function () {
  45571. return this._blurScale;
  45572. },
  45573. /**
  45574. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  45575. * 2 means half of the size.
  45576. */
  45577. set: function (value) {
  45578. if (this._blurScale === value) {
  45579. return;
  45580. }
  45581. this._blurScale = value;
  45582. this._disposeBlurPostProcesses();
  45583. },
  45584. enumerable: true,
  45585. configurable: true
  45586. });
  45587. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  45588. /**
  45589. * Gets the blur kernel: kernel size of the blur pass.
  45590. * Only useful if useKernelBlur = true
  45591. */
  45592. get: function () {
  45593. return this._blurKernel;
  45594. },
  45595. /**
  45596. * Sets the blur kernel: kernel size of the blur pass.
  45597. * Only useful if useKernelBlur = true
  45598. */
  45599. set: function (value) {
  45600. if (this._blurKernel === value) {
  45601. return;
  45602. }
  45603. this._blurKernel = value;
  45604. this._disposeBlurPostProcesses();
  45605. },
  45606. enumerable: true,
  45607. configurable: true
  45608. });
  45609. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  45610. /**
  45611. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  45612. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  45613. */
  45614. get: function () {
  45615. return this._useKernelBlur;
  45616. },
  45617. /**
  45618. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  45619. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  45620. */
  45621. set: function (value) {
  45622. if (this._useKernelBlur === value) {
  45623. return;
  45624. }
  45625. this._useKernelBlur = value;
  45626. this._disposeBlurPostProcesses();
  45627. },
  45628. enumerable: true,
  45629. configurable: true
  45630. });
  45631. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  45632. /**
  45633. * Gets the depth scale used in ESM mode.
  45634. */
  45635. get: function () {
  45636. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  45637. },
  45638. /**
  45639. * Sets the depth scale used in ESM mode.
  45640. * This can override the scale stored on the light.
  45641. */
  45642. set: function (value) {
  45643. this._depthScale = value;
  45644. },
  45645. enumerable: true,
  45646. configurable: true
  45647. });
  45648. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  45649. /**
  45650. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  45651. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  45652. */
  45653. get: function () {
  45654. return this._filter;
  45655. },
  45656. /**
  45657. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  45658. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  45659. */
  45660. set: function (value) {
  45661. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  45662. if (this._light.needCube()) {
  45663. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  45664. this.useExponentialShadowMap = true;
  45665. return;
  45666. }
  45667. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  45668. this.useCloseExponentialShadowMap = true;
  45669. return;
  45670. }
  45671. // PCF on cubemap would also be expensive
  45672. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  45673. this.usePoissonSampling = true;
  45674. return;
  45675. }
  45676. }
  45677. // Weblg1 fallback for PCF.
  45678. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  45679. if (this._scene.getEngine().webGLVersion === 1) {
  45680. this.usePoissonSampling = true;
  45681. return;
  45682. }
  45683. }
  45684. if (this._filter === value) {
  45685. return;
  45686. }
  45687. this._filter = value;
  45688. this._disposeBlurPostProcesses();
  45689. this._applyFilterValues();
  45690. this._light._markMeshesAsLightDirty();
  45691. },
  45692. enumerable: true,
  45693. configurable: true
  45694. });
  45695. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  45696. /**
  45697. * Gets if the current filter is set to Poisson Sampling.
  45698. */
  45699. get: function () {
  45700. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  45701. },
  45702. /**
  45703. * Sets the current filter to Poisson Sampling.
  45704. */
  45705. set: function (value) {
  45706. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  45707. return;
  45708. }
  45709. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  45710. },
  45711. enumerable: true,
  45712. configurable: true
  45713. });
  45714. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  45715. /**
  45716. * Gets if the current filter is set to ESM.
  45717. */
  45718. get: function () {
  45719. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  45720. },
  45721. /**
  45722. * Sets the current filter is to ESM.
  45723. */
  45724. set: function (value) {
  45725. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  45726. return;
  45727. }
  45728. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45729. },
  45730. enumerable: true,
  45731. configurable: true
  45732. });
  45733. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  45734. /**
  45735. * Gets if the current filter is set to filtered ESM.
  45736. */
  45737. get: function () {
  45738. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  45739. },
  45740. /**
  45741. * Gets if the current filter is set to filtered ESM.
  45742. */
  45743. set: function (value) {
  45744. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  45745. return;
  45746. }
  45747. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45748. },
  45749. enumerable: true,
  45750. configurable: true
  45751. });
  45752. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  45753. /**
  45754. * Gets if the current filter is set to "close ESM" (using the inverse of the
  45755. * exponential to prevent steep falloff artifacts).
  45756. */
  45757. get: function () {
  45758. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  45759. },
  45760. /**
  45761. * Sets the current filter to "close ESM" (using the inverse of the
  45762. * exponential to prevent steep falloff artifacts).
  45763. */
  45764. set: function (value) {
  45765. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  45766. return;
  45767. }
  45768. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45769. },
  45770. enumerable: true,
  45771. configurable: true
  45772. });
  45773. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  45774. /**
  45775. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  45776. * exponential to prevent steep falloff artifacts).
  45777. */
  45778. get: function () {
  45779. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  45780. },
  45781. /**
  45782. * Sets the current filter to filtered "close ESM" (using the inverse of the
  45783. * exponential to prevent steep falloff artifacts).
  45784. */
  45785. set: function (value) {
  45786. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  45787. return;
  45788. }
  45789. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  45790. },
  45791. enumerable: true,
  45792. configurable: true
  45793. });
  45794. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  45795. /**
  45796. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  45797. */
  45798. get: function () {
  45799. return this.filter === ShadowGenerator.FILTER_PCF;
  45800. },
  45801. /**
  45802. * Sets the current filter to "PCF" (percentage closer filtering).
  45803. */
  45804. set: function (value) {
  45805. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  45806. return;
  45807. }
  45808. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  45809. },
  45810. enumerable: true,
  45811. configurable: true
  45812. });
  45813. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  45814. /**
  45815. * Gets the PCF or PCSS Quality.
  45816. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  45817. */
  45818. get: function () {
  45819. return this._filteringQuality;
  45820. },
  45821. /**
  45822. * Sets the PCF or PCSS Quality.
  45823. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  45824. */
  45825. set: function (filteringQuality) {
  45826. this._filteringQuality = filteringQuality;
  45827. },
  45828. enumerable: true,
  45829. configurable: true
  45830. });
  45831. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  45832. /**
  45833. * Gets if the current filter is set to "PCSS" (contact hardening).
  45834. */
  45835. get: function () {
  45836. return this.filter === ShadowGenerator.FILTER_PCSS;
  45837. },
  45838. /**
  45839. * Sets the current filter to "PCSS" (contact hardening).
  45840. */
  45841. set: function (value) {
  45842. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  45843. return;
  45844. }
  45845. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  45846. },
  45847. enumerable: true,
  45848. configurable: true
  45849. });
  45850. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  45851. /**
  45852. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  45853. * Using a ratio helps keeping shape stability independently of the map size.
  45854. *
  45855. * It does not account for the light projection as it was having too much
  45856. * instability during the light setup or during light position changes.
  45857. *
  45858. * Only valid if useContactHardeningShadow is true.
  45859. */
  45860. get: function () {
  45861. return this._contactHardeningLightSizeUVRatio;
  45862. },
  45863. /**
  45864. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  45865. * Using a ratio helps keeping shape stability independently of the map size.
  45866. *
  45867. * It does not account for the light projection as it was having too much
  45868. * instability during the light setup or during light position changes.
  45869. *
  45870. * Only valid if useContactHardeningShadow is true.
  45871. */
  45872. set: function (contactHardeningLightSizeUVRatio) {
  45873. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  45874. },
  45875. enumerable: true,
  45876. configurable: true
  45877. });
  45878. /**
  45879. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  45880. * 0 means strongest and 1 would means no shadow.
  45881. * @returns the darkness.
  45882. */
  45883. ShadowGenerator.prototype.getDarkness = function () {
  45884. return this._darkness;
  45885. };
  45886. /**
  45887. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  45888. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  45889. * @returns the shadow generator allowing fluent coding.
  45890. */
  45891. ShadowGenerator.prototype.setDarkness = function (darkness) {
  45892. if (darkness >= 1.0) {
  45893. this._darkness = 1.0;
  45894. }
  45895. else if (darkness <= 0.0) {
  45896. this._darkness = 0.0;
  45897. }
  45898. else {
  45899. this._darkness = darkness;
  45900. }
  45901. return this;
  45902. };
  45903. /**
  45904. * Sets the ability to have transparent shadow (boolean).
  45905. * @param transparent True if transparent else False
  45906. * @returns the shadow generator allowing fluent coding
  45907. */
  45908. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  45909. this._transparencyShadow = transparent;
  45910. return this;
  45911. };
  45912. /**
  45913. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  45914. * @returns The render target texture if present otherwise, null
  45915. */
  45916. ShadowGenerator.prototype.getShadowMap = function () {
  45917. return this._shadowMap;
  45918. };
  45919. /**
  45920. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  45921. * @returns The render target texture if the shadow map is present otherwise, null
  45922. */
  45923. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  45924. if (this._shadowMap2) {
  45925. return this._shadowMap2;
  45926. }
  45927. return this._shadowMap;
  45928. };
  45929. /**
  45930. * Helper function to add a mesh and its descendants to the list of shadow casters.
  45931. * @param mesh Mesh to add
  45932. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  45933. * @returns the Shadow Generator itself
  45934. */
  45935. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  45936. if (includeDescendants === void 0) { includeDescendants = true; }
  45937. var _a;
  45938. if (!this._shadowMap) {
  45939. return this;
  45940. }
  45941. if (!this._shadowMap.renderList) {
  45942. this._shadowMap.renderList = [];
  45943. }
  45944. this._shadowMap.renderList.push(mesh);
  45945. if (includeDescendants) {
  45946. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  45947. }
  45948. return this;
  45949. };
  45950. /**
  45951. * Helper function to remove a mesh and its descendants from the list of shadow casters
  45952. * @param mesh Mesh to remove
  45953. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  45954. * @returns the Shadow Generator itself
  45955. */
  45956. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  45957. if (includeDescendants === void 0) { includeDescendants = true; }
  45958. if (!this._shadowMap || !this._shadowMap.renderList) {
  45959. return this;
  45960. }
  45961. var index = this._shadowMap.renderList.indexOf(mesh);
  45962. if (index !== -1) {
  45963. this._shadowMap.renderList.splice(index, 1);
  45964. }
  45965. if (includeDescendants) {
  45966. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  45967. var child = _a[_i];
  45968. this.removeShadowCaster(child);
  45969. }
  45970. }
  45971. return this;
  45972. };
  45973. /**
  45974. * Returns the associated light object.
  45975. * @returns the light generating the shadow
  45976. */
  45977. ShadowGenerator.prototype.getLight = function () {
  45978. return this._light;
  45979. };
  45980. ShadowGenerator.prototype._initializeGenerator = function () {
  45981. this._light._markMeshesAsLightDirty();
  45982. this._initializeShadowMap();
  45983. };
  45984. ShadowGenerator.prototype._initializeShadowMap = function () {
  45985. var _this = this;
  45986. // Render target
  45987. var engine = this._scene.getEngine();
  45988. if (engine.webGLVersion > 1) {
  45989. 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);
  45990. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].LESS, true);
  45991. }
  45992. else {
  45993. 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());
  45994. }
  45995. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45996. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  45997. this._shadowMap.anisotropicFilteringLevel = 1;
  45998. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  45999. this._shadowMap.renderParticles = false;
  46000. this._shadowMap.ignoreCameraViewport = true;
  46001. // Record Face Index before render.
  46002. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  46003. _this._currentFaceIndex = faceIndex;
  46004. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  46005. engine.setColorWrite(false);
  46006. }
  46007. });
  46008. // Custom render function.
  46009. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  46010. // Blur if required afer render.
  46011. this._shadowMap.onAfterUnbindObservable.add(function () {
  46012. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  46013. engine.setColorWrite(true);
  46014. }
  46015. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  46016. return;
  46017. }
  46018. var shadowMap = _this.getShadowMapForRendering();
  46019. if (shadowMap) {
  46020. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  46021. }
  46022. });
  46023. // Clear according to the chosen filter.
  46024. var clearZero = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  46025. var clearOne = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  46026. this._shadowMap.onClearObservable.add(function (engine) {
  46027. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  46028. engine.clear(clearOne, false, true, false);
  46029. }
  46030. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  46031. engine.clear(clearZero, true, true, false);
  46032. }
  46033. else {
  46034. engine.clear(clearOne, true, true, false);
  46035. }
  46036. });
  46037. };
  46038. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  46039. var _this = this;
  46040. var engine = this._scene.getEngine();
  46041. var targetSize = this._mapSize / this.blurScale;
  46042. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  46043. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  46044. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  46045. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  46046. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  46047. }
  46048. if (this.useKernelBlur) {
  46049. 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);
  46050. this._kernelBlurXPostprocess.width = targetSize;
  46051. this._kernelBlurXPostprocess.height = targetSize;
  46052. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  46053. effect.setTexture("textureSampler", _this._shadowMap);
  46054. });
  46055. 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);
  46056. this._kernelBlurXPostprocess.autoClear = false;
  46057. this._kernelBlurYPostprocess.autoClear = false;
  46058. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  46059. this._kernelBlurXPostprocess.packedFloat = true;
  46060. this._kernelBlurYPostprocess.packedFloat = true;
  46061. }
  46062. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  46063. }
  46064. else {
  46065. 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);
  46066. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  46067. effect.setFloat2("screenSize", targetSize, targetSize);
  46068. effect.setTexture("textureSampler", _this._shadowMap);
  46069. });
  46070. this._boxBlurPostprocess.autoClear = false;
  46071. this._blurPostProcesses = [this._boxBlurPostprocess];
  46072. }
  46073. };
  46074. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  46075. var index;
  46076. var engine = this._scene.getEngine();
  46077. if (depthOnlySubMeshes.length) {
  46078. engine.setColorWrite(false);
  46079. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  46080. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  46081. }
  46082. engine.setColorWrite(true);
  46083. }
  46084. for (index = 0; index < opaqueSubMeshes.length; index++) {
  46085. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  46086. }
  46087. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  46088. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  46089. }
  46090. if (this._transparencyShadow) {
  46091. for (index = 0; index < transparentSubMeshes.length; index++) {
  46092. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  46093. }
  46094. }
  46095. };
  46096. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  46097. var _this = this;
  46098. var mesh = subMesh.getRenderingMesh();
  46099. var scene = this._scene;
  46100. var engine = scene.getEngine();
  46101. var material = subMesh.getMaterial();
  46102. if (!material || subMesh.verticesCount === 0) {
  46103. return;
  46104. }
  46105. // Culling
  46106. engine.setState(material.backFaceCulling);
  46107. // Managing instances
  46108. var batch = mesh._getInstancesRenderList(subMesh._id);
  46109. if (batch.mustReturn) {
  46110. return;
  46111. }
  46112. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  46113. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  46114. engine.enableEffect(this._effect);
  46115. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  46116. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  46117. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  46118. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  46119. this._effect.setVector3("lightData", this._cachedDirection);
  46120. }
  46121. else {
  46122. this._effect.setVector3("lightData", this._cachedPosition);
  46123. }
  46124. if (scene.activeCamera) {
  46125. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  46126. }
  46127. // Alpha test
  46128. if (material && material.needAlphaTesting()) {
  46129. var alphaTexture = material.getAlphaTestTexture();
  46130. if (alphaTexture) {
  46131. this._effect.setTexture("diffuseSampler", alphaTexture);
  46132. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  46133. }
  46134. }
  46135. // Bones
  46136. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  46137. var skeleton = mesh.skeleton;
  46138. if (skeleton.isUsingTextureForMatrices) {
  46139. var boneTexture = skeleton.getTransformMatrixTexture();
  46140. if (!boneTexture) {
  46141. return;
  46142. }
  46143. this._effect.setTexture("boneSampler", boneTexture);
  46144. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  46145. }
  46146. else {
  46147. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  46148. }
  46149. }
  46150. // Morph targets
  46151. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  46152. if (this.forceBackFacesOnly) {
  46153. engine.setState(true, 0, false, true);
  46154. }
  46155. // Observables
  46156. this.onBeforeShadowMapRenderMeshObservable.notifyObservers(mesh);
  46157. this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect);
  46158. // Draw
  46159. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  46160. if (this.forceBackFacesOnly) {
  46161. engine.setState(true, 0, false, false);
  46162. }
  46163. }
  46164. else {
  46165. // Need to reset refresh rate of the shadowMap
  46166. if (this._shadowMap) {
  46167. this._shadowMap.resetRefreshCounter();
  46168. }
  46169. }
  46170. };
  46171. ShadowGenerator.prototype._applyFilterValues = function () {
  46172. if (!this._shadowMap) {
  46173. return;
  46174. }
  46175. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  46176. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].NEAREST_SAMPLINGMODE);
  46177. }
  46178. else {
  46179. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  46180. }
  46181. };
  46182. /**
  46183. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  46184. * @param onCompiled Callback triggered at the and of the effects compilation
  46185. * @param options Sets of optional options forcing the compilation with different modes
  46186. */
  46187. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  46188. var _this = this;
  46189. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  46190. var shadowMap = this.getShadowMap();
  46191. if (!shadowMap) {
  46192. if (onCompiled) {
  46193. onCompiled(this);
  46194. }
  46195. return;
  46196. }
  46197. var renderList = shadowMap.renderList;
  46198. if (!renderList) {
  46199. if (onCompiled) {
  46200. onCompiled(this);
  46201. }
  46202. return;
  46203. }
  46204. var subMeshes = new Array();
  46205. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  46206. var mesh = renderList_1[_i];
  46207. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  46208. }
  46209. if (subMeshes.length === 0) {
  46210. if (onCompiled) {
  46211. onCompiled(this);
  46212. }
  46213. return;
  46214. }
  46215. var currentIndex = 0;
  46216. var checkReady = function () {
  46217. if (!_this._scene || !_this._scene.getEngine()) {
  46218. return;
  46219. }
  46220. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  46221. currentIndex++;
  46222. if (currentIndex >= subMeshes.length) {
  46223. if (onCompiled) {
  46224. onCompiled(_this);
  46225. }
  46226. return;
  46227. }
  46228. }
  46229. setTimeout(checkReady, 16);
  46230. };
  46231. checkReady();
  46232. };
  46233. /**
  46234. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  46235. * @param options Sets of optional options forcing the compilation with different modes
  46236. * @returns A promise that resolves when the compilation completes
  46237. */
  46238. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  46239. var _this = this;
  46240. return new Promise(function (resolve) {
  46241. _this.forceCompilation(function () {
  46242. resolve();
  46243. }, options);
  46244. });
  46245. };
  46246. /**
  46247. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  46248. * @param subMesh The submesh we want to render in the shadow map
  46249. * @param useInstances Defines wether will draw in the map using instances
  46250. * @returns true if ready otherwise, false
  46251. */
  46252. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  46253. var defines = [];
  46254. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  46255. defines.push("#define FLOAT");
  46256. }
  46257. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  46258. defines.push("#define ESM");
  46259. }
  46260. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  46261. defines.push("#define DEPTHTEXTURE");
  46262. }
  46263. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  46264. var mesh = subMesh.getMesh();
  46265. var material = subMesh.getMaterial();
  46266. // Normal bias.
  46267. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  46268. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  46269. defines.push("#define NORMAL");
  46270. if (mesh.nonUniformScaling) {
  46271. defines.push("#define NONUNIFORMSCALING");
  46272. }
  46273. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  46274. defines.push("#define DIRECTIONINLIGHTDATA");
  46275. }
  46276. }
  46277. // Alpha test
  46278. if (material && material.needAlphaTesting()) {
  46279. var alphaTexture = material.getAlphaTestTexture();
  46280. if (alphaTexture) {
  46281. defines.push("#define ALPHATEST");
  46282. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  46283. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  46284. defines.push("#define UV1");
  46285. }
  46286. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  46287. if (alphaTexture.coordinatesIndex === 1) {
  46288. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  46289. defines.push("#define UV2");
  46290. }
  46291. }
  46292. }
  46293. }
  46294. // Bones
  46295. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  46296. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  46297. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  46298. if (mesh.numBoneInfluencers > 4) {
  46299. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  46300. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind);
  46301. }
  46302. var skeleton = mesh.skeleton;
  46303. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  46304. if (skeleton.isUsingTextureForMatrices) {
  46305. defines.push("#define BONETEXTURE");
  46306. }
  46307. else {
  46308. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  46309. }
  46310. }
  46311. else {
  46312. defines.push("#define NUM_BONE_INFLUENCERS 0");
  46313. }
  46314. // Morph targets
  46315. var manager = mesh.morphTargetManager;
  46316. var morphInfluencers = 0;
  46317. if (manager) {
  46318. if (manager.numInfluencers > 0) {
  46319. defines.push("#define MORPHTARGETS");
  46320. morphInfluencers = manager.numInfluencers;
  46321. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  46322. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  46323. }
  46324. }
  46325. // Instances
  46326. if (useInstances) {
  46327. defines.push("#define INSTANCES");
  46328. attribs.push("world0");
  46329. attribs.push("world1");
  46330. attribs.push("world2");
  46331. attribs.push("world3");
  46332. }
  46333. if (this.customShaderOptions) {
  46334. if (this.customShaderOptions.defines) {
  46335. for (var _i = 0, _a = this.customShaderOptions.defines; _i < _a.length; _i++) {
  46336. var define = _a[_i];
  46337. if (defines.indexOf(define) === -1) {
  46338. defines.push(define);
  46339. }
  46340. }
  46341. }
  46342. }
  46343. // Get correct effect
  46344. var join = defines.join("\n");
  46345. if (this._cachedDefines !== join) {
  46346. this._cachedDefines = join;
  46347. var shaderName = "shadowMap";
  46348. var uniforms = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"];
  46349. var samplers = ["diffuseSampler", "boneSampler"];
  46350. // Custom shader?
  46351. if (this.customShaderOptions) {
  46352. shaderName = this.customShaderOptions.shaderName;
  46353. if (this.customShaderOptions.attributes) {
  46354. for (var _b = 0, _c = this.customShaderOptions.attributes; _b < _c.length; _b++) {
  46355. var attrib = _c[_b];
  46356. if (attribs.indexOf(attrib) === -1) {
  46357. attribs.push(attrib);
  46358. }
  46359. }
  46360. }
  46361. if (this.customShaderOptions.uniforms) {
  46362. for (var _d = 0, _e = this.customShaderOptions.uniforms; _d < _e.length; _d++) {
  46363. var uniform = _e[_d];
  46364. if (uniforms.indexOf(uniform) === -1) {
  46365. uniforms.push(uniform);
  46366. }
  46367. }
  46368. }
  46369. if (this.customShaderOptions.samplers) {
  46370. for (var _f = 0, _g = this.customShaderOptions.samplers; _f < _g.length; _f++) {
  46371. var sampler = _g[_f];
  46372. if (samplers.indexOf(sampler) === -1) {
  46373. samplers.push(sampler);
  46374. }
  46375. }
  46376. }
  46377. }
  46378. this._effect = this._scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  46379. }
  46380. if (!this._effect.isReady()) {
  46381. return false;
  46382. }
  46383. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  46384. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  46385. this._initializeBlurRTTAndPostProcesses();
  46386. }
  46387. }
  46388. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  46389. return false;
  46390. }
  46391. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  46392. return false;
  46393. }
  46394. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  46395. return false;
  46396. }
  46397. return true;
  46398. };
  46399. /**
  46400. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  46401. * @param defines Defines of the material we want to update
  46402. * @param lightIndex Index of the light in the enabled light list of the material
  46403. */
  46404. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  46405. var scene = this._scene;
  46406. var light = this._light;
  46407. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  46408. return;
  46409. }
  46410. defines["SHADOW" + lightIndex] = true;
  46411. if (this.useContactHardeningShadow) {
  46412. defines["SHADOWPCSS" + lightIndex] = true;
  46413. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  46414. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  46415. }
  46416. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  46417. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  46418. }
  46419. // else default to high.
  46420. }
  46421. if (this.usePercentageCloserFiltering) {
  46422. defines["SHADOWPCF" + lightIndex] = true;
  46423. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  46424. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  46425. }
  46426. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  46427. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  46428. }
  46429. // else default to high.
  46430. }
  46431. else if (this.usePoissonSampling) {
  46432. defines["SHADOWPOISSON" + lightIndex] = true;
  46433. }
  46434. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  46435. defines["SHADOWESM" + lightIndex] = true;
  46436. }
  46437. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  46438. defines["SHADOWCLOSEESM" + lightIndex] = true;
  46439. }
  46440. if (light.needCube()) {
  46441. defines["SHADOWCUBE" + lightIndex] = true;
  46442. }
  46443. };
  46444. /**
  46445. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  46446. * defined in the generator but impacting the effect).
  46447. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  46448. * @param effect The effect we are binfing the information for
  46449. */
  46450. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  46451. var light = this._light;
  46452. var scene = this._scene;
  46453. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  46454. return;
  46455. }
  46456. var camera = scene.activeCamera;
  46457. if (!camera) {
  46458. return;
  46459. }
  46460. var shadowMap = this.getShadowMap();
  46461. if (!shadowMap) {
  46462. return;
  46463. }
  46464. if (!light.needCube()) {
  46465. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  46466. }
  46467. // Only PCF uses depth stencil texture.
  46468. if (this._filter === ShadowGenerator.FILTER_PCF) {
  46469. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  46470. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  46471. }
  46472. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  46473. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  46474. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  46475. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  46476. }
  46477. else {
  46478. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  46479. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  46480. }
  46481. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  46482. };
  46483. /**
  46484. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  46485. * (eq to shadow prjection matrix * light transform matrix)
  46486. * @returns The transform matrix used to create the shadow map
  46487. */
  46488. ShadowGenerator.prototype.getTransformMatrix = function () {
  46489. var scene = this._scene;
  46490. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  46491. return this._transformMatrix;
  46492. }
  46493. this._currentRenderID = scene.getRenderId();
  46494. this._currentFaceIndexCache = this._currentFaceIndex;
  46495. var lightPosition = this._light.position;
  46496. if (this._light.computeTransformedInformation()) {
  46497. lightPosition = this._light.transformedPosition;
  46498. }
  46499. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  46500. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  46501. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  46502. }
  46503. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  46504. this._cachedPosition.copyFrom(lightPosition);
  46505. this._cachedDirection.copyFrom(this._lightDirection);
  46506. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  46507. var shadowMap = this.getShadowMap();
  46508. if (shadowMap) {
  46509. var renderList = shadowMap.renderList;
  46510. if (renderList) {
  46511. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  46512. }
  46513. }
  46514. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  46515. }
  46516. return this._transformMatrix;
  46517. };
  46518. /**
  46519. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  46520. * Cube and 2D textures for instance.
  46521. */
  46522. ShadowGenerator.prototype.recreateShadowMap = function () {
  46523. var shadowMap = this._shadowMap;
  46524. if (!shadowMap) {
  46525. return;
  46526. }
  46527. // Track render list.
  46528. var renderList = shadowMap.renderList;
  46529. // Clean up existing data.
  46530. this._disposeRTTandPostProcesses();
  46531. // Reinitializes.
  46532. this._initializeGenerator();
  46533. // Reaffect the filter to ensure a correct fallback if necessary.
  46534. this.filter = this.filter;
  46535. // Reaffect the filter.
  46536. this._applyFilterValues();
  46537. // Reaffect Render List.
  46538. this._shadowMap.renderList = renderList;
  46539. };
  46540. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  46541. if (this._shadowMap2) {
  46542. this._shadowMap2.dispose();
  46543. this._shadowMap2 = null;
  46544. }
  46545. if (this._boxBlurPostprocess) {
  46546. this._boxBlurPostprocess.dispose();
  46547. this._boxBlurPostprocess = null;
  46548. }
  46549. if (this._kernelBlurXPostprocess) {
  46550. this._kernelBlurXPostprocess.dispose();
  46551. this._kernelBlurXPostprocess = null;
  46552. }
  46553. if (this._kernelBlurYPostprocess) {
  46554. this._kernelBlurYPostprocess.dispose();
  46555. this._kernelBlurYPostprocess = null;
  46556. }
  46557. this._blurPostProcesses = [];
  46558. };
  46559. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  46560. if (this._shadowMap) {
  46561. this._shadowMap.dispose();
  46562. this._shadowMap = null;
  46563. }
  46564. this._disposeBlurPostProcesses();
  46565. };
  46566. /**
  46567. * Disposes the ShadowGenerator.
  46568. * Returns nothing.
  46569. */
  46570. ShadowGenerator.prototype.dispose = function () {
  46571. this._disposeRTTandPostProcesses();
  46572. if (this._light) {
  46573. this._light._shadowGenerator = null;
  46574. this._light._markMeshesAsLightDirty();
  46575. }
  46576. };
  46577. /**
  46578. * Serializes the shadow generator setup to a json object.
  46579. * @returns The serialized JSON object
  46580. */
  46581. ShadowGenerator.prototype.serialize = function () {
  46582. var serializationObject = {};
  46583. var shadowMap = this.getShadowMap();
  46584. if (!shadowMap) {
  46585. return serializationObject;
  46586. }
  46587. serializationObject.lightId = this._light.id;
  46588. serializationObject.mapSize = shadowMap.getRenderSize();
  46589. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  46590. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  46591. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  46592. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  46593. serializationObject.usePoissonSampling = this.usePoissonSampling;
  46594. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  46595. serializationObject.depthScale = this.depthScale;
  46596. serializationObject.darkness = this.getDarkness();
  46597. serializationObject.blurBoxOffset = this.blurBoxOffset;
  46598. serializationObject.blurKernel = this.blurKernel;
  46599. serializationObject.blurScale = this.blurScale;
  46600. serializationObject.useKernelBlur = this.useKernelBlur;
  46601. serializationObject.transparencyShadow = this._transparencyShadow;
  46602. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  46603. serializationObject.bias = this.bias;
  46604. serializationObject.normalBias = this.normalBias;
  46605. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  46606. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  46607. serializationObject.filteringQuality = this.filteringQuality;
  46608. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  46609. serializationObject.renderList = [];
  46610. if (shadowMap.renderList) {
  46611. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  46612. var mesh = shadowMap.renderList[meshIndex];
  46613. serializationObject.renderList.push(mesh.id);
  46614. }
  46615. }
  46616. return serializationObject;
  46617. };
  46618. /**
  46619. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  46620. * @param parsedShadowGenerator The JSON object to parse
  46621. * @param scene The scene to create the shadow map for
  46622. * @returns The parsed shadow generator
  46623. */
  46624. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  46625. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  46626. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  46627. var shadowMap = shadowGenerator.getShadowMap();
  46628. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  46629. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  46630. meshes.forEach(function (mesh) {
  46631. if (!shadowMap) {
  46632. return;
  46633. }
  46634. if (!shadowMap.renderList) {
  46635. shadowMap.renderList = [];
  46636. }
  46637. shadowMap.renderList.push(mesh);
  46638. });
  46639. }
  46640. if (parsedShadowGenerator.usePoissonSampling) {
  46641. shadowGenerator.usePoissonSampling = true;
  46642. }
  46643. else if (parsedShadowGenerator.useExponentialShadowMap) {
  46644. shadowGenerator.useExponentialShadowMap = true;
  46645. }
  46646. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  46647. shadowGenerator.useBlurExponentialShadowMap = true;
  46648. }
  46649. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  46650. shadowGenerator.useCloseExponentialShadowMap = true;
  46651. }
  46652. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  46653. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  46654. }
  46655. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  46656. shadowGenerator.usePercentageCloserFiltering = true;
  46657. }
  46658. else if (parsedShadowGenerator.useContactHardeningShadow) {
  46659. shadowGenerator.useContactHardeningShadow = true;
  46660. }
  46661. if (parsedShadowGenerator.filteringQuality) {
  46662. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  46663. }
  46664. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  46665. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  46666. }
  46667. // Backward compat
  46668. else if (parsedShadowGenerator.useVarianceShadowMap) {
  46669. shadowGenerator.useExponentialShadowMap = true;
  46670. }
  46671. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  46672. shadowGenerator.useBlurExponentialShadowMap = true;
  46673. }
  46674. if (parsedShadowGenerator.depthScale) {
  46675. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  46676. }
  46677. if (parsedShadowGenerator.blurScale) {
  46678. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  46679. }
  46680. if (parsedShadowGenerator.blurBoxOffset) {
  46681. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  46682. }
  46683. if (parsedShadowGenerator.useKernelBlur) {
  46684. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  46685. }
  46686. if (parsedShadowGenerator.blurKernel) {
  46687. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  46688. }
  46689. if (parsedShadowGenerator.bias !== undefined) {
  46690. shadowGenerator.bias = parsedShadowGenerator.bias;
  46691. }
  46692. if (parsedShadowGenerator.normalBias !== undefined) {
  46693. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  46694. }
  46695. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  46696. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  46697. }
  46698. if (parsedShadowGenerator.darkness) {
  46699. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  46700. }
  46701. if (parsedShadowGenerator.transparencyShadow) {
  46702. shadowGenerator.setTransparencyShadow(true);
  46703. }
  46704. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  46705. return shadowGenerator;
  46706. };
  46707. /**
  46708. * Shadow generator mode None: no filtering applied.
  46709. */
  46710. ShadowGenerator.FILTER_NONE = 0;
  46711. /**
  46712. * Shadow generator mode ESM: Exponential Shadow Mapping.
  46713. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46714. */
  46715. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  46716. /**
  46717. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  46718. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  46719. */
  46720. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  46721. /**
  46722. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  46723. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46724. */
  46725. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  46726. /**
  46727. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  46728. * edge artifacts on steep falloff.
  46729. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46730. */
  46731. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  46732. /**
  46733. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  46734. * edge artifacts on steep falloff.
  46735. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  46736. */
  46737. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  46738. /**
  46739. * Shadow generator mode PCF: Percentage Closer Filtering
  46740. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  46741. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  46742. */
  46743. ShadowGenerator.FILTER_PCF = 6;
  46744. /**
  46745. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  46746. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  46747. * Contact Hardening
  46748. */
  46749. ShadowGenerator.FILTER_PCSS = 7;
  46750. /**
  46751. * Reserved for PCF and PCSS
  46752. * Highest Quality.
  46753. *
  46754. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  46755. *
  46756. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  46757. */
  46758. ShadowGenerator.QUALITY_HIGH = 0;
  46759. /**
  46760. * Reserved for PCF and PCSS
  46761. * Good tradeoff for quality/perf cross devices
  46762. *
  46763. * Execute PCF on a 3*3 kernel.
  46764. *
  46765. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  46766. */
  46767. ShadowGenerator.QUALITY_MEDIUM = 1;
  46768. /**
  46769. * Reserved for PCF and PCSS
  46770. * The lowest quality but the fastest.
  46771. *
  46772. * Execute PCF on a 1*1 kernel.
  46773. *
  46774. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  46775. */
  46776. ShadowGenerator.QUALITY_LOW = 2;
  46777. /** @hidden */
  46778. ShadowGenerator._SceneComponentInitialization = function (_) {
  46779. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__["_DevTools"].WarnImport("ShadowGeneratorSceneComponent");
  46780. };
  46781. return ShadowGenerator;
  46782. }());
  46783. /***/ }),
  46784. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  46785. /*!*********************************************************!*\
  46786. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  46787. \*********************************************************/
  46788. /*! exports provided: ShadowGeneratorSceneComponent */
  46789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46790. "use strict";
  46791. __webpack_require__.r(__webpack_exports__);
  46792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  46793. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  46794. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  46795. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  46796. // Adds the parser to the scene parsers.
  46797. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  46798. // Shadows
  46799. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  46800. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  46801. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  46802. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  46803. // SG would be available on their associated lights
  46804. }
  46805. }
  46806. });
  46807. /**
  46808. * Defines the shadow generator component responsible to manage any shadow generators
  46809. * in a given scene.
  46810. */
  46811. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  46812. /**
  46813. * Creates a new instance of the component for the given scene
  46814. * @param scene Defines the scene to register the component in
  46815. */
  46816. function ShadowGeneratorSceneComponent(scene) {
  46817. /**
  46818. * The component name helpfull to identify the component in the list of scene components.
  46819. */
  46820. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  46821. this.scene = scene;
  46822. }
  46823. /**
  46824. * Registers the component in a given scene
  46825. */
  46826. ShadowGeneratorSceneComponent.prototype.register = function () {
  46827. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  46828. };
  46829. /**
  46830. * Rebuilds the elements related to this component in case of
  46831. * context lost for instance.
  46832. */
  46833. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  46834. // Nothing To Do Here.
  46835. };
  46836. /**
  46837. * Serializes the component data to the specified json object
  46838. * @param serializationObject The object to serialize to
  46839. */
  46840. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  46841. // Shadows
  46842. serializationObject.shadowGenerators = [];
  46843. var lights = this.scene.lights;
  46844. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  46845. var light = lights_1[_i];
  46846. var shadowGenerator = light.getShadowGenerator();
  46847. if (shadowGenerator) {
  46848. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  46849. }
  46850. }
  46851. };
  46852. /**
  46853. * Adds all the element from the container to the scene
  46854. * @param container the container holding the elements
  46855. */
  46856. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  46857. // Nothing To Do Here. (directly attached to a light)
  46858. };
  46859. /**
  46860. * Removes all the elements in the container from the scene
  46861. * @param container contains the elements to remove
  46862. * @param dispose if the removed element should be disposed (default: false)
  46863. */
  46864. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container, dispose) {
  46865. // Nothing To Do Here. (directly attached to a light)
  46866. };
  46867. /**
  46868. * Rebuilds the elements related to this component in case of
  46869. * context lost for instance.
  46870. */
  46871. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  46872. // Nothing To Do Here.
  46873. };
  46874. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  46875. // Shadows
  46876. var scene = this.scene;
  46877. if (this.scene.shadowsEnabled) {
  46878. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  46879. var light = scene.lights[lightIndex];
  46880. var shadowGenerator = light.getShadowGenerator();
  46881. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  46882. var shadowMap = (shadowGenerator.getShadowMap());
  46883. if (scene.textures.indexOf(shadowMap) !== -1) {
  46884. renderTargets.push(shadowMap);
  46885. }
  46886. }
  46887. }
  46888. }
  46889. };
  46890. return ShadowGeneratorSceneComponent;
  46891. }());
  46892. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  46893. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  46894. if (!component) {
  46895. component = new ShadowGeneratorSceneComponent(scene);
  46896. scene._addComponent(component);
  46897. }
  46898. };
  46899. /***/ }),
  46900. /***/ "./Lights/directionalLight.ts":
  46901. /*!************************************!*\
  46902. !*** ./Lights/directionalLight.ts ***!
  46903. \************************************/
  46904. /*! exports provided: DirectionalLight */
  46905. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46906. "use strict";
  46907. __webpack_require__.r(__webpack_exports__);
  46908. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  46909. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46910. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46911. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46912. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46913. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46914. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46915. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  46916. return function () { return new DirectionalLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46917. });
  46918. /**
  46919. * A directional light is defined by a direction (what a surprise!).
  46920. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46921. * 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.
  46922. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46923. */
  46924. var DirectionalLight = /** @class */ (function (_super) {
  46925. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  46926. /**
  46927. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46928. * The directional light is emitted from everywhere in the given direction.
  46929. * It can cast shadows.
  46930. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46931. * @param name The friendly name of the light
  46932. * @param direction The direction of the light
  46933. * @param scene The scene the light belongs to
  46934. */
  46935. function DirectionalLight(name, direction, scene) {
  46936. var _this = _super.call(this, name, scene) || this;
  46937. _this._shadowFrustumSize = 0;
  46938. _this._shadowOrthoScale = 0.1;
  46939. /**
  46940. * Automatically compute the projection matrix to best fit (including all the casters)
  46941. * on each frame.
  46942. */
  46943. _this.autoUpdateExtends = true;
  46944. // Cache
  46945. _this._orthoLeft = Number.MAX_VALUE;
  46946. _this._orthoRight = Number.MIN_VALUE;
  46947. _this._orthoTop = Number.MIN_VALUE;
  46948. _this._orthoBottom = Number.MAX_VALUE;
  46949. _this.position = direction.scale(-1.0);
  46950. _this.direction = direction;
  46951. return _this;
  46952. }
  46953. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  46954. /**
  46955. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46956. */
  46957. get: function () {
  46958. return this._shadowFrustumSize;
  46959. },
  46960. /**
  46961. * Specifies a fix frustum size for the shadow generation.
  46962. */
  46963. set: function (value) {
  46964. this._shadowFrustumSize = value;
  46965. this.forceProjectionMatrixCompute();
  46966. },
  46967. enumerable: true,
  46968. configurable: true
  46969. });
  46970. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  46971. /**
  46972. * Gets the shadow projection scale against the optimal computed one.
  46973. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46974. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46975. */
  46976. get: function () {
  46977. return this._shadowOrthoScale;
  46978. },
  46979. /**
  46980. * Sets the shadow projection scale against the optimal computed one.
  46981. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46982. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46983. */
  46984. set: function (value) {
  46985. this._shadowOrthoScale = value;
  46986. this.forceProjectionMatrixCompute();
  46987. },
  46988. enumerable: true,
  46989. configurable: true
  46990. });
  46991. /**
  46992. * Returns the string "DirectionalLight".
  46993. * @return The class name
  46994. */
  46995. DirectionalLight.prototype.getClassName = function () {
  46996. return "DirectionalLight";
  46997. };
  46998. /**
  46999. * Returns the integer 1.
  47000. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47001. */
  47002. DirectionalLight.prototype.getTypeID = function () {
  47003. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  47004. };
  47005. /**
  47006. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47007. * Returns the DirectionalLight Shadow projection matrix.
  47008. */
  47009. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47010. if (this.shadowFrustumSize > 0) {
  47011. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  47012. }
  47013. else {
  47014. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  47015. }
  47016. };
  47017. /**
  47018. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47019. * Returns the DirectionalLight Shadow projection matrix.
  47020. */
  47021. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  47022. var activeCamera = this.getScene().activeCamera;
  47023. if (!activeCamera) {
  47024. return;
  47025. }
  47026. _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);
  47027. };
  47028. /**
  47029. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47030. * Returns the DirectionalLight Shadow projection matrix.
  47031. */
  47032. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47033. var activeCamera = this.getScene().activeCamera;
  47034. if (!activeCamera) {
  47035. return;
  47036. }
  47037. // Check extends
  47038. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  47039. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47040. this._orthoLeft = Number.MAX_VALUE;
  47041. this._orthoRight = Number.MIN_VALUE;
  47042. this._orthoTop = Number.MIN_VALUE;
  47043. this._orthoBottom = Number.MAX_VALUE;
  47044. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  47045. var mesh = renderList[meshIndex];
  47046. if (!mesh) {
  47047. continue;
  47048. }
  47049. var boundingInfo = mesh.getBoundingInfo();
  47050. var boundingBox = boundingInfo.boundingBox;
  47051. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  47052. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  47053. if (tempVector3.x < this._orthoLeft) {
  47054. this._orthoLeft = tempVector3.x;
  47055. }
  47056. if (tempVector3.y < this._orthoBottom) {
  47057. this._orthoBottom = tempVector3.y;
  47058. }
  47059. if (tempVector3.x > this._orthoRight) {
  47060. this._orthoRight = tempVector3.x;
  47061. }
  47062. if (tempVector3.y > this._orthoTop) {
  47063. this._orthoTop = tempVector3.y;
  47064. }
  47065. }
  47066. }
  47067. }
  47068. var xOffset = this._orthoRight - this._orthoLeft;
  47069. var yOffset = this._orthoTop - this._orthoBottom;
  47070. _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);
  47071. };
  47072. DirectionalLight.prototype._buildUniformLayout = function () {
  47073. this._uniformBuffer.addUniform("vLightData", 4);
  47074. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47075. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47076. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47077. this._uniformBuffer.addUniform("depthValues", 2);
  47078. this._uniformBuffer.create();
  47079. };
  47080. /**
  47081. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47082. * @param effect The effect to update
  47083. * @param lightIndex The index of the light in the effect to update
  47084. * @returns The directional light
  47085. */
  47086. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  47087. if (this.computeTransformedInformation()) {
  47088. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  47089. return this;
  47090. }
  47091. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  47092. return this;
  47093. };
  47094. /**
  47095. * Gets the minZ used for shadow according to both the scene and the light.
  47096. *
  47097. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47098. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47099. * @param activeCamera The camera we are returning the min for
  47100. * @returns the depth min z
  47101. */
  47102. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  47103. return 1;
  47104. };
  47105. /**
  47106. * Gets the maxZ used for shadow according to both the scene and the light.
  47107. *
  47108. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47109. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47110. * @param activeCamera The camera we are returning the max for
  47111. * @returns the depth max z
  47112. */
  47113. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  47114. return 1;
  47115. };
  47116. /**
  47117. * Prepares the list of defines specific to the light type.
  47118. * @param defines the list of defines
  47119. * @param lightIndex defines the index of the light for the effect
  47120. */
  47121. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47122. defines["DIRLIGHT" + lightIndex] = true;
  47123. };
  47124. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47125. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47126. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  47127. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47128. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47129. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  47130. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47131. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47132. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  47133. return DirectionalLight;
  47134. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  47135. /***/ }),
  47136. /***/ "./Lights/hemisphericLight.ts":
  47137. /*!************************************!*\
  47138. !*** ./Lights/hemisphericLight.ts ***!
  47139. \************************************/
  47140. /*! exports provided: HemisphericLight */
  47141. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47142. "use strict";
  47143. __webpack_require__.r(__webpack_exports__);
  47144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  47145. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47146. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47147. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47148. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47149. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47150. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  47151. return function () { return new HemisphericLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  47152. });
  47153. /**
  47154. * The HemisphericLight simulates the ambient environment light,
  47155. * so the passed direction is the light reflection direction, not the incoming direction.
  47156. */
  47157. var HemisphericLight = /** @class */ (function (_super) {
  47158. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  47159. /**
  47160. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  47161. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  47162. * The HemisphericLight can't cast shadows.
  47163. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47164. * @param name The friendly name of the light
  47165. * @param direction The direction of the light reflection
  47166. * @param scene The scene the light belongs to
  47167. */
  47168. function HemisphericLight(name, direction, scene) {
  47169. var _this = _super.call(this, name, scene) || this;
  47170. /**
  47171. * The groundColor is the light in the opposite direction to the one specified during creation.
  47172. * 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.
  47173. */
  47174. _this.groundColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.0, 0.0, 0.0);
  47175. _this.direction = direction || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  47176. return _this;
  47177. }
  47178. HemisphericLight.prototype._buildUniformLayout = function () {
  47179. this._uniformBuffer.addUniform("vLightData", 4);
  47180. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47181. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47182. this._uniformBuffer.addUniform("vLightGround", 3);
  47183. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47184. this._uniformBuffer.addUniform("depthValues", 2);
  47185. this._uniformBuffer.create();
  47186. };
  47187. /**
  47188. * Returns the string "HemisphericLight".
  47189. * @return The class name
  47190. */
  47191. HemisphericLight.prototype.getClassName = function () {
  47192. return "HemisphericLight";
  47193. };
  47194. /**
  47195. * Sets the HemisphericLight direction towards the passed target (Vector3).
  47196. * Returns the updated direction.
  47197. * @param target The target the direction should point to
  47198. * @return The computed direction
  47199. */
  47200. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  47201. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  47202. return this.direction;
  47203. };
  47204. /**
  47205. * Returns the shadow generator associated to the light.
  47206. * @returns Always null for hemispheric lights because it does not support shadows.
  47207. */
  47208. HemisphericLight.prototype.getShadowGenerator = function () {
  47209. return null;
  47210. };
  47211. /**
  47212. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  47213. * @param effect The effect to update
  47214. * @param lightIndex The index of the light in the effect to update
  47215. * @returns The hemispheric light
  47216. */
  47217. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  47218. var normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  47219. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  47220. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  47221. return this;
  47222. };
  47223. /**
  47224. * Computes the world matrix of the node
  47225. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  47226. * @param useWasUpdatedFlag defines a reserved property
  47227. * @returns the world matrix
  47228. */
  47229. HemisphericLight.prototype.computeWorldMatrix = function () {
  47230. if (!this._worldMatrix) {
  47231. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  47232. }
  47233. return this._worldMatrix;
  47234. };
  47235. /**
  47236. * Returns the integer 3.
  47237. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47238. */
  47239. HemisphericLight.prototype.getTypeID = function () {
  47240. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  47241. };
  47242. /**
  47243. * Prepares the list of defines specific to the light type.
  47244. * @param defines the list of defines
  47245. * @param lightIndex defines the index of the light for the effect
  47246. */
  47247. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47248. defines["HEMILIGHT" + lightIndex] = true;
  47249. };
  47250. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47251. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  47252. ], HemisphericLight.prototype, "groundColor", void 0);
  47253. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47255. ], HemisphericLight.prototype, "direction", void 0);
  47256. return HemisphericLight;
  47257. }(_light__WEBPACK_IMPORTED_MODULE_4__["Light"]));
  47258. /***/ }),
  47259. /***/ "./Lights/index.ts":
  47260. /*!*************************!*\
  47261. !*** ./Lights/index.ts ***!
  47262. \*************************/
  47263. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  47264. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47265. "use strict";
  47266. __webpack_require__.r(__webpack_exports__);
  47267. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  47269. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  47270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  47271. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  47272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  47273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  47274. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  47275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  47276. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  47277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  47278. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  47279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  47280. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  47281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  47282. /***/ }),
  47283. /***/ "./Lights/light.ts":
  47284. /*!*************************!*\
  47285. !*** ./Lights/light.ts ***!
  47286. \*************************/
  47287. /*! exports provided: Light */
  47288. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47289. "use strict";
  47290. __webpack_require__.r(__webpack_exports__);
  47291. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  47292. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47293. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47294. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47295. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47296. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  47297. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  47298. /**
  47299. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  47300. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  47301. * 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.
  47302. */
  47303. var Light = /** @class */ (function (_super) {
  47304. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  47305. /**
  47306. * Creates a Light object in the scene.
  47307. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47308. * @param name The firendly name of the light
  47309. * @param scene The scene the light belongs too
  47310. */
  47311. function Light(name, scene) {
  47312. var _this = _super.call(this, name, scene) || this;
  47313. /**
  47314. * Diffuse gives the basic color to an object.
  47315. */
  47316. _this.diffuse = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  47317. /**
  47318. * Specular produces a highlight color on an object.
  47319. * Note: This is note affecting PBR materials.
  47320. */
  47321. _this.specular = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  47322. /**
  47323. * Defines the falloff type for this light. This lets overrriding how punctual light are
  47324. * falling off base on range or angle.
  47325. * This can be set to any values in Light.FALLOFF_x.
  47326. *
  47327. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  47328. * other types of materials.
  47329. */
  47330. _this.falloffType = Light.FALLOFF_DEFAULT;
  47331. /**
  47332. * Strength of the light.
  47333. * Note: By default it is define in the framework own unit.
  47334. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  47335. */
  47336. _this.intensity = 1.0;
  47337. _this._range = Number.MAX_VALUE;
  47338. _this._inverseSquaredRange = 0;
  47339. /**
  47340. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  47341. * of light.
  47342. */
  47343. _this._photometricScale = 1.0;
  47344. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  47345. _this._radius = 0.00001;
  47346. /**
  47347. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  47348. * exceeding the number allowed of the materials.
  47349. */
  47350. _this.renderPriority = 0;
  47351. _this._shadowEnabled = true;
  47352. _this._excludeWithLayerMask = 0;
  47353. _this._includeOnlyWithLayerMask = 0;
  47354. _this._lightmapMode = 0;
  47355. /**
  47356. * @hidden Internal use only.
  47357. */
  47358. _this._excludedMeshesIds = new Array();
  47359. /**
  47360. * @hidden Internal use only.
  47361. */
  47362. _this._includedOnlyMeshesIds = new Array();
  47363. /** @hidden */
  47364. _this._isLight = true;
  47365. _this.getScene().addLight(_this);
  47366. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__["UniformBuffer"](_this.getScene().getEngine());
  47367. _this._buildUniformLayout();
  47368. _this.includedOnlyMeshes = new Array();
  47369. _this.excludedMeshes = new Array();
  47370. _this._resyncMeshes();
  47371. return _this;
  47372. }
  47373. Object.defineProperty(Light.prototype, "range", {
  47374. /**
  47375. * Defines how far from the source the light is impacting in scene units.
  47376. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  47377. */
  47378. get: function () {
  47379. return this._range;
  47380. },
  47381. /**
  47382. * Defines how far from the source the light is impacting in scene units.
  47383. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  47384. */
  47385. set: function (value) {
  47386. this._range = value;
  47387. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  47388. },
  47389. enumerable: true,
  47390. configurable: true
  47391. });
  47392. Object.defineProperty(Light.prototype, "intensityMode", {
  47393. /**
  47394. * Gets the photometric scale used to interpret the intensity.
  47395. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  47396. */
  47397. get: function () {
  47398. return this._intensityMode;
  47399. },
  47400. /**
  47401. * Sets the photometric scale used to interpret the intensity.
  47402. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  47403. */
  47404. set: function (value) {
  47405. this._intensityMode = value;
  47406. this._computePhotometricScale();
  47407. },
  47408. enumerable: true,
  47409. configurable: true
  47410. });
  47411. Object.defineProperty(Light.prototype, "radius", {
  47412. /**
  47413. * Gets the light radius used by PBR Materials to simulate soft area lights.
  47414. */
  47415. get: function () {
  47416. return this._radius;
  47417. },
  47418. /**
  47419. * sets the light radius used by PBR Materials to simulate soft area lights.
  47420. */
  47421. set: function (value) {
  47422. this._radius = value;
  47423. this._computePhotometricScale();
  47424. },
  47425. enumerable: true,
  47426. configurable: true
  47427. });
  47428. Object.defineProperty(Light.prototype, "shadowEnabled", {
  47429. /**
  47430. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  47431. * the current shadow generator.
  47432. */
  47433. get: function () {
  47434. return this._shadowEnabled;
  47435. },
  47436. /**
  47437. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  47438. * the current shadow generator.
  47439. */
  47440. set: function (value) {
  47441. if (this._shadowEnabled === value) {
  47442. return;
  47443. }
  47444. this._shadowEnabled = value;
  47445. this._markMeshesAsLightDirty();
  47446. },
  47447. enumerable: true,
  47448. configurable: true
  47449. });
  47450. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  47451. /**
  47452. * Gets the only meshes impacted by this light.
  47453. */
  47454. get: function () {
  47455. return this._includedOnlyMeshes;
  47456. },
  47457. /**
  47458. * Sets the only meshes impacted by this light.
  47459. */
  47460. set: function (value) {
  47461. this._includedOnlyMeshes = value;
  47462. this._hookArrayForIncludedOnly(value);
  47463. },
  47464. enumerable: true,
  47465. configurable: true
  47466. });
  47467. Object.defineProperty(Light.prototype, "excludedMeshes", {
  47468. /**
  47469. * Gets the meshes not impacted by this light.
  47470. */
  47471. get: function () {
  47472. return this._excludedMeshes;
  47473. },
  47474. /**
  47475. * Sets the meshes not impacted by this light.
  47476. */
  47477. set: function (value) {
  47478. this._excludedMeshes = value;
  47479. this._hookArrayForExcluded(value);
  47480. },
  47481. enumerable: true,
  47482. configurable: true
  47483. });
  47484. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  47485. /**
  47486. * Gets the layer id use to find what meshes are not impacted by the light.
  47487. * Inactive if 0
  47488. */
  47489. get: function () {
  47490. return this._excludeWithLayerMask;
  47491. },
  47492. /**
  47493. * Sets the layer id use to find what meshes are not impacted by the light.
  47494. * Inactive if 0
  47495. */
  47496. set: function (value) {
  47497. this._excludeWithLayerMask = value;
  47498. this._resyncMeshes();
  47499. },
  47500. enumerable: true,
  47501. configurable: true
  47502. });
  47503. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  47504. /**
  47505. * Gets the layer id use to find what meshes are impacted by the light.
  47506. * Inactive if 0
  47507. */
  47508. get: function () {
  47509. return this._includeOnlyWithLayerMask;
  47510. },
  47511. /**
  47512. * Sets the layer id use to find what meshes are impacted by the light.
  47513. * Inactive if 0
  47514. */
  47515. set: function (value) {
  47516. this._includeOnlyWithLayerMask = value;
  47517. this._resyncMeshes();
  47518. },
  47519. enumerable: true,
  47520. configurable: true
  47521. });
  47522. Object.defineProperty(Light.prototype, "lightmapMode", {
  47523. /**
  47524. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  47525. */
  47526. get: function () {
  47527. return this._lightmapMode;
  47528. },
  47529. /**
  47530. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  47531. */
  47532. set: function (value) {
  47533. if (this._lightmapMode === value) {
  47534. return;
  47535. }
  47536. this._lightmapMode = value;
  47537. this._markMeshesAsLightDirty();
  47538. },
  47539. enumerable: true,
  47540. configurable: true
  47541. });
  47542. /**
  47543. * Returns the string "Light".
  47544. * @returns the class name
  47545. */
  47546. Light.prototype.getClassName = function () {
  47547. return "Light";
  47548. };
  47549. /**
  47550. * Converts the light information to a readable string for debug purpose.
  47551. * @param fullDetails Supports for multiple levels of logging within scene loading
  47552. * @returns the human readable light info
  47553. */
  47554. Light.prototype.toString = function (fullDetails) {
  47555. var ret = "Name: " + this.name;
  47556. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  47557. if (this.animations) {
  47558. for (var i = 0; i < this.animations.length; i++) {
  47559. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  47560. }
  47561. }
  47562. if (fullDetails) {
  47563. }
  47564. return ret;
  47565. };
  47566. /** @hidden */
  47567. Light.prototype._syncParentEnabledState = function () {
  47568. _super.prototype._syncParentEnabledState.call(this);
  47569. this._resyncMeshes();
  47570. };
  47571. /**
  47572. * Set the enabled state of this node.
  47573. * @param value - the new enabled state
  47574. */
  47575. Light.prototype.setEnabled = function (value) {
  47576. _super.prototype.setEnabled.call(this, value);
  47577. this._resyncMeshes();
  47578. };
  47579. /**
  47580. * Returns the Light associated shadow generator if any.
  47581. * @return the associated shadow generator.
  47582. */
  47583. Light.prototype.getShadowGenerator = function () {
  47584. return this._shadowGenerator;
  47585. };
  47586. /**
  47587. * Returns a Vector3, the absolute light position in the World.
  47588. * @returns the world space position of the light
  47589. */
  47590. Light.prototype.getAbsolutePosition = function () {
  47591. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47592. };
  47593. /**
  47594. * Specifies if the light will affect the passed mesh.
  47595. * @param mesh The mesh to test against the light
  47596. * @return true the mesh is affected otherwise, false.
  47597. */
  47598. Light.prototype.canAffectMesh = function (mesh) {
  47599. if (!mesh) {
  47600. return true;
  47601. }
  47602. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  47603. return false;
  47604. }
  47605. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  47606. return false;
  47607. }
  47608. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  47609. return false;
  47610. }
  47611. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  47612. return false;
  47613. }
  47614. return true;
  47615. };
  47616. /**
  47617. * Sort function to order lights for rendering.
  47618. * @param a First Light object to compare to second.
  47619. * @param b Second Light object to compare first.
  47620. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  47621. */
  47622. Light.CompareLightsPriority = function (a, b) {
  47623. //shadow-casting lights have priority over non-shadow-casting lights
  47624. //the renderPrioirty is a secondary sort criterion
  47625. if (a.shadowEnabled !== b.shadowEnabled) {
  47626. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  47627. }
  47628. return b.renderPriority - a.renderPriority;
  47629. };
  47630. /**
  47631. * Releases resources associated with this node.
  47632. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47633. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47634. */
  47635. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  47636. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  47637. if (this._shadowGenerator) {
  47638. this._shadowGenerator.dispose();
  47639. this._shadowGenerator = null;
  47640. }
  47641. // Animations
  47642. this.getScene().stopAnimation(this);
  47643. // Remove from meshes
  47644. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47645. var mesh = _a[_i];
  47646. mesh._removeLightSource(this);
  47647. }
  47648. this._uniformBuffer.dispose();
  47649. // Remove from scene
  47650. this.getScene().removeLight(this);
  47651. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  47652. };
  47653. /**
  47654. * Returns the light type ID (integer).
  47655. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47656. */
  47657. Light.prototype.getTypeID = function () {
  47658. return 0;
  47659. };
  47660. /**
  47661. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  47662. * @returns the scaled intensity in intensity mode unit
  47663. */
  47664. Light.prototype.getScaledIntensity = function () {
  47665. return this._photometricScale * this.intensity;
  47666. };
  47667. /**
  47668. * Returns a new Light object, named "name", from the current one.
  47669. * @param name The name of the cloned light
  47670. * @returns the new created light
  47671. */
  47672. Light.prototype.clone = function (name) {
  47673. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  47674. if (!constructor) {
  47675. return null;
  47676. }
  47677. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  47678. };
  47679. /**
  47680. * Serializes the current light into a Serialization object.
  47681. * @returns the serialized object.
  47682. */
  47683. Light.prototype.serialize = function () {
  47684. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  47685. // Type
  47686. serializationObject.type = this.getTypeID();
  47687. // Parent
  47688. if (this.parent) {
  47689. serializationObject.parentId = this.parent.id;
  47690. }
  47691. // Inclusion / exclusions
  47692. if (this.excludedMeshes.length > 0) {
  47693. serializationObject.excludedMeshesIds = [];
  47694. this.excludedMeshes.forEach(function (mesh) {
  47695. serializationObject.excludedMeshesIds.push(mesh.id);
  47696. });
  47697. }
  47698. if (this.includedOnlyMeshes.length > 0) {
  47699. serializationObject.includedOnlyMeshesIds = [];
  47700. this.includedOnlyMeshes.forEach(function (mesh) {
  47701. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  47702. });
  47703. }
  47704. // Animations
  47705. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  47706. serializationObject.ranges = this.serializeAnimationRanges();
  47707. return serializationObject;
  47708. };
  47709. /**
  47710. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  47711. * This new light is named "name" and added to the passed scene.
  47712. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  47713. * @param name The friendly name of the light
  47714. * @param scene The scene the new light will belong to
  47715. * @returns the constructor function
  47716. */
  47717. Light.GetConstructorFromName = function (type, name, scene) {
  47718. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_3__["Node"].Construct("Light_Type_" + type, name, scene);
  47719. if (constructorFunc) {
  47720. return constructorFunc;
  47721. }
  47722. // Default to no light for none present once.
  47723. return null;
  47724. };
  47725. /**
  47726. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  47727. * @param parsedLight The JSON representation of the light
  47728. * @param scene The scene to create the parsed light in
  47729. * @returns the created light after parsing
  47730. */
  47731. Light.Parse = function (parsedLight, scene) {
  47732. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  47733. if (!constructor) {
  47734. return null;
  47735. }
  47736. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  47737. // Inclusion / exclusions
  47738. if (parsedLight.excludedMeshesIds) {
  47739. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  47740. }
  47741. if (parsedLight.includedOnlyMeshesIds) {
  47742. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  47743. }
  47744. // Parent
  47745. if (parsedLight.parentId) {
  47746. light._waitingParentId = parsedLight.parentId;
  47747. }
  47748. // Animations
  47749. if (parsedLight.animations) {
  47750. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  47751. var parsedAnimation = parsedLight.animations[animationIndex];
  47752. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  47753. if (internalClass) {
  47754. light.animations.push(internalClass.Parse(parsedAnimation));
  47755. }
  47756. }
  47757. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  47758. }
  47759. if (parsedLight.autoAnimate) {
  47760. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  47761. }
  47762. return light;
  47763. };
  47764. Light.prototype._hookArrayForExcluded = function (array) {
  47765. var _this = this;
  47766. var oldPush = array.push;
  47767. array.push = function () {
  47768. var items = [];
  47769. for (var _i = 0; _i < arguments.length; _i++) {
  47770. items[_i] = arguments[_i];
  47771. }
  47772. var result = oldPush.apply(array, items);
  47773. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  47774. var item = items_1[_a];
  47775. item._resyncLighSource(_this);
  47776. }
  47777. return result;
  47778. };
  47779. var oldSplice = array.splice;
  47780. array.splice = function (index, deleteCount) {
  47781. var deleted = oldSplice.apply(array, [index, deleteCount]);
  47782. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  47783. var item = deleted_1[_i];
  47784. item._resyncLighSource(_this);
  47785. }
  47786. return deleted;
  47787. };
  47788. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  47789. var item = array_1[_i];
  47790. item._resyncLighSource(this);
  47791. }
  47792. };
  47793. Light.prototype._hookArrayForIncludedOnly = function (array) {
  47794. var _this = this;
  47795. var oldPush = array.push;
  47796. array.push = function () {
  47797. var items = [];
  47798. for (var _i = 0; _i < arguments.length; _i++) {
  47799. items[_i] = arguments[_i];
  47800. }
  47801. var result = oldPush.apply(array, items);
  47802. _this._resyncMeshes();
  47803. return result;
  47804. };
  47805. var oldSplice = array.splice;
  47806. array.splice = function (index, deleteCount) {
  47807. var deleted = oldSplice.apply(array, [index, deleteCount]);
  47808. _this._resyncMeshes();
  47809. return deleted;
  47810. };
  47811. this._resyncMeshes();
  47812. };
  47813. Light.prototype._resyncMeshes = function () {
  47814. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47815. var mesh = _a[_i];
  47816. mesh._resyncLighSource(this);
  47817. }
  47818. };
  47819. /**
  47820. * Forces the meshes to update their light related information in their rendering used effects
  47821. * @hidden Internal Use Only
  47822. */
  47823. Light.prototype._markMeshesAsLightDirty = function () {
  47824. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  47825. var mesh = _a[_i];
  47826. if (mesh._lightSources.indexOf(this) !== -1) {
  47827. mesh._markSubMeshesAsLightDirty();
  47828. }
  47829. }
  47830. };
  47831. /**
  47832. * Recomputes the cached photometric scale if needed.
  47833. */
  47834. Light.prototype._computePhotometricScale = function () {
  47835. this._photometricScale = this._getPhotometricScale();
  47836. this.getScene().resetCachedMaterial();
  47837. };
  47838. /**
  47839. * Returns the Photometric Scale according to the light type and intensity mode.
  47840. */
  47841. Light.prototype._getPhotometricScale = function () {
  47842. var photometricScale = 0.0;
  47843. var lightTypeID = this.getTypeID();
  47844. //get photometric mode
  47845. var photometricMode = this.intensityMode;
  47846. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  47847. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  47848. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  47849. }
  47850. else {
  47851. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  47852. }
  47853. }
  47854. //compute photometric scale
  47855. switch (lightTypeID) {
  47856. case Light.LIGHTTYPEID_POINTLIGHT:
  47857. case Light.LIGHTTYPEID_SPOTLIGHT:
  47858. switch (photometricMode) {
  47859. case Light.INTENSITYMODE_LUMINOUSPOWER:
  47860. photometricScale = 1.0 / (4.0 * Math.PI);
  47861. break;
  47862. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  47863. photometricScale = 1.0;
  47864. break;
  47865. case Light.INTENSITYMODE_LUMINANCE:
  47866. photometricScale = this.radius * this.radius;
  47867. break;
  47868. }
  47869. break;
  47870. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  47871. switch (photometricMode) {
  47872. case Light.INTENSITYMODE_ILLUMINANCE:
  47873. photometricScale = 1.0;
  47874. break;
  47875. case Light.INTENSITYMODE_LUMINANCE:
  47876. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  47877. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  47878. var apexAngleRadians = this.radius;
  47879. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  47880. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  47881. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  47882. photometricScale = solidAngle;
  47883. break;
  47884. }
  47885. break;
  47886. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  47887. // No fall off in hemisperic light.
  47888. photometricScale = 1.0;
  47889. break;
  47890. }
  47891. return photometricScale;
  47892. };
  47893. /**
  47894. * Reorder the light in the scene according to their defined priority.
  47895. * @hidden Internal Use Only
  47896. */
  47897. Light.prototype._reorderLightsInScene = function () {
  47898. var scene = this.getScene();
  47899. if (this._renderPriority != 0) {
  47900. scene.requireLightSorting = true;
  47901. }
  47902. this.getScene().sortLightsByPriority();
  47903. };
  47904. /**
  47905. * Falloff Default: light is falling off following the material specification:
  47906. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  47907. */
  47908. Light.FALLOFF_DEFAULT = 0;
  47909. /**
  47910. * Falloff Physical: light is falling off following the inverse squared distance law.
  47911. */
  47912. Light.FALLOFF_PHYSICAL = 1;
  47913. /**
  47914. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  47915. * to enhance interoperability with other engines.
  47916. */
  47917. Light.FALLOFF_GLTF = 2;
  47918. /**
  47919. * Falloff Standard: light is falling off like in the standard material
  47920. * to enhance interoperability with other materials.
  47921. */
  47922. Light.FALLOFF_STANDARD = 3;
  47923. //lightmapMode Consts
  47924. /**
  47925. * If every light affecting the material is in this lightmapMode,
  47926. * material.lightmapTexture adds or multiplies
  47927. * (depends on material.useLightmapAsShadowmap)
  47928. * after every other light calculations.
  47929. */
  47930. Light.LIGHTMAP_DEFAULT = 0;
  47931. /**
  47932. * material.lightmapTexture as only diffuse lighting from this light
  47933. * adds only specular lighting from this light
  47934. * adds dynamic shadows
  47935. */
  47936. Light.LIGHTMAP_SPECULAR = 1;
  47937. /**
  47938. * material.lightmapTexture as only lighting
  47939. * no light calculation from this light
  47940. * only adds dynamic shadows from this light
  47941. */
  47942. Light.LIGHTMAP_SHADOWSONLY = 2;
  47943. // Intensity Mode Consts
  47944. /**
  47945. * Each light type uses the default quantity according to its type:
  47946. * point/spot lights use luminous intensity
  47947. * directional lights use illuminance
  47948. */
  47949. Light.INTENSITYMODE_AUTOMATIC = 0;
  47950. /**
  47951. * lumen (lm)
  47952. */
  47953. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  47954. /**
  47955. * candela (lm/sr)
  47956. */
  47957. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  47958. /**
  47959. * lux (lm/m^2)
  47960. */
  47961. Light.INTENSITYMODE_ILLUMINANCE = 3;
  47962. /**
  47963. * nit (cd/m^2)
  47964. */
  47965. Light.INTENSITYMODE_LUMINANCE = 4;
  47966. // Light types ids const.
  47967. /**
  47968. * Light type const id of the point light.
  47969. */
  47970. Light.LIGHTTYPEID_POINTLIGHT = 0;
  47971. /**
  47972. * Light type const id of the directional light.
  47973. */
  47974. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  47975. /**
  47976. * Light type const id of the spot light.
  47977. */
  47978. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  47979. /**
  47980. * Light type const id of the hemispheric light.
  47981. */
  47982. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  47983. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47984. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  47985. ], Light.prototype, "diffuse", void 0);
  47986. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47987. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  47988. ], Light.prototype, "specular", void 0);
  47989. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47990. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47991. ], Light.prototype, "falloffType", void 0);
  47992. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47993. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47994. ], Light.prototype, "intensity", void 0);
  47995. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47996. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47997. ], Light.prototype, "range", null);
  47998. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47999. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48000. ], Light.prototype, "intensityMode", null);
  48001. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48002. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48003. ], Light.prototype, "radius", null);
  48004. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48005. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48006. ], Light.prototype, "_renderPriority", void 0);
  48007. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48008. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  48009. ], Light.prototype, "renderPriority", void 0);
  48010. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48011. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  48012. ], Light.prototype, "_shadowEnabled", void 0);
  48013. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48014. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  48015. ], Light.prototype, "_excludeWithLayerMask", void 0);
  48016. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48017. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  48018. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  48019. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48020. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  48021. ], Light.prototype, "_lightmapMode", void 0);
  48022. return Light;
  48023. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  48024. /***/ }),
  48025. /***/ "./Lights/pointLight.ts":
  48026. /*!******************************!*\
  48027. !*** ./Lights/pointLight.ts ***!
  48028. \******************************/
  48029. /*! exports provided: PointLight */
  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__, "PointLight", function() { return PointLight; });
  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_0", function (name, scene) {
  48041. return function () { return new PointLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  48042. });
  48043. /**
  48044. * A point light is a light defined by an unique point in world space.
  48045. * The light is emitted in every direction from this point.
  48046. * A good example of a point light is a standard light bulb.
  48047. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48048. */
  48049. var PointLight = /** @class */ (function (_super) {
  48050. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  48051. /**
  48052. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48053. * A PointLight emits the light in every direction.
  48054. * It can cast shadows.
  48055. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48056. * ```javascript
  48057. * var pointLight = new PointLight("pl", camera.position, scene);
  48058. * ```
  48059. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48060. * @param name The light friendly name
  48061. * @param position The position of the point light in the scene
  48062. * @param scene The scene the lights belongs to
  48063. */
  48064. function PointLight(name, position, scene) {
  48065. var _this = _super.call(this, name, scene) || this;
  48066. _this._shadowAngle = Math.PI / 2;
  48067. _this.position = position;
  48068. return _this;
  48069. }
  48070. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  48071. /**
  48072. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48073. * This specifies what angle the shadow will use to be created.
  48074. *
  48075. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48076. */
  48077. get: function () {
  48078. return this._shadowAngle;
  48079. },
  48080. /**
  48081. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48082. * This specifies what angle the shadow will use to be created.
  48083. *
  48084. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48085. */
  48086. set: function (value) {
  48087. this._shadowAngle = value;
  48088. this.forceProjectionMatrixCompute();
  48089. },
  48090. enumerable: true,
  48091. configurable: true
  48092. });
  48093. Object.defineProperty(PointLight.prototype, "direction", {
  48094. /**
  48095. * Gets the direction if it has been set.
  48096. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48097. */
  48098. get: function () {
  48099. return this._direction;
  48100. },
  48101. /**
  48102. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48103. */
  48104. set: function (value) {
  48105. var previousNeedCube = this.needCube();
  48106. this._direction = value;
  48107. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  48108. this._shadowGenerator.recreateShadowMap();
  48109. }
  48110. },
  48111. enumerable: true,
  48112. configurable: true
  48113. });
  48114. /**
  48115. * Returns the string "PointLight"
  48116. * @returns the class name
  48117. */
  48118. PointLight.prototype.getClassName = function () {
  48119. return "PointLight";
  48120. };
  48121. /**
  48122. * Returns the integer 0.
  48123. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48124. */
  48125. PointLight.prototype.getTypeID = function () {
  48126. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  48127. };
  48128. /**
  48129. * Specifies wether or not the shadowmap should be a cube texture.
  48130. * @returns true if the shadowmap needs to be a cube texture.
  48131. */
  48132. PointLight.prototype.needCube = function () {
  48133. return !this.direction;
  48134. };
  48135. /**
  48136. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48137. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48138. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48139. */
  48140. PointLight.prototype.getShadowDirection = function (faceIndex) {
  48141. if (this.direction) {
  48142. return _super.prototype.getShadowDirection.call(this, faceIndex);
  48143. }
  48144. else {
  48145. switch (faceIndex) {
  48146. case 0:
  48147. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  48148. case 1:
  48149. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  48150. case 2:
  48151. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  48152. case 3:
  48153. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  48154. case 4:
  48155. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  48156. case 5:
  48157. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  48158. }
  48159. }
  48160. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48161. };
  48162. /**
  48163. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48164. * - fov = PI / 2
  48165. * - aspect ratio : 1.0
  48166. * - z-near and far equal to the active camera minZ and maxZ.
  48167. * Returns the PointLight.
  48168. */
  48169. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48170. var activeCamera = this.getScene().activeCamera;
  48171. if (!activeCamera) {
  48172. return;
  48173. }
  48174. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  48175. };
  48176. PointLight.prototype._buildUniformLayout = function () {
  48177. this._uniformBuffer.addUniform("vLightData", 4);
  48178. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  48179. this._uniformBuffer.addUniform("vLightSpecular", 3);
  48180. this._uniformBuffer.addUniform("vLightFalloff", 4);
  48181. this._uniformBuffer.addUniform("shadowsInfo", 3);
  48182. this._uniformBuffer.addUniform("depthValues", 2);
  48183. this._uniformBuffer.create();
  48184. };
  48185. /**
  48186. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48187. * @param effect The effect to update
  48188. * @param lightIndex The index of the light in the effect to update
  48189. * @returns The point light
  48190. */
  48191. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  48192. if (this.computeTransformedInformation()) {
  48193. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  48194. }
  48195. else {
  48196. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  48197. }
  48198. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  48199. return this;
  48200. };
  48201. /**
  48202. * Prepares the list of defines specific to the light type.
  48203. * @param defines the list of defines
  48204. * @param lightIndex defines the index of the light for the effect
  48205. */
  48206. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  48207. defines["POINTLIGHT" + lightIndex] = true;
  48208. };
  48209. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48210. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48211. ], PointLight.prototype, "shadowAngle", null);
  48212. return PointLight;
  48213. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  48214. /***/ }),
  48215. /***/ "./Lights/shadowLight.ts":
  48216. /*!*******************************!*\
  48217. !*** ./Lights/shadowLight.ts ***!
  48218. \*******************************/
  48219. /*! exports provided: ShadowLight */
  48220. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48221. "use strict";
  48222. __webpack_require__.r(__webpack_exports__);
  48223. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  48224. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48225. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  48226. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  48227. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  48228. /**
  48229. * Base implementation IShadowLight
  48230. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  48231. */
  48232. var ShadowLight = /** @class */ (function (_super) {
  48233. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  48234. function ShadowLight() {
  48235. var _this = _super !== null && _super.apply(this, arguments) || this;
  48236. _this._needProjectionMatrixCompute = true;
  48237. return _this;
  48238. }
  48239. ShadowLight.prototype._setPosition = function (value) {
  48240. this._position = value;
  48241. };
  48242. Object.defineProperty(ShadowLight.prototype, "position", {
  48243. /**
  48244. * Sets the position the shadow will be casted from. Also use as the light position for both
  48245. * point and spot lights.
  48246. */
  48247. get: function () {
  48248. return this._position;
  48249. },
  48250. /**
  48251. * Sets the position the shadow will be casted from. Also use as the light position for both
  48252. * point and spot lights.
  48253. */
  48254. set: function (value) {
  48255. this._setPosition(value);
  48256. },
  48257. enumerable: true,
  48258. configurable: true
  48259. });
  48260. ShadowLight.prototype._setDirection = function (value) {
  48261. this._direction = value;
  48262. };
  48263. Object.defineProperty(ShadowLight.prototype, "direction", {
  48264. /**
  48265. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  48266. * Also use as the light direction on spot and directional lights.
  48267. */
  48268. get: function () {
  48269. return this._direction;
  48270. },
  48271. /**
  48272. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  48273. * Also use as the light direction on spot and directional lights.
  48274. */
  48275. set: function (value) {
  48276. this._setDirection(value);
  48277. },
  48278. enumerable: true,
  48279. configurable: true
  48280. });
  48281. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  48282. /**
  48283. * Gets the shadow projection clipping minimum z value.
  48284. */
  48285. get: function () {
  48286. return this._shadowMinZ;
  48287. },
  48288. /**
  48289. * Sets the shadow projection clipping minimum z value.
  48290. */
  48291. set: function (value) {
  48292. this._shadowMinZ = value;
  48293. this.forceProjectionMatrixCompute();
  48294. },
  48295. enumerable: true,
  48296. configurable: true
  48297. });
  48298. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  48299. /**
  48300. * Sets the shadow projection clipping maximum z value.
  48301. */
  48302. get: function () {
  48303. return this._shadowMaxZ;
  48304. },
  48305. /**
  48306. * Gets the shadow projection clipping maximum z value.
  48307. */
  48308. set: function (value) {
  48309. this._shadowMaxZ = value;
  48310. this.forceProjectionMatrixCompute();
  48311. },
  48312. enumerable: true,
  48313. configurable: true
  48314. });
  48315. /**
  48316. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  48317. * @returns true if the information has been computed, false if it does not need to (no parenting)
  48318. */
  48319. ShadowLight.prototype.computeTransformedInformation = function () {
  48320. if (this.parent && this.parent.getWorldMatrix) {
  48321. if (!this.transformedPosition) {
  48322. this.transformedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48323. }
  48324. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  48325. // In case the direction is present.
  48326. if (this.direction) {
  48327. if (!this.transformedDirection) {
  48328. this.transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48329. }
  48330. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  48331. }
  48332. return true;
  48333. }
  48334. return false;
  48335. };
  48336. /**
  48337. * Return the depth scale used for the shadow map.
  48338. * @returns the depth scale.
  48339. */
  48340. ShadowLight.prototype.getDepthScale = function () {
  48341. return 50.0;
  48342. };
  48343. /**
  48344. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  48345. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48346. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48347. */
  48348. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  48349. return this.transformedDirection ? this.transformedDirection : this.direction;
  48350. };
  48351. /**
  48352. * Returns the ShadowLight absolute position in the World.
  48353. * @returns the position vector in world space
  48354. */
  48355. ShadowLight.prototype.getAbsolutePosition = function () {
  48356. return this.transformedPosition ? this.transformedPosition : this.position;
  48357. };
  48358. /**
  48359. * Sets the ShadowLight direction toward the passed target.
  48360. * @param target The point to target in local space
  48361. * @returns the updated ShadowLight direction
  48362. */
  48363. ShadowLight.prototype.setDirectionToTarget = function (target) {
  48364. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  48365. return this.direction;
  48366. };
  48367. /**
  48368. * Returns the light rotation in euler definition.
  48369. * @returns the x y z rotation in local space.
  48370. */
  48371. ShadowLight.prototype.getRotation = function () {
  48372. this.direction.normalize();
  48373. var xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y);
  48374. var yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  48375. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  48376. };
  48377. /**
  48378. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  48379. * @returns true if a cube texture needs to be use
  48380. */
  48381. ShadowLight.prototype.needCube = function () {
  48382. return false;
  48383. };
  48384. /**
  48385. * Detects if the projection matrix requires to be recomputed this frame.
  48386. * @returns true if it requires to be recomputed otherwise, false.
  48387. */
  48388. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  48389. return this._needProjectionMatrixCompute;
  48390. };
  48391. /**
  48392. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  48393. */
  48394. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  48395. this._needProjectionMatrixCompute = true;
  48396. };
  48397. /** @hidden */
  48398. ShadowLight.prototype._initCache = function () {
  48399. _super.prototype._initCache.call(this);
  48400. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48401. };
  48402. /** @hidden */
  48403. ShadowLight.prototype._isSynchronized = function () {
  48404. if (!this._cache.position.equals(this.position)) {
  48405. return false;
  48406. }
  48407. return true;
  48408. };
  48409. /**
  48410. * Computes the world matrix of the node
  48411. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  48412. * @returns the world matrix
  48413. */
  48414. ShadowLight.prototype.computeWorldMatrix = function (force) {
  48415. if (!force && this.isSynchronized()) {
  48416. this._currentRenderId = this.getScene().getRenderId();
  48417. return this._worldMatrix;
  48418. }
  48419. this._updateCache();
  48420. this._cache.position.copyFrom(this.position);
  48421. if (!this._worldMatrix) {
  48422. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  48423. }
  48424. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  48425. if (this.parent && this.parent.getWorldMatrix) {
  48426. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  48427. this._markSyncedWithParent();
  48428. }
  48429. // Cache the determinant
  48430. this._worldMatrixDeterminantIsDirty = true;
  48431. return this._worldMatrix;
  48432. };
  48433. /**
  48434. * Gets the minZ used for shadow according to both the scene and the light.
  48435. * @param activeCamera The camera we are returning the min for
  48436. * @returns the depth min z
  48437. */
  48438. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  48439. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  48440. };
  48441. /**
  48442. * Gets the maxZ used for shadow according to both the scene and the light.
  48443. * @param activeCamera The camera we are returning the max for
  48444. * @returns the depth max z
  48445. */
  48446. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  48447. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  48448. };
  48449. /**
  48450. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  48451. * @param matrix The materix to updated with the projection information
  48452. * @param viewMatrix The transform matrix of the light
  48453. * @param renderList The list of mesh to render in the map
  48454. * @returns The current light
  48455. */
  48456. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48457. if (this.customProjectionMatrixBuilder) {
  48458. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  48459. }
  48460. else {
  48461. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  48462. }
  48463. return this;
  48464. };
  48465. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48466. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  48467. ], ShadowLight.prototype, "position", null);
  48468. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48469. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  48470. ], ShadowLight.prototype, "direction", null);
  48471. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48472. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48473. ], ShadowLight.prototype, "shadowMinZ", null);
  48474. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48475. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48476. ], ShadowLight.prototype, "shadowMaxZ", null);
  48477. return ShadowLight;
  48478. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  48479. /***/ }),
  48480. /***/ "./Lights/spotLight.ts":
  48481. /*!*****************************!*\
  48482. !*** ./Lights/spotLight.ts ***!
  48483. \*****************************/
  48484. /*! exports provided: SpotLight */
  48485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48486. "use strict";
  48487. __webpack_require__.r(__webpack_exports__);
  48488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  48489. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  48490. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  48491. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  48492. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  48493. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  48494. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  48495. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  48496. 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); };
  48497. });
  48498. /**
  48499. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48500. * These values define a cone of light starting from the position, emitting toward the direction.
  48501. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48502. * and the exponent defines the speed of the decay of the light with distance (reach).
  48503. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48504. */
  48505. var SpotLight = /** @class */ (function (_super) {
  48506. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  48507. /**
  48508. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48509. * It can cast shadows.
  48510. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48511. * @param name The light friendly name
  48512. * @param position The position of the spot light in the scene
  48513. * @param direction The direction of the light in the scene
  48514. * @param angle The cone angle of the light in Radians
  48515. * @param exponent The light decay speed with the distance from the emission spot
  48516. * @param scene The scene the lights belongs to
  48517. */
  48518. function SpotLight(name, position, direction, angle, exponent, scene) {
  48519. var _this = _super.call(this, name, scene) || this;
  48520. _this._innerAngle = 0;
  48521. _this._projectionTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  48522. _this._projectionTextureLightNear = 1e-6;
  48523. _this._projectionTextureLightFar = 1000.0;
  48524. _this._projectionTextureUpDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  48525. _this._projectionTextureViewLightDirty = true;
  48526. _this._projectionTextureProjectionLightDirty = true;
  48527. _this._projectionTextureDirty = true;
  48528. _this._projectionTextureViewTargetVector = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  48529. _this._projectionTextureViewLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  48530. _this._projectionTextureProjectionLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  48531. _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);
  48532. _this.position = position;
  48533. _this.direction = direction;
  48534. _this.angle = angle;
  48535. _this.exponent = exponent;
  48536. return _this;
  48537. }
  48538. Object.defineProperty(SpotLight.prototype, "angle", {
  48539. /**
  48540. * Gets the cone angle of the spot light in Radians.
  48541. */
  48542. get: function () {
  48543. return this._angle;
  48544. },
  48545. /**
  48546. * Sets the cone angle of the spot light in Radians.
  48547. */
  48548. set: function (value) {
  48549. this._angle = value;
  48550. this._cosHalfAngle = Math.cos(value * 0.5);
  48551. this._projectionTextureProjectionLightDirty = true;
  48552. this.forceProjectionMatrixCompute();
  48553. this._computeAngleValues();
  48554. },
  48555. enumerable: true,
  48556. configurable: true
  48557. });
  48558. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  48559. /**
  48560. * Only used in gltf falloff mode, this defines the angle where
  48561. * the directional falloff will start before cutting at angle which could be seen
  48562. * as outer angle.
  48563. */
  48564. get: function () {
  48565. return this._innerAngle;
  48566. },
  48567. /**
  48568. * Only used in gltf falloff mode, this defines the angle where
  48569. * the directional falloff will start before cutting at angle which could be seen
  48570. * as outer angle.
  48571. */
  48572. set: function (value) {
  48573. this._innerAngle = value;
  48574. this._computeAngleValues();
  48575. },
  48576. enumerable: true,
  48577. configurable: true
  48578. });
  48579. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  48580. /**
  48581. * Allows scaling the angle of the light for shadow generation only.
  48582. */
  48583. get: function () {
  48584. return this._shadowAngleScale;
  48585. },
  48586. /**
  48587. * Allows scaling the angle of the light for shadow generation only.
  48588. */
  48589. set: function (value) {
  48590. this._shadowAngleScale = value;
  48591. this.forceProjectionMatrixCompute();
  48592. },
  48593. enumerable: true,
  48594. configurable: true
  48595. });
  48596. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  48597. /**
  48598. * Allows reading the projecton texture
  48599. */
  48600. get: function () {
  48601. return this._projectionTextureMatrix;
  48602. },
  48603. enumerable: true,
  48604. configurable: true
  48605. });
  48606. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  48607. /**
  48608. * Gets the near clip of the Spotlight for texture projection.
  48609. */
  48610. get: function () {
  48611. return this._projectionTextureLightNear;
  48612. },
  48613. /**
  48614. * Sets the near clip of the Spotlight for texture projection.
  48615. */
  48616. set: function (value) {
  48617. this._projectionTextureLightNear = value;
  48618. this._projectionTextureProjectionLightDirty = true;
  48619. },
  48620. enumerable: true,
  48621. configurable: true
  48622. });
  48623. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  48624. /**
  48625. * Gets the far clip of the Spotlight for texture projection.
  48626. */
  48627. get: function () {
  48628. return this._projectionTextureLightFar;
  48629. },
  48630. /**
  48631. * Sets the far clip of the Spotlight for texture projection.
  48632. */
  48633. set: function (value) {
  48634. this._projectionTextureLightFar = value;
  48635. this._projectionTextureProjectionLightDirty = true;
  48636. },
  48637. enumerable: true,
  48638. configurable: true
  48639. });
  48640. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  48641. /**
  48642. * Gets the Up vector of the Spotlight for texture projection.
  48643. */
  48644. get: function () {
  48645. return this._projectionTextureUpDirection;
  48646. },
  48647. /**
  48648. * Sets the Up vector of the Spotlight for texture projection.
  48649. */
  48650. set: function (value) {
  48651. this._projectionTextureUpDirection = value;
  48652. this._projectionTextureProjectionLightDirty = true;
  48653. },
  48654. enumerable: true,
  48655. configurable: true
  48656. });
  48657. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  48658. /**
  48659. * Gets the projection texture of the light.
  48660. */
  48661. get: function () {
  48662. return this._projectionTexture;
  48663. },
  48664. /**
  48665. * Sets the projection texture of the light.
  48666. */
  48667. set: function (value) {
  48668. this._projectionTexture = value;
  48669. this._projectionTextureDirty = true;
  48670. },
  48671. enumerable: true,
  48672. configurable: true
  48673. });
  48674. /**
  48675. * Returns the string "SpotLight".
  48676. * @returns the class name
  48677. */
  48678. SpotLight.prototype.getClassName = function () {
  48679. return "SpotLight";
  48680. };
  48681. /**
  48682. * Returns the integer 2.
  48683. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48684. */
  48685. SpotLight.prototype.getTypeID = function () {
  48686. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  48687. };
  48688. /**
  48689. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48690. */
  48691. SpotLight.prototype._setDirection = function (value) {
  48692. _super.prototype._setDirection.call(this, value);
  48693. this._projectionTextureViewLightDirty = true;
  48694. };
  48695. /**
  48696. * Overrides the position setter to recompute the projection texture view light Matrix.
  48697. */
  48698. SpotLight.prototype._setPosition = function (value) {
  48699. _super.prototype._setPosition.call(this, value);
  48700. this._projectionTextureViewLightDirty = true;
  48701. };
  48702. /**
  48703. * 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.
  48704. * Returns the SpotLight.
  48705. */
  48706. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  48707. var activeCamera = this.getScene().activeCamera;
  48708. if (!activeCamera) {
  48709. return;
  48710. }
  48711. this._shadowAngleScale = this._shadowAngleScale || 1;
  48712. var angle = this._shadowAngleScale * this._angle;
  48713. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  48714. };
  48715. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  48716. this._projectionTextureViewLightDirty = false;
  48717. this._projectionTextureDirty = true;
  48718. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  48719. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  48720. };
  48721. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  48722. this._projectionTextureProjectionLightDirty = false;
  48723. this._projectionTextureDirty = true;
  48724. var light_far = this.projectionTextureLightFar;
  48725. var light_near = this.projectionTextureLightNear;
  48726. var P = light_far / (light_far - light_near);
  48727. var Q = -P * light_near;
  48728. var S = 1.0 / Math.tan(this._angle / 2.0);
  48729. var A = 1.0;
  48730. _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);
  48731. };
  48732. /**
  48733. * Main function for light texture projection matrix computing.
  48734. */
  48735. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  48736. this._projectionTextureDirty = false;
  48737. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  48738. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  48739. };
  48740. SpotLight.prototype._buildUniformLayout = function () {
  48741. this._uniformBuffer.addUniform("vLightData", 4);
  48742. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  48743. this._uniformBuffer.addUniform("vLightSpecular", 3);
  48744. this._uniformBuffer.addUniform("vLightDirection", 3);
  48745. this._uniformBuffer.addUniform("vLightFalloff", 4);
  48746. this._uniformBuffer.addUniform("shadowsInfo", 3);
  48747. this._uniformBuffer.addUniform("depthValues", 2);
  48748. this._uniformBuffer.create();
  48749. };
  48750. SpotLight.prototype._computeAngleValues = function () {
  48751. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  48752. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  48753. };
  48754. /**
  48755. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48756. * @param effect The effect to update
  48757. * @param lightIndex The index of the light in the effect to update
  48758. * @returns The spot light
  48759. */
  48760. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  48761. var normalizeDirection;
  48762. if (this.computeTransformedInformation()) {
  48763. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  48764. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  48765. }
  48766. else {
  48767. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  48768. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  48769. }
  48770. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  48771. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  48772. if (this.projectionTexture && this.projectionTexture.isReady()) {
  48773. if (this._projectionTextureViewLightDirty) {
  48774. this._computeProjectionTextureViewLightMatrix();
  48775. }
  48776. if (this._projectionTextureProjectionLightDirty) {
  48777. this._computeProjectionTextureProjectionLightMatrix();
  48778. }
  48779. if (this._projectionTextureDirty) {
  48780. this._computeProjectionTextureMatrix();
  48781. }
  48782. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  48783. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  48784. }
  48785. return this;
  48786. };
  48787. /**
  48788. * Disposes the light and the associated resources.
  48789. */
  48790. SpotLight.prototype.dispose = function () {
  48791. _super.prototype.dispose.call(this);
  48792. if (this._projectionTexture) {
  48793. this._projectionTexture.dispose();
  48794. }
  48795. };
  48796. /**
  48797. * Prepares the list of defines specific to the light type.
  48798. * @param defines the list of defines
  48799. * @param lightIndex defines the index of the light for the effect
  48800. */
  48801. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  48802. defines["SPOTLIGHT" + lightIndex] = true;
  48803. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture ? true : false;
  48804. };
  48805. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48806. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48807. ], SpotLight.prototype, "angle", null);
  48808. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48809. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48810. ], SpotLight.prototype, "innerAngle", null);
  48811. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48812. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48813. ], SpotLight.prototype, "shadowAngleScale", null);
  48814. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48815. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48816. ], SpotLight.prototype, "exponent", void 0);
  48817. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48818. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48819. ], SpotLight.prototype, "projectionTextureLightNear", null);
  48820. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48822. ], SpotLight.prototype, "projectionTextureLightFar", null);
  48823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  48825. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  48826. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  48827. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  48828. ], SpotLight.prototype, "_projectionTexture", void 0);
  48829. return SpotLight;
  48830. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  48831. /***/ }),
  48832. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  48833. /*!**********************************************!*\
  48834. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  48835. \**********************************************/
  48836. /*! exports provided: _BabylonLoaderRegistered */
  48837. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48838. "use strict";
  48839. __webpack_require__.r(__webpack_exports__);
  48840. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  48841. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  48842. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  48843. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  48844. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  48845. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  48846. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  48847. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  48848. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  48849. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  48850. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  48851. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  48852. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  48853. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  48854. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  48855. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  48856. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  48857. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  48858. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  48859. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  48860. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  48861. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  48862. /* harmony import */ var _Physics_Plugins_ammoJSPlugin__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Physics/Plugins/ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  48863. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  48864. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  48865. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  48866. /** @hidden */
  48867. var _BabylonLoaderRegistered = true;
  48868. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  48869. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  48870. var parsedMaterial = parsedData.materials[index];
  48871. if (parsedMaterial.id === id) {
  48872. return _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  48873. }
  48874. }
  48875. return null;
  48876. };
  48877. var isDescendantOf = function (mesh, names, hierarchyIds) {
  48878. for (var i in names) {
  48879. if (mesh.name === names[i]) {
  48880. hierarchyIds.push(mesh.id);
  48881. return true;
  48882. }
  48883. }
  48884. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  48885. hierarchyIds.push(mesh.id);
  48886. return true;
  48887. }
  48888. return false;
  48889. };
  48890. var logOperation = function (operation, producer) {
  48891. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  48892. };
  48893. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  48894. if (addToScene === void 0) { addToScene = false; }
  48895. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_15__["AssetContainer"](scene);
  48896. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48897. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48898. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48899. // and avoid problems with multiple concurrent .babylon loads.
  48900. var log = "importScene has failed JSON parse";
  48901. try {
  48902. var parsedData = JSON.parse(data);
  48903. log = "";
  48904. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  48905. var index;
  48906. var cache;
  48907. // Environment texture
  48908. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  48909. // PBR needed for both HDR texture (gamma space) & a sky box
  48910. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  48911. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  48912. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  48913. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"]((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  48914. if (parsedData.environmentTextureRotationY) {
  48915. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  48916. }
  48917. scene.environmentTexture = hdrTexture;
  48918. }
  48919. else {
  48920. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_24__["Tools"].EndsWith(parsedData.environmentTexture, ".env")) {
  48921. var compressedTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"]((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene);
  48922. if (parsedData.environmentTextureRotationY) {
  48923. compressedTexture.rotationY = parsedData.environmentTextureRotationY;
  48924. }
  48925. scene.environmentTexture = compressedTexture;
  48926. }
  48927. else {
  48928. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData((parsedData.environmentTexture.match(/https?:\/\//g) ? "" : rootUrl) + parsedData.environmentTexture, scene);
  48929. if (parsedData.environmentTextureRotationY) {
  48930. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  48931. }
  48932. scene.environmentTexture = cubeTexture;
  48933. }
  48934. }
  48935. if (parsedData.createDefaultSkybox === true) {
  48936. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  48937. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  48938. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  48939. }
  48940. container.environmentTexture = scene.environmentTexture;
  48941. }
  48942. // Lights
  48943. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  48944. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  48945. var parsedLight = parsedData.lights[index];
  48946. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_11__["Light"].Parse(parsedLight, scene);
  48947. if (light) {
  48948. container.lights.push(light);
  48949. log += (index === 0 ? "\n\tLights:" : "");
  48950. log += "\n\t\t" + light.toString(fullDetails);
  48951. }
  48952. }
  48953. }
  48954. // Reflection probes
  48955. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  48956. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  48957. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  48958. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_22__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  48959. if (reflectionProbe) {
  48960. container.reflectionProbes.push(reflectionProbe);
  48961. log += (index === 0 ? "\n\tReflection Probes:" : "");
  48962. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  48963. }
  48964. }
  48965. }
  48966. // Animations
  48967. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  48968. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  48969. var parsedAnimation = parsedData.animations[index];
  48970. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_23__["_TypeStore"].GetClass("BABYLON.Animation");
  48971. if (internalClass) {
  48972. var animation = internalClass.Parse(parsedAnimation);
  48973. scene.animations.push(animation);
  48974. container.animations.push(animation);
  48975. log += (index === 0 ? "\n\tAnimations:" : "");
  48976. log += "\n\t\t" + animation.toString(fullDetails);
  48977. }
  48978. }
  48979. }
  48980. // Materials
  48981. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  48982. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  48983. var parsedMaterial = parsedData.materials[index];
  48984. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  48985. if (mat) {
  48986. container.materials.push(mat);
  48987. log += (index === 0 ? "\n\tMaterials:" : "");
  48988. log += "\n\t\t" + mat.toString(fullDetails);
  48989. // Textures
  48990. var textures = mat.getActiveTextures();
  48991. textures.forEach(function (t) {
  48992. if (container.textures.indexOf(t) == -1) {
  48993. container.textures.push(t);
  48994. }
  48995. });
  48996. }
  48997. }
  48998. }
  48999. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  49000. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  49001. var parsedMultiMaterial = parsedData.multiMaterials[index];
  49002. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  49003. container.multiMaterials.push(mmat);
  49004. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  49005. log += "\n\t\t" + mmat.toString(fullDetails);
  49006. // Textures
  49007. var textures = mmat.getActiveTextures();
  49008. textures.forEach(function (t) {
  49009. if (container.textures.indexOf(t) == -1) {
  49010. container.textures.push(t);
  49011. }
  49012. });
  49013. }
  49014. }
  49015. // Morph targets
  49016. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  49017. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  49018. var managerData = _a[_i];
  49019. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene));
  49020. }
  49021. }
  49022. // Skeletons
  49023. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  49024. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  49025. var parsedSkeleton = parsedData.skeletons[index];
  49026. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  49027. container.skeletons.push(skeleton);
  49028. log += (index === 0 ? "\n\tSkeletons:" : "");
  49029. log += "\n\t\t" + skeleton.toString(fullDetails);
  49030. }
  49031. }
  49032. // Geometries
  49033. var geometries = parsedData.geometries;
  49034. if (geometries !== undefined && geometries !== null) {
  49035. var addedGeometry = new Array();
  49036. // VertexData
  49037. var vertexData = geometries.vertexData;
  49038. if (vertexData !== undefined && vertexData !== null) {
  49039. for (index = 0, cache = vertexData.length; index < cache; index++) {
  49040. var parsedVertexData = vertexData[index];
  49041. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  49042. }
  49043. }
  49044. addedGeometry.forEach(function (g) {
  49045. if (g) {
  49046. container.geometries.push(g);
  49047. }
  49048. });
  49049. }
  49050. // Transform nodes
  49051. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  49052. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  49053. var parsedTransformNode = parsedData.transformNodes[index];
  49054. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  49055. container.transformNodes.push(node);
  49056. }
  49057. }
  49058. // Meshes
  49059. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  49060. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  49061. var parsedMesh = parsedData.meshes[index];
  49062. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  49063. container.meshes.push(mesh);
  49064. log += (index === 0 ? "\n\tMeshes:" : "");
  49065. log += "\n\t\t" + mesh.toString(fullDetails);
  49066. }
  49067. }
  49068. // Cameras
  49069. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  49070. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  49071. var parsedCamera = parsedData.cameras[index];
  49072. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  49073. container.cameras.push(camera);
  49074. log += (index === 0 ? "\n\tCameras:" : "");
  49075. log += "\n\t\t" + camera.toString(fullDetails);
  49076. }
  49077. }
  49078. // Animation Groups
  49079. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  49080. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  49081. var parsedAnimationGroup = parsedData.animationGroups[index];
  49082. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  49083. container.animationGroups.push(animationGroup);
  49084. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  49085. log += "\n\t\t" + animationGroup.toString(fullDetails);
  49086. }
  49087. }
  49088. // Browsing all the graph to connect the dots
  49089. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  49090. var camera = scene.cameras[index];
  49091. if (camera._waitingParentId) {
  49092. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  49093. camera._waitingParentId = null;
  49094. }
  49095. }
  49096. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  49097. var light_1 = scene.lights[index];
  49098. if (light_1 && light_1._waitingParentId) {
  49099. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  49100. light_1._waitingParentId = null;
  49101. }
  49102. }
  49103. // Connect parents & children and parse actions
  49104. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  49105. var transformNode = scene.transformNodes[index];
  49106. if (transformNode._waitingParentId) {
  49107. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  49108. transformNode._waitingParentId = null;
  49109. }
  49110. }
  49111. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49112. var mesh = scene.meshes[index];
  49113. if (mesh._waitingParentId) {
  49114. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  49115. mesh._waitingParentId = null;
  49116. }
  49117. }
  49118. // freeze world matrix application
  49119. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49120. var currentMesh = scene.meshes[index];
  49121. if (currentMesh._waitingFreezeWorldMatrix) {
  49122. currentMesh.freezeWorldMatrix();
  49123. currentMesh._waitingFreezeWorldMatrix = null;
  49124. }
  49125. else {
  49126. currentMesh.computeWorldMatrix(true);
  49127. }
  49128. }
  49129. // Lights exclusions / inclusions
  49130. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  49131. var light_2 = scene.lights[index];
  49132. // Excluded check
  49133. if (light_2._excludedMeshesIds.length > 0) {
  49134. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  49135. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  49136. if (excludedMesh) {
  49137. light_2.excludedMeshes.push(excludedMesh);
  49138. }
  49139. }
  49140. light_2._excludedMeshesIds = [];
  49141. }
  49142. // Included check
  49143. if (light_2._includedOnlyMeshesIds.length > 0) {
  49144. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  49145. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  49146. if (includedOnlyMesh) {
  49147. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  49148. }
  49149. }
  49150. light_2._includedOnlyMeshesIds = [];
  49151. }
  49152. }
  49153. _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  49154. // Actions (scene) Done last as it can access other objects.
  49155. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49156. var mesh = scene.meshes[index];
  49157. if (mesh._waitingActions) {
  49158. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(mesh._waitingActions, mesh, scene);
  49159. mesh._waitingActions = null;
  49160. }
  49161. }
  49162. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  49163. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(parsedData.actions, null, scene);
  49164. }
  49165. if (!addToScene) {
  49166. container.removeAllFromScene();
  49167. }
  49168. }
  49169. catch (err) {
  49170. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  49171. if (onError) {
  49172. onError(msg, err);
  49173. }
  49174. else {
  49175. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  49176. throw err;
  49177. }
  49178. }
  49179. finally {
  49180. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  49181. _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 : ""));
  49182. }
  49183. }
  49184. return container;
  49185. };
  49186. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].RegisterPlugin({
  49187. name: "babylon.js",
  49188. extensions: ".babylon",
  49189. canDirectLoad: function (data) {
  49190. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  49191. return true;
  49192. }
  49193. return false;
  49194. },
  49195. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  49196. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  49197. // when SceneLoader.debugLogging = true (default), or exception encountered.
  49198. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  49199. // and avoid problems with multiple concurrent .babylon loads.
  49200. var log = "importMesh has failed JSON parse";
  49201. try {
  49202. var parsedData = JSON.parse(data);
  49203. log = "";
  49204. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  49205. if (!meshesNames) {
  49206. meshesNames = null;
  49207. }
  49208. else if (!Array.isArray(meshesNames)) {
  49209. meshesNames = [meshesNames];
  49210. }
  49211. var hierarchyIds = new Array();
  49212. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  49213. var loadedSkeletonsIds = [];
  49214. var loadedMaterialsIds = [];
  49215. var index;
  49216. var cache;
  49217. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  49218. var parsedMesh = parsedData.meshes[index];
  49219. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  49220. if (meshesNames !== null) {
  49221. // Remove found mesh name from list.
  49222. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  49223. }
  49224. //Geometry?
  49225. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  49226. //does the file contain geometries?
  49227. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  49228. //find the correct geometry and add it to the scene
  49229. var found = false;
  49230. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  49231. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  49232. return;
  49233. }
  49234. else {
  49235. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  49236. if (parsedGeometryData.id === parsedMesh.geometryId) {
  49237. switch (geometryType) {
  49238. case "vertexData":
  49239. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  49240. break;
  49241. }
  49242. found = true;
  49243. }
  49244. });
  49245. }
  49246. });
  49247. if (found === false) {
  49248. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  49249. }
  49250. }
  49251. }
  49252. // Material ?
  49253. if (parsedMesh.materialId) {
  49254. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  49255. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  49256. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  49257. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  49258. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  49259. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  49260. var subMatId = parsedMultiMaterial.materials[matIndex];
  49261. loadedMaterialsIds.push(subMatId);
  49262. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  49263. if (mat) {
  49264. log += "\n\tMaterial " + mat.toString(fullDetails);
  49265. }
  49266. }
  49267. loadedMaterialsIds.push(parsedMultiMaterial.id);
  49268. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  49269. if (mmat) {
  49270. materialFound = true;
  49271. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  49272. }
  49273. break;
  49274. }
  49275. }
  49276. }
  49277. if (materialFound === false) {
  49278. loadedMaterialsIds.push(parsedMesh.materialId);
  49279. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  49280. if (!mat) {
  49281. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  49282. }
  49283. else {
  49284. log += "\n\tMaterial " + mat.toString(fullDetails);
  49285. }
  49286. }
  49287. }
  49288. // Skeleton ?
  49289. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  49290. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  49291. if (skeletonAlreadyLoaded === false) {
  49292. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  49293. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  49294. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  49295. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  49296. skeletons.push(skeleton);
  49297. loadedSkeletonsIds.push(parsedSkeleton.id);
  49298. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  49299. }
  49300. }
  49301. }
  49302. }
  49303. // Morph targets ?
  49304. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  49305. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  49306. var managerData = _a[_i];
  49307. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene);
  49308. }
  49309. }
  49310. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  49311. meshes.push(mesh);
  49312. log += "\n\tMesh " + mesh.toString(fullDetails);
  49313. }
  49314. }
  49315. // Connecting parents
  49316. var currentMesh;
  49317. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49318. currentMesh = scene.meshes[index];
  49319. if (currentMesh._waitingParentId) {
  49320. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  49321. currentMesh._waitingParentId = null;
  49322. }
  49323. }
  49324. // freeze and compute world matrix application
  49325. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  49326. currentMesh = scene.meshes[index];
  49327. if (currentMesh._waitingFreezeWorldMatrix) {
  49328. currentMesh.freezeWorldMatrix();
  49329. currentMesh._waitingFreezeWorldMatrix = null;
  49330. }
  49331. else {
  49332. currentMesh.computeWorldMatrix(true);
  49333. }
  49334. }
  49335. }
  49336. // Particles
  49337. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  49338. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_12__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  49339. if (parser) {
  49340. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  49341. var parsedParticleSystem = parsedData.particleSystems[index];
  49342. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  49343. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  49344. }
  49345. }
  49346. }
  49347. }
  49348. return true;
  49349. }
  49350. catch (err) {
  49351. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  49352. if (onError) {
  49353. onError(msg, err);
  49354. }
  49355. else {
  49356. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  49357. throw err;
  49358. }
  49359. }
  49360. finally {
  49361. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  49362. _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 : ""));
  49363. }
  49364. }
  49365. return false;
  49366. },
  49367. load: function (scene, data, rootUrl, onError) {
  49368. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  49369. // when SceneLoader.debugLogging = true (default), or exception encountered.
  49370. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  49371. // and avoid problems with multiple concurrent .babylon loads.
  49372. var log = "importScene has failed JSON parse";
  49373. try {
  49374. var parsedData = JSON.parse(data);
  49375. log = "";
  49376. // Scene
  49377. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  49378. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  49379. }
  49380. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  49381. scene.autoClear = parsedData.autoClear;
  49382. }
  49383. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  49384. scene.clearColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(parsedData.clearColor);
  49385. }
  49386. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  49387. scene.ambientColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.ambientColor);
  49388. }
  49389. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  49390. scene.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  49391. }
  49392. // Fog
  49393. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  49394. scene.fogMode = parsedData.fogMode;
  49395. scene.fogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.fogColor);
  49396. scene.fogStart = parsedData.fogStart;
  49397. scene.fogEnd = parsedData.fogEnd;
  49398. scene.fogDensity = parsedData.fogDensity;
  49399. log += "\tFog mode for scene: ";
  49400. switch (scene.fogMode) {
  49401. // getters not compiling, so using hardcoded
  49402. case 1:
  49403. log += "exp\n";
  49404. break;
  49405. case 2:
  49406. log += "exp2\n";
  49407. break;
  49408. case 3:
  49409. log += "linear\n";
  49410. break;
  49411. }
  49412. }
  49413. //Physics
  49414. if (parsedData.physicsEnabled) {
  49415. var physicsPlugin;
  49416. if (parsedData.physicsEngine === "cannon") {
  49417. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__["CannonJSPlugin"]();
  49418. }
  49419. else if (parsedData.physicsEngine === "oimo") {
  49420. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__["OimoJSPlugin"]();
  49421. }
  49422. else if (parsedData.physicsEngine === "ammo") {
  49423. physicsPlugin = new _Physics_Plugins_ammoJSPlugin__WEBPACK_IMPORTED_MODULE_21__["AmmoJSPlugin"]();
  49424. }
  49425. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  49426. //else - default engine, which is currently oimo
  49427. var physicsGravity = parsedData.physicsGravity ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  49428. scene.enablePhysics(physicsGravity, physicsPlugin);
  49429. }
  49430. // Metadata
  49431. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  49432. scene.metadata = parsedData.metadata;
  49433. }
  49434. //collisions, if defined. otherwise, default is true
  49435. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  49436. scene.collisionsEnabled = parsedData.collisionsEnabled;
  49437. }
  49438. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  49439. if (!container) {
  49440. return false;
  49441. }
  49442. if (parsedData.autoAnimate) {
  49443. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  49444. }
  49445. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  49446. scene.setActiveCameraByID(parsedData.activeCameraID);
  49447. }
  49448. // Environment texture
  49449. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  49450. // PBR needed for both HDR texture (gamma space) & a sky box
  49451. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  49452. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  49453. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  49454. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  49455. if (parsedData.environmentTextureRotationY) {
  49456. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  49457. }
  49458. scene.environmentTexture = hdrTexture;
  49459. }
  49460. else {
  49461. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_24__["Tools"].EndsWith(parsedData.environmentTexture, ".env")) {
  49462. var compressedTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](rootUrl + parsedData.environmentTexture, scene);
  49463. if (parsedData.environmentTextureRotationY) {
  49464. compressedTexture.rotationY = parsedData.environmentTextureRotationY;
  49465. }
  49466. scene.environmentTexture = compressedTexture;
  49467. }
  49468. else {
  49469. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  49470. if (parsedData.environmentTextureRotationY) {
  49471. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  49472. }
  49473. scene.environmentTexture = cubeTexture;
  49474. }
  49475. }
  49476. if (parsedData.createDefaultSkybox === true) {
  49477. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  49478. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  49479. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  49480. }
  49481. }
  49482. // Finish
  49483. return true;
  49484. }
  49485. catch (err) {
  49486. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  49487. if (onError) {
  49488. onError(msg, err);
  49489. }
  49490. else {
  49491. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  49492. throw err;
  49493. }
  49494. }
  49495. finally {
  49496. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  49497. _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 : ""));
  49498. }
  49499. }
  49500. return false;
  49501. },
  49502. loadAssetContainer: function (scene, data, rootUrl, onError) {
  49503. var container = loadAssetContainer(scene, data, rootUrl, onError);
  49504. return container;
  49505. }
  49506. });
  49507. /***/ }),
  49508. /***/ "./Loading/Plugins/index.ts":
  49509. /*!**********************************!*\
  49510. !*** ./Loading/Plugins/index.ts ***!
  49511. \**********************************/
  49512. /*! exports provided: _BabylonLoaderRegistered */
  49513. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49514. "use strict";
  49515. __webpack_require__.r(__webpack_exports__);
  49516. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  49517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  49518. /***/ }),
  49519. /***/ "./Loading/index.ts":
  49520. /*!**************************!*\
  49521. !*** ./Loading/index.ts ***!
  49522. \**************************/
  49523. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  49524. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49525. "use strict";
  49526. __webpack_require__.r(__webpack_exports__);
  49527. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  49528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  49529. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  49530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  49531. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  49532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  49533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  49534. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  49535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  49536. /***/ }),
  49537. /***/ "./Loading/loadingScreen.ts":
  49538. /*!**********************************!*\
  49539. !*** ./Loading/loadingScreen.ts ***!
  49540. \**********************************/
  49541. /*! exports provided: DefaultLoadingScreen */
  49542. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49543. "use strict";
  49544. __webpack_require__.r(__webpack_exports__);
  49545. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  49546. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  49547. /**
  49548. * Class used for the default loading screen
  49549. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  49550. */
  49551. var DefaultLoadingScreen = /** @class */ (function () {
  49552. /**
  49553. * Creates a new default loading screen
  49554. * @param _renderingCanvas defines the canvas used to render the scene
  49555. * @param _loadingText defines the default text to display
  49556. * @param _loadingDivBackgroundColor defines the default background color
  49557. */
  49558. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  49559. if (_loadingText === void 0) { _loadingText = ""; }
  49560. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  49561. var _this = this;
  49562. this._renderingCanvas = _renderingCanvas;
  49563. this._loadingText = _loadingText;
  49564. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  49565. // Resize
  49566. this._resizeLoadingUI = function () {
  49567. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  49568. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  49569. if (!_this._loadingDiv) {
  49570. return;
  49571. }
  49572. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  49573. _this._loadingDiv.style.left = canvasRect.left + "px";
  49574. _this._loadingDiv.style.top = canvasRect.top + "px";
  49575. _this._loadingDiv.style.width = canvasRect.width + "px";
  49576. _this._loadingDiv.style.height = canvasRect.height + "px";
  49577. };
  49578. }
  49579. /**
  49580. * Function called to display the loading screen
  49581. */
  49582. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  49583. if (this._loadingDiv) {
  49584. // Do not add a loading screen if there is already one
  49585. return;
  49586. }
  49587. this._loadingDiv = document.createElement("div");
  49588. this._loadingDiv.id = "babylonjsLoadingDiv";
  49589. this._loadingDiv.style.opacity = "0";
  49590. this._loadingDiv.style.transition = "opacity 1.5s ease";
  49591. this._loadingDiv.style.pointerEvents = "none";
  49592. // Loading text
  49593. this._loadingTextDiv = document.createElement("div");
  49594. this._loadingTextDiv.style.position = "absolute";
  49595. this._loadingTextDiv.style.left = "0";
  49596. this._loadingTextDiv.style.top = "50%";
  49597. this._loadingTextDiv.style.marginTop = "80px";
  49598. this._loadingTextDiv.style.width = "100%";
  49599. this._loadingTextDiv.style.height = "20px";
  49600. this._loadingTextDiv.style.fontFamily = "Arial";
  49601. this._loadingTextDiv.style.fontSize = "14px";
  49602. this._loadingTextDiv.style.color = "white";
  49603. this._loadingTextDiv.style.textAlign = "center";
  49604. this._loadingTextDiv.innerHTML = "Loading";
  49605. this._loadingDiv.appendChild(this._loadingTextDiv);
  49606. //set the predefined text
  49607. this._loadingTextDiv.innerHTML = this._loadingText;
  49608. // Generating keyframes
  49609. var style = document.createElement('style');
  49610. style.type = 'text/css';
  49611. 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 }";
  49612. style.innerHTML = keyFrames;
  49613. document.getElementsByTagName('head')[0].appendChild(style);
  49614. // Loading img
  49615. var imgBack = new Image();
  49616. 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";
  49617. imgBack.style.position = "absolute";
  49618. imgBack.style.left = "50%";
  49619. imgBack.style.top = "50%";
  49620. imgBack.style.marginLeft = "-60px";
  49621. imgBack.style.marginTop = "-60px";
  49622. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  49623. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  49624. imgBack.style.transformOrigin = "50% 50%";
  49625. imgBack.style.webkitTransformOrigin = "50% 50%";
  49626. this._loadingDiv.appendChild(imgBack);
  49627. this._resizeLoadingUI();
  49628. window.addEventListener("resize", this._resizeLoadingUI);
  49629. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  49630. document.body.appendChild(this._loadingDiv);
  49631. this._loadingDiv.style.opacity = "1";
  49632. };
  49633. /**
  49634. * Function called to hide the loading screen
  49635. */
  49636. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  49637. var _this = this;
  49638. if (!this._loadingDiv) {
  49639. return;
  49640. }
  49641. var onTransitionEnd = function () {
  49642. if (!_this._loadingDiv) {
  49643. return;
  49644. }
  49645. if (_this._loadingDiv.parentElement) {
  49646. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  49647. }
  49648. window.removeEventListener("resize", _this._resizeLoadingUI);
  49649. _this._loadingDiv = null;
  49650. };
  49651. this._loadingDiv.style.opacity = "0";
  49652. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  49653. };
  49654. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  49655. get: function () {
  49656. return this._loadingText;
  49657. },
  49658. /**
  49659. * Gets or sets the text to display while loading
  49660. */
  49661. set: function (text) {
  49662. this._loadingText = text;
  49663. if (this._loadingTextDiv) {
  49664. this._loadingTextDiv.innerHTML = this._loadingText;
  49665. }
  49666. },
  49667. enumerable: true,
  49668. configurable: true
  49669. });
  49670. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  49671. /**
  49672. * Gets or sets the color to use for the background
  49673. */
  49674. get: function () {
  49675. return this._loadingDivBackgroundColor;
  49676. },
  49677. set: function (color) {
  49678. this._loadingDivBackgroundColor = color;
  49679. if (!this._loadingDiv) {
  49680. return;
  49681. }
  49682. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  49683. },
  49684. enumerable: true,
  49685. configurable: true
  49686. });
  49687. return DefaultLoadingScreen;
  49688. }());
  49689. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  49690. /***/ }),
  49691. /***/ "./Loading/sceneLoader.ts":
  49692. /*!********************************!*\
  49693. !*** ./Loading/sceneLoader.ts ***!
  49694. \********************************/
  49695. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  49696. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49697. "use strict";
  49698. __webpack_require__.r(__webpack_exports__);
  49699. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  49700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  49701. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  49702. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  49703. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  49704. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  49705. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  49706. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  49707. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  49708. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  49709. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  49710. /**
  49711. * Class used to represent data loading progression
  49712. */
  49713. var SceneLoaderProgressEvent = /** @class */ (function () {
  49714. /**
  49715. * Create a new progress event
  49716. * @param lengthComputable defines if data length to load can be evaluated
  49717. * @param loaded defines the loaded data length
  49718. * @param total defines the data length to load
  49719. */
  49720. function SceneLoaderProgressEvent(
  49721. /** defines if data length to load can be evaluated */
  49722. lengthComputable,
  49723. /** defines the loaded data length */
  49724. loaded,
  49725. /** defines the data length to load */
  49726. total) {
  49727. this.lengthComputable = lengthComputable;
  49728. this.loaded = loaded;
  49729. this.total = total;
  49730. }
  49731. /**
  49732. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  49733. * @param event defines the source event
  49734. * @returns a new SceneLoaderProgressEvent
  49735. */
  49736. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  49737. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  49738. };
  49739. return SceneLoaderProgressEvent;
  49740. }());
  49741. /**
  49742. * Class used to load scene from various file formats using registered plugins
  49743. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  49744. */
  49745. var SceneLoader = /** @class */ (function () {
  49746. function SceneLoader() {
  49747. }
  49748. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  49749. /**
  49750. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49751. */
  49752. get: function () {
  49753. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  49754. },
  49755. set: function (value) {
  49756. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  49757. },
  49758. enumerable: true,
  49759. configurable: true
  49760. });
  49761. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  49762. /**
  49763. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49764. */
  49765. get: function () {
  49766. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  49767. },
  49768. set: function (value) {
  49769. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  49770. },
  49771. enumerable: true,
  49772. configurable: true
  49773. });
  49774. Object.defineProperty(SceneLoader, "loggingLevel", {
  49775. /**
  49776. * Defines the current logging level (while loading the scene)
  49777. * @ignorenaming
  49778. */
  49779. get: function () {
  49780. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  49781. },
  49782. set: function (value) {
  49783. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  49784. },
  49785. enumerable: true,
  49786. configurable: true
  49787. });
  49788. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  49789. /**
  49790. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49791. */
  49792. get: function () {
  49793. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  49794. },
  49795. set: function (value) {
  49796. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  49797. },
  49798. enumerable: true,
  49799. configurable: true
  49800. });
  49801. SceneLoader._getDefaultPlugin = function () {
  49802. return SceneLoader._registeredPlugins[".babylon"];
  49803. };
  49804. SceneLoader._getPluginForExtension = function (extension) {
  49805. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  49806. if (registeredPlugin) {
  49807. return registeredPlugin;
  49808. }
  49809. _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");
  49810. return SceneLoader._getDefaultPlugin();
  49811. };
  49812. SceneLoader._getPluginForDirectLoad = function (data) {
  49813. for (var extension in SceneLoader._registeredPlugins) {
  49814. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  49815. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  49816. return SceneLoader._registeredPlugins[extension];
  49817. }
  49818. }
  49819. return SceneLoader._getDefaultPlugin();
  49820. };
  49821. SceneLoader._getPluginForFilename = function (sceneFilename) {
  49822. var queryStringPosition = sceneFilename.indexOf("?");
  49823. if (queryStringPosition !== -1) {
  49824. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  49825. }
  49826. var dotPosition = sceneFilename.lastIndexOf(".");
  49827. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  49828. return SceneLoader._getPluginForExtension(extension);
  49829. };
  49830. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  49831. SceneLoader._getDirectLoad = function (sceneFilename) {
  49832. if (sceneFilename.substr(0, 5) === "data:") {
  49833. return sceneFilename.substr(5);
  49834. }
  49835. return null;
  49836. };
  49837. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  49838. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  49839. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  49840. var plugin;
  49841. if (registeredPlugin.plugin.createPlugin) {
  49842. plugin = registeredPlugin.plugin.createPlugin();
  49843. }
  49844. else {
  49845. plugin = registeredPlugin.plugin;
  49846. }
  49847. if (!plugin) {
  49848. 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.";
  49849. }
  49850. var useArrayBuffer = registeredPlugin.isBinary;
  49851. var offlineProvider;
  49852. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  49853. var dataCallback = function (data, responseURL) {
  49854. if (scene.isDisposed) {
  49855. onError("Scene has been disposed");
  49856. return;
  49857. }
  49858. scene.offlineProvider = offlineProvider;
  49859. onSuccess(plugin, data, responseURL);
  49860. };
  49861. var request = null;
  49862. var pluginDisposed = false;
  49863. var onDisposeObservable = plugin.onDisposeObservable;
  49864. if (onDisposeObservable) {
  49865. onDisposeObservable.add(function () {
  49866. pluginDisposed = true;
  49867. if (request) {
  49868. request.abort();
  49869. request = null;
  49870. }
  49871. onDispose();
  49872. });
  49873. }
  49874. var manifestChecked = function () {
  49875. if (pluginDisposed) {
  49876. return;
  49877. }
  49878. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  49879. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  49880. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  49881. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  49882. });
  49883. };
  49884. if (directLoad) {
  49885. dataCallback(directLoad);
  49886. return plugin;
  49887. }
  49888. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  49889. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  49890. var engine = scene.getEngine();
  49891. var canUseOfflineSupport = engine.enableOfflineSupport;
  49892. if (canUseOfflineSupport) {
  49893. // Also check for exceptions
  49894. var exceptionFound = false;
  49895. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  49896. var regex = _a[_i];
  49897. if (regex.test(fileInfo.url)) {
  49898. exceptionFound = true;
  49899. break;
  49900. }
  49901. }
  49902. canUseOfflineSupport = !exceptionFound;
  49903. }
  49904. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  49905. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  49906. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  49907. }
  49908. else {
  49909. manifestChecked();
  49910. }
  49911. }
  49912. // Loading file from disk via input file or drag'n'drop
  49913. else {
  49914. if (file) {
  49915. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  49916. }
  49917. else {
  49918. onError("Unable to find file named " + fileInfo.name);
  49919. }
  49920. }
  49921. return plugin;
  49922. };
  49923. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  49924. var url;
  49925. var name;
  49926. var file = null;
  49927. if (!sceneFilename) {
  49928. url = rootUrl;
  49929. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  49930. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  49931. }
  49932. else if (sceneFilename.name) {
  49933. var sceneFile = sceneFilename;
  49934. url = rootUrl + sceneFile.name;
  49935. name = sceneFile.name;
  49936. file = sceneFile;
  49937. }
  49938. else {
  49939. var filename = sceneFilename;
  49940. if (filename.substr(0, 1) === "/") {
  49941. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  49942. return null;
  49943. }
  49944. url = rootUrl + filename;
  49945. name = filename;
  49946. }
  49947. return {
  49948. url: url,
  49949. rootUrl: rootUrl,
  49950. name: name,
  49951. file: file
  49952. };
  49953. };
  49954. // Public functions
  49955. /**
  49956. * Gets a plugin that can load the given extension
  49957. * @param extension defines the extension to load
  49958. * @returns a plugin or null if none works
  49959. */
  49960. SceneLoader.GetPluginForExtension = function (extension) {
  49961. return SceneLoader._getPluginForExtension(extension).plugin;
  49962. };
  49963. /**
  49964. * Gets a boolean indicating that the given extension can be loaded
  49965. * @param extension defines the extension to load
  49966. * @returns true if the extension is supported
  49967. */
  49968. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  49969. return !!SceneLoader._registeredPlugins[extension];
  49970. };
  49971. /**
  49972. * Adds a new plugin to the list of registered plugins
  49973. * @param plugin defines the plugin to add
  49974. */
  49975. SceneLoader.RegisterPlugin = function (plugin) {
  49976. if (typeof plugin.extensions === "string") {
  49977. var extension = plugin.extensions;
  49978. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  49979. plugin: plugin,
  49980. isBinary: false
  49981. };
  49982. }
  49983. else {
  49984. var extensions = plugin.extensions;
  49985. Object.keys(extensions).forEach(function (extension) {
  49986. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  49987. plugin: plugin,
  49988. isBinary: extensions[extension].isBinary
  49989. };
  49990. });
  49991. }
  49992. };
  49993. /**
  49994. * Import meshes into a scene
  49995. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49996. * @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)
  49997. * @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)
  49998. * @param scene the instance of BABYLON.Scene to append to
  49999. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  50000. * @param onProgress a callback with a progress event for each file being loaded
  50001. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50002. * @param pluginExtension the extension used to determine the plugin
  50003. * @returns The loaded plugin
  50004. */
  50005. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  50006. if (sceneFilename === void 0) { sceneFilename = ""; }
  50007. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50008. if (onSuccess === void 0) { onSuccess = null; }
  50009. if (onProgress === void 0) { onProgress = null; }
  50010. if (onError === void 0) { onError = null; }
  50011. if (pluginExtension === void 0) { pluginExtension = null; }
  50012. if (!scene) {
  50013. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  50014. return null;
  50015. }
  50016. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  50017. if (!fileInfo) {
  50018. return null;
  50019. }
  50020. var loadingToken = {};
  50021. scene._addPendingData(loadingToken);
  50022. var disposeHandler = function () {
  50023. scene._removePendingData(loadingToken);
  50024. };
  50025. var errorHandler = function (message, exception) {
  50026. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  50027. if (onError) {
  50028. onError(scene, errorMessage, exception);
  50029. }
  50030. else {
  50031. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  50032. // should the exception be thrown?
  50033. }
  50034. disposeHandler();
  50035. };
  50036. var progressHandler = onProgress ? function (event) {
  50037. try {
  50038. onProgress(event);
  50039. }
  50040. catch (e) {
  50041. errorHandler("Error in onProgress callback", e);
  50042. }
  50043. } : undefined;
  50044. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  50045. scene.importedMeshesFiles.push(fileInfo.url);
  50046. if (onSuccess) {
  50047. try {
  50048. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  50049. }
  50050. catch (e) {
  50051. errorHandler("Error in onSuccess callback", e);
  50052. }
  50053. }
  50054. scene._removePendingData(loadingToken);
  50055. };
  50056. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  50057. if (plugin.rewriteRootURL) {
  50058. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  50059. }
  50060. if (plugin.importMesh) {
  50061. var syncedPlugin = plugin;
  50062. var meshes = new Array();
  50063. var particleSystems = new Array();
  50064. var skeletons = new Array();
  50065. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  50066. return;
  50067. }
  50068. scene.loadingPluginName = plugin.name;
  50069. successHandler(meshes, particleSystems, skeletons, []);
  50070. }
  50071. else {
  50072. var asyncedPlugin = plugin;
  50073. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  50074. scene.loadingPluginName = plugin.name;
  50075. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  50076. }).catch(function (error) {
  50077. errorHandler(error.message, error);
  50078. });
  50079. }
  50080. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  50081. };
  50082. /**
  50083. * Import meshes into a scene
  50084. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50085. * @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)
  50086. * @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)
  50087. * @param scene the instance of BABYLON.Scene to append to
  50088. * @param onProgress a callback with a progress event for each file being loaded
  50089. * @param pluginExtension the extension used to determine the plugin
  50090. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  50091. */
  50092. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  50093. if (sceneFilename === void 0) { sceneFilename = ""; }
  50094. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50095. if (onProgress === void 0) { onProgress = null; }
  50096. if (pluginExtension === void 0) { pluginExtension = null; }
  50097. return new Promise(function (resolve, reject) {
  50098. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  50099. resolve({
  50100. meshes: meshes,
  50101. particleSystems: particleSystems,
  50102. skeletons: skeletons,
  50103. animationGroups: animationGroups
  50104. });
  50105. }, onProgress, function (scene, message, exception) {
  50106. reject(exception || new Error(message));
  50107. }, pluginExtension);
  50108. });
  50109. };
  50110. /**
  50111. * Load a scene
  50112. * @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)
  50113. * @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)
  50114. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50115. * @param onSuccess a callback with the scene when import succeeds
  50116. * @param onProgress a callback with a progress event for each file being loaded
  50117. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50118. * @param pluginExtension the extension used to determine the plugin
  50119. * @returns The loaded plugin
  50120. */
  50121. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  50122. if (sceneFilename === void 0) { sceneFilename = ""; }
  50123. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  50124. if (onSuccess === void 0) { onSuccess = null; }
  50125. if (onProgress === void 0) { onProgress = null; }
  50126. if (onError === void 0) { onError = null; }
  50127. if (pluginExtension === void 0) { pluginExtension = null; }
  50128. if (!engine) {
  50129. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  50130. return null;
  50131. }
  50132. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  50133. };
  50134. /**
  50135. * Load a scene
  50136. * @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)
  50137. * @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)
  50138. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50139. * @param onProgress a callback with a progress event for each file being loaded
  50140. * @param pluginExtension the extension used to determine the plugin
  50141. * @returns The loaded scene
  50142. */
  50143. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  50144. if (sceneFilename === void 0) { sceneFilename = ""; }
  50145. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  50146. if (onProgress === void 0) { onProgress = null; }
  50147. if (pluginExtension === void 0) { pluginExtension = null; }
  50148. return new Promise(function (resolve, reject) {
  50149. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  50150. resolve(scene);
  50151. }, onProgress, function (scene, message, exception) {
  50152. reject(exception || new Error(message));
  50153. }, pluginExtension);
  50154. });
  50155. };
  50156. /**
  50157. * Append a scene
  50158. * @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)
  50159. * @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)
  50160. * @param scene is the instance of BABYLON.Scene to append to
  50161. * @param onSuccess a callback with the scene when import succeeds
  50162. * @param onProgress a callback with a progress event for each file being loaded
  50163. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50164. * @param pluginExtension the extension used to determine the plugin
  50165. * @returns The loaded plugin
  50166. */
  50167. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  50168. if (sceneFilename === void 0) { sceneFilename = ""; }
  50169. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50170. if (onSuccess === void 0) { onSuccess = null; }
  50171. if (onProgress === void 0) { onProgress = null; }
  50172. if (onError === void 0) { onError = null; }
  50173. if (pluginExtension === void 0) { pluginExtension = null; }
  50174. if (!scene) {
  50175. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  50176. return null;
  50177. }
  50178. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  50179. if (!fileInfo) {
  50180. return null;
  50181. }
  50182. if (SceneLoader.ShowLoadingScreen) {
  50183. scene.getEngine().displayLoadingUI();
  50184. }
  50185. var loadingToken = {};
  50186. scene._addPendingData(loadingToken);
  50187. var disposeHandler = function () {
  50188. scene._removePendingData(loadingToken);
  50189. scene.getEngine().hideLoadingUI();
  50190. };
  50191. var errorHandler = function (message, exception) {
  50192. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  50193. if (onError) {
  50194. onError(scene, errorMessage, exception);
  50195. }
  50196. else {
  50197. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  50198. // should the exception be thrown?
  50199. }
  50200. disposeHandler();
  50201. };
  50202. var progressHandler = onProgress ? function (event) {
  50203. try {
  50204. onProgress(event);
  50205. }
  50206. catch (e) {
  50207. errorHandler("Error in onProgress callback", e);
  50208. }
  50209. } : undefined;
  50210. var successHandler = function () {
  50211. if (onSuccess) {
  50212. try {
  50213. onSuccess(scene);
  50214. }
  50215. catch (e) {
  50216. errorHandler("Error in onSuccess callback", e);
  50217. }
  50218. }
  50219. scene._removePendingData(loadingToken);
  50220. };
  50221. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  50222. if (plugin.load) {
  50223. var syncedPlugin = plugin;
  50224. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  50225. return;
  50226. }
  50227. scene.loadingPluginName = plugin.name;
  50228. successHandler();
  50229. }
  50230. else {
  50231. var asyncedPlugin = plugin;
  50232. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  50233. scene.loadingPluginName = plugin.name;
  50234. successHandler();
  50235. }).catch(function (error) {
  50236. errorHandler(error.message, error);
  50237. });
  50238. }
  50239. if (SceneLoader.ShowLoadingScreen) {
  50240. scene.executeWhenReady(function () {
  50241. scene.getEngine().hideLoadingUI();
  50242. });
  50243. }
  50244. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  50245. };
  50246. /**
  50247. * Append a scene
  50248. * @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)
  50249. * @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)
  50250. * @param scene is the instance of BABYLON.Scene to append to
  50251. * @param onProgress a callback with a progress event for each file being loaded
  50252. * @param pluginExtension the extension used to determine the plugin
  50253. * @returns The given scene
  50254. */
  50255. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  50256. if (sceneFilename === void 0) { sceneFilename = ""; }
  50257. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50258. if (onProgress === void 0) { onProgress = null; }
  50259. if (pluginExtension === void 0) { pluginExtension = null; }
  50260. return new Promise(function (resolve, reject) {
  50261. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  50262. resolve(scene);
  50263. }, onProgress, function (scene, message, exception) {
  50264. reject(exception || new Error(message));
  50265. }, pluginExtension);
  50266. });
  50267. };
  50268. /**
  50269. * Load a scene into an asset container
  50270. * @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)
  50271. * @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)
  50272. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  50273. * @param onSuccess a callback with the scene when import succeeds
  50274. * @param onProgress a callback with a progress event for each file being loaded
  50275. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50276. * @param pluginExtension the extension used to determine the plugin
  50277. * @returns The loaded plugin
  50278. */
  50279. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  50280. if (sceneFilename === void 0) { sceneFilename = ""; }
  50281. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50282. if (onSuccess === void 0) { onSuccess = null; }
  50283. if (onProgress === void 0) { onProgress = null; }
  50284. if (onError === void 0) { onError = null; }
  50285. if (pluginExtension === void 0) { pluginExtension = null; }
  50286. if (!scene) {
  50287. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  50288. return null;
  50289. }
  50290. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  50291. if (!fileInfo) {
  50292. return null;
  50293. }
  50294. var loadingToken = {};
  50295. scene._addPendingData(loadingToken);
  50296. var disposeHandler = function () {
  50297. scene._removePendingData(loadingToken);
  50298. };
  50299. var errorHandler = function (message, exception) {
  50300. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  50301. if (onError) {
  50302. onError(scene, errorMessage, exception);
  50303. }
  50304. else {
  50305. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  50306. // should the exception be thrown?
  50307. }
  50308. disposeHandler();
  50309. };
  50310. var progressHandler = onProgress ? function (event) {
  50311. try {
  50312. onProgress(event);
  50313. }
  50314. catch (e) {
  50315. errorHandler("Error in onProgress callback", e);
  50316. }
  50317. } : undefined;
  50318. var successHandler = function (assets) {
  50319. if (onSuccess) {
  50320. try {
  50321. onSuccess(assets);
  50322. }
  50323. catch (e) {
  50324. errorHandler("Error in onSuccess callback", e);
  50325. }
  50326. }
  50327. scene._removePendingData(loadingToken);
  50328. };
  50329. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  50330. if (plugin.loadAssetContainer) {
  50331. var syncedPlugin = plugin;
  50332. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  50333. if (!assetContainer) {
  50334. return;
  50335. }
  50336. scene.loadingPluginName = plugin.name;
  50337. successHandler(assetContainer);
  50338. }
  50339. else if (plugin.loadAssetContainerAsync) {
  50340. var asyncedPlugin = plugin;
  50341. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  50342. scene.loadingPluginName = plugin.name;
  50343. successHandler(assetContainer);
  50344. }).catch(function (error) {
  50345. errorHandler(error.message, error);
  50346. });
  50347. }
  50348. else {
  50349. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  50350. }
  50351. if (SceneLoader.ShowLoadingScreen) {
  50352. scene.executeWhenReady(function () {
  50353. scene.getEngine().hideLoadingUI();
  50354. });
  50355. }
  50356. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  50357. };
  50358. /**
  50359. * Load a scene into an asset container
  50360. * @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)
  50361. * @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)
  50362. * @param scene is the instance of Scene to append to
  50363. * @param onProgress a callback with a progress event for each file being loaded
  50364. * @param pluginExtension the extension used to determine the plugin
  50365. * @returns The loaded asset container
  50366. */
  50367. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  50368. if (sceneFilename === void 0) { sceneFilename = ""; }
  50369. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  50370. if (onProgress === void 0) { onProgress = null; }
  50371. if (pluginExtension === void 0) { pluginExtension = null; }
  50372. return new Promise(function (resolve, reject) {
  50373. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  50374. resolve(assetContainer);
  50375. }, onProgress, function (scene, message, exception) {
  50376. reject(exception || new Error(message));
  50377. }, pluginExtension);
  50378. });
  50379. };
  50380. /**
  50381. * No logging while loading
  50382. */
  50383. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  50384. /**
  50385. * Minimal logging while loading
  50386. */
  50387. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  50388. /**
  50389. * Summary logging while loading
  50390. */
  50391. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  50392. /**
  50393. * Detailled logging while loading
  50394. */
  50395. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  50396. // Members
  50397. /**
  50398. * Event raised when a plugin is used to load a scene
  50399. */
  50400. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  50401. SceneLoader._registeredPlugins = {};
  50402. return SceneLoader;
  50403. }());
  50404. /***/ }),
  50405. /***/ "./Loading/sceneLoaderFlags.ts":
  50406. /*!*************************************!*\
  50407. !*** ./Loading/sceneLoaderFlags.ts ***!
  50408. \*************************************/
  50409. /*! exports provided: SceneLoaderFlags */
  50410. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50411. "use strict";
  50412. __webpack_require__.r(__webpack_exports__);
  50413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  50414. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  50415. /**
  50416. * Class used to represent data loading progression
  50417. */
  50418. var SceneLoaderFlags = /** @class */ (function () {
  50419. function SceneLoaderFlags() {
  50420. }
  50421. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  50422. /**
  50423. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  50424. */
  50425. get: function () {
  50426. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  50427. },
  50428. set: function (value) {
  50429. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  50430. },
  50431. enumerable: true,
  50432. configurable: true
  50433. });
  50434. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  50435. /**
  50436. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  50437. */
  50438. get: function () {
  50439. return SceneLoaderFlags._ShowLoadingScreen;
  50440. },
  50441. set: function (value) {
  50442. SceneLoaderFlags._ShowLoadingScreen = value;
  50443. },
  50444. enumerable: true,
  50445. configurable: true
  50446. });
  50447. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  50448. /**
  50449. * Defines the current logging level (while loading the scene)
  50450. * @ignorenaming
  50451. */
  50452. get: function () {
  50453. return SceneLoaderFlags._loggingLevel;
  50454. },
  50455. set: function (value) {
  50456. SceneLoaderFlags._loggingLevel = value;
  50457. },
  50458. enumerable: true,
  50459. configurable: true
  50460. });
  50461. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  50462. /**
  50463. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  50464. */
  50465. get: function () {
  50466. return SceneLoaderFlags._CleanBoneMatrixWeights;
  50467. },
  50468. set: function (value) {
  50469. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  50470. },
  50471. enumerable: true,
  50472. configurable: true
  50473. });
  50474. // Flags
  50475. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  50476. SceneLoaderFlags._ShowLoadingScreen = true;
  50477. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  50478. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  50479. return SceneLoaderFlags;
  50480. }());
  50481. /***/ }),
  50482. /***/ "./Materials/Background/backgroundMaterial.ts":
  50483. /*!****************************************************!*\
  50484. !*** ./Materials/Background/backgroundMaterial.ts ***!
  50485. \****************************************************/
  50486. /*! exports provided: BackgroundMaterial */
  50487. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50488. "use strict";
  50489. __webpack_require__.r(__webpack_exports__);
  50490. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  50491. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  50492. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  50493. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  50494. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  50495. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  50496. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  50497. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  50498. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  50499. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  50500. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  50501. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  50502. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  50503. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  50504. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  50505. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  50506. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  50507. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  50508. /**
  50509. * Background material defines definition.
  50510. * @hidden Mainly internal Use
  50511. */
  50512. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  50513. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  50514. /**
  50515. * Constructor of the defines.
  50516. */
  50517. function BackgroundMaterialDefines() {
  50518. var _this = _super.call(this) || this;
  50519. /**
  50520. * True if the diffuse texture is in use.
  50521. */
  50522. _this.DIFFUSE = false;
  50523. /**
  50524. * The direct UV channel to use.
  50525. */
  50526. _this.DIFFUSEDIRECTUV = 0;
  50527. /**
  50528. * True if the diffuse texture is in gamma space.
  50529. */
  50530. _this.GAMMADIFFUSE = false;
  50531. /**
  50532. * True if the diffuse texture has opacity in the alpha channel.
  50533. */
  50534. _this.DIFFUSEHASALPHA = false;
  50535. /**
  50536. * True if you want the material to fade to transparent at grazing angle.
  50537. */
  50538. _this.OPACITYFRESNEL = false;
  50539. /**
  50540. * True if an extra blur needs to be added in the reflection.
  50541. */
  50542. _this.REFLECTIONBLUR = false;
  50543. /**
  50544. * True if you want the material to fade to reflection at grazing angle.
  50545. */
  50546. _this.REFLECTIONFRESNEL = false;
  50547. /**
  50548. * True if you want the material to falloff as far as you move away from the scene center.
  50549. */
  50550. _this.REFLECTIONFALLOFF = false;
  50551. /**
  50552. * False if the current Webgl implementation does not support the texture lod extension.
  50553. */
  50554. _this.TEXTURELODSUPPORT = false;
  50555. /**
  50556. * True to ensure the data are premultiplied.
  50557. */
  50558. _this.PREMULTIPLYALPHA = false;
  50559. /**
  50560. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  50561. */
  50562. _this.USERGBCOLOR = false;
  50563. /**
  50564. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  50565. * stays aligned with the desired configuration.
  50566. */
  50567. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  50568. /**
  50569. * True to add noise in order to reduce the banding effect.
  50570. */
  50571. _this.NOISE = false;
  50572. /**
  50573. * is the reflection texture in BGR color scheme?
  50574. * Mainly used to solve a bug in ios10 video tag
  50575. */
  50576. _this.REFLECTIONBGR = false;
  50577. _this.IMAGEPROCESSING = false;
  50578. _this.VIGNETTE = false;
  50579. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  50580. _this.VIGNETTEBLENDMODEOPAQUE = false;
  50581. _this.TONEMAPPING = false;
  50582. _this.TONEMAPPING_ACES = false;
  50583. _this.CONTRAST = false;
  50584. _this.COLORCURVES = false;
  50585. _this.COLORGRADING = false;
  50586. _this.COLORGRADING3D = false;
  50587. _this.SAMPLER3DGREENDEPTH = false;
  50588. _this.SAMPLER3DBGRMAP = false;
  50589. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  50590. _this.EXPOSURE = false;
  50591. _this.MULTIVIEW = false;
  50592. // Reflection.
  50593. _this.REFLECTION = false;
  50594. _this.REFLECTIONMAP_3D = false;
  50595. _this.REFLECTIONMAP_SPHERICAL = false;
  50596. _this.REFLECTIONMAP_PLANAR = false;
  50597. _this.REFLECTIONMAP_CUBIC = false;
  50598. _this.REFLECTIONMAP_PROJECTION = false;
  50599. _this.REFLECTIONMAP_SKYBOX = false;
  50600. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50601. _this.REFLECTIONMAP_EXPLICIT = false;
  50602. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50603. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50604. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50605. _this.INVERTCUBICMAP = false;
  50606. _this.REFLECTIONMAP_OPPOSITEZ = false;
  50607. _this.LODINREFLECTIONALPHA = false;
  50608. _this.GAMMAREFLECTION = false;
  50609. _this.RGBDREFLECTION = false;
  50610. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  50611. // Default BJS.
  50612. _this.MAINUV1 = false;
  50613. _this.MAINUV2 = false;
  50614. _this.UV1 = false;
  50615. _this.UV2 = false;
  50616. _this.CLIPPLANE = false;
  50617. _this.CLIPPLANE2 = false;
  50618. _this.CLIPPLANE3 = false;
  50619. _this.CLIPPLANE4 = false;
  50620. _this.POINTSIZE = false;
  50621. _this.FOG = false;
  50622. _this.NORMAL = false;
  50623. _this.NUM_BONE_INFLUENCERS = 0;
  50624. _this.BonesPerMesh = 0;
  50625. _this.INSTANCES = false;
  50626. _this.SHADOWFLOAT = false;
  50627. _this.rebuild();
  50628. return _this;
  50629. }
  50630. return BackgroundMaterialDefines;
  50631. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  50632. /**
  50633. * Background material used to create an efficient environement around your scene.
  50634. */
  50635. var BackgroundMaterial = /** @class */ (function (_super) {
  50636. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  50637. /**
  50638. * Instantiates a Background Material in the given scene
  50639. * @param name The friendly name of the material
  50640. * @param scene The scene to add the material to
  50641. */
  50642. function BackgroundMaterial(name, scene) {
  50643. var _this = _super.call(this, name, scene) || this;
  50644. /**
  50645. * Key light Color (multiply against the environement texture)
  50646. */
  50647. _this.primaryColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  50648. _this._primaryColorShadowLevel = 0;
  50649. _this._primaryColorHighlightLevel = 0;
  50650. /**
  50651. * Reflection Texture used in the material.
  50652. * Should be author in a specific way for the best result (refer to the documentation).
  50653. */
  50654. _this.reflectionTexture = null;
  50655. /**
  50656. * Reflection Texture level of blur.
  50657. *
  50658. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50659. * texture twice.
  50660. */
  50661. _this.reflectionBlur = 0;
  50662. /**
  50663. * Diffuse Texture used in the material.
  50664. * Should be author in a specific way for the best result (refer to the documentation).
  50665. */
  50666. _this.diffuseTexture = null;
  50667. _this._shadowLights = null;
  50668. /**
  50669. * Specify the list of lights casting shadow on the material.
  50670. * All scene shadow lights will be included if null.
  50671. */
  50672. _this.shadowLights = null;
  50673. /**
  50674. * Helps adjusting the shadow to a softer level if required.
  50675. * 0 means black shadows and 1 means no shadows.
  50676. */
  50677. _this.shadowLevel = 0;
  50678. /**
  50679. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50680. * It is usually zero but might be interesting to modify according to your setup.
  50681. */
  50682. _this.sceneCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  50683. /**
  50684. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50685. * This helps ensuring a nice transition when the camera goes under the ground.
  50686. */
  50687. _this.opacityFresnel = true;
  50688. /**
  50689. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50690. * This helps adding a mirror texture on the ground.
  50691. */
  50692. _this.reflectionFresnel = false;
  50693. /**
  50694. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50695. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50696. */
  50697. _this.reflectionFalloffDistance = 0.0;
  50698. /**
  50699. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50700. */
  50701. _this.reflectionAmount = 1.0;
  50702. /**
  50703. * This specifies the weight of the reflection at grazing angle.
  50704. */
  50705. _this.reflectionReflectance0 = 0.05;
  50706. /**
  50707. * This specifies the weight of the reflection at a perpendicular point of view.
  50708. */
  50709. _this.reflectionReflectance90 = 0.5;
  50710. /**
  50711. * Helps to directly use the maps channels instead of their level.
  50712. */
  50713. _this.useRGBColor = true;
  50714. /**
  50715. * This helps reducing the banding effect that could occur on the background.
  50716. */
  50717. _this.enableNoise = false;
  50718. _this._fovMultiplier = 1.0;
  50719. /**
  50720. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50721. */
  50722. _this.useEquirectangularFOV = false;
  50723. _this._maxSimultaneousLights = 4;
  50724. /**
  50725. * Number of Simultaneous lights allowed on the material.
  50726. */
  50727. _this.maxSimultaneousLights = 4;
  50728. /**
  50729. * Keep track of the image processing observer to allow dispose and replace.
  50730. */
  50731. _this._imageProcessingObserver = null;
  50732. /**
  50733. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50734. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50735. */
  50736. _this.switchToBGR = false;
  50737. // Temp values kept as cache in the material.
  50738. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  50739. _this._reflectionControls = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  50740. _this._white = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  50741. _this._primaryShadowColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  50742. _this._primaryHighlightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  50743. // Setup the default processing configuration to the scene.
  50744. _this._attachImageProcessingConfiguration(null);
  50745. _this.getRenderTargetTextures = function () {
  50746. _this._renderTargets.reset();
  50747. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  50748. _this._renderTargets.push(_this._diffuseTexture);
  50749. }
  50750. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  50751. _this._renderTargets.push(_this._reflectionTexture);
  50752. }
  50753. return _this._renderTargets;
  50754. };
  50755. return _this;
  50756. }
  50757. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  50758. /**
  50759. * Experimental Internal Use Only.
  50760. *
  50761. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50762. * This acts as a helper to set the primary color to a more "human friendly" value.
  50763. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50764. * output color as close as possible from the chosen value.
  50765. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50766. * part of lighting setup.)
  50767. */
  50768. get: function () {
  50769. return this.__perceptualColor;
  50770. },
  50771. set: function (value) {
  50772. this.__perceptualColor = value;
  50773. this._computePrimaryColorFromPerceptualColor();
  50774. this._markAllSubMeshesAsLightsDirty();
  50775. },
  50776. enumerable: true,
  50777. configurable: true
  50778. });
  50779. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  50780. /**
  50781. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50782. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50783. */
  50784. get: function () {
  50785. return this._primaryColorShadowLevel;
  50786. },
  50787. set: function (value) {
  50788. this._primaryColorShadowLevel = value;
  50789. this._computePrimaryColors();
  50790. this._markAllSubMeshesAsLightsDirty();
  50791. },
  50792. enumerable: true,
  50793. configurable: true
  50794. });
  50795. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  50796. /**
  50797. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50798. * The primary color is used at the level chosen to define what the white area would look.
  50799. */
  50800. get: function () {
  50801. return this._primaryColorHighlightLevel;
  50802. },
  50803. set: function (value) {
  50804. this._primaryColorHighlightLevel = value;
  50805. this._computePrimaryColors();
  50806. this._markAllSubMeshesAsLightsDirty();
  50807. },
  50808. enumerable: true,
  50809. configurable: true
  50810. });
  50811. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  50812. /**
  50813. * Sets the reflection reflectance fresnel values according to the default standard
  50814. * empirically know to work well :-)
  50815. */
  50816. set: function (value) {
  50817. var reflectionWeight = value;
  50818. if (reflectionWeight < 0.5) {
  50819. reflectionWeight = reflectionWeight * 2.0;
  50820. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  50821. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  50822. }
  50823. else {
  50824. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  50825. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  50826. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  50827. }
  50828. },
  50829. enumerable: true,
  50830. configurable: true
  50831. });
  50832. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  50833. /**
  50834. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50835. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50836. * Recommended to be keep at 1.0 except for special cases.
  50837. */
  50838. get: function () {
  50839. return this._fovMultiplier;
  50840. },
  50841. set: function (value) {
  50842. if (isNaN(value)) {
  50843. value = 1.0;
  50844. }
  50845. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  50846. },
  50847. enumerable: true,
  50848. configurable: true
  50849. });
  50850. /**
  50851. * Attaches a new image processing configuration to the PBR Material.
  50852. * @param configuration (if null the scene configuration will be use)
  50853. */
  50854. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  50855. var _this = this;
  50856. if (configuration === this._imageProcessingConfiguration) {
  50857. return;
  50858. }
  50859. // Detaches observer.
  50860. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50861. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50862. }
  50863. // Pick the scene configuration if needed.
  50864. if (!configuration) {
  50865. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  50866. }
  50867. else {
  50868. this._imageProcessingConfiguration = configuration;
  50869. }
  50870. // Attaches observer.
  50871. if (this._imageProcessingConfiguration) {
  50872. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  50873. _this._computePrimaryColorFromPerceptualColor();
  50874. _this._markAllSubMeshesAsImageProcessingDirty();
  50875. });
  50876. }
  50877. };
  50878. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  50879. /**
  50880. * Gets the image processing configuration used either in this material.
  50881. */
  50882. get: function () {
  50883. return this._imageProcessingConfiguration;
  50884. },
  50885. /**
  50886. * Sets the Default image processing configuration used either in the this material.
  50887. *
  50888. * If sets to null, the scene one is in use.
  50889. */
  50890. set: function (value) {
  50891. this._attachImageProcessingConfiguration(value);
  50892. // Ensure the effect will be rebuilt.
  50893. this._markAllSubMeshesAsTexturesDirty();
  50894. },
  50895. enumerable: true,
  50896. configurable: true
  50897. });
  50898. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  50899. /**
  50900. * Gets wether the color curves effect is enabled.
  50901. */
  50902. get: function () {
  50903. return this.imageProcessingConfiguration.colorCurvesEnabled;
  50904. },
  50905. /**
  50906. * Sets wether the color curves effect is enabled.
  50907. */
  50908. set: function (value) {
  50909. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  50910. },
  50911. enumerable: true,
  50912. configurable: true
  50913. });
  50914. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  50915. /**
  50916. * Gets wether the color grading effect is enabled.
  50917. */
  50918. get: function () {
  50919. return this.imageProcessingConfiguration.colorGradingEnabled;
  50920. },
  50921. /**
  50922. * Gets wether the color grading effect is enabled.
  50923. */
  50924. set: function (value) {
  50925. this.imageProcessingConfiguration.colorGradingEnabled = value;
  50926. },
  50927. enumerable: true,
  50928. configurable: true
  50929. });
  50930. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  50931. /**
  50932. * Gets wether tonemapping is enabled or not.
  50933. */
  50934. get: function () {
  50935. return this._imageProcessingConfiguration.toneMappingEnabled;
  50936. },
  50937. /**
  50938. * Sets wether tonemapping is enabled or not
  50939. */
  50940. set: function (value) {
  50941. this._imageProcessingConfiguration.toneMappingEnabled = value;
  50942. },
  50943. enumerable: true,
  50944. configurable: true
  50945. });
  50946. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  50947. /**
  50948. * The camera exposure used on this material.
  50949. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50950. * This corresponds to a photographic exposure.
  50951. */
  50952. get: function () {
  50953. return this._imageProcessingConfiguration.exposure;
  50954. },
  50955. /**
  50956. * The camera exposure used on this material.
  50957. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50958. * This corresponds to a photographic exposure.
  50959. */
  50960. set: function (value) {
  50961. this._imageProcessingConfiguration.exposure = value;
  50962. },
  50963. enumerable: true,
  50964. configurable: true
  50965. });
  50966. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  50967. /**
  50968. * Gets The camera contrast used on this material.
  50969. */
  50970. get: function () {
  50971. return this._imageProcessingConfiguration.contrast;
  50972. },
  50973. /**
  50974. * Sets The camera contrast used on this material.
  50975. */
  50976. set: function (value) {
  50977. this._imageProcessingConfiguration.contrast = value;
  50978. },
  50979. enumerable: true,
  50980. configurable: true
  50981. });
  50982. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  50983. /**
  50984. * Gets the Color Grading 2D Lookup Texture.
  50985. */
  50986. get: function () {
  50987. return this._imageProcessingConfiguration.colorGradingTexture;
  50988. },
  50989. /**
  50990. * Sets the Color Grading 2D Lookup Texture.
  50991. */
  50992. set: function (value) {
  50993. this.imageProcessingConfiguration.colorGradingTexture = value;
  50994. },
  50995. enumerable: true,
  50996. configurable: true
  50997. });
  50998. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  50999. /**
  51000. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51001. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51002. * 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;
  51003. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51004. */
  51005. get: function () {
  51006. return this.imageProcessingConfiguration.colorCurves;
  51007. },
  51008. /**
  51009. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51010. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51011. * 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;
  51012. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51013. */
  51014. set: function (value) {
  51015. this.imageProcessingConfiguration.colorCurves = value;
  51016. },
  51017. enumerable: true,
  51018. configurable: true
  51019. });
  51020. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  51021. /**
  51022. * Gets a boolean indicating that current material needs to register RTT
  51023. */
  51024. get: function () {
  51025. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  51026. return true;
  51027. }
  51028. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  51029. return true;
  51030. }
  51031. return false;
  51032. },
  51033. enumerable: true,
  51034. configurable: true
  51035. });
  51036. /**
  51037. * The entire material has been created in order to prevent overdraw.
  51038. * @returns false
  51039. */
  51040. BackgroundMaterial.prototype.needAlphaTesting = function () {
  51041. return true;
  51042. };
  51043. /**
  51044. * The entire material has been created in order to prevent overdraw.
  51045. * @returns true if blending is enable
  51046. */
  51047. BackgroundMaterial.prototype.needAlphaBlending = function () {
  51048. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  51049. };
  51050. /**
  51051. * Checks wether the material is ready to be rendered for a given mesh.
  51052. * @param mesh The mesh to render
  51053. * @param subMesh The submesh to check against
  51054. * @param useInstances Specify wether or not the material is used with instances
  51055. * @returns true if all the dependencies are ready (Textures, Effects...)
  51056. */
  51057. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  51058. var _this = this;
  51059. if (useInstances === void 0) { useInstances = false; }
  51060. if (subMesh.effect && this.isFrozen) {
  51061. if (this._wasPreviouslyReady) {
  51062. return true;
  51063. }
  51064. }
  51065. if (!subMesh._materialDefines) {
  51066. subMesh._materialDefines = new BackgroundMaterialDefines();
  51067. }
  51068. var scene = this.getScene();
  51069. var defines = subMesh._materialDefines;
  51070. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  51071. if (defines._renderId === scene.getRenderId()) {
  51072. return true;
  51073. }
  51074. }
  51075. var engine = scene.getEngine();
  51076. // Lights
  51077. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  51078. defines._needNormals = true;
  51079. // Multiview
  51080. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMultiview(scene, defines);
  51081. // Textures
  51082. if (defines._areTexturesDirty) {
  51083. defines._needUVs = false;
  51084. if (scene.texturesEnabled) {
  51085. if (scene.getEngine().getCaps().textureLOD) {
  51086. defines.TEXTURELODSUPPORT = true;
  51087. }
  51088. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51089. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  51090. return false;
  51091. }
  51092. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  51093. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  51094. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  51095. defines.OPACITYFRESNEL = this._opacityFresnel;
  51096. }
  51097. else {
  51098. defines.DIFFUSE = false;
  51099. defines.DIFFUSEHASALPHA = false;
  51100. defines.GAMMADIFFUSE = false;
  51101. defines.OPACITYFRESNEL = false;
  51102. }
  51103. var reflectionTexture = this._reflectionTexture;
  51104. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51105. if (!reflectionTexture.isReadyOrNotBlocking()) {
  51106. return false;
  51107. }
  51108. defines.REFLECTION = true;
  51109. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  51110. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  51111. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  51112. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  51113. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  51114. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  51115. defines.REFLECTIONBGR = this.switchToBGR;
  51116. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  51117. defines.INVERTCUBICMAP = true;
  51118. }
  51119. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  51120. switch (reflectionTexture.coordinatesMode) {
  51121. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  51122. defines.REFLECTIONMAP_EXPLICIT = true;
  51123. break;
  51124. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  51125. defines.REFLECTIONMAP_PLANAR = true;
  51126. break;
  51127. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  51128. defines.REFLECTIONMAP_PROJECTION = true;
  51129. break;
  51130. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  51131. defines.REFLECTIONMAP_SKYBOX = true;
  51132. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  51133. break;
  51134. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  51135. defines.REFLECTIONMAP_SPHERICAL = true;
  51136. break;
  51137. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  51138. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  51139. break;
  51140. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  51141. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  51142. break;
  51143. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  51144. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  51145. break;
  51146. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  51147. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  51148. default:
  51149. defines.REFLECTIONMAP_CUBIC = true;
  51150. break;
  51151. }
  51152. if (this.reflectionFresnel) {
  51153. defines.REFLECTIONFRESNEL = true;
  51154. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  51155. this._reflectionControls.x = this.reflectionAmount;
  51156. this._reflectionControls.y = this.reflectionReflectance0;
  51157. this._reflectionControls.z = this.reflectionReflectance90;
  51158. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  51159. }
  51160. else {
  51161. defines.REFLECTIONFRESNEL = false;
  51162. defines.REFLECTIONFALLOFF = false;
  51163. }
  51164. }
  51165. else {
  51166. defines.REFLECTION = false;
  51167. defines.REFLECTIONFRESNEL = false;
  51168. defines.REFLECTIONFALLOFF = false;
  51169. defines.REFLECTIONBLUR = false;
  51170. defines.REFLECTIONMAP_3D = false;
  51171. defines.REFLECTIONMAP_SPHERICAL = false;
  51172. defines.REFLECTIONMAP_PLANAR = false;
  51173. defines.REFLECTIONMAP_CUBIC = false;
  51174. defines.REFLECTIONMAP_PROJECTION = false;
  51175. defines.REFLECTIONMAP_SKYBOX = false;
  51176. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51177. defines.REFLECTIONMAP_EXPLICIT = false;
  51178. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51179. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51180. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51181. defines.INVERTCUBICMAP = false;
  51182. defines.REFLECTIONMAP_OPPOSITEZ = false;
  51183. defines.LODINREFLECTIONALPHA = false;
  51184. defines.GAMMAREFLECTION = false;
  51185. defines.RGBDREFLECTION = false;
  51186. }
  51187. }
  51188. 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);
  51189. defines.USERGBCOLOR = this._useRGBColor;
  51190. defines.NOISE = this._enableNoise;
  51191. }
  51192. if (defines._areLightsDirty) {
  51193. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  51194. }
  51195. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  51196. if (!this._imageProcessingConfiguration.isReady()) {
  51197. return false;
  51198. }
  51199. this._imageProcessingConfiguration.prepareDefines(defines);
  51200. }
  51201. // Misc.
  51202. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  51203. // Values that need to be evaluated on every frame
  51204. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  51205. // Attribs
  51206. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  51207. if (mesh) {
  51208. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  51209. mesh.createNormals(true);
  51210. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  51211. }
  51212. }
  51213. }
  51214. // Get correct effect
  51215. if (defines.isDirty) {
  51216. defines.markAsProcessed();
  51217. scene.resetCachedMaterial();
  51218. // Fallbacks
  51219. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  51220. if (defines.FOG) {
  51221. fallbacks.addFallback(0, "FOG");
  51222. }
  51223. if (defines.POINTSIZE) {
  51224. fallbacks.addFallback(1, "POINTSIZE");
  51225. }
  51226. if (defines.MULTIVIEW) {
  51227. fallbacks.addFallback(0, "MULTIVIEW");
  51228. }
  51229. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  51230. if (defines.NUM_BONE_INFLUENCERS > 0) {
  51231. fallbacks.addCPUSkinningFallback(0, mesh);
  51232. }
  51233. //Attributes
  51234. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  51235. if (defines.NORMAL) {
  51236. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  51237. }
  51238. if (defines.UV1) {
  51239. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  51240. }
  51241. if (defines.UV2) {
  51242. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  51243. }
  51244. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  51245. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  51246. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  51247. "vFogInfos", "vFogColor", "pointSize",
  51248. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  51249. "vPrimaryColor", "vPrimaryColorShadow",
  51250. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  51251. "shadowLevel", "alpha",
  51252. "vBackgroundCenter", "vReflectionControl",
  51253. "vDiffuseInfos", "diffuseMatrix",
  51254. ];
  51255. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  51256. var uniformBuffers = ["Material", "Scene"];
  51257. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  51258. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  51259. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  51260. }
  51261. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  51262. uniformsNames: uniforms,
  51263. uniformBuffersNames: uniformBuffers,
  51264. samplers: samplers,
  51265. defines: defines,
  51266. maxSimultaneousLights: this._maxSimultaneousLights
  51267. });
  51268. var onCompiled = function (effect) {
  51269. if (_this.onCompiled) {
  51270. _this.onCompiled(effect);
  51271. }
  51272. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  51273. };
  51274. var join = defines.toString();
  51275. subMesh.setEffect(scene.getEngine().createEffect("background", {
  51276. attributes: attribs,
  51277. uniformsNames: uniforms,
  51278. uniformBuffersNames: uniformBuffers,
  51279. samplers: samplers,
  51280. defines: join,
  51281. fallbacks: fallbacks,
  51282. onCompiled: onCompiled,
  51283. onError: this.onError,
  51284. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  51285. }, engine), defines);
  51286. this.buildUniformLayout();
  51287. }
  51288. if (!subMesh.effect || !subMesh.effect.isReady()) {
  51289. return false;
  51290. }
  51291. defines._renderId = scene.getRenderId();
  51292. this._wasPreviouslyReady = true;
  51293. return true;
  51294. };
  51295. /**
  51296. * Compute the primary color according to the chosen perceptual color.
  51297. */
  51298. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  51299. if (!this.__perceptualColor) {
  51300. return;
  51301. }
  51302. this._primaryColor.copyFrom(this.__perceptualColor);
  51303. // Revert gamma space.
  51304. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  51305. // Revert image processing configuration.
  51306. if (this._imageProcessingConfiguration) {
  51307. // Revert Exposure.
  51308. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  51309. }
  51310. this._computePrimaryColors();
  51311. };
  51312. /**
  51313. * Compute the highlights and shadow colors according to their chosen levels.
  51314. */
  51315. BackgroundMaterial.prototype._computePrimaryColors = function () {
  51316. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  51317. return;
  51318. }
  51319. // Find the highlight color based on the configuration.
  51320. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  51321. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  51322. // Find the shadow color based on the configuration.
  51323. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  51324. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  51325. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  51326. };
  51327. /**
  51328. * Build the uniform buffer used in the material.
  51329. */
  51330. BackgroundMaterial.prototype.buildUniformLayout = function () {
  51331. // Order is important !
  51332. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  51333. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  51334. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  51335. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  51336. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  51337. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  51338. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  51339. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  51340. this._uniformBuffer.addUniform("pointSize", 1);
  51341. this._uniformBuffer.addUniform("shadowLevel", 1);
  51342. this._uniformBuffer.addUniform("alpha", 1);
  51343. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  51344. this._uniformBuffer.addUniform("vReflectionControl", 4);
  51345. this._uniformBuffer.create();
  51346. };
  51347. /**
  51348. * Unbind the material.
  51349. */
  51350. BackgroundMaterial.prototype.unbind = function () {
  51351. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  51352. this._uniformBuffer.setTexture("diffuseSampler", null);
  51353. }
  51354. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  51355. this._uniformBuffer.setTexture("reflectionSampler", null);
  51356. }
  51357. _super.prototype.unbind.call(this);
  51358. };
  51359. /**
  51360. * Bind only the world matrix to the material.
  51361. * @param world The world matrix to bind.
  51362. */
  51363. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  51364. this._activeEffect.setMatrix("world", world);
  51365. };
  51366. /**
  51367. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51368. * @param world The world matrix to bind.
  51369. * @param subMesh The submesh to bind for.
  51370. */
  51371. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  51372. var scene = this.getScene();
  51373. var defines = subMesh._materialDefines;
  51374. if (!defines) {
  51375. return;
  51376. }
  51377. var effect = subMesh.effect;
  51378. if (!effect) {
  51379. return;
  51380. }
  51381. this._activeEffect = effect;
  51382. // Matrices
  51383. this.bindOnlyWorldMatrix(world);
  51384. // Bones
  51385. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  51386. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  51387. if (mustRebind) {
  51388. this._uniformBuffer.bindToEffect(effect, "Material");
  51389. this.bindViewProjection(effect);
  51390. var reflectionTexture = this._reflectionTexture;
  51391. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  51392. // Texture uniforms
  51393. if (scene.texturesEnabled) {
  51394. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51395. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  51396. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  51397. }
  51398. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51399. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  51400. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  51401. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  51402. }
  51403. }
  51404. if (this.shadowLevel > 0) {
  51405. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  51406. }
  51407. this._uniformBuffer.updateFloat("alpha", this.alpha);
  51408. // Point size
  51409. if (this.pointsCloud) {
  51410. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  51411. }
  51412. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  51413. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  51414. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  51415. }
  51416. else {
  51417. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  51418. }
  51419. }
  51420. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  51421. // Textures
  51422. if (scene.texturesEnabled) {
  51423. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  51424. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  51425. }
  51426. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  51427. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  51428. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  51429. }
  51430. else if (!defines.REFLECTIONBLUR) {
  51431. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  51432. }
  51433. else {
  51434. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  51435. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  51436. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  51437. }
  51438. if (defines.REFLECTIONFRESNEL) {
  51439. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  51440. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  51441. }
  51442. }
  51443. }
  51444. // Clip plane
  51445. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  51446. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  51447. }
  51448. if (mustRebind || !this.isFrozen) {
  51449. if (scene.lightsEnabled) {
  51450. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  51451. }
  51452. // View
  51453. this.bindView(effect);
  51454. // Fog
  51455. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  51456. // image processing
  51457. if (this._imageProcessingConfiguration) {
  51458. this._imageProcessingConfiguration.bind(this._activeEffect);
  51459. }
  51460. }
  51461. this._uniformBuffer.update();
  51462. this._afterBind(mesh, this._activeEffect);
  51463. };
  51464. /**
  51465. * Dispose the material.
  51466. * @param forceDisposeEffect Force disposal of the associated effect.
  51467. * @param forceDisposeTextures Force disposal of the associated textures.
  51468. */
  51469. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  51470. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  51471. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  51472. if (forceDisposeTextures) {
  51473. if (this.diffuseTexture) {
  51474. this.diffuseTexture.dispose();
  51475. }
  51476. if (this.reflectionTexture) {
  51477. this.reflectionTexture.dispose();
  51478. }
  51479. }
  51480. this._renderTargets.dispose();
  51481. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  51482. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  51483. }
  51484. _super.prototype.dispose.call(this, forceDisposeEffect);
  51485. };
  51486. /**
  51487. * Clones the material.
  51488. * @param name The cloned name.
  51489. * @returns The cloned material.
  51490. */
  51491. BackgroundMaterial.prototype.clone = function (name) {
  51492. var _this = this;
  51493. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  51494. };
  51495. /**
  51496. * Serializes the current material to its JSON representation.
  51497. * @returns The JSON representation.
  51498. */
  51499. BackgroundMaterial.prototype.serialize = function () {
  51500. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51501. serializationObject.customType = "BABYLON.BackgroundMaterial";
  51502. return serializationObject;
  51503. };
  51504. /**
  51505. * Gets the class name of the material
  51506. * @returns "BackgroundMaterial"
  51507. */
  51508. BackgroundMaterial.prototype.getClassName = function () {
  51509. return "BackgroundMaterial";
  51510. };
  51511. /**
  51512. * Parse a JSON input to create back a background material.
  51513. * @param source The JSON data to parse
  51514. * @param scene The scene to create the parsed material in
  51515. * @param rootUrl The root url of the assets the material depends upon
  51516. * @returns the instantiated BackgroundMaterial.
  51517. */
  51518. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  51519. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  51520. };
  51521. /**
  51522. * Standard reflectance value at parallel view angle.
  51523. */
  51524. BackgroundMaterial.StandardReflectance0 = 0.05;
  51525. /**
  51526. * Standard reflectance value at grazing angle.
  51527. */
  51528. BackgroundMaterial.StandardReflectance90 = 0.5;
  51529. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51530. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  51531. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  51532. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51533. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51534. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  51535. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51536. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  51537. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  51538. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51539. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51540. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  51541. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51542. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51543. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  51544. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51545. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  51546. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  51547. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51548. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51549. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  51550. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51551. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51552. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  51553. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51554. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51555. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  51556. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51557. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51558. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  51559. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51560. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51561. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  51562. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51563. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51564. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  51565. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51566. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51567. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  51568. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51569. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51570. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  51571. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51572. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51573. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  51574. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51575. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  51576. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  51577. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51578. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51579. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  51580. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51581. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51582. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  51583. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51584. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51585. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  51586. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51587. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51588. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  51589. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51590. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51591. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  51592. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51593. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51594. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  51595. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51596. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51597. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  51598. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51599. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51600. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  51601. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51602. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51603. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  51604. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51605. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51606. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  51607. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51608. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51609. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  51610. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51611. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51612. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  51613. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51614. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51615. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  51616. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51617. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51618. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  51619. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51620. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51621. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  51622. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51623. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51624. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  51625. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51626. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51627. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  51628. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51629. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51630. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  51631. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51632. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51633. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  51634. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51635. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  51636. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  51637. return BackgroundMaterial;
  51638. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  51639. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  51640. /***/ }),
  51641. /***/ "./Materials/Background/index.ts":
  51642. /*!***************************************!*\
  51643. !*** ./Materials/Background/index.ts ***!
  51644. \***************************************/
  51645. /*! exports provided: BackgroundMaterial */
  51646. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51647. "use strict";
  51648. __webpack_require__.r(__webpack_exports__);
  51649. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  51650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  51651. /***/ }),
  51652. /***/ "./Materials/PBR/index.ts":
  51653. /*!********************************!*\
  51654. !*** ./Materials/PBR/index.ts ***!
  51655. \********************************/
  51656. /*! exports provided: PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  51657. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51658. "use strict";
  51659. __webpack_require__.r(__webpack_exports__);
  51660. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  51661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRMaterialDefines"]; });
  51662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  51663. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  51664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  51665. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  51666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  51667. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  51668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  51669. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  51670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  51671. /***/ }),
  51672. /***/ "./Materials/PBR/pbrAnisotropicConfiguration.ts":
  51673. /*!******************************************************!*\
  51674. !*** ./Materials/PBR/pbrAnisotropicConfiguration.ts ***!
  51675. \******************************************************/
  51676. /*! exports provided: PBRAnisotropicConfiguration */
  51677. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51678. "use strict";
  51679. __webpack_require__.r(__webpack_exports__);
  51680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRAnisotropicConfiguration", function() { return PBRAnisotropicConfiguration; });
  51681. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51682. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51683. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  51684. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  51685. /* harmony import */ var _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialFlags */ "./Materials/materialFlags.ts");
  51686. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  51687. /**
  51688. * Define the code related to the anisotropic parameters of the pbr material.
  51689. */
  51690. var PBRAnisotropicConfiguration = /** @class */ (function () {
  51691. /**
  51692. * Instantiate a new istance of anisotropy configuration.
  51693. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51694. */
  51695. function PBRAnisotropicConfiguration(markAllSubMeshesAsTexturesDirty) {
  51696. this._isEnabled = false;
  51697. /**
  51698. * Defines if the anisotropy is enabled in the material.
  51699. */
  51700. this.isEnabled = false;
  51701. /**
  51702. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51703. */
  51704. this.intensity = 1;
  51705. /**
  51706. * Defines if the effect is along the tangents, bitangents or in between.
  51707. * By default, the effect is "strectching" the highlights along the tangents.
  51708. */
  51709. this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 0);
  51710. this._texture = null;
  51711. /**
  51712. * Stores the anisotropy values in a texture.
  51713. * rg is direction (like normal from -1 to 1)
  51714. * b is a intensity
  51715. */
  51716. this.texture = null;
  51717. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  51718. }
  51719. /** @hidden */
  51720. PBRAnisotropicConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  51721. this._internalMarkAllSubMeshesAsTexturesDirty();
  51722. };
  51723. /**
  51724. * Specifies that the submesh is ready to be used.
  51725. * @param defines the list of "defines" to update.
  51726. * @param scene defines the scene the material belongs to.
  51727. * @returns - boolean indicating that the submesh is ready or not.
  51728. */
  51729. PBRAnisotropicConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  51730. if (defines._areTexturesDirty) {
  51731. if (scene.texturesEnabled) {
  51732. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51733. if (!this._texture.isReadyOrNotBlocking()) {
  51734. return false;
  51735. }
  51736. }
  51737. }
  51738. }
  51739. return true;
  51740. };
  51741. /**
  51742. * Checks to see if a texture is used in the material.
  51743. * @param defines the list of "defines" to update.
  51744. * @param mesh the mesh we are preparing the defines for.
  51745. * @param scene defines the scene the material belongs to.
  51746. */
  51747. PBRAnisotropicConfiguration.prototype.prepareDefines = function (defines, mesh, scene) {
  51748. if (this._isEnabled) {
  51749. defines.ANISOTROPIC = this._isEnabled;
  51750. if (this._isEnabled && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  51751. defines._needUVs = true;
  51752. defines.MAINUV1 = true;
  51753. }
  51754. if (defines._areTexturesDirty) {
  51755. if (scene.texturesEnabled) {
  51756. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51757. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "ANISOTROPIC_TEXTURE");
  51758. }
  51759. else {
  51760. defines.ANISOTROPIC_TEXTURE = false;
  51761. }
  51762. }
  51763. }
  51764. }
  51765. else {
  51766. defines.ANISOTROPIC = false;
  51767. defines.ANISOTROPIC_TEXTURE = false;
  51768. }
  51769. };
  51770. /**
  51771. * Binds the material data.
  51772. * @param uniformBuffer defines the Uniform buffer to fill in.
  51773. * @param scene defines the scene the material belongs to.
  51774. * @param isFrozen defines wether the material is frozen or not.
  51775. */
  51776. PBRAnisotropicConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, isFrozen) {
  51777. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  51778. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51779. uniformBuffer.updateFloat2("vAnisotropyInfos", this._texture.coordinatesIndex, this._texture.level);
  51780. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "anisotropy");
  51781. }
  51782. // Anisotropy
  51783. uniformBuffer.updateFloat3("vAnisotropy", this.direction.x, this.direction.y, this.intensity);
  51784. }
  51785. // Textures
  51786. if (scene.texturesEnabled) {
  51787. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_4__["MaterialFlags"].AnisotropicTextureEnabled) {
  51788. uniformBuffer.setTexture("anisotropySampler", this._texture);
  51789. }
  51790. }
  51791. };
  51792. /**
  51793. * Checks to see if a texture is used in the material.
  51794. * @param texture - Base texture to use.
  51795. * @returns - Boolean specifying if a texture is used in the material.
  51796. */
  51797. PBRAnisotropicConfiguration.prototype.hasTexture = function (texture) {
  51798. if (this._texture === texture) {
  51799. return true;
  51800. }
  51801. return false;
  51802. };
  51803. /**
  51804. * Returns an array of the actively used textures.
  51805. * @param activeTextures Array of BaseTextures
  51806. */
  51807. PBRAnisotropicConfiguration.prototype.getActiveTextures = function (activeTextures) {
  51808. if (this._texture) {
  51809. activeTextures.push(this._texture);
  51810. }
  51811. };
  51812. /**
  51813. * Returns the animatable textures.
  51814. * @param animatables Array of animatable textures.
  51815. */
  51816. PBRAnisotropicConfiguration.prototype.getAnimatables = function (animatables) {
  51817. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  51818. animatables.push(this._texture);
  51819. }
  51820. };
  51821. /**
  51822. * Disposes the resources of the material.
  51823. * @param forceDisposeTextures - Forces the disposal of all textures.
  51824. */
  51825. PBRAnisotropicConfiguration.prototype.dispose = function (forceDisposeTextures) {
  51826. if (forceDisposeTextures) {
  51827. if (this._texture) {
  51828. this._texture.dispose();
  51829. }
  51830. }
  51831. };
  51832. /**
  51833. * Get the current class name of the texture useful for serialization or dynamic coding.
  51834. * @returns "PBRAnisotropicConfiguration"
  51835. */
  51836. PBRAnisotropicConfiguration.prototype.getClassName = function () {
  51837. return "PBRAnisotropicConfiguration";
  51838. };
  51839. /**
  51840. * Add fallbacks to the effect fallbacks list.
  51841. * @param defines defines the Base texture to use.
  51842. * @param fallbacks defines the current fallback list.
  51843. * @param currentRank defines the current fallback rank.
  51844. * @returns the new fallback rank.
  51845. */
  51846. PBRAnisotropicConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  51847. if (defines.ANISOTROPIC) {
  51848. fallbacks.addFallback(currentRank++, "ANISOTROPIC");
  51849. }
  51850. return currentRank;
  51851. };
  51852. /**
  51853. * Add the required uniforms to the current list.
  51854. * @param uniforms defines the current uniform list.
  51855. */
  51856. PBRAnisotropicConfiguration.AddUniforms = function (uniforms) {
  51857. uniforms.push("vAnisotropy", "vAnisotropyInfos", "anisotropyMatrix");
  51858. };
  51859. /**
  51860. * Add the required uniforms to the current buffer.
  51861. * @param uniformBuffer defines the current uniform buffer.
  51862. */
  51863. PBRAnisotropicConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  51864. uniformBuffer.addUniform("vAnisotropy", 3);
  51865. uniformBuffer.addUniform("vAnisotropyInfos", 2);
  51866. uniformBuffer.addUniform("anisotropyMatrix", 16);
  51867. };
  51868. /**
  51869. * Add the required samplers to the current list.
  51870. * @param samplers defines the current sampler list.
  51871. */
  51872. PBRAnisotropicConfiguration.AddSamplers = function (samplers) {
  51873. samplers.push("anisotropySampler");
  51874. };
  51875. /**
  51876. * Makes a duplicate of the current configuration into another one.
  51877. * @param anisotropicConfiguration define the config where to copy the info
  51878. */
  51879. PBRAnisotropicConfiguration.prototype.copyTo = function (anisotropicConfiguration) {
  51880. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return anisotropicConfiguration; }, this);
  51881. };
  51882. /**
  51883. * Serializes this anisotropy configuration.
  51884. * @returns - An object with the serialized config.
  51885. */
  51886. PBRAnisotropicConfiguration.prototype.serialize = function () {
  51887. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51888. };
  51889. /**
  51890. * Parses a anisotropy Configuration from a serialized object.
  51891. * @param source - Serialized object.
  51892. */
  51893. PBRAnisotropicConfiguration.prototype.parse = function (source) {
  51894. var _this = this;
  51895. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  51896. };
  51897. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51898. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51899. ], PBRAnisotropicConfiguration.prototype, "_isEnabled", void 0);
  51900. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51901. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51902. ], PBRAnisotropicConfiguration.prototype, "isEnabled", void 0);
  51903. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51904. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  51905. ], PBRAnisotropicConfiguration.prototype, "intensity", void 0);
  51906. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51907. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector2"])()
  51908. ], PBRAnisotropicConfiguration.prototype, "direction", void 0);
  51909. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51910. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  51911. ], PBRAnisotropicConfiguration.prototype, "_texture", void 0);
  51912. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  51913. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  51914. ], PBRAnisotropicConfiguration.prototype, "texture", void 0);
  51915. return PBRAnisotropicConfiguration;
  51916. }());
  51917. /***/ }),
  51918. /***/ "./Materials/PBR/pbrBRDFConfiguration.ts":
  51919. /*!***********************************************!*\
  51920. !*** ./Materials/PBR/pbrBRDFConfiguration.ts ***!
  51921. \***********************************************/
  51922. /*! exports provided: PBRBRDFConfiguration */
  51923. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  51924. "use strict";
  51925. __webpack_require__.r(__webpack_exports__);
  51926. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBRDFConfiguration", function() { return PBRBRDFConfiguration; });
  51927. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  51928. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  51929. /**
  51930. * Define the code related to the BRDF parameters of the pbr material.
  51931. */
  51932. var PBRBRDFConfiguration = /** @class */ (function () {
  51933. /**
  51934. * Instantiate a new istance of clear coat configuration.
  51935. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51936. */
  51937. function PBRBRDFConfiguration(markAllSubMeshesAsMiscDirty) {
  51938. this._useEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION;
  51939. /**
  51940. * Defines if the material uses energy conservation.
  51941. */
  51942. this.useEnergyConservation = PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION;
  51943. this._useSmithVisibilityHeightCorrelated = PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED;
  51944. /**
  51945. * LEGACY Mode set to false
  51946. * Defines if the material uses height smith correlated visibility term.
  51947. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  51948. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51949. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51950. * Not relying on height correlated will also disable energy conservation.
  51951. */
  51952. this.useSmithVisibilityHeightCorrelated = PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED;
  51953. this._internalMarkAllSubMeshesAsMiscDirty = markAllSubMeshesAsMiscDirty;
  51954. }
  51955. /** @hidden */
  51956. PBRBRDFConfiguration.prototype._markAllSubMeshesAsMiscDirty = function () {
  51957. this._internalMarkAllSubMeshesAsMiscDirty();
  51958. };
  51959. /**
  51960. * Checks to see if a texture is used in the material.
  51961. * @param defines the list of "defines" to update.
  51962. */
  51963. PBRBRDFConfiguration.prototype.prepareDefines = function (defines) {
  51964. defines.BRDF_V_HEIGHT_CORRELATED = this._useSmithVisibilityHeightCorrelated;
  51965. defines.MS_BRDF_ENERGY_CONSERVATION = this._useEnergyConservation && this._useSmithVisibilityHeightCorrelated;
  51966. };
  51967. /**
  51968. * Get the current class name of the texture useful for serialization or dynamic coding.
  51969. * @returns "PBRClearCoatConfiguration"
  51970. */
  51971. PBRBRDFConfiguration.prototype.getClassName = function () {
  51972. return "PBRClearCoatConfiguration";
  51973. };
  51974. /**
  51975. * Makes a duplicate of the current configuration into another one.
  51976. * @param brdfConfiguration define the config where to copy the info
  51977. */
  51978. PBRBRDFConfiguration.prototype.copyTo = function (brdfConfiguration) {
  51979. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return brdfConfiguration; }, this);
  51980. };
  51981. /**
  51982. * Serializes this BRDF configuration.
  51983. * @returns - An object with the serialized config.
  51984. */
  51985. PBRBRDFConfiguration.prototype.serialize = function () {
  51986. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  51987. };
  51988. /**
  51989. * Parses a BRDF Configuration from a serialized object.
  51990. * @param source - Serialized object.
  51991. */
  51992. PBRBRDFConfiguration.prototype.parse = function (source) {
  51993. var _this = this;
  51994. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  51995. };
  51996. /**
  51997. * Default value used for the energy conservation.
  51998. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51999. */
  52000. PBRBRDFConfiguration.DEFAULT_USE_ENERGY_CONSERVATION = true;
  52001. /**
  52002. * Default value used for the Smith Visibility Height Correlated mode.
  52003. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52004. */
  52005. PBRBRDFConfiguration.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED = true;
  52006. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52007. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52008. ], PBRBRDFConfiguration.prototype, "_useEnergyConservation", void 0);
  52009. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52010. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  52011. ], PBRBRDFConfiguration.prototype, "useEnergyConservation", void 0);
  52012. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52013. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52014. ], PBRBRDFConfiguration.prototype, "_useSmithVisibilityHeightCorrelated", void 0);
  52015. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  52017. ], PBRBRDFConfiguration.prototype, "useSmithVisibilityHeightCorrelated", void 0);
  52018. return PBRBRDFConfiguration;
  52019. }());
  52020. /***/ }),
  52021. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  52022. /*!******************************************!*\
  52023. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  52024. \******************************************/
  52025. /*! exports provided: PBRMaterialDefines, PBRBaseMaterial */
  52026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52027. "use strict";
  52028. __webpack_require__.r(__webpack_exports__);
  52029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return PBRMaterialDefines; });
  52030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  52031. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52032. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52033. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  52034. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  52035. /* harmony import */ var _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/brdfTextureTools */ "./Misc/brdfTextureTools.ts");
  52036. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  52037. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  52038. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  52039. /* harmony import */ var _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./pbrClearCoatConfiguration */ "./Materials/PBR/pbrClearCoatConfiguration.ts");
  52040. /* harmony import */ var _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pbrAnisotropicConfiguration */ "./Materials/PBR/pbrAnisotropicConfiguration.ts");
  52041. /* harmony import */ var _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pbrBRDFConfiguration */ "./Materials/PBR/pbrBRDFConfiguration.ts");
  52042. /* harmony import */ var _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./pbrSheenConfiguration */ "./Materials/PBR/pbrSheenConfiguration.ts");
  52043. /* harmony import */ var _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./pbrSubSurfaceConfiguration */ "./Materials/PBR/pbrSubSurfaceConfiguration.ts");
  52044. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  52045. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  52046. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  52047. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  52048. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  52049. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  52050. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  52051. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  52052. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  52053. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  52054. /**
  52055. * Manages the defines for the PBR Material.
  52056. * @hidden
  52057. */
  52058. var PBRMaterialDefines = /** @class */ (function (_super) {
  52059. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  52060. /**
  52061. * Initializes the PBR Material defines.
  52062. */
  52063. function PBRMaterialDefines() {
  52064. var _this = _super.call(this) || this;
  52065. _this.PBR = true;
  52066. _this.MAINUV1 = false;
  52067. _this.MAINUV2 = false;
  52068. _this.UV1 = false;
  52069. _this.UV2 = false;
  52070. _this.ALBEDO = false;
  52071. _this.ALBEDODIRECTUV = 0;
  52072. _this.VERTEXCOLOR = false;
  52073. _this.AMBIENT = false;
  52074. _this.AMBIENTDIRECTUV = 0;
  52075. _this.AMBIENTINGRAYSCALE = false;
  52076. _this.OPACITY = false;
  52077. _this.VERTEXALPHA = false;
  52078. _this.OPACITYDIRECTUV = 0;
  52079. _this.OPACITYRGB = false;
  52080. _this.ALPHATEST = false;
  52081. _this.DEPTHPREPASS = false;
  52082. _this.ALPHABLEND = false;
  52083. _this.ALPHAFROMALBEDO = false;
  52084. _this.ALPHATESTVALUE = "0.5";
  52085. _this.SPECULAROVERALPHA = false;
  52086. _this.RADIANCEOVERALPHA = false;
  52087. _this.ALPHAFRESNEL = false;
  52088. _this.LINEARALPHAFRESNEL = false;
  52089. _this.PREMULTIPLYALPHA = false;
  52090. _this.EMISSIVE = false;
  52091. _this.EMISSIVEDIRECTUV = 0;
  52092. _this.REFLECTIVITY = false;
  52093. _this.REFLECTIVITYDIRECTUV = 0;
  52094. _this.SPECULARTERM = false;
  52095. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  52096. _this.MICROSURFACEAUTOMATIC = false;
  52097. _this.LODBASEDMICROSFURACE = false;
  52098. _this.MICROSURFACEMAP = false;
  52099. _this.MICROSURFACEMAPDIRECTUV = 0;
  52100. _this.METALLICWORKFLOW = false;
  52101. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  52102. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  52103. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  52104. _this.AOSTOREINMETALMAPRED = false;
  52105. _this.ENVIRONMENTBRDF = false;
  52106. _this.ENVIRONMENTBRDF_RGBD = false;
  52107. _this.NORMAL = false;
  52108. _this.TANGENT = false;
  52109. _this.BUMP = false;
  52110. _this.BUMPDIRECTUV = 0;
  52111. _this.OBJECTSPACE_NORMALMAP = false;
  52112. _this.PARALLAX = false;
  52113. _this.PARALLAXOCCLUSION = false;
  52114. _this.NORMALXYSCALE = true;
  52115. _this.LIGHTMAP = false;
  52116. _this.LIGHTMAPDIRECTUV = 0;
  52117. _this.USELIGHTMAPASSHADOWMAP = false;
  52118. _this.GAMMALIGHTMAP = false;
  52119. _this.REFLECTION = false;
  52120. _this.REFLECTIONMAP_3D = false;
  52121. _this.REFLECTIONMAP_SPHERICAL = false;
  52122. _this.REFLECTIONMAP_PLANAR = false;
  52123. _this.REFLECTIONMAP_CUBIC = false;
  52124. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  52125. _this.REFLECTIONMAP_PROJECTION = false;
  52126. _this.REFLECTIONMAP_SKYBOX = false;
  52127. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  52128. _this.REFLECTIONMAP_EXPLICIT = false;
  52129. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  52130. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  52131. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  52132. _this.INVERTCUBICMAP = false;
  52133. _this.USESPHERICALFROMREFLECTIONMAP = false;
  52134. _this.USESPHERICALINVERTEX = false;
  52135. _this.REFLECTIONMAP_OPPOSITEZ = false;
  52136. _this.LODINREFLECTIONALPHA = false;
  52137. _this.GAMMAREFLECTION = false;
  52138. _this.RGBDREFLECTION = false;
  52139. _this.RADIANCEOCCLUSION = false;
  52140. _this.HORIZONOCCLUSION = false;
  52141. _this.INSTANCES = false;
  52142. _this.NUM_BONE_INFLUENCERS = 0;
  52143. _this.BonesPerMesh = 0;
  52144. _this.BONETEXTURE = false;
  52145. _this.NONUNIFORMSCALING = false;
  52146. _this.MORPHTARGETS = false;
  52147. _this.MORPHTARGETS_NORMAL = false;
  52148. _this.MORPHTARGETS_TANGENT = false;
  52149. _this.NUM_MORPH_INFLUENCERS = 0;
  52150. _this.IMAGEPROCESSING = false;
  52151. _this.VIGNETTE = false;
  52152. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  52153. _this.VIGNETTEBLENDMODEOPAQUE = false;
  52154. _this.TONEMAPPING = false;
  52155. _this.TONEMAPPING_ACES = false;
  52156. _this.CONTRAST = false;
  52157. _this.COLORCURVES = false;
  52158. _this.COLORGRADING = false;
  52159. _this.COLORGRADING3D = false;
  52160. _this.SAMPLER3DGREENDEPTH = false;
  52161. _this.SAMPLER3DBGRMAP = false;
  52162. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  52163. _this.EXPOSURE = false;
  52164. _this.MULTIVIEW = false;
  52165. _this.USEPHYSICALLIGHTFALLOFF = false;
  52166. _this.USEGLTFLIGHTFALLOFF = false;
  52167. _this.TWOSIDEDLIGHTING = false;
  52168. _this.SHADOWFLOAT = false;
  52169. _this.CLIPPLANE = false;
  52170. _this.CLIPPLANE2 = false;
  52171. _this.CLIPPLANE3 = false;
  52172. _this.CLIPPLANE4 = false;
  52173. _this.POINTSIZE = false;
  52174. _this.FOG = false;
  52175. _this.LOGARITHMICDEPTH = false;
  52176. _this.FORCENORMALFORWARD = false;
  52177. _this.SPECULARAA = false;
  52178. _this.CLEARCOAT = false;
  52179. _this.CLEARCOAT_DEFAULTIOR = false;
  52180. _this.CLEARCOAT_TEXTURE = false;
  52181. _this.CLEARCOAT_TEXTUREDIRECTUV = 0;
  52182. _this.CLEARCOAT_BUMP = false;
  52183. _this.CLEARCOAT_BUMPDIRECTUV = 0;
  52184. _this.CLEARCOAT_TINT = false;
  52185. _this.CLEARCOAT_TINT_TEXTURE = false;
  52186. _this.CLEARCOAT_TINT_TEXTUREDIRECTUV = 0;
  52187. _this.ANISOTROPIC = false;
  52188. _this.ANISOTROPIC_TEXTURE = false;
  52189. _this.ANISOTROPIC_TEXTUREDIRECTUV = 0;
  52190. _this.BRDF_V_HEIGHT_CORRELATED = false;
  52191. _this.MS_BRDF_ENERGY_CONSERVATION = false;
  52192. _this.SHEEN = false;
  52193. _this.SHEEN_TEXTURE = false;
  52194. _this.SHEEN_TEXTUREDIRECTUV = 0;
  52195. _this.SHEEN_LINKWITHALBEDO = false;
  52196. _this.SUBSURFACE = false;
  52197. _this.SS_REFRACTION = false;
  52198. _this.SS_TRANSLUCENCY = false;
  52199. _this.SS_SCATERRING = false;
  52200. _this.SS_THICKNESSANDMASK_TEXTURE = false;
  52201. _this.SS_THICKNESSANDMASK_TEXTUREDIRECTUV = 0;
  52202. _this.SS_REFRACTIONMAP_3D = false;
  52203. _this.SS_REFRACTIONMAP_OPPOSITEZ = false;
  52204. _this.SS_LODINREFRACTIONALPHA = false;
  52205. _this.SS_GAMMAREFRACTION = false;
  52206. _this.SS_RGBDREFRACTION = false;
  52207. _this.SS_LINKREFRACTIONTOTRANSPARENCY = false;
  52208. _this.SS_MASK_FROM_THICKNESS_TEXTURE = false;
  52209. _this.UNLIT = false;
  52210. _this.DEBUGMODE = 0;
  52211. _this.rebuild();
  52212. return _this;
  52213. }
  52214. /**
  52215. * Resets the PBR Material defines.
  52216. */
  52217. PBRMaterialDefines.prototype.reset = function () {
  52218. _super.prototype.reset.call(this);
  52219. this.ALPHATESTVALUE = "0.5";
  52220. this.PBR = true;
  52221. };
  52222. return PBRMaterialDefines;
  52223. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_15__["MaterialDefines"]));
  52224. /**
  52225. * The Physically based material base class of BJS.
  52226. *
  52227. * This offers the main features of a standard PBR material.
  52228. * For more information, please refer to the documentation :
  52229. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  52230. */
  52231. var PBRBaseMaterial = /** @class */ (function (_super) {
  52232. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  52233. /**
  52234. * Instantiates a new PBRMaterial instance.
  52235. *
  52236. * @param name The material name
  52237. * @param scene The scene the material will be use in.
  52238. */
  52239. function PBRBaseMaterial(name, scene) {
  52240. var _this = _super.call(this, name, scene) || this;
  52241. /**
  52242. * Intensity of the direct lights e.g. the four lights available in your scene.
  52243. * This impacts both the direct diffuse and specular highlights.
  52244. */
  52245. _this._directIntensity = 1.0;
  52246. /**
  52247. * Intensity of the emissive part of the material.
  52248. * This helps controlling the emissive effect without modifying the emissive color.
  52249. */
  52250. _this._emissiveIntensity = 1.0;
  52251. /**
  52252. * Intensity of the environment e.g. how much the environment will light the object
  52253. * either through harmonics for rough material or through the refelction for shiny ones.
  52254. */
  52255. _this._environmentIntensity = 1.0;
  52256. /**
  52257. * This is a special control allowing the reduction of the specular highlights coming from the
  52258. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52259. */
  52260. _this._specularIntensity = 1.0;
  52261. /**
  52262. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  52263. */
  52264. _this._lightingInfos = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  52265. /**
  52266. * Debug Control allowing disabling the bump map on this material.
  52267. */
  52268. _this._disableBumpMap = false;
  52269. /**
  52270. * AKA Occlusion Texture Intensity in other nomenclature.
  52271. */
  52272. _this._ambientTextureStrength = 1.0;
  52273. /**
  52274. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52275. * 1 means it completely occludes it
  52276. * 0 mean it has no impact
  52277. */
  52278. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  52279. /**
  52280. * The color of a material in ambient lighting.
  52281. */
  52282. _this._ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  52283. /**
  52284. * AKA Diffuse Color in other nomenclature.
  52285. */
  52286. _this._albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  52287. /**
  52288. * AKA Specular Color in other nomenclature.
  52289. */
  52290. _this._reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  52291. /**
  52292. * The color applied when light is reflected from a material.
  52293. */
  52294. _this._reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  52295. /**
  52296. * The color applied when light is emitted from a material.
  52297. */
  52298. _this._emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  52299. /**
  52300. * AKA Glossiness in other nomenclature.
  52301. */
  52302. _this._microSurface = 0.9;
  52303. /**
  52304. * Specifies that the material will use the light map as a show map.
  52305. */
  52306. _this._useLightmapAsShadowmap = false;
  52307. /**
  52308. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52309. * makes the reflect vector face the model (under horizon).
  52310. */
  52311. _this._useHorizonOcclusion = true;
  52312. /**
  52313. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52314. * too much the area relying on ambient texture to define their ambient occlusion.
  52315. */
  52316. _this._useRadianceOcclusion = true;
  52317. /**
  52318. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52319. */
  52320. _this._useAlphaFromAlbedoTexture = false;
  52321. /**
  52322. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  52323. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52324. */
  52325. _this._useSpecularOverAlpha = true;
  52326. /**
  52327. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52328. */
  52329. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  52330. /**
  52331. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52332. */
  52333. _this._useRoughnessFromMetallicTextureAlpha = true;
  52334. /**
  52335. * Specifies if the metallic texture contains the roughness information in its green channel.
  52336. */
  52337. _this._useRoughnessFromMetallicTextureGreen = false;
  52338. /**
  52339. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52340. */
  52341. _this._useMetallnessFromMetallicTextureBlue = false;
  52342. /**
  52343. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52344. */
  52345. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  52346. /**
  52347. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52348. */
  52349. _this._useAmbientInGrayScale = false;
  52350. /**
  52351. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52352. * The material will try to infer what glossiness each pixel should be.
  52353. */
  52354. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  52355. /**
  52356. * Defines the falloff type used in this material.
  52357. * It by default is Physical.
  52358. */
  52359. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  52360. /**
  52361. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52362. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52363. */
  52364. _this._useRadianceOverAlpha = true;
  52365. /**
  52366. * Allows using an object space normal map (instead of tangent space).
  52367. */
  52368. _this._useObjectSpaceNormalMap = false;
  52369. /**
  52370. * Allows using the bump map in parallax mode.
  52371. */
  52372. _this._useParallax = false;
  52373. /**
  52374. * Allows using the bump map in parallax occlusion mode.
  52375. */
  52376. _this._useParallaxOcclusion = false;
  52377. /**
  52378. * Controls the scale bias of the parallax mode.
  52379. */
  52380. _this._parallaxScaleBias = 0.05;
  52381. /**
  52382. * If sets to true, disables all the lights affecting the material.
  52383. */
  52384. _this._disableLighting = false;
  52385. /**
  52386. * Number of Simultaneous lights allowed on the material.
  52387. */
  52388. _this._maxSimultaneousLights = 4;
  52389. /**
  52390. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52391. */
  52392. _this._invertNormalMapX = false;
  52393. /**
  52394. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52395. */
  52396. _this._invertNormalMapY = false;
  52397. /**
  52398. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52399. */
  52400. _this._twoSidedLighting = false;
  52401. /**
  52402. * Defines the alpha limits in alpha test mode.
  52403. */
  52404. _this._alphaCutOff = 0.4;
  52405. /**
  52406. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52407. */
  52408. _this._forceAlphaTest = false;
  52409. /**
  52410. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52411. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52412. */
  52413. _this._useAlphaFresnel = false;
  52414. /**
  52415. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52416. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52417. */
  52418. _this._useLinearAlphaFresnel = false;
  52419. /**
  52420. * The transparency mode of the material.
  52421. */
  52422. _this._transparencyMode = null;
  52423. /**
  52424. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52425. * from cos thetav and roughness:
  52426. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52427. */
  52428. _this._environmentBRDFTexture = null;
  52429. /**
  52430. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52431. */
  52432. _this._forceIrradianceInFragment = false;
  52433. /**
  52434. * Force normal to face away from face.
  52435. */
  52436. _this._forceNormalForward = false;
  52437. /**
  52438. * Enables specular anti aliasing in the PBR shader.
  52439. * It will both interacts on the Geometry for analytical and IBL lighting.
  52440. * It also prefilter the roughness map based on the bump values.
  52441. */
  52442. _this._enableSpecularAntiAliasing = false;
  52443. /**
  52444. * Stores the available render targets.
  52445. */
  52446. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  52447. /**
  52448. * Sets the global ambient color for the material used in lighting calculations.
  52449. */
  52450. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  52451. /**
  52452. * If set to true, no lighting calculations will be applied.
  52453. */
  52454. _this._unlit = false;
  52455. _this._debugMode = 0;
  52456. /**
  52457. * @hidden
  52458. * This is reserved for the inspector.
  52459. * Defines the material debug mode.
  52460. * It helps seeing only some components of the material while troubleshooting.
  52461. */
  52462. _this.debugMode = 0;
  52463. /**
  52464. * @hidden
  52465. * This is reserved for the inspector.
  52466. * Specify from where on screen the debug mode should start.
  52467. * The value goes from -1 (full screen) to 1 (not visible)
  52468. * It helps with side by side comparison against the final render
  52469. * This defaults to -1
  52470. */
  52471. _this.debugLimit = -1;
  52472. /**
  52473. * @hidden
  52474. * This is reserved for the inspector.
  52475. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52476. * You can use the factor to better multiply the final value.
  52477. */
  52478. _this.debugFactor = 1;
  52479. /**
  52480. * Defines the clear coat layer parameters for the material.
  52481. */
  52482. _this.clearCoat = new _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  52483. /**
  52484. * Defines the anisotropic parameters for the material.
  52485. */
  52486. _this.anisotropy = new _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  52487. /**
  52488. * Defines the BRDF parameters for the material.
  52489. */
  52490. _this.brdf = new _pbrBRDFConfiguration__WEBPACK_IMPORTED_MODULE_10__["PBRBRDFConfiguration"](_this._markAllSubMeshesAsMiscDirty.bind(_this));
  52491. /**
  52492. * Defines the Sheen parameters for the material.
  52493. */
  52494. _this.sheen = new _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  52495. /**
  52496. * Defines the SubSurface parameters for the material.
  52497. */
  52498. _this.subSurface = new _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  52499. // Setup the default processing configuration to the scene.
  52500. _this._attachImageProcessingConfiguration(null);
  52501. _this.getRenderTargetTextures = function () {
  52502. _this._renderTargets.reset();
  52503. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  52504. _this._renderTargets.push(_this._reflectionTexture);
  52505. }
  52506. _this.subSurface.fillRenderTargetTextures(_this._renderTargets);
  52507. return _this._renderTargets;
  52508. };
  52509. _this._environmentBRDFTexture = _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_4__["BRDFTextureTools"].GetEnvironmentBRDFTexture(scene);
  52510. return _this;
  52511. }
  52512. /**
  52513. * Attaches a new image processing configuration to the PBR Material.
  52514. * @param configuration
  52515. */
  52516. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  52517. var _this = this;
  52518. if (configuration === this._imageProcessingConfiguration) {
  52519. return;
  52520. }
  52521. // Detaches observer.
  52522. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  52523. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  52524. }
  52525. // Pick the scene configuration if needed.
  52526. if (!configuration) {
  52527. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  52528. }
  52529. else {
  52530. this._imageProcessingConfiguration = configuration;
  52531. }
  52532. // Attaches observer.
  52533. if (this._imageProcessingConfiguration) {
  52534. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  52535. _this._markAllSubMeshesAsImageProcessingDirty();
  52536. });
  52537. }
  52538. };
  52539. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  52540. /**
  52541. * Gets a boolean indicating that current material needs to register RTT
  52542. */
  52543. get: function () {
  52544. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  52545. return true;
  52546. }
  52547. return this.subSurface.hasRenderTargetTextures();
  52548. },
  52549. enumerable: true,
  52550. configurable: true
  52551. });
  52552. /**
  52553. * Gets the name of the material class.
  52554. */
  52555. PBRBaseMaterial.prototype.getClassName = function () {
  52556. return "PBRBaseMaterial";
  52557. };
  52558. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  52559. /**
  52560. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52561. */
  52562. get: function () {
  52563. return this._useLogarithmicDepth;
  52564. },
  52565. /**
  52566. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52567. */
  52568. set: function (value) {
  52569. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  52570. },
  52571. enumerable: true,
  52572. configurable: true
  52573. });
  52574. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  52575. /**
  52576. * Gets the current transparency mode.
  52577. */
  52578. get: function () {
  52579. return this._transparencyMode;
  52580. },
  52581. /**
  52582. * Sets the transparency mode of the material.
  52583. *
  52584. * | Value | Type | Description |
  52585. * | ----- | ----------------------------------- | ----------- |
  52586. * | 0 | OPAQUE | |
  52587. * | 1 | ALPHATEST | |
  52588. * | 2 | ALPHABLEND | |
  52589. * | 3 | ALPHATESTANDBLEND | |
  52590. *
  52591. */
  52592. set: function (value) {
  52593. if (this._transparencyMode === value) {
  52594. return;
  52595. }
  52596. this._transparencyMode = value;
  52597. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  52598. this._markAllSubMeshesAsTexturesAndMiscDirty();
  52599. },
  52600. enumerable: true,
  52601. configurable: true
  52602. });
  52603. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  52604. /**
  52605. * Returns true if alpha blending should be disabled.
  52606. */
  52607. get: function () {
  52608. return (this.subSurface.disableAlphaBlending ||
  52609. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  52610. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  52611. },
  52612. enumerable: true,
  52613. configurable: true
  52614. });
  52615. /**
  52616. * Specifies whether or not this material should be rendered in alpha blend mode.
  52617. */
  52618. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  52619. if (this._disableAlphaBlending) {
  52620. return false;
  52621. }
  52622. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  52623. };
  52624. /**
  52625. * Specifies if the mesh will require alpha blending.
  52626. * @param mesh - BJS mesh.
  52627. */
  52628. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  52629. if (this._disableAlphaBlending && mesh.visibility >= 1.0) {
  52630. return false;
  52631. }
  52632. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  52633. };
  52634. /**
  52635. * Specifies whether or not this material should be rendered in alpha test mode.
  52636. */
  52637. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  52638. if (this._forceAlphaTest) {
  52639. return true;
  52640. }
  52641. if (this.subSurface.disableAlphaBlending) {
  52642. return false;
  52643. }
  52644. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  52645. };
  52646. /**
  52647. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52648. */
  52649. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  52650. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  52651. };
  52652. /**
  52653. * Gets the texture used for the alpha test.
  52654. */
  52655. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  52656. return this._albedoTexture;
  52657. };
  52658. /**
  52659. * Specifies that the submesh is ready to be used.
  52660. * @param mesh - BJS mesh.
  52661. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52662. * @param useInstances - Specifies that instances should be used.
  52663. * @returns - boolean indicating that the submesh is ready or not.
  52664. */
  52665. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  52666. if (subMesh.effect && this.isFrozen) {
  52667. if (this._wasPreviouslyReady) {
  52668. return true;
  52669. }
  52670. }
  52671. if (!subMesh._materialDefines) {
  52672. subMesh._materialDefines = new PBRMaterialDefines();
  52673. }
  52674. var defines = subMesh._materialDefines;
  52675. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  52676. if (defines._renderId === this.getScene().getRenderId()) {
  52677. return true;
  52678. }
  52679. }
  52680. var scene = this.getScene();
  52681. var engine = scene.getEngine();
  52682. if (defines._areTexturesDirty) {
  52683. if (scene.texturesEnabled) {
  52684. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  52685. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  52686. return false;
  52687. }
  52688. }
  52689. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].AmbientTextureEnabled) {
  52690. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  52691. return false;
  52692. }
  52693. }
  52694. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].OpacityTextureEnabled) {
  52695. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  52696. return false;
  52697. }
  52698. }
  52699. var reflectionTexture = this._getReflectionTexture();
  52700. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  52701. if (!reflectionTexture.isReadyOrNotBlocking()) {
  52702. return false;
  52703. }
  52704. }
  52705. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].LightmapTextureEnabled) {
  52706. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  52707. return false;
  52708. }
  52709. }
  52710. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled) {
  52711. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  52712. return false;
  52713. }
  52714. }
  52715. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].SpecularTextureEnabled) {
  52716. if (this._metallicTexture) {
  52717. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  52718. return false;
  52719. }
  52720. }
  52721. else if (this._reflectivityTexture) {
  52722. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  52723. return false;
  52724. }
  52725. }
  52726. if (this._microSurfaceTexture) {
  52727. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  52728. return false;
  52729. }
  52730. }
  52731. }
  52732. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  52733. // Bump texture cannot be not blocking.
  52734. if (!this._bumpTexture.isReady()) {
  52735. return false;
  52736. }
  52737. }
  52738. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  52739. // This is blocking.
  52740. if (!this._environmentBRDFTexture.isReady()) {
  52741. return false;
  52742. }
  52743. }
  52744. }
  52745. }
  52746. if (!this.subSurface.isReadyForSubMesh(defines, scene) ||
  52747. !this.clearCoat.isReadyForSubMesh(defines, scene, engine, this._disableBumpMap) ||
  52748. !this.sheen.isReadyForSubMesh(defines, scene) ||
  52749. !this.anisotropy.isReadyForSubMesh(defines, scene)) {
  52750. return false;
  52751. }
  52752. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  52753. if (!this._imageProcessingConfiguration.isReady()) {
  52754. return false;
  52755. }
  52756. }
  52757. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  52758. mesh.createNormals(true);
  52759. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  52760. }
  52761. var previousEffect = subMesh.effect;
  52762. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  52763. if (effect) {
  52764. // Use previous effect while new one is compiling
  52765. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  52766. effect = previousEffect;
  52767. defines.markAsUnprocessed();
  52768. }
  52769. else {
  52770. scene.resetCachedMaterial();
  52771. subMesh.setEffect(effect, defines);
  52772. this.buildUniformLayout();
  52773. }
  52774. }
  52775. if (!subMesh.effect || !subMesh.effect.isReady()) {
  52776. return false;
  52777. }
  52778. defines._renderId = scene.getRenderId();
  52779. this._wasPreviouslyReady = true;
  52780. return true;
  52781. };
  52782. /**
  52783. * Specifies if the material uses metallic roughness workflow.
  52784. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52785. */
  52786. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  52787. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  52788. return true;
  52789. }
  52790. return false;
  52791. };
  52792. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  52793. if (onCompiled === void 0) { onCompiled = null; }
  52794. if (onError === void 0) { onError = null; }
  52795. if (useInstances === void 0) { useInstances = null; }
  52796. if (useClipPlane === void 0) { useClipPlane = null; }
  52797. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  52798. if (!defines.isDirty) {
  52799. return null;
  52800. }
  52801. defines.markAsProcessed();
  52802. var scene = this.getScene();
  52803. var engine = scene.getEngine();
  52804. // Fallbacks
  52805. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_14__["EffectFallbacks"]();
  52806. var fallbackRank = 0;
  52807. if (defines.USESPHERICALINVERTEX) {
  52808. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  52809. }
  52810. if (defines.FOG) {
  52811. fallbacks.addFallback(fallbackRank, "FOG");
  52812. }
  52813. if (defines.SPECULARAA) {
  52814. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  52815. }
  52816. if (defines.POINTSIZE) {
  52817. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  52818. }
  52819. if (defines.LOGARITHMICDEPTH) {
  52820. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  52821. }
  52822. if (defines.PARALLAX) {
  52823. fallbacks.addFallback(fallbackRank, "PARALLAX");
  52824. }
  52825. if (defines.PARALLAXOCCLUSION) {
  52826. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  52827. }
  52828. fallbackRank = _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52829. fallbackRank = _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52830. fallbackRank = _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52831. fallbackRank = _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  52832. if (defines.ENVIRONMENTBRDF) {
  52833. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  52834. }
  52835. if (defines.TANGENT) {
  52836. fallbacks.addFallback(fallbackRank++, "TANGENT");
  52837. }
  52838. if (defines.BUMP) {
  52839. fallbacks.addFallback(fallbackRank++, "BUMP");
  52840. }
  52841. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  52842. if (defines.SPECULARTERM) {
  52843. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  52844. }
  52845. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  52846. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  52847. }
  52848. if (defines.LIGHTMAP) {
  52849. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  52850. }
  52851. if (defines.NORMAL) {
  52852. fallbacks.addFallback(fallbackRank++, "NORMAL");
  52853. }
  52854. if (defines.AMBIENT) {
  52855. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  52856. }
  52857. if (defines.EMISSIVE) {
  52858. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  52859. }
  52860. if (defines.VERTEXCOLOR) {
  52861. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  52862. }
  52863. if (defines.NUM_BONE_INFLUENCERS > 0) {
  52864. fallbacks.addCPUSkinningFallback(fallbackRank++, mesh);
  52865. }
  52866. if (defines.MORPHTARGETS) {
  52867. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  52868. }
  52869. if (defines.MULTIVIEW) {
  52870. fallbacks.addFallback(0, "MULTIVIEW");
  52871. }
  52872. //Attributes
  52873. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  52874. if (defines.NORMAL) {
  52875. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  52876. }
  52877. if (defines.TANGENT) {
  52878. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  52879. }
  52880. if (defines.UV1) {
  52881. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  52882. }
  52883. if (defines.UV2) {
  52884. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  52885. }
  52886. if (defines.VERTEXCOLOR) {
  52887. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  52888. }
  52889. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  52890. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  52891. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  52892. var shaderName = "pbr";
  52893. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "visibility", "vReflectionColor",
  52894. "vFogInfos", "vFogColor", "pointSize",
  52895. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  52896. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos",
  52897. "mBones",
  52898. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix",
  52899. "vLightingIntensity",
  52900. "logarithmicDepthConstant",
  52901. "vSphericalX", "vSphericalY", "vSphericalZ",
  52902. "vSphericalXX", "vSphericalYY", "vSphericalZZ",
  52903. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  52904. "vReflectionMicrosurfaceInfos",
  52905. "vTangentSpaceParams", "boneTextureWidth",
  52906. "vDebugMode"
  52907. ];
  52908. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  52909. "bumpSampler", "lightmapSampler", "opacitySampler",
  52910. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh",
  52911. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  52912. var uniformBuffers = ["Material", "Scene"];
  52913. _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].AddUniforms(uniforms);
  52914. _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].AddSamplers(samplers);
  52915. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddUniforms(uniforms);
  52916. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddSamplers(samplers);
  52917. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddUniforms(uniforms);
  52918. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddSamplers(samplers);
  52919. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddUniforms(uniforms);
  52920. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].AddSamplers(samplers);
  52921. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__["ImageProcessingConfiguration"]) {
  52922. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  52923. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_13__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  52924. }
  52925. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareUniformsAndSamplersList({
  52926. uniformsNames: uniforms,
  52927. uniformBuffersNames: uniformBuffers,
  52928. samplers: samplers,
  52929. defines: defines,
  52930. maxSimultaneousLights: this._maxSimultaneousLights
  52931. });
  52932. if (this.customShaderNameResolve) {
  52933. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  52934. }
  52935. var join = defines.toString();
  52936. return engine.createEffect(shaderName, {
  52937. attributes: attribs,
  52938. uniformsNames: uniforms,
  52939. uniformBuffersNames: uniformBuffers,
  52940. samplers: samplers,
  52941. defines: join,
  52942. fallbacks: fallbacks,
  52943. onCompiled: onCompiled,
  52944. onError: onError,
  52945. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  52946. }, engine);
  52947. };
  52948. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  52949. if (useInstances === void 0) { useInstances = null; }
  52950. if (useClipPlane === void 0) { useClipPlane = null; }
  52951. var scene = this.getScene();
  52952. var engine = scene.getEngine();
  52953. // Lights
  52954. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  52955. defines._needNormals = true;
  52956. // Multiview
  52957. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMultiview(scene, defines);
  52958. // Textures
  52959. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  52960. if (defines._areTexturesDirty) {
  52961. defines._needUVs = false;
  52962. if (scene.texturesEnabled) {
  52963. if (scene.getEngine().getCaps().textureLOD) {
  52964. defines.LODBASEDMICROSFURACE = true;
  52965. }
  52966. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  52967. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  52968. }
  52969. else {
  52970. defines.ALBEDO = false;
  52971. }
  52972. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].AmbientTextureEnabled) {
  52973. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  52974. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  52975. }
  52976. else {
  52977. defines.AMBIENT = false;
  52978. }
  52979. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].OpacityTextureEnabled) {
  52980. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  52981. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  52982. }
  52983. else {
  52984. defines.OPACITY = false;
  52985. }
  52986. var reflectionTexture = this._getReflectionTexture();
  52987. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  52988. defines.REFLECTION = true;
  52989. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  52990. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  52991. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  52992. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  52993. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].INVCUBIC_MODE) {
  52994. defines.INVERTCUBICMAP = true;
  52995. }
  52996. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  52997. defines.REFLECTIONMAP_CUBIC = false;
  52998. defines.REFLECTIONMAP_EXPLICIT = false;
  52999. defines.REFLECTIONMAP_PLANAR = false;
  53000. defines.REFLECTIONMAP_PROJECTION = false;
  53001. defines.REFLECTIONMAP_SKYBOX = false;
  53002. defines.REFLECTIONMAP_SPHERICAL = false;
  53003. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  53004. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  53005. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  53006. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  53007. switch (reflectionTexture.coordinatesMode) {
  53008. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].EXPLICIT_MODE:
  53009. defines.REFLECTIONMAP_EXPLICIT = true;
  53010. break;
  53011. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].PLANAR_MODE:
  53012. defines.REFLECTIONMAP_PLANAR = true;
  53013. break;
  53014. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].PROJECTION_MODE:
  53015. defines.REFLECTIONMAP_PROJECTION = true;
  53016. break;
  53017. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].SKYBOX_MODE:
  53018. defines.REFLECTIONMAP_SKYBOX = true;
  53019. break;
  53020. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].SPHERICAL_MODE:
  53021. defines.REFLECTIONMAP_SPHERICAL = true;
  53022. break;
  53023. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].EQUIRECTANGULAR_MODE:
  53024. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  53025. break;
  53026. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  53027. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  53028. break;
  53029. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  53030. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  53031. break;
  53032. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].CUBIC_MODE:
  53033. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].INVCUBIC_MODE:
  53034. default:
  53035. defines.REFLECTIONMAP_CUBIC = true;
  53036. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  53037. break;
  53038. }
  53039. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_18__["Texture"].SKYBOX_MODE) {
  53040. if (reflectionTexture.sphericalPolynomial) {
  53041. defines.USESPHERICALFROMREFLECTIONMAP = true;
  53042. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  53043. defines.USESPHERICALINVERTEX = false;
  53044. }
  53045. else {
  53046. defines.USESPHERICALINVERTEX = true;
  53047. }
  53048. }
  53049. }
  53050. else {
  53051. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  53052. }
  53053. }
  53054. else {
  53055. defines.REFLECTION = false;
  53056. defines.REFLECTIONMAP_3D = false;
  53057. defines.REFLECTIONMAP_SPHERICAL = false;
  53058. defines.REFLECTIONMAP_PLANAR = false;
  53059. defines.REFLECTIONMAP_CUBIC = false;
  53060. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  53061. defines.REFLECTIONMAP_PROJECTION = false;
  53062. defines.REFLECTIONMAP_SKYBOX = false;
  53063. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  53064. defines.REFLECTIONMAP_EXPLICIT = false;
  53065. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  53066. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  53067. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  53068. defines.INVERTCUBICMAP = false;
  53069. defines.USESPHERICALFROMREFLECTIONMAP = false;
  53070. defines.USESPHERICALINVERTEX = false;
  53071. defines.REFLECTIONMAP_OPPOSITEZ = false;
  53072. defines.LODINREFLECTIONALPHA = false;
  53073. defines.GAMMAREFLECTION = false;
  53074. defines.RGBDREFLECTION = false;
  53075. }
  53076. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].LightmapTextureEnabled) {
  53077. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  53078. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  53079. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  53080. }
  53081. else {
  53082. defines.LIGHTMAP = false;
  53083. }
  53084. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled) {
  53085. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  53086. }
  53087. else {
  53088. defines.EMISSIVE = false;
  53089. }
  53090. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].SpecularTextureEnabled) {
  53091. if (this._metallicTexture) {
  53092. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  53093. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  53094. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  53095. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  53096. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  53097. }
  53098. else if (this._reflectivityTexture) {
  53099. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  53100. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  53101. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  53102. }
  53103. else {
  53104. defines.REFLECTIVITY = false;
  53105. }
  53106. if (this._microSurfaceTexture) {
  53107. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  53108. }
  53109. else {
  53110. defines.MICROSURFACEMAP = false;
  53111. }
  53112. }
  53113. else {
  53114. defines.REFLECTIVITY = false;
  53115. defines.MICROSURFACEMAP = false;
  53116. }
  53117. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  53118. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  53119. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  53120. defines.PARALLAX = true;
  53121. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  53122. }
  53123. else {
  53124. defines.PARALLAX = false;
  53125. }
  53126. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  53127. }
  53128. else {
  53129. defines.BUMP = false;
  53130. }
  53131. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  53132. defines.ENVIRONMENTBRDF = true;
  53133. // Not actual true RGBD, only the B chanel is encoded as RGBD for sheen.
  53134. defines.ENVIRONMENTBRDF_RGBD = this._environmentBRDFTexture.isRGBD;
  53135. }
  53136. else {
  53137. defines.ENVIRONMENTBRDF = false;
  53138. defines.ENVIRONMENTBRDF_RGBD = false;
  53139. }
  53140. if (this._shouldUseAlphaFromAlbedoTexture()) {
  53141. defines.ALPHAFROMALBEDO = true;
  53142. }
  53143. else {
  53144. defines.ALPHAFROMALBEDO = false;
  53145. }
  53146. }
  53147. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  53148. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  53149. defines.USEPHYSICALLIGHTFALLOFF = false;
  53150. defines.USEGLTFLIGHTFALLOFF = false;
  53151. }
  53152. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  53153. defines.USEPHYSICALLIGHTFALLOFF = false;
  53154. defines.USEGLTFLIGHTFALLOFF = true;
  53155. }
  53156. else {
  53157. defines.USEPHYSICALLIGHTFALLOFF = true;
  53158. defines.USEGLTFLIGHTFALLOFF = false;
  53159. }
  53160. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  53161. if (!this.backFaceCulling && this._twoSidedLighting) {
  53162. defines.TWOSIDEDLIGHTING = true;
  53163. }
  53164. else {
  53165. defines.TWOSIDEDLIGHTING = false;
  53166. }
  53167. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  53168. defines.PREMULTIPLYALPHA = (this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ALPHA_PREMULTIPLIED || this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_20__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF);
  53169. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  53170. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  53171. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  53172. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  53173. }
  53174. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  53175. this._imageProcessingConfiguration.prepareDefines(defines);
  53176. }
  53177. defines.FORCENORMALFORWARD = this._forceNormalForward;
  53178. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  53179. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  53180. // Misc.
  53181. if (defines._areMiscDirty) {
  53182. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  53183. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  53184. defines.DEBUGMODE = this._debugMode;
  53185. }
  53186. // External config
  53187. this.subSurface.prepareDefines(defines, scene);
  53188. this.clearCoat.prepareDefines(defines, scene);
  53189. this.anisotropy.prepareDefines(defines, mesh, scene);
  53190. this.brdf.prepareDefines(defines);
  53191. this.sheen.prepareDefines(defines, scene);
  53192. // Values that need to be evaluated on every frame
  53193. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  53194. // Attribs
  53195. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  53196. };
  53197. /**
  53198. * Force shader compilation
  53199. */
  53200. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  53201. var _this = this;
  53202. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  53203. var defines = new PBRMaterialDefines();
  53204. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  53205. if (effect.isReady()) {
  53206. if (onCompiled) {
  53207. onCompiled(this);
  53208. }
  53209. }
  53210. else {
  53211. effect.onCompileObservable.add(function () {
  53212. if (onCompiled) {
  53213. onCompiled(_this);
  53214. }
  53215. });
  53216. }
  53217. };
  53218. /**
  53219. * Initializes the uniform buffer layout for the shader.
  53220. */
  53221. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  53222. // Order is important !
  53223. this._uniformBuffer.addUniform("vAlbedoInfos", 2);
  53224. this._uniformBuffer.addUniform("vAmbientInfos", 4);
  53225. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  53226. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  53227. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  53228. this._uniformBuffer.addUniform("vReflectivityInfos", 3);
  53229. this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos", 2);
  53230. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  53231. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  53232. this._uniformBuffer.addUniform("vReflectionSize", 3);
  53233. this._uniformBuffer.addUniform("vBumpInfos", 3);
  53234. this._uniformBuffer.addUniform("albedoMatrix", 16);
  53235. this._uniformBuffer.addUniform("ambientMatrix", 16);
  53236. this._uniformBuffer.addUniform("opacityMatrix", 16);
  53237. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  53238. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  53239. this._uniformBuffer.addUniform("reflectivityMatrix", 16);
  53240. this._uniformBuffer.addUniform("microSurfaceSamplerMatrix", 16);
  53241. this._uniformBuffer.addUniform("bumpMatrix", 16);
  53242. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  53243. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  53244. this._uniformBuffer.addUniform("vReflectionColor", 3);
  53245. this._uniformBuffer.addUniform("vAlbedoColor", 4);
  53246. this._uniformBuffer.addUniform("vLightingIntensity", 4);
  53247. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  53248. this._uniformBuffer.addUniform("pointSize", 1);
  53249. this._uniformBuffer.addUniform("vReflectivityColor", 4);
  53250. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  53251. this._uniformBuffer.addUniform("visibility", 1);
  53252. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  53253. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  53254. _pbrSheenConfiguration__WEBPACK_IMPORTED_MODULE_11__["PBRSheenConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  53255. _pbrSubSurfaceConfiguration__WEBPACK_IMPORTED_MODULE_12__["PBRSubSurfaceConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  53256. this._uniformBuffer.create();
  53257. };
  53258. /**
  53259. * Unbinds the material from the mesh
  53260. */
  53261. PBRBaseMaterial.prototype.unbind = function () {
  53262. if (this._activeEffect) {
  53263. var needFlag = false;
  53264. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  53265. this._activeEffect.setTexture("reflection2DSampler", null);
  53266. needFlag = true;
  53267. }
  53268. if (this.subSurface.unbind(this._activeEffect)) {
  53269. needFlag = true;
  53270. }
  53271. if (needFlag) {
  53272. this._markAllSubMeshesAsTexturesDirty();
  53273. }
  53274. }
  53275. _super.prototype.unbind.call(this);
  53276. };
  53277. /**
  53278. * Binds the submesh data.
  53279. * @param world - The world matrix.
  53280. * @param mesh - The BJS mesh.
  53281. * @param subMesh - A submesh of the BJS mesh.
  53282. */
  53283. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  53284. var scene = this.getScene();
  53285. var defines = subMesh._materialDefines;
  53286. if (!defines) {
  53287. return;
  53288. }
  53289. var effect = subMesh.effect;
  53290. if (!effect) {
  53291. return;
  53292. }
  53293. this._activeEffect = effect;
  53294. // Matrices
  53295. this.bindOnlyWorldMatrix(world);
  53296. // Normal Matrix
  53297. if (defines.OBJECTSPACE_NORMALMAP) {
  53298. world.toNormalMatrix(this._normalMatrix);
  53299. this.bindOnlyNormalMatrix(this._normalMatrix);
  53300. }
  53301. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  53302. // Bones
  53303. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  53304. var reflectionTexture = null;
  53305. if (mustRebind) {
  53306. var engine = scene.getEngine();
  53307. this._uniformBuffer.bindToEffect(effect, "Material");
  53308. this.bindViewProjection(effect);
  53309. reflectionTexture = this._getReflectionTexture();
  53310. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  53311. // Texture uniforms
  53312. if (scene.texturesEnabled) {
  53313. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  53314. this._uniformBuffer.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  53315. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, this._uniformBuffer, "albedo");
  53316. }
  53317. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].AmbientTextureEnabled) {
  53318. this._uniformBuffer.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  53319. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  53320. }
  53321. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].OpacityTextureEnabled) {
  53322. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  53323. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  53324. }
  53325. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  53326. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  53327. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  53328. if (reflectionTexture.boundingBoxSize) {
  53329. var cubeTexture = reflectionTexture;
  53330. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  53331. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  53332. }
  53333. var polynomials = reflectionTexture.sphericalPolynomial;
  53334. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  53335. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  53336. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  53337. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  53338. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  53339. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  53340. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  53341. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  53342. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  53343. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  53344. }
  53345. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  53346. }
  53347. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled) {
  53348. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  53349. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  53350. }
  53351. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].LightmapTextureEnabled) {
  53352. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  53353. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  53354. }
  53355. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].SpecularTextureEnabled) {
  53356. if (this._metallicTexture) {
  53357. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  53358. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, this._uniformBuffer, "reflectivity");
  53359. }
  53360. else if (this._reflectivityTexture) {
  53361. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  53362. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, this._uniformBuffer, "reflectivity");
  53363. }
  53364. if (this._microSurfaceTexture) {
  53365. this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  53366. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, this._uniformBuffer, "microSurfaceSampler");
  53367. }
  53368. }
  53369. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  53370. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  53371. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  53372. if (scene._mirroredCameraPosition) {
  53373. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  53374. }
  53375. else {
  53376. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  53377. }
  53378. }
  53379. }
  53380. // Point size
  53381. if (this.pointsCloud) {
  53382. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  53383. }
  53384. // Colors
  53385. if (defines.METALLICWORKFLOW) {
  53386. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  53387. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  53388. this._uniformBuffer.updateColor4("vReflectivityColor", _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0], 0);
  53389. }
  53390. else {
  53391. this._uniformBuffer.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  53392. }
  53393. this._uniformBuffer.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"].BlackReadOnly);
  53394. this._uniformBuffer.updateColor3("vReflectionColor", this._reflectionColor);
  53395. this._uniformBuffer.updateColor4("vAlbedoColor", this._albedoColor, this.alpha);
  53396. // Visibility
  53397. this._uniformBuffer.updateFloat("visibility", mesh.visibility);
  53398. // Misc
  53399. this._lightingInfos.x = this._directIntensity;
  53400. this._lightingInfos.y = this._emissiveIntensity;
  53401. this._lightingInfos.z = this._environmentIntensity;
  53402. this._lightingInfos.w = this._specularIntensity;
  53403. this._uniformBuffer.updateVector4("vLightingIntensity", this._lightingInfos);
  53404. }
  53405. // Textures
  53406. if (scene.texturesEnabled) {
  53407. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].DiffuseTextureEnabled) {
  53408. this._uniformBuffer.setTexture("albedoSampler", this._albedoTexture);
  53409. }
  53410. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].AmbientTextureEnabled) {
  53411. this._uniformBuffer.setTexture("ambientSampler", this._ambientTexture);
  53412. }
  53413. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].OpacityTextureEnabled) {
  53414. this._uniformBuffer.setTexture("opacitySampler", this._opacityTexture);
  53415. }
  53416. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].ReflectionTextureEnabled) {
  53417. if (defines.LODBASEDMICROSFURACE) {
  53418. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  53419. }
  53420. else {
  53421. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  53422. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  53423. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  53424. }
  53425. }
  53426. if (defines.ENVIRONMENTBRDF) {
  53427. this._uniformBuffer.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  53428. }
  53429. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].EmissiveTextureEnabled) {
  53430. this._uniformBuffer.setTexture("emissiveSampler", this._emissiveTexture);
  53431. }
  53432. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].LightmapTextureEnabled) {
  53433. this._uniformBuffer.setTexture("lightmapSampler", this._lightmapTexture);
  53434. }
  53435. if (_materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].SpecularTextureEnabled) {
  53436. if (this._metallicTexture) {
  53437. this._uniformBuffer.setTexture("reflectivitySampler", this._metallicTexture);
  53438. }
  53439. else if (this._reflectivityTexture) {
  53440. this._uniformBuffer.setTexture("reflectivitySampler", this._reflectivityTexture);
  53441. }
  53442. if (this._microSurfaceTexture) {
  53443. this._uniformBuffer.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  53444. }
  53445. }
  53446. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_19__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  53447. this._uniformBuffer.setTexture("bumpSampler", this._bumpTexture);
  53448. }
  53449. }
  53450. this.subSurface.bindForSubMesh(this._uniformBuffer, scene, engine, this.isFrozen, defines.LODBASEDMICROSFURACE);
  53451. this.clearCoat.bindForSubMesh(this._uniformBuffer, scene, engine, this._disableBumpMap, this.isFrozen, this._invertNormalMapX, this._invertNormalMapY);
  53452. this.anisotropy.bindForSubMesh(this._uniformBuffer, scene, this.isFrozen);
  53453. this.sheen.bindForSubMesh(this._uniformBuffer, scene, this.isFrozen);
  53454. // Clip plane
  53455. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  53456. // Colors
  53457. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  53458. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  53459. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  53460. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  53461. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  53462. effect.setFloat2("vDebugMode", this.debugLimit, this.debugFactor);
  53463. }
  53464. if (mustRebind || !this.isFrozen) {
  53465. // Lights
  53466. if (scene.lightsEnabled && !this._disableLighting) {
  53467. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  53468. }
  53469. // View
  53470. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  53471. this.bindView(effect);
  53472. }
  53473. // Fog
  53474. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  53475. // Morph targets
  53476. if (defines.NUM_MORPH_INFLUENCERS) {
  53477. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  53478. }
  53479. // image processing
  53480. this._imageProcessingConfiguration.bind(this._activeEffect);
  53481. // Log. depth
  53482. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_17__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  53483. }
  53484. this._uniformBuffer.update();
  53485. this._afterBind(mesh, this._activeEffect);
  53486. };
  53487. /**
  53488. * Returns the animatable textures.
  53489. * @returns - Array of animatable textures.
  53490. */
  53491. PBRBaseMaterial.prototype.getAnimatables = function () {
  53492. var results = [];
  53493. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  53494. results.push(this._albedoTexture);
  53495. }
  53496. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  53497. results.push(this._ambientTexture);
  53498. }
  53499. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  53500. results.push(this._opacityTexture);
  53501. }
  53502. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  53503. results.push(this._reflectionTexture);
  53504. }
  53505. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  53506. results.push(this._emissiveTexture);
  53507. }
  53508. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  53509. results.push(this._metallicTexture);
  53510. }
  53511. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  53512. results.push(this._reflectivityTexture);
  53513. }
  53514. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  53515. results.push(this._bumpTexture);
  53516. }
  53517. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  53518. results.push(this._lightmapTexture);
  53519. }
  53520. this.subSurface.getAnimatables(results);
  53521. this.clearCoat.getAnimatables(results);
  53522. this.sheen.getAnimatables(results);
  53523. this.anisotropy.getAnimatables(results);
  53524. return results;
  53525. };
  53526. /**
  53527. * Returns the texture used for reflections.
  53528. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53529. */
  53530. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  53531. if (this._reflectionTexture) {
  53532. return this._reflectionTexture;
  53533. }
  53534. return this.getScene().environmentTexture;
  53535. };
  53536. /**
  53537. * Returns an array of the actively used textures.
  53538. * @returns - Array of BaseTextures
  53539. */
  53540. PBRBaseMaterial.prototype.getActiveTextures = function () {
  53541. var activeTextures = _super.prototype.getActiveTextures.call(this);
  53542. if (this._albedoTexture) {
  53543. activeTextures.push(this._albedoTexture);
  53544. }
  53545. if (this._ambientTexture) {
  53546. activeTextures.push(this._ambientTexture);
  53547. }
  53548. if (this._opacityTexture) {
  53549. activeTextures.push(this._opacityTexture);
  53550. }
  53551. if (this._reflectionTexture) {
  53552. activeTextures.push(this._reflectionTexture);
  53553. }
  53554. if (this._emissiveTexture) {
  53555. activeTextures.push(this._emissiveTexture);
  53556. }
  53557. if (this._reflectivityTexture) {
  53558. activeTextures.push(this._reflectivityTexture);
  53559. }
  53560. if (this._metallicTexture) {
  53561. activeTextures.push(this._metallicTexture);
  53562. }
  53563. if (this._microSurfaceTexture) {
  53564. activeTextures.push(this._microSurfaceTexture);
  53565. }
  53566. if (this._bumpTexture) {
  53567. activeTextures.push(this._bumpTexture);
  53568. }
  53569. if (this._lightmapTexture) {
  53570. activeTextures.push(this._lightmapTexture);
  53571. }
  53572. this.subSurface.getActiveTextures(activeTextures);
  53573. this.clearCoat.getActiveTextures(activeTextures);
  53574. this.sheen.getActiveTextures(activeTextures);
  53575. this.anisotropy.getActiveTextures(activeTextures);
  53576. return activeTextures;
  53577. };
  53578. /**
  53579. * Checks to see if a texture is used in the material.
  53580. * @param texture - Base texture to use.
  53581. * @returns - Boolean specifying if a texture is used in the material.
  53582. */
  53583. PBRBaseMaterial.prototype.hasTexture = function (texture) {
  53584. if (_super.prototype.hasTexture.call(this, texture)) {
  53585. return true;
  53586. }
  53587. if (this._albedoTexture === texture) {
  53588. return true;
  53589. }
  53590. if (this._ambientTexture === texture) {
  53591. return true;
  53592. }
  53593. if (this._opacityTexture === texture) {
  53594. return true;
  53595. }
  53596. if (this._reflectionTexture === texture) {
  53597. return true;
  53598. }
  53599. if (this._reflectivityTexture === texture) {
  53600. return true;
  53601. }
  53602. if (this._metallicTexture === texture) {
  53603. return true;
  53604. }
  53605. if (this._microSurfaceTexture === texture) {
  53606. return true;
  53607. }
  53608. if (this._bumpTexture === texture) {
  53609. return true;
  53610. }
  53611. if (this._lightmapTexture === texture) {
  53612. return true;
  53613. }
  53614. return this.subSurface.hasTexture(texture) ||
  53615. this.clearCoat.hasTexture(texture) ||
  53616. this.sheen.hasTexture(texture) ||
  53617. this.anisotropy.hasTexture(texture);
  53618. };
  53619. /**
  53620. * Disposes the resources of the material.
  53621. * @param forceDisposeEffect - Forces the disposal of effects.
  53622. * @param forceDisposeTextures - Forces the disposal of all textures.
  53623. */
  53624. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  53625. if (forceDisposeTextures) {
  53626. if (this._albedoTexture) {
  53627. this._albedoTexture.dispose();
  53628. }
  53629. if (this._ambientTexture) {
  53630. this._ambientTexture.dispose();
  53631. }
  53632. if (this._opacityTexture) {
  53633. this._opacityTexture.dispose();
  53634. }
  53635. if (this._reflectionTexture) {
  53636. this._reflectionTexture.dispose();
  53637. }
  53638. if (this._environmentBRDFTexture && this.getScene().environmentBRDFTexture !== this._environmentBRDFTexture) {
  53639. this._environmentBRDFTexture.dispose();
  53640. }
  53641. if (this._emissiveTexture) {
  53642. this._emissiveTexture.dispose();
  53643. }
  53644. if (this._metallicTexture) {
  53645. this._metallicTexture.dispose();
  53646. }
  53647. if (this._reflectivityTexture) {
  53648. this._reflectivityTexture.dispose();
  53649. }
  53650. if (this._bumpTexture) {
  53651. this._bumpTexture.dispose();
  53652. }
  53653. if (this._lightmapTexture) {
  53654. this._lightmapTexture.dispose();
  53655. }
  53656. }
  53657. this.subSurface.dispose(forceDisposeTextures);
  53658. this.clearCoat.dispose(forceDisposeTextures);
  53659. this.sheen.dispose(forceDisposeTextures);
  53660. this.anisotropy.dispose(forceDisposeTextures);
  53661. this._renderTargets.dispose();
  53662. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  53663. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  53664. }
  53665. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  53666. };
  53667. /**
  53668. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53669. */
  53670. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  53671. /**
  53672. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53673. */
  53674. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  53675. /**
  53676. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53677. */
  53678. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  53679. /**
  53680. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53681. * They are also discarded below the alpha cutoff threshold to improve performances.
  53682. */
  53683. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  53684. /**
  53685. * Defines the default value of how much AO map is occluding the analytical lights
  53686. * (point spot...).
  53687. */
  53688. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 0;
  53689. /**
  53690. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53691. */
  53692. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  53693. /**
  53694. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53695. * to enhance interoperability with other engines.
  53696. */
  53697. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  53698. /**
  53699. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53700. * to enhance interoperability with other materials.
  53701. */
  53702. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  53703. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53704. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  53705. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  53706. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53707. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  53708. ], PBRBaseMaterial.prototype, "debugMode", void 0);
  53709. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53710. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53711. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  53712. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53713. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53714. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  53715. return PBRBaseMaterial;
  53716. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_16__["PushMaterial"]));
  53717. /***/ }),
  53718. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  53719. /*!************************************************!*\
  53720. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  53721. \************************************************/
  53722. /*! exports provided: PBRBaseSimpleMaterial */
  53723. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53724. "use strict";
  53725. __webpack_require__.r(__webpack_exports__);
  53726. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  53727. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53728. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53729. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53730. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  53731. /**
  53732. * The Physically based simple base material of BJS.
  53733. *
  53734. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53735. * It is used as the base class for both the specGloss and metalRough conventions.
  53736. */
  53737. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  53738. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  53739. /**
  53740. * Instantiates a new PBRMaterial instance.
  53741. *
  53742. * @param name The material name
  53743. * @param scene The scene the material will be use in.
  53744. */
  53745. function PBRBaseSimpleMaterial(name, scene) {
  53746. var _this = _super.call(this, name, scene) || this;
  53747. /**
  53748. * Number of Simultaneous lights allowed on the material.
  53749. */
  53750. _this.maxSimultaneousLights = 4;
  53751. /**
  53752. * If sets to true, disables all the lights affecting the material.
  53753. */
  53754. _this.disableLighting = false;
  53755. /**
  53756. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53757. */
  53758. _this.invertNormalMapX = false;
  53759. /**
  53760. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53761. */
  53762. _this.invertNormalMapY = false;
  53763. /**
  53764. * Emissivie color used to self-illuminate the model.
  53765. */
  53766. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  53767. /**
  53768. * Occlusion Channel Strenght.
  53769. */
  53770. _this.occlusionStrength = 1.0;
  53771. /**
  53772. * If true, the light map contains occlusion information instead of lighting info.
  53773. */
  53774. _this.useLightmapAsShadowmap = false;
  53775. _this._useAlphaFromAlbedoTexture = true;
  53776. _this._useAmbientInGrayScale = true;
  53777. return _this;
  53778. }
  53779. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  53780. /**
  53781. * Gets the current double sided mode.
  53782. */
  53783. get: function () {
  53784. return this._twoSidedLighting;
  53785. },
  53786. /**
  53787. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53788. */
  53789. set: function (value) {
  53790. if (this._twoSidedLighting === value) {
  53791. return;
  53792. }
  53793. this._twoSidedLighting = value;
  53794. this.backFaceCulling = !value;
  53795. this._markAllSubMeshesAsTexturesDirty();
  53796. },
  53797. enumerable: true,
  53798. configurable: true
  53799. });
  53800. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  53801. return "PBRBaseSimpleMaterial";
  53802. };
  53803. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53804. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53805. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  53806. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  53807. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53808. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53809. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  53810. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  53811. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53812. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53813. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  53814. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  53815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53816. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53817. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53818. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  53819. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53820. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53821. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53822. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  53823. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53824. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  53826. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  53827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  53829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53830. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  53831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53834. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  53835. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53836. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  53838. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  53839. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53840. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53841. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  53842. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  53843. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53844. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53845. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  53846. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  53847. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53848. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53849. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  53850. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53851. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  53853. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  53854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53856. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53857. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  53858. return PBRBaseSimpleMaterial;
  53859. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  53860. /***/ }),
  53861. /***/ "./Materials/PBR/pbrClearCoatConfiguration.ts":
  53862. /*!****************************************************!*\
  53863. !*** ./Materials/PBR/pbrClearCoatConfiguration.ts ***!
  53864. \****************************************************/
  53865. /*! exports provided: PBRClearCoatConfiguration */
  53866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53867. "use strict";
  53868. __webpack_require__.r(__webpack_exports__);
  53869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRClearCoatConfiguration", function() { return PBRClearCoatConfiguration; });
  53870. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53871. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53872. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  53873. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  53874. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  53875. /**
  53876. * Define the code related to the clear coat parameters of the pbr material.
  53877. */
  53878. var PBRClearCoatConfiguration = /** @class */ (function () {
  53879. /**
  53880. * Instantiate a new istance of clear coat configuration.
  53881. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53882. */
  53883. function PBRClearCoatConfiguration(markAllSubMeshesAsTexturesDirty) {
  53884. this._isEnabled = false;
  53885. /**
  53886. * Defines if the clear coat is enabled in the material.
  53887. */
  53888. this.isEnabled = false;
  53889. /**
  53890. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  53891. */
  53892. this.intensity = 1;
  53893. /**
  53894. * Defines the clear coat layer roughness.
  53895. */
  53896. this.roughness = 0;
  53897. this._indiceOfRefraction = PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53898. /**
  53899. * Defines the indice of refraction of the clear coat.
  53900. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  53901. * The default fits with a polyurethane material.
  53902. * Changing the default value is more performance intensive.
  53903. */
  53904. this.indiceOfRefraction = PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  53905. this._texture = null;
  53906. /**
  53907. * Stores the clear coat values in a texture.
  53908. */
  53909. this.texture = null;
  53910. this._bumpTexture = null;
  53911. /**
  53912. * Define the clear coat specific bump texture.
  53913. */
  53914. this.bumpTexture = null;
  53915. this._isTintEnabled = false;
  53916. /**
  53917. * Defines if the clear coat tint is enabled in the material.
  53918. */
  53919. this.isTintEnabled = false;
  53920. /**
  53921. * Defines the clear coat tint of the material.
  53922. * This is only use if tint is enabled
  53923. */
  53924. this.tintColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  53925. /**
  53926. * Defines the distance at which the tint color should be found in the
  53927. * clear coat media.
  53928. * This is only use if tint is enabled
  53929. */
  53930. this.tintColorAtDistance = 1;
  53931. /**
  53932. * Defines the clear coat layer thickness.
  53933. * This is only use if tint is enabled
  53934. */
  53935. this.tintThickness = 1;
  53936. this._tintTexture = null;
  53937. /**
  53938. * Stores the clear tint values in a texture.
  53939. * rgb is tint
  53940. * a is a thickness factor
  53941. */
  53942. this.tintTexture = null;
  53943. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  53944. }
  53945. /** @hidden */
  53946. PBRClearCoatConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  53947. this._internalMarkAllSubMeshesAsTexturesDirty();
  53948. };
  53949. /**
  53950. * Gets wehter the submesh is ready to be used or not.
  53951. * @param defines the list of "defines" to update.
  53952. * @param scene defines the scene the material belongs to.
  53953. * @param engine defines the engine the material belongs to.
  53954. * @param disableBumpMap defines wether the material disables bump or not.
  53955. * @returns - boolean indicating that the submesh is ready or not.
  53956. */
  53957. PBRClearCoatConfiguration.prototype.isReadyForSubMesh = function (defines, scene, engine, disableBumpMap) {
  53958. if (defines._areTexturesDirty) {
  53959. if (scene.texturesEnabled) {
  53960. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53961. if (!this._texture.isReadyOrNotBlocking()) {
  53962. return false;
  53963. }
  53964. }
  53965. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  53966. // Bump texture cannot be not blocking.
  53967. if (!this._bumpTexture.isReady()) {
  53968. return false;
  53969. }
  53970. }
  53971. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  53972. if (!this._tintTexture.isReadyOrNotBlocking()) {
  53973. return false;
  53974. }
  53975. }
  53976. }
  53977. }
  53978. return true;
  53979. };
  53980. /**
  53981. * Checks to see if a texture is used in the material.
  53982. * @param defines the list of "defines" to update.
  53983. * @param scene defines the scene to the material belongs to.
  53984. */
  53985. PBRClearCoatConfiguration.prototype.prepareDefines = function (defines, scene) {
  53986. if (this._isEnabled) {
  53987. defines.CLEARCOAT = true;
  53988. if (defines._areTexturesDirty) {
  53989. if (scene.texturesEnabled) {
  53990. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  53991. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "CLEARCOAT_TEXTURE");
  53992. }
  53993. else {
  53994. defines.CLEARCOAT_TEXTURE = false;
  53995. }
  53996. if (this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled) {
  53997. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "CLEARCOAT_BUMP");
  53998. }
  53999. else {
  54000. defines.CLEARCOAT_BUMP = false;
  54001. }
  54002. defines.CLEARCOAT_DEFAULTIOR = this._indiceOfRefraction === PBRClearCoatConfiguration._DefaultIndiceOfRefraction;
  54003. if (this._isTintEnabled) {
  54004. defines.CLEARCOAT_TINT = true;
  54005. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  54006. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._tintTexture, defines, "CLEARCOAT_TINT_TEXTURE");
  54007. }
  54008. else {
  54009. defines.CLEARCOAT_TINT_TEXTURE = false;
  54010. }
  54011. }
  54012. else {
  54013. defines.CLEARCOAT_TINT = false;
  54014. defines.CLEARCOAT_TINT_TEXTURE = false;
  54015. }
  54016. }
  54017. }
  54018. }
  54019. else {
  54020. defines.CLEARCOAT = false;
  54021. defines.CLEARCOAT_TEXTURE = false;
  54022. defines.CLEARCOAT_BUMP = false;
  54023. defines.CLEARCOAT_TINT = false;
  54024. defines.CLEARCOAT_TINT_TEXTURE = false;
  54025. }
  54026. };
  54027. /**
  54028. * Binds the material data.
  54029. * @param uniformBuffer defines the Uniform buffer to fill in.
  54030. * @param scene defines the scene the material belongs to.
  54031. * @param engine defines the engine the material belongs to.
  54032. * @param disableBumpMap defines wether the material disables bump or not.
  54033. * @param isFrozen defines wether the material is frozen or not.
  54034. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54035. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54036. */
  54037. PBRClearCoatConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, engine, disableBumpMap, isFrozen, invertNormalMapX, invertNormalMapY) {
  54038. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  54039. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  54040. uniformBuffer.updateFloat2("vClearCoatInfos", this._texture.coordinatesIndex, this._texture.level);
  54041. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "clearCoat");
  54042. }
  54043. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled && !disableBumpMap) {
  54044. uniformBuffer.updateFloat2("vClearCoatBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level);
  54045. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, uniformBuffer, "clearCoatBump");
  54046. if (scene._mirroredCameraPosition) {
  54047. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? 1.0 : -1.0, invertNormalMapY ? 1.0 : -1.0);
  54048. }
  54049. else {
  54050. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? -1.0 : 1.0, invertNormalMapY ? -1.0 : 1.0);
  54051. }
  54052. }
  54053. if (this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  54054. uniformBuffer.updateFloat2("vClearCoatTintInfos", this._tintTexture.coordinatesIndex, this._tintTexture.level);
  54055. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._tintTexture, uniformBuffer, "clearCoatTint");
  54056. }
  54057. // Clear Coat General params
  54058. uniformBuffer.updateFloat2("vClearCoatParams", this.intensity, this.roughness);
  54059. // Clear Coat Refraction params
  54060. var a = 1 - this._indiceOfRefraction;
  54061. var b = 1 + this._indiceOfRefraction;
  54062. var f0 = Math.pow((-a / b), 2); // Schlicks approx: (ior1 - ior2) / (ior1 + ior2) where ior2 for air is close to vacuum = 1.
  54063. var eta = 1 / this._indiceOfRefraction;
  54064. uniformBuffer.updateFloat4("vClearCoatRefractionParams", f0, eta, a, b);
  54065. if (this._isTintEnabled) {
  54066. uniformBuffer.updateFloat4("vClearCoatTintParams", this.tintColor.r, this.tintColor.g, this.tintColor.b, Math.max(0.00001, this.tintThickness));
  54067. uniformBuffer.updateFloat("clearCoatColorAtDistance", Math.max(0.00001, this.tintColorAtDistance));
  54068. }
  54069. }
  54070. // Textures
  54071. if (scene.texturesEnabled) {
  54072. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTextureEnabled) {
  54073. uniformBuffer.setTexture("clearCoatSampler", this._texture);
  54074. }
  54075. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  54076. uniformBuffer.setTexture("clearCoatBumpSampler", this._bumpTexture);
  54077. }
  54078. if (this._isTintEnabled && this._tintTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ClearCoatTintTextureEnabled) {
  54079. uniformBuffer.setTexture("clearCoatTintSampler", this._tintTexture);
  54080. }
  54081. }
  54082. };
  54083. /**
  54084. * Checks to see if a texture is used in the material.
  54085. * @param texture - Base texture to use.
  54086. * @returns - Boolean specifying if a texture is used in the material.
  54087. */
  54088. PBRClearCoatConfiguration.prototype.hasTexture = function (texture) {
  54089. if (this._texture === texture) {
  54090. return true;
  54091. }
  54092. if (this._bumpTexture === texture) {
  54093. return true;
  54094. }
  54095. if (this._tintTexture === texture) {
  54096. return true;
  54097. }
  54098. return false;
  54099. };
  54100. /**
  54101. * Returns an array of the actively used textures.
  54102. * @param activeTextures Array of BaseTextures
  54103. */
  54104. PBRClearCoatConfiguration.prototype.getActiveTextures = function (activeTextures) {
  54105. if (this._texture) {
  54106. activeTextures.push(this._texture);
  54107. }
  54108. if (this._bumpTexture) {
  54109. activeTextures.push(this._bumpTexture);
  54110. }
  54111. if (this._tintTexture) {
  54112. activeTextures.push(this._tintTexture);
  54113. }
  54114. };
  54115. /**
  54116. * Returns the animatable textures.
  54117. * @param animatables Array of animatable textures.
  54118. */
  54119. PBRClearCoatConfiguration.prototype.getAnimatables = function (animatables) {
  54120. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  54121. animatables.push(this._texture);
  54122. }
  54123. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  54124. animatables.push(this._bumpTexture);
  54125. }
  54126. if (this._tintTexture && this._tintTexture.animations && this._tintTexture.animations.length > 0) {
  54127. animatables.push(this._tintTexture);
  54128. }
  54129. };
  54130. /**
  54131. * Disposes the resources of the material.
  54132. * @param forceDisposeTextures - Forces the disposal of all textures.
  54133. */
  54134. PBRClearCoatConfiguration.prototype.dispose = function (forceDisposeTextures) {
  54135. if (forceDisposeTextures) {
  54136. if (this._texture) {
  54137. this._texture.dispose();
  54138. }
  54139. if (this._bumpTexture) {
  54140. this._bumpTexture.dispose();
  54141. }
  54142. if (this._tintTexture) {
  54143. this._tintTexture.dispose();
  54144. }
  54145. }
  54146. };
  54147. /**
  54148. * Get the current class name of the texture useful for serialization or dynamic coding.
  54149. * @returns "PBRClearCoatConfiguration"
  54150. */
  54151. PBRClearCoatConfiguration.prototype.getClassName = function () {
  54152. return "PBRClearCoatConfiguration";
  54153. };
  54154. /**
  54155. * Add fallbacks to the effect fallbacks list.
  54156. * @param defines defines the Base texture to use.
  54157. * @param fallbacks defines the current fallback list.
  54158. * @param currentRank defines the current fallback rank.
  54159. * @returns the new fallback rank.
  54160. */
  54161. PBRClearCoatConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  54162. if (defines.CLEARCOAT_BUMP) {
  54163. fallbacks.addFallback(currentRank++, "CLEARCOAT_BUMP");
  54164. }
  54165. if (defines.CLEARCOAT_TINT) {
  54166. fallbacks.addFallback(currentRank++, "CLEARCOAT_TINT");
  54167. }
  54168. if (defines.CLEARCOAT) {
  54169. fallbacks.addFallback(currentRank++, "CLEARCOAT");
  54170. }
  54171. return currentRank;
  54172. };
  54173. /**
  54174. * Add the required uniforms to the current list.
  54175. * @param uniforms defines the current uniform list.
  54176. */
  54177. PBRClearCoatConfiguration.AddUniforms = function (uniforms) {
  54178. uniforms.push("vClearCoatTangentSpaceParams", "vClearCoatParams", "vClearCoatRefractionParams", "vClearCoatTintParams", "clearCoatColorAtDistance", "clearCoatMatrix", "clearCoatBumpMatrix", "clearCoatTintMatrix", "vClearCoatInfos", "vClearCoatBumpInfos", "vClearCoatTintInfos");
  54179. };
  54180. /**
  54181. * Add the required samplers to the current list.
  54182. * @param samplers defines the current sampler list.
  54183. */
  54184. PBRClearCoatConfiguration.AddSamplers = function (samplers) {
  54185. samplers.push("clearCoatSampler", "clearCoatBumpSampler", "clearCoatTintSampler");
  54186. };
  54187. /**
  54188. * Add the required uniforms to the current buffer.
  54189. * @param uniformBuffer defines the current uniform buffer.
  54190. */
  54191. PBRClearCoatConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  54192. uniformBuffer.addUniform("vClearCoatParams", 2);
  54193. uniformBuffer.addUniform("vClearCoatRefractionParams", 4);
  54194. uniformBuffer.addUniform("vClearCoatInfos", 2);
  54195. uniformBuffer.addUniform("clearCoatMatrix", 16);
  54196. uniformBuffer.addUniform("vClearCoatBumpInfos", 2);
  54197. uniformBuffer.addUniform("vClearCoatTangentSpaceParams", 2);
  54198. uniformBuffer.addUniform("clearCoatBumpMatrix", 16);
  54199. uniformBuffer.addUniform("vClearCoatTintParams", 4);
  54200. uniformBuffer.addUniform("clearCoatColorAtDistance", 1);
  54201. uniformBuffer.addUniform("vClearCoatTintInfos", 2);
  54202. uniformBuffer.addUniform("clearCoatTintMatrix", 16);
  54203. };
  54204. /**
  54205. * Makes a duplicate of the current configuration into another one.
  54206. * @param clearCoatConfiguration define the config where to copy the info
  54207. */
  54208. PBRClearCoatConfiguration.prototype.copyTo = function (clearCoatConfiguration) {
  54209. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return clearCoatConfiguration; }, this);
  54210. };
  54211. /**
  54212. * Serializes this clear coat configuration.
  54213. * @returns - An object with the serialized config.
  54214. */
  54215. PBRClearCoatConfiguration.prototype.serialize = function () {
  54216. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54217. };
  54218. /**
  54219. * Parses a Clear Coat Configuration from a serialized object.
  54220. * @param source - Serialized object.
  54221. */
  54222. PBRClearCoatConfiguration.prototype.parse = function (source) {
  54223. var _this = this;
  54224. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  54225. };
  54226. /**
  54227. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54228. * The default fits with a polyurethane material.
  54229. */
  54230. PBRClearCoatConfiguration._DefaultIndiceOfRefraction = 1.5;
  54231. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54232. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54233. ], PBRClearCoatConfiguration.prototype, "_isEnabled", void 0);
  54234. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54235. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54236. ], PBRClearCoatConfiguration.prototype, "isEnabled", void 0);
  54237. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54238. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54239. ], PBRClearCoatConfiguration.prototype, "intensity", void 0);
  54240. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54241. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54242. ], PBRClearCoatConfiguration.prototype, "roughness", void 0);
  54243. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54244. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54245. ], PBRClearCoatConfiguration.prototype, "_indiceOfRefraction", void 0);
  54246. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54247. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54248. ], PBRClearCoatConfiguration.prototype, "indiceOfRefraction", void 0);
  54249. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54250. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  54251. ], PBRClearCoatConfiguration.prototype, "_texture", void 0);
  54252. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54253. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54254. ], PBRClearCoatConfiguration.prototype, "texture", void 0);
  54255. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54256. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  54257. ], PBRClearCoatConfiguration.prototype, "_bumpTexture", void 0);
  54258. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54259. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54260. ], PBRClearCoatConfiguration.prototype, "bumpTexture", void 0);
  54261. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54262. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54263. ], PBRClearCoatConfiguration.prototype, "_isTintEnabled", void 0);
  54264. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54265. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54266. ], PBRClearCoatConfiguration.prototype, "isTintEnabled", void 0);
  54267. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54268. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  54269. ], PBRClearCoatConfiguration.prototype, "tintColor", void 0);
  54270. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54271. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54272. ], PBRClearCoatConfiguration.prototype, "tintColorAtDistance", void 0);
  54273. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54274. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54275. ], PBRClearCoatConfiguration.prototype, "tintThickness", void 0);
  54276. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54277. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  54278. ], PBRClearCoatConfiguration.prototype, "_tintTexture", void 0);
  54279. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54280. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54281. ], PBRClearCoatConfiguration.prototype, "tintTexture", void 0);
  54282. return PBRClearCoatConfiguration;
  54283. }());
  54284. /***/ }),
  54285. /***/ "./Materials/PBR/pbrMaterial.ts":
  54286. /*!**************************************!*\
  54287. !*** ./Materials/PBR/pbrMaterial.ts ***!
  54288. \**************************************/
  54289. /*! exports provided: PBRMaterial */
  54290. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54291. "use strict";
  54292. __webpack_require__.r(__webpack_exports__);
  54293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  54294. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54295. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54296. /* harmony import */ var _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/brdfTextureTools */ "./Misc/brdfTextureTools.ts");
  54297. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54298. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  54299. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  54300. /**
  54301. * The Physically based material of BJS.
  54302. *
  54303. * This offers the main features of a standard PBR material.
  54304. * For more information, please refer to the documentation :
  54305. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  54306. */
  54307. var PBRMaterial = /** @class */ (function (_super) {
  54308. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  54309. /**
  54310. * Instantiates a new PBRMaterial instance.
  54311. *
  54312. * @param name The material name
  54313. * @param scene The scene the material will be use in.
  54314. */
  54315. function PBRMaterial(name, scene) {
  54316. var _this = _super.call(this, name, scene) || this;
  54317. /**
  54318. * Intensity of the direct lights e.g. the four lights available in your scene.
  54319. * This impacts both the direct diffuse and specular highlights.
  54320. */
  54321. _this.directIntensity = 1.0;
  54322. /**
  54323. * Intensity of the emissive part of the material.
  54324. * This helps controlling the emissive effect without modifying the emissive color.
  54325. */
  54326. _this.emissiveIntensity = 1.0;
  54327. /**
  54328. * Intensity of the environment e.g. how much the environment will light the object
  54329. * either through harmonics for rough material or through the refelction for shiny ones.
  54330. */
  54331. _this.environmentIntensity = 1.0;
  54332. /**
  54333. * This is a special control allowing the reduction of the specular highlights coming from the
  54334. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54335. */
  54336. _this.specularIntensity = 1.0;
  54337. /**
  54338. * Debug Control allowing disabling the bump map on this material.
  54339. */
  54340. _this.disableBumpMap = false;
  54341. /**
  54342. * AKA Occlusion Texture Intensity in other nomenclature.
  54343. */
  54344. _this.ambientTextureStrength = 1.0;
  54345. /**
  54346. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54347. * 1 means it completely occludes it
  54348. * 0 mean it has no impact
  54349. */
  54350. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  54351. /**
  54352. * The color of a material in ambient lighting.
  54353. */
  54354. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  54355. /**
  54356. * AKA Diffuse Color in other nomenclature.
  54357. */
  54358. _this.albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  54359. /**
  54360. * AKA Specular Color in other nomenclature.
  54361. */
  54362. _this.reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  54363. /**
  54364. * The color reflected from the material.
  54365. */
  54366. _this.reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  54367. /**
  54368. * The color emitted from the material.
  54369. */
  54370. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  54371. /**
  54372. * AKA Glossiness in other nomenclature.
  54373. */
  54374. _this.microSurface = 1.0;
  54375. /**
  54376. * If true, the light map contains occlusion information instead of lighting info.
  54377. */
  54378. _this.useLightmapAsShadowmap = false;
  54379. /**
  54380. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54381. */
  54382. _this.useAlphaFromAlbedoTexture = false;
  54383. /**
  54384. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54385. */
  54386. _this.forceAlphaTest = false;
  54387. /**
  54388. * Defines the alpha limits in alpha test mode.
  54389. */
  54390. _this.alphaCutOff = 0.4;
  54391. /**
  54392. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54393. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54394. */
  54395. _this.useSpecularOverAlpha = true;
  54396. /**
  54397. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54398. */
  54399. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  54400. /**
  54401. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54402. */
  54403. _this.useRoughnessFromMetallicTextureAlpha = true;
  54404. /**
  54405. * Specifies if the metallic texture contains the roughness information in its green channel.
  54406. */
  54407. _this.useRoughnessFromMetallicTextureGreen = false;
  54408. /**
  54409. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54410. */
  54411. _this.useMetallnessFromMetallicTextureBlue = false;
  54412. /**
  54413. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54414. */
  54415. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  54416. /**
  54417. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54418. */
  54419. _this.useAmbientInGrayScale = false;
  54420. /**
  54421. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54422. * The material will try to infer what glossiness each pixel should be.
  54423. */
  54424. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  54425. /**
  54426. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54427. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54428. */
  54429. _this.useRadianceOverAlpha = true;
  54430. /**
  54431. * Allows using an object space normal map (instead of tangent space).
  54432. */
  54433. _this.useObjectSpaceNormalMap = false;
  54434. /**
  54435. * Allows using the bump map in parallax mode.
  54436. */
  54437. _this.useParallax = false;
  54438. /**
  54439. * Allows using the bump map in parallax occlusion mode.
  54440. */
  54441. _this.useParallaxOcclusion = false;
  54442. /**
  54443. * Controls the scale bias of the parallax mode.
  54444. */
  54445. _this.parallaxScaleBias = 0.05;
  54446. /**
  54447. * If sets to true, disables all the lights affecting the material.
  54448. */
  54449. _this.disableLighting = false;
  54450. /**
  54451. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54452. */
  54453. _this.forceIrradianceInFragment = false;
  54454. /**
  54455. * Number of Simultaneous lights allowed on the material.
  54456. */
  54457. _this.maxSimultaneousLights = 4;
  54458. /**
  54459. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54460. */
  54461. _this.invertNormalMapX = false;
  54462. /**
  54463. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54464. */
  54465. _this.invertNormalMapY = false;
  54466. /**
  54467. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54468. */
  54469. _this.twoSidedLighting = false;
  54470. /**
  54471. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54472. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54473. */
  54474. _this.useAlphaFresnel = false;
  54475. /**
  54476. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54477. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54478. */
  54479. _this.useLinearAlphaFresnel = false;
  54480. /**
  54481. * Let user defines the brdf lookup texture used for IBL.
  54482. * A default 8bit version is embedded but you could point at :
  54483. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  54484. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54485. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54486. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54487. */
  54488. _this.environmentBRDFTexture = null;
  54489. /**
  54490. * Force normal to face away from face.
  54491. */
  54492. _this.forceNormalForward = false;
  54493. /**
  54494. * Enables specular anti aliasing in the PBR shader.
  54495. * It will both interacts on the Geometry for analytical and IBL lighting.
  54496. * It also prefilter the roughness map based on the bump values.
  54497. */
  54498. _this.enableSpecularAntiAliasing = false;
  54499. /**
  54500. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54501. * makes the reflect vector face the model (under horizon).
  54502. */
  54503. _this.useHorizonOcclusion = true;
  54504. /**
  54505. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54506. * too much the area relying on ambient texture to define their ambient occlusion.
  54507. */
  54508. _this.useRadianceOcclusion = true;
  54509. /**
  54510. * If set to true, no lighting calculations will be applied.
  54511. */
  54512. _this.unlit = false;
  54513. _this._environmentBRDFTexture = _Misc_brdfTextureTools__WEBPACK_IMPORTED_MODULE_2__["BRDFTextureTools"].GetEnvironmentBRDFTexture(scene);
  54514. return _this;
  54515. }
  54516. Object.defineProperty(PBRMaterial.prototype, "refractionTexture", {
  54517. /**
  54518. * Stores the refracted light information in a texture.
  54519. */
  54520. get: function () {
  54521. return this.subSurface.refractionTexture;
  54522. },
  54523. set: function (value) {
  54524. this.subSurface.refractionTexture = value;
  54525. if (value) {
  54526. this.subSurface.isRefractionEnabled = true;
  54527. }
  54528. else if (!this.subSurface.linkRefractionWithTransparency) {
  54529. this.subSurface.isRefractionEnabled = false;
  54530. }
  54531. },
  54532. enumerable: true,
  54533. configurable: true
  54534. });
  54535. Object.defineProperty(PBRMaterial.prototype, "indexOfRefraction", {
  54536. /**
  54537. * source material index of refraction (IOR)' / 'destination material IOR.
  54538. */
  54539. get: function () {
  54540. return 1 / this.subSurface.indexOfRefraction;
  54541. },
  54542. set: function (value) {
  54543. this.subSurface.indexOfRefraction = 1 / value;
  54544. },
  54545. enumerable: true,
  54546. configurable: true
  54547. });
  54548. Object.defineProperty(PBRMaterial.prototype, "invertRefractionY", {
  54549. /**
  54550. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54551. */
  54552. get: function () {
  54553. return this.subSurface.invertRefractionY;
  54554. },
  54555. set: function (value) {
  54556. this.subSurface.invertRefractionY = value;
  54557. },
  54558. enumerable: true,
  54559. configurable: true
  54560. });
  54561. Object.defineProperty(PBRMaterial.prototype, "linkRefractionWithTransparency", {
  54562. /**
  54563. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54564. * Materials half opaque for instance using refraction could benefit from this control.
  54565. */
  54566. get: function () {
  54567. return this.subSurface.linkRefractionWithTransparency;
  54568. },
  54569. set: function (value) {
  54570. this.subSurface.linkRefractionWithTransparency = value;
  54571. if (value) {
  54572. this.subSurface.isRefractionEnabled = true;
  54573. }
  54574. },
  54575. enumerable: true,
  54576. configurable: true
  54577. });
  54578. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  54579. /**
  54580. * BJS is using an harcoded light falloff based on a manually sets up range.
  54581. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54582. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54583. */
  54584. get: function () {
  54585. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  54586. },
  54587. /**
  54588. * BJS is using an harcoded light falloff based on a manually sets up range.
  54589. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54590. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54591. */
  54592. set: function (value) {
  54593. if (value !== this.usePhysicalLightFalloff) {
  54594. // Ensure the effect will be rebuilt.
  54595. this._markAllSubMeshesAsTexturesDirty();
  54596. if (value) {
  54597. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  54598. }
  54599. else {
  54600. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  54601. }
  54602. }
  54603. },
  54604. enumerable: true,
  54605. configurable: true
  54606. });
  54607. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  54608. /**
  54609. * In order to support the falloff compatibility with gltf, a special mode has been added
  54610. * to reproduce the gltf light falloff.
  54611. */
  54612. get: function () {
  54613. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  54614. },
  54615. /**
  54616. * In order to support the falloff compatibility with gltf, a special mode has been added
  54617. * to reproduce the gltf light falloff.
  54618. */
  54619. set: function (value) {
  54620. if (value !== this.useGLTFLightFalloff) {
  54621. // Ensure the effect will be rebuilt.
  54622. this._markAllSubMeshesAsTexturesDirty();
  54623. if (value) {
  54624. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  54625. }
  54626. else {
  54627. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  54628. }
  54629. }
  54630. },
  54631. enumerable: true,
  54632. configurable: true
  54633. });
  54634. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  54635. /**
  54636. * Gets the image processing configuration used either in this material.
  54637. */
  54638. get: function () {
  54639. return this._imageProcessingConfiguration;
  54640. },
  54641. /**
  54642. * Sets the Default image processing configuration used either in the this material.
  54643. *
  54644. * If sets to null, the scene one is in use.
  54645. */
  54646. set: function (value) {
  54647. this._attachImageProcessingConfiguration(value);
  54648. // Ensure the effect will be rebuilt.
  54649. this._markAllSubMeshesAsTexturesDirty();
  54650. },
  54651. enumerable: true,
  54652. configurable: true
  54653. });
  54654. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  54655. /**
  54656. * Gets wether the color curves effect is enabled.
  54657. */
  54658. get: function () {
  54659. return this.imageProcessingConfiguration.colorCurvesEnabled;
  54660. },
  54661. /**
  54662. * Sets wether the color curves effect is enabled.
  54663. */
  54664. set: function (value) {
  54665. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  54666. },
  54667. enumerable: true,
  54668. configurable: true
  54669. });
  54670. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  54671. /**
  54672. * Gets wether the color grading effect is enabled.
  54673. */
  54674. get: function () {
  54675. return this.imageProcessingConfiguration.colorGradingEnabled;
  54676. },
  54677. /**
  54678. * Gets wether the color grading effect is enabled.
  54679. */
  54680. set: function (value) {
  54681. this.imageProcessingConfiguration.colorGradingEnabled = value;
  54682. },
  54683. enumerable: true,
  54684. configurable: true
  54685. });
  54686. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  54687. /**
  54688. * Gets wether tonemapping is enabled or not.
  54689. */
  54690. get: function () {
  54691. return this._imageProcessingConfiguration.toneMappingEnabled;
  54692. },
  54693. /**
  54694. * Sets wether tonemapping is enabled or not
  54695. */
  54696. set: function (value) {
  54697. this._imageProcessingConfiguration.toneMappingEnabled = value;
  54698. },
  54699. enumerable: true,
  54700. configurable: true
  54701. });
  54702. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  54703. /**
  54704. * The camera exposure used on this material.
  54705. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54706. * This corresponds to a photographic exposure.
  54707. */
  54708. get: function () {
  54709. return this._imageProcessingConfiguration.exposure;
  54710. },
  54711. /**
  54712. * The camera exposure used on this material.
  54713. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54714. * This corresponds to a photographic exposure.
  54715. */
  54716. set: function (value) {
  54717. this._imageProcessingConfiguration.exposure = value;
  54718. },
  54719. enumerable: true,
  54720. configurable: true
  54721. });
  54722. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  54723. /**
  54724. * Gets The camera contrast used on this material.
  54725. */
  54726. get: function () {
  54727. return this._imageProcessingConfiguration.contrast;
  54728. },
  54729. /**
  54730. * Sets The camera contrast used on this material.
  54731. */
  54732. set: function (value) {
  54733. this._imageProcessingConfiguration.contrast = value;
  54734. },
  54735. enumerable: true,
  54736. configurable: true
  54737. });
  54738. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  54739. /**
  54740. * Gets the Color Grading 2D Lookup Texture.
  54741. */
  54742. get: function () {
  54743. return this._imageProcessingConfiguration.colorGradingTexture;
  54744. },
  54745. /**
  54746. * Sets the Color Grading 2D Lookup Texture.
  54747. */
  54748. set: function (value) {
  54749. this._imageProcessingConfiguration.colorGradingTexture = value;
  54750. },
  54751. enumerable: true,
  54752. configurable: true
  54753. });
  54754. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  54755. /**
  54756. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54757. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54758. * 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;
  54759. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54760. */
  54761. get: function () {
  54762. return this._imageProcessingConfiguration.colorCurves;
  54763. },
  54764. /**
  54765. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54766. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54767. * 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;
  54768. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54769. */
  54770. set: function (value) {
  54771. this._imageProcessingConfiguration.colorCurves = value;
  54772. },
  54773. enumerable: true,
  54774. configurable: true
  54775. });
  54776. /**
  54777. * Returns the name of this material class.
  54778. */
  54779. PBRMaterial.prototype.getClassName = function () {
  54780. return "PBRMaterial";
  54781. };
  54782. /**
  54783. * Makes a duplicate of the current material.
  54784. * @param name - name to use for the new material.
  54785. */
  54786. PBRMaterial.prototype.clone = function (name) {
  54787. var _this = this;
  54788. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  54789. clone.id = name;
  54790. clone.name = name;
  54791. this.clearCoat.copyTo(clone.clearCoat);
  54792. this.anisotropy.copyTo(clone.anisotropy);
  54793. this.brdf.copyTo(clone.brdf);
  54794. this.sheen.copyTo(clone.sheen);
  54795. return clone;
  54796. };
  54797. /**
  54798. * Serializes this PBR Material.
  54799. * @returns - An object with the serialized material.
  54800. */
  54801. PBRMaterial.prototype.serialize = function () {
  54802. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  54803. serializationObject.customType = "BABYLON.PBRMaterial";
  54804. serializationObject.clearCoat = this.clearCoat.serialize();
  54805. serializationObject.anisotropy = this.anisotropy.serialize();
  54806. serializationObject.brdf = this.brdf.serialize();
  54807. serializationObject.sheen = this.sheen.serialize();
  54808. return serializationObject;
  54809. };
  54810. // Statics
  54811. /**
  54812. * Parses a PBR Material from a serialized object.
  54813. * @param source - Serialized object.
  54814. * @param scene - BJS scene instance.
  54815. * @param rootUrl - url for the scene object
  54816. * @returns - PBRMaterial
  54817. */
  54818. PBRMaterial.Parse = function (source, scene, rootUrl) {
  54819. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  54820. if (source.clearCoat) {
  54821. material.clearCoat.parse(source.clearCoat);
  54822. }
  54823. if (source.anisotropy) {
  54824. material.anisotropy.parse(source.anisotropy);
  54825. }
  54826. if (source.brdf) {
  54827. material.brdf.parse(source.brdf);
  54828. }
  54829. if (source.sheen) {
  54830. material.sheen.parse(source.brdf);
  54831. }
  54832. return material;
  54833. };
  54834. /**
  54835. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54836. */
  54837. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  54838. /**
  54839. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54840. */
  54841. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  54842. /**
  54843. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54844. */
  54845. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  54846. /**
  54847. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54848. * They are also discarded below the alpha cutoff threshold to improve performances.
  54849. */
  54850. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  54851. /**
  54852. * Defines the default value of how much AO map is occluding the analytical lights
  54853. * (point spot...).
  54854. */
  54855. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  54856. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54857. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54859. ], PBRMaterial.prototype, "directIntensity", void 0);
  54860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54862. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54863. ], PBRMaterial.prototype, "emissiveIntensity", void 0);
  54864. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54865. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54866. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54867. ], PBRMaterial.prototype, "environmentIntensity", void 0);
  54868. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54869. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54870. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54871. ], PBRMaterial.prototype, "specularIntensity", void 0);
  54872. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54873. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54874. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54875. ], PBRMaterial.prototype, "disableBumpMap", void 0);
  54876. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54877. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54878. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54879. ], PBRMaterial.prototype, "albedoTexture", void 0);
  54880. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54881. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54882. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54883. ], PBRMaterial.prototype, "ambientTexture", void 0);
  54884. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54885. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54886. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54887. ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
  54888. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54889. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54890. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54891. ], PBRMaterial.prototype, "ambientTextureImpactOnAnalyticalLights", void 0);
  54892. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54893. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54894. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54895. ], PBRMaterial.prototype, "opacityTexture", void 0);
  54896. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54897. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54898. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54899. ], PBRMaterial.prototype, "reflectionTexture", void 0);
  54900. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54901. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54902. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54903. ], PBRMaterial.prototype, "emissiveTexture", void 0);
  54904. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54905. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54906. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54907. ], PBRMaterial.prototype, "reflectivityTexture", void 0);
  54908. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54909. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54910. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54911. ], PBRMaterial.prototype, "metallicTexture", void 0);
  54912. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54913. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54914. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54915. ], PBRMaterial.prototype, "metallic", void 0);
  54916. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54917. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54918. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54919. ], PBRMaterial.prototype, "roughness", void 0);
  54920. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54921. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54922. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54923. ], PBRMaterial.prototype, "microSurfaceTexture", void 0);
  54924. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54925. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54926. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54927. ], PBRMaterial.prototype, "bumpTexture", void 0);
  54928. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54929. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  54930. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  54931. ], PBRMaterial.prototype, "lightmapTexture", void 0);
  54932. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54933. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  54934. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54935. ], PBRMaterial.prototype, "ambientColor", void 0);
  54936. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54937. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  54938. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54939. ], PBRMaterial.prototype, "albedoColor", void 0);
  54940. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54941. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  54942. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54943. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  54944. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54945. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  54946. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54947. ], PBRMaterial.prototype, "reflectionColor", void 0);
  54948. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54949. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  54950. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54951. ], PBRMaterial.prototype, "emissiveColor", void 0);
  54952. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54953. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54954. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54955. ], PBRMaterial.prototype, "microSurface", void 0);
  54956. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54957. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54958. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54959. ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
  54960. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54961. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54962. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54963. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
  54964. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54965. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54966. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54967. ], PBRMaterial.prototype, "forceAlphaTest", void 0);
  54968. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54969. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  54971. ], PBRMaterial.prototype, "alphaCutOff", void 0);
  54972. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54973. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54974. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54975. ], PBRMaterial.prototype, "useSpecularOverAlpha", void 0);
  54976. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54977. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54978. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54979. ], PBRMaterial.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0);
  54980. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54981. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54982. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54983. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureAlpha", void 0);
  54984. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54985. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54986. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54987. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureGreen", void 0);
  54988. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54989. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54990. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54991. ], PBRMaterial.prototype, "useMetallnessFromMetallicTextureBlue", void 0);
  54992. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54993. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54994. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54995. ], PBRMaterial.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0);
  54996. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54997. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  54998. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  54999. ], PBRMaterial.prototype, "useAmbientInGrayScale", void 0);
  55000. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55001. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55002. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55003. ], PBRMaterial.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  55004. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55005. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55006. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  55007. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55008. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55009. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  55010. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55011. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55012. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55013. ], PBRMaterial.prototype, "useRadianceOverAlpha", void 0);
  55014. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55015. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55017. ], PBRMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  55018. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55020. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55021. ], PBRMaterial.prototype, "useParallax", void 0);
  55022. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55023. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55024. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55025. ], PBRMaterial.prototype, "useParallaxOcclusion", 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")
  55029. ], PBRMaterial.prototype, "parallaxScaleBias", void 0);
  55030. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55032. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  55033. ], PBRMaterial.prototype, "disableLighting", void 0);
  55034. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55035. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55036. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55037. ], PBRMaterial.prototype, "forceIrradianceInFragment", void 0);
  55038. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55039. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  55041. ], PBRMaterial.prototype, "maxSimultaneousLights", void 0);
  55042. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55044. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55045. ], PBRMaterial.prototype, "invertNormalMapX", void 0);
  55046. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55047. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55048. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55049. ], PBRMaterial.prototype, "invertNormalMapY", void 0);
  55050. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55051. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55052. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55053. ], PBRMaterial.prototype, "twoSidedLighting", void 0);
  55054. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55055. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55056. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55057. ], PBRMaterial.prototype, "useAlphaFresnel", void 0);
  55058. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55059. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55060. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55061. ], PBRMaterial.prototype, "useLinearAlphaFresnel", void 0);
  55062. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55063. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55064. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55065. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  55066. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55067. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55068. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55069. ], PBRMaterial.prototype, "forceNormalForward", void 0);
  55070. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55071. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55072. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55073. ], PBRMaterial.prototype, "enableSpecularAntiAliasing", void 0);
  55074. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55075. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55076. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55077. ], PBRMaterial.prototype, "useHorizonOcclusion", void 0);
  55078. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55079. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55080. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55081. ], PBRMaterial.prototype, "useRadianceOcclusion", void 0);
  55082. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55083. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55084. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  55085. ], PBRMaterial.prototype, "unlit", void 0);
  55086. return PBRMaterial;
  55087. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  55088. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  55089. /***/ }),
  55090. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  55091. /*!*******************************************************!*\
  55092. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  55093. \*******************************************************/
  55094. /*! exports provided: PBRMetallicRoughnessMaterial */
  55095. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55096. "use strict";
  55097. __webpack_require__.r(__webpack_exports__);
  55098. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  55099. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55100. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55101. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  55102. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55103. /**
  55104. * The PBR material of BJS following the metal roughness convention.
  55105. *
  55106. * This fits to the PBR convention in the GLTF definition:
  55107. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55108. */
  55109. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  55110. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  55111. /**
  55112. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55113. *
  55114. * @param name The material name
  55115. * @param scene The scene the material will be use in.
  55116. */
  55117. function PBRMetallicRoughnessMaterial(name, scene) {
  55118. var _this = _super.call(this, name, scene) || this;
  55119. _this._useRoughnessFromMetallicTextureAlpha = false;
  55120. _this._useRoughnessFromMetallicTextureGreen = true;
  55121. _this._useMetallnessFromMetallicTextureBlue = true;
  55122. _this.metallic = 1.0;
  55123. _this.roughness = 1.0;
  55124. return _this;
  55125. }
  55126. /**
  55127. * Return the currrent class name of the material.
  55128. */
  55129. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  55130. return "PBRMetallicRoughnessMaterial";
  55131. };
  55132. /**
  55133. * Makes a duplicate of the current material.
  55134. * @param name - name to use for the new material.
  55135. */
  55136. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  55137. var _this = this;
  55138. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  55139. clone.id = name;
  55140. clone.name = name;
  55141. this.clearCoat.copyTo(clone.clearCoat);
  55142. this.anisotropy.copyTo(clone.anisotropy);
  55143. this.brdf.copyTo(clone.brdf);
  55144. this.sheen.copyTo(clone.sheen);
  55145. return clone;
  55146. };
  55147. /**
  55148. * Serialize the material to a parsable JSON object.
  55149. */
  55150. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  55151. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55152. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  55153. serializationObject.clearCoat = this.clearCoat.serialize();
  55154. serializationObject.anisotropy = this.anisotropy.serialize();
  55155. serializationObject.brdf = this.brdf.serialize();
  55156. serializationObject.sheen = this.sheen.serialize();
  55157. return serializationObject;
  55158. };
  55159. /**
  55160. * Parses a JSON object correponding to the serialize function.
  55161. */
  55162. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  55163. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  55164. if (source.clearCoat) {
  55165. material.clearCoat.parse(source.clearCoat);
  55166. }
  55167. if (source.anisotropy) {
  55168. material.anisotropy.parse(source.anisotropy);
  55169. }
  55170. if (source.brdf) {
  55171. material.brdf.parse(source.brdf);
  55172. }
  55173. if (source.sheen) {
  55174. material.sheen.parse(source.brdf);
  55175. }
  55176. return material;
  55177. };
  55178. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55179. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  55180. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  55181. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  55182. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55183. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55184. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  55185. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  55186. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55187. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55188. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55189. ], PBRMetallicRoughnessMaterial.prototype, "metallic", void 0);
  55190. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55191. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55192. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55193. ], PBRMetallicRoughnessMaterial.prototype, "roughness", void 0);
  55194. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55195. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55196. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  55197. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  55198. return PBRMetallicRoughnessMaterial;
  55199. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  55200. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  55201. /***/ }),
  55202. /***/ "./Materials/PBR/pbrSheenConfiguration.ts":
  55203. /*!************************************************!*\
  55204. !*** ./Materials/PBR/pbrSheenConfiguration.ts ***!
  55205. \************************************************/
  55206. /*! exports provided: PBRSheenConfiguration */
  55207. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55208. "use strict";
  55209. __webpack_require__.r(__webpack_exports__);
  55210. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSheenConfiguration", function() { return PBRSheenConfiguration; });
  55211. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55212. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55213. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55214. /* harmony import */ var _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/materialFlags */ "./Materials/materialFlags.ts");
  55215. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  55216. /**
  55217. * Define the code related to the Sheen parameters of the pbr material.
  55218. */
  55219. var PBRSheenConfiguration = /** @class */ (function () {
  55220. /**
  55221. * Instantiate a new istance of clear coat configuration.
  55222. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55223. */
  55224. function PBRSheenConfiguration(markAllSubMeshesAsTexturesDirty) {
  55225. this._isEnabled = false;
  55226. /**
  55227. * Defines if the material uses sheen.
  55228. */
  55229. this.isEnabled = false;
  55230. this._linkSheenWithAlbedo = false;
  55231. /**
  55232. * Defines if the sheen is linked to the sheen color.
  55233. */
  55234. this.linkSheenWithAlbedo = false;
  55235. /**
  55236. * Defines the sheen intensity.
  55237. */
  55238. this.intensity = 1;
  55239. /**
  55240. * Defines the sheen color.
  55241. */
  55242. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  55243. this._texture = null;
  55244. /**
  55245. * Stores the sheen tint values in a texture.
  55246. * rgb is tint
  55247. * a is a intensity
  55248. */
  55249. this.texture = null;
  55250. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  55251. }
  55252. /** @hidden */
  55253. PBRSheenConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  55254. this._internalMarkAllSubMeshesAsTexturesDirty();
  55255. };
  55256. /**
  55257. * Specifies that the submesh is ready to be used.
  55258. * @param defines the list of "defines" to update.
  55259. * @param scene defines the scene the material belongs to.
  55260. * @returns - boolean indicating that the submesh is ready or not.
  55261. */
  55262. PBRSheenConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  55263. if (defines._areTexturesDirty) {
  55264. if (scene.texturesEnabled) {
  55265. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  55266. if (!this._texture.isReadyOrNotBlocking()) {
  55267. return false;
  55268. }
  55269. }
  55270. }
  55271. }
  55272. return true;
  55273. };
  55274. /**
  55275. * Checks to see if a texture is used in the material.
  55276. * @param defines the list of "defines" to update.
  55277. * @param scene defines the scene the material belongs to.
  55278. */
  55279. PBRSheenConfiguration.prototype.prepareDefines = function (defines, scene) {
  55280. if (this._isEnabled) {
  55281. defines.SHEEN = this._isEnabled;
  55282. defines.SHEEN_LINKWITHALBEDO = this._linkSheenWithAlbedo;
  55283. if (defines._areTexturesDirty) {
  55284. if (scene.texturesEnabled) {
  55285. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  55286. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "SHEEN_TEXTURE");
  55287. }
  55288. else {
  55289. defines.SHEEN_TEXTURE = false;
  55290. }
  55291. }
  55292. }
  55293. }
  55294. else {
  55295. defines.SHEEN = false;
  55296. defines.SHEEN_TEXTURE = false;
  55297. defines.SHEEN_LINKWITHALBEDO = false;
  55298. }
  55299. };
  55300. /**
  55301. * Binds the material data.
  55302. * @param uniformBuffer defines the Uniform buffer to fill in.
  55303. * @param scene defines the scene the material belongs to.
  55304. * @param isFrozen defines wether the material is frozen or not.
  55305. */
  55306. PBRSheenConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, isFrozen) {
  55307. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  55308. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  55309. uniformBuffer.updateFloat2("vSheenInfos", this._texture.coordinatesIndex, this._texture.level);
  55310. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "sheen");
  55311. }
  55312. // Sheen
  55313. uniformBuffer.updateFloat4("vSheenColor", this.color.r, this.color.g, this.color.b, this.intensity);
  55314. }
  55315. // Textures
  55316. if (scene.texturesEnabled) {
  55317. if (this._texture && _Materials_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].SheenTextureEnabled) {
  55318. uniformBuffer.setTexture("sheenSampler", this._texture);
  55319. }
  55320. }
  55321. };
  55322. /**
  55323. * Checks to see if a texture is used in the material.
  55324. * @param texture - Base texture to use.
  55325. * @returns - Boolean specifying if a texture is used in the material.
  55326. */
  55327. PBRSheenConfiguration.prototype.hasTexture = function (texture) {
  55328. if (this._texture === texture) {
  55329. return true;
  55330. }
  55331. return false;
  55332. };
  55333. /**
  55334. * Returns an array of the actively used textures.
  55335. * @param activeTextures Array of BaseTextures
  55336. */
  55337. PBRSheenConfiguration.prototype.getActiveTextures = function (activeTextures) {
  55338. if (this._texture) {
  55339. activeTextures.push(this._texture);
  55340. }
  55341. };
  55342. /**
  55343. * Returns the animatable textures.
  55344. * @param animatables Array of animatable textures.
  55345. */
  55346. PBRSheenConfiguration.prototype.getAnimatables = function (animatables) {
  55347. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  55348. animatables.push(this._texture);
  55349. }
  55350. };
  55351. /**
  55352. * Disposes the resources of the material.
  55353. * @param forceDisposeTextures - Forces the disposal of all textures.
  55354. */
  55355. PBRSheenConfiguration.prototype.dispose = function (forceDisposeTextures) {
  55356. if (forceDisposeTextures) {
  55357. if (this._texture) {
  55358. this._texture.dispose();
  55359. }
  55360. }
  55361. };
  55362. /**
  55363. * Get the current class name of the texture useful for serialization or dynamic coding.
  55364. * @returns "PBRSheenConfiguration"
  55365. */
  55366. PBRSheenConfiguration.prototype.getClassName = function () {
  55367. return "PBRSheenConfiguration";
  55368. };
  55369. /**
  55370. * Add fallbacks to the effect fallbacks list.
  55371. * @param defines defines the Base texture to use.
  55372. * @param fallbacks defines the current fallback list.
  55373. * @param currentRank defines the current fallback rank.
  55374. * @returns the new fallback rank.
  55375. */
  55376. PBRSheenConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  55377. if (defines.SHEEN) {
  55378. fallbacks.addFallback(currentRank++, "SHEEN");
  55379. }
  55380. return currentRank;
  55381. };
  55382. /**
  55383. * Add the required uniforms to the current list.
  55384. * @param uniforms defines the current uniform list.
  55385. */
  55386. PBRSheenConfiguration.AddUniforms = function (uniforms) {
  55387. uniforms.push("vSheenColor", "vSheenInfos", "sheenMatrix");
  55388. };
  55389. /**
  55390. * Add the required uniforms to the current buffer.
  55391. * @param uniformBuffer defines the current uniform buffer.
  55392. */
  55393. PBRSheenConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  55394. uniformBuffer.addUniform("vSheenColor", 4);
  55395. uniformBuffer.addUniform("vSheenInfos", 2);
  55396. uniformBuffer.addUniform("sheenMatrix", 16);
  55397. };
  55398. /**
  55399. * Add the required samplers to the current list.
  55400. * @param samplers defines the current sampler list.
  55401. */
  55402. PBRSheenConfiguration.AddSamplers = function (samplers) {
  55403. samplers.push("sheenSampler");
  55404. };
  55405. /**
  55406. * Makes a duplicate of the current configuration into another one.
  55407. * @param sheenConfiguration define the config where to copy the info
  55408. */
  55409. PBRSheenConfiguration.prototype.copyTo = function (sheenConfiguration) {
  55410. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return sheenConfiguration; }, this);
  55411. };
  55412. /**
  55413. * Serializes this BRDF configuration.
  55414. * @returns - An object with the serialized config.
  55415. */
  55416. PBRSheenConfiguration.prototype.serialize = function () {
  55417. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55418. };
  55419. /**
  55420. * Parses a Sheen Configuration from a serialized object.
  55421. * @param source - Serialized object.
  55422. */
  55423. PBRSheenConfiguration.prototype.parse = function (source) {
  55424. var _this = this;
  55425. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  55426. };
  55427. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55428. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55429. ], PBRSheenConfiguration.prototype, "_isEnabled", void 0);
  55430. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55431. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55432. ], PBRSheenConfiguration.prototype, "isEnabled", void 0);
  55433. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55434. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55435. ], PBRSheenConfiguration.prototype, "_linkSheenWithAlbedo", void 0);
  55436. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55437. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55438. ], PBRSheenConfiguration.prototype, "linkSheenWithAlbedo", void 0);
  55439. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55440. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55441. ], PBRSheenConfiguration.prototype, "intensity", void 0);
  55442. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55443. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  55444. ], PBRSheenConfiguration.prototype, "color", void 0);
  55445. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55446. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  55447. ], PBRSheenConfiguration.prototype, "_texture", void 0);
  55448. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55449. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55450. ], PBRSheenConfiguration.prototype, "texture", void 0);
  55451. return PBRSheenConfiguration;
  55452. }());
  55453. /***/ }),
  55454. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  55455. /*!********************************************************!*\
  55456. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  55457. \********************************************************/
  55458. /*! exports provided: PBRSpecularGlossinessMaterial */
  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__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  55463. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55464. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55465. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  55466. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55467. /**
  55468. * The PBR material of BJS following the specular glossiness convention.
  55469. *
  55470. * This fits to the PBR convention in the GLTF definition:
  55471. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55472. */
  55473. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  55474. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  55475. /**
  55476. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55477. *
  55478. * @param name The material name
  55479. * @param scene The scene the material will be use in.
  55480. */
  55481. function PBRSpecularGlossinessMaterial(name, scene) {
  55482. var _this = _super.call(this, name, scene) || this;
  55483. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  55484. return _this;
  55485. }
  55486. /**
  55487. * Return the currrent class name of the material.
  55488. */
  55489. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  55490. return "PBRSpecularGlossinessMaterial";
  55491. };
  55492. /**
  55493. * Makes a duplicate of the current material.
  55494. * @param name - name to use for the new material.
  55495. */
  55496. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  55497. var _this = this;
  55498. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  55499. clone.id = name;
  55500. clone.name = name;
  55501. this.clearCoat.copyTo(clone.clearCoat);
  55502. this.anisotropy.copyTo(clone.anisotropy);
  55503. this.brdf.copyTo(clone.brdf);
  55504. this.sheen.copyTo(clone.sheen);
  55505. return clone;
  55506. };
  55507. /**
  55508. * Serialize the material to a parsable JSON object.
  55509. */
  55510. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  55511. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55512. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  55513. serializationObject.clearCoat = this.clearCoat.serialize();
  55514. serializationObject.anisotropy = this.anisotropy.serialize();
  55515. serializationObject.brdf = this.brdf.serialize();
  55516. serializationObject.sheen = this.sheen.serialize();
  55517. return serializationObject;
  55518. };
  55519. /**
  55520. * Parses a JSON object correponding to the serialize function.
  55521. */
  55522. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  55523. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  55524. if (source.clearCoat) {
  55525. material.clearCoat.parse(source.clearCoat);
  55526. }
  55527. if (source.anisotropy) {
  55528. material.anisotropy.parse(source.anisotropy);
  55529. }
  55530. if (source.brdf) {
  55531. material.brdf.parse(source.brdf);
  55532. }
  55533. if (source.sheen) {
  55534. material.sheen.parse(source.brdf);
  55535. }
  55536. return material;
  55537. };
  55538. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55539. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  55540. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  55541. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  55542. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55543. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55544. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  55545. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  55546. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55547. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  55548. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  55549. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  55550. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55551. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  55552. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  55553. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  55554. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55555. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  55556. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  55557. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  55558. return PBRSpecularGlossinessMaterial;
  55559. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  55560. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  55561. /***/ }),
  55562. /***/ "./Materials/PBR/pbrSubSurfaceConfiguration.ts":
  55563. /*!*****************************************************!*\
  55564. !*** ./Materials/PBR/pbrSubSurfaceConfiguration.ts ***!
  55565. \*****************************************************/
  55566. /*! exports provided: PBRSubSurfaceConfiguration */
  55567. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55568. "use strict";
  55569. __webpack_require__.r(__webpack_exports__);
  55570. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSubSurfaceConfiguration", function() { return PBRSubSurfaceConfiguration; });
  55571. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55572. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55573. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55574. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  55575. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  55576. /**
  55577. * Define the code related to the sub surface parameters of the pbr material.
  55578. */
  55579. var PBRSubSurfaceConfiguration = /** @class */ (function () {
  55580. /**
  55581. * Instantiate a new istance of sub surface configuration.
  55582. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55583. */
  55584. function PBRSubSurfaceConfiguration(markAllSubMeshesAsTexturesDirty) {
  55585. this._isRefractionEnabled = false;
  55586. /**
  55587. * Defines if the refraction is enabled in the material.
  55588. */
  55589. this.isRefractionEnabled = false;
  55590. this._isTranslucencyEnabled = false;
  55591. /**
  55592. * Defines if the translucency is enabled in the material.
  55593. */
  55594. this.isTranslucencyEnabled = false;
  55595. this._isScatteringEnabled = false;
  55596. // /**
  55597. // * Defines if the sub surface scattering is enabled in the material.
  55598. // */
  55599. // @expandToProperty("_markAllSubMeshesAsTexturesDirty")
  55600. // public isScatteringEnabled = false;
  55601. /**
  55602. * Defines the refraction intensity of the material.
  55603. * The refraction when enabled replaces the Diffuse part of the material.
  55604. * The intensity helps transitionning between diffuse and refraction.
  55605. */
  55606. this.refractionIntensity = 1;
  55607. /**
  55608. * Defines the translucency intensity of the material.
  55609. * When translucency has been enabled, this defines how much of the "translucency"
  55610. * is addded to the diffuse part of the material.
  55611. */
  55612. this.translucencyIntensity = 1;
  55613. /**
  55614. * Defines the scattering intensity of the material.
  55615. * When scattering has been enabled, this defines how much of the "scattered light"
  55616. * is addded to the diffuse part of the material.
  55617. */
  55618. this.scatteringIntensity = 1;
  55619. this._thicknessTexture = null;
  55620. /**
  55621. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55622. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55623. * 0 would mean minimumThickness
  55624. * 1 would mean maximumThickness
  55625. * The other channels might be use as a mask to vary the different effects intensity.
  55626. */
  55627. this.thicknessTexture = null;
  55628. this._refractionTexture = null;
  55629. /**
  55630. * Defines the texture to use for refraction.
  55631. */
  55632. this.refractionTexture = null;
  55633. this._indexOfRefraction = 1;
  55634. /**
  55635. * Defines the indice of refraction used in the material.
  55636. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55637. */
  55638. this.indexOfRefraction = 1;
  55639. this._invertRefractionY = false;
  55640. /**
  55641. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55642. */
  55643. this.invertRefractionY = false;
  55644. this._linkRefractionWithTransparency = false;
  55645. /**
  55646. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55647. * Materials half opaque for instance using refraction could benefit from this control.
  55648. */
  55649. this.linkRefractionWithTransparency = false;
  55650. /**
  55651. * Defines the minimum thickness stored in the thickness map.
  55652. * If no thickness map is defined, this value will be used to simulate thickness.
  55653. */
  55654. this.minimumThickness = 0;
  55655. /**
  55656. * Defines the maximum thickness stored in the thickness map.
  55657. */
  55658. this.maximumThickness = 1;
  55659. /**
  55660. * Defines the volume tint of the material.
  55661. * This is used for both translucency and scattering.
  55662. */
  55663. this.tintColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  55664. /**
  55665. * Defines the distance at which the tint color should be found in the media.
  55666. * This is used for refraction only.
  55667. */
  55668. this.tintColorAtDistance = 1;
  55669. /**
  55670. * Defines how far each channel transmit through the media.
  55671. * It is defined as a color to simplify it selection.
  55672. */
  55673. this.diffusionDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  55674. this._useMaskFromThicknessTexture = false;
  55675. /**
  55676. * Stores the intensity of the different subsurface effects in the thickness texture.
  55677. * * the green channel is the translucency intensity.
  55678. * * the blue channel is the scattering intensity.
  55679. * * the alpha channel is the refraction intensity.
  55680. */
  55681. this.useMaskFromThicknessTexture = false;
  55682. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  55683. }
  55684. /** @hidden */
  55685. PBRSubSurfaceConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  55686. this._internalMarkAllSubMeshesAsTexturesDirty();
  55687. };
  55688. /**
  55689. * Gets wehter the submesh is ready to be used or not.
  55690. * @param defines the list of "defines" to update.
  55691. * @param scene defines the scene the material belongs to.
  55692. * @returns - boolean indicating that the submesh is ready or not.
  55693. */
  55694. PBRSubSurfaceConfiguration.prototype.isReadyForSubMesh = function (defines, scene) {
  55695. if (defines._areTexturesDirty) {
  55696. if (scene.texturesEnabled) {
  55697. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  55698. if (!this._thicknessTexture.isReadyOrNotBlocking()) {
  55699. return false;
  55700. }
  55701. }
  55702. var refractionTexture = this._getRefractionTexture(scene);
  55703. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  55704. if (!refractionTexture.isReadyOrNotBlocking()) {
  55705. return false;
  55706. }
  55707. }
  55708. }
  55709. }
  55710. return true;
  55711. };
  55712. /**
  55713. * Checks to see if a texture is used in the material.
  55714. * @param defines the list of "defines" to update.
  55715. * @param scene defines the scene to the material belongs to.
  55716. */
  55717. PBRSubSurfaceConfiguration.prototype.prepareDefines = function (defines, scene) {
  55718. if (defines._areTexturesDirty) {
  55719. defines.SUBSURFACE = false;
  55720. defines.SS_TRANSLUCENCY = this._isTranslucencyEnabled;
  55721. defines.SS_SCATERRING = this._isScatteringEnabled;
  55722. defines.SS_THICKNESSANDMASK_TEXTURE = false;
  55723. defines.SS_MASK_FROM_THICKNESS_TEXTURE = false;
  55724. defines.SS_REFRACTION = false;
  55725. defines.SS_REFRACTIONMAP_3D = false;
  55726. defines.SS_GAMMAREFRACTION = false;
  55727. defines.SS_RGBDREFRACTION = false;
  55728. defines.SS_REFRACTIONMAP_OPPOSITEZ = false;
  55729. defines.SS_LODINREFRACTIONALPHA = false;
  55730. defines.SS_LINKREFRACTIONTOTRANSPARENCY = false;
  55731. if (this._isRefractionEnabled || this._isTranslucencyEnabled || this._isScatteringEnabled) {
  55732. defines.SUBSURFACE = true;
  55733. if (defines._areTexturesDirty) {
  55734. if (scene.texturesEnabled) {
  55735. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  55736. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].PrepareDefinesForMergedUV(this._thicknessTexture, defines, "SS_THICKNESSANDMASK_TEXTURE");
  55737. }
  55738. }
  55739. }
  55740. defines.SS_MASK_FROM_THICKNESS_TEXTURE = this._useMaskFromThicknessTexture;
  55741. }
  55742. if (this._isRefractionEnabled) {
  55743. if (scene.texturesEnabled) {
  55744. var refractionTexture = this._getRefractionTexture(scene);
  55745. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  55746. defines.SS_REFRACTION = true;
  55747. defines.SS_REFRACTIONMAP_3D = refractionTexture.isCube;
  55748. defines.SS_GAMMAREFRACTION = refractionTexture.gammaSpace;
  55749. defines.SS_RGBDREFRACTION = refractionTexture.isRGBD;
  55750. defines.SS_REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  55751. defines.SS_LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  55752. defines.SS_LINKREFRACTIONTOTRANSPARENCY = this._linkRefractionWithTransparency;
  55753. }
  55754. }
  55755. }
  55756. }
  55757. };
  55758. /**
  55759. * Binds the material data.
  55760. * @param uniformBuffer defines the Uniform buffer to fill in.
  55761. * @param scene defines the scene the material belongs to.
  55762. * @param engine defines the engine the material belongs to.
  55763. * @param isFrozen defines wether the material is frozen or not.
  55764. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  55765. */
  55766. PBRSubSurfaceConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, engine, isFrozen, lodBasedMicrosurface) {
  55767. var refractionTexture = this._getRefractionTexture(scene);
  55768. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  55769. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  55770. uniformBuffer.updateFloat2("vThicknessInfos", this._thicknessTexture.coordinatesIndex, this._thicknessTexture.level);
  55771. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_4__["MaterialHelper"].BindTextureMatrix(this._thicknessTexture, uniformBuffer, "thickness");
  55772. }
  55773. uniformBuffer.updateFloat2("vThicknessParam", this.minimumThickness, this.maximumThickness - this.minimumThickness);
  55774. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  55775. uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  55776. var depth = 1.0;
  55777. if (!refractionTexture.isCube) {
  55778. if (refractionTexture.depth) {
  55779. depth = refractionTexture.depth;
  55780. }
  55781. }
  55782. uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, 1 / this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  55783. uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  55784. }
  55785. uniformBuffer.updateColor3("vDiffusionDistance", this.diffusionDistance);
  55786. uniformBuffer.updateFloat4("vTintColor", this.tintColor.r, this.tintColor.g, this.tintColor.b, this.tintColorAtDistance);
  55787. uniformBuffer.updateFloat3("vSubSurfaceIntensity", this.refractionIntensity, this.translucencyIntensity, this.scatteringIntensity);
  55788. }
  55789. // Textures
  55790. if (scene.texturesEnabled) {
  55791. if (this._thicknessTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].ThicknessTextureEnabled) {
  55792. uniformBuffer.setTexture("thicknessSampler", this._thicknessTexture);
  55793. }
  55794. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled) {
  55795. if (lodBasedMicrosurface) {
  55796. uniformBuffer.setTexture("refractionSampler", refractionTexture);
  55797. }
  55798. else {
  55799. uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  55800. uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  55801. uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  55802. }
  55803. }
  55804. }
  55805. };
  55806. /**
  55807. * Unbinds the material from the mesh.
  55808. * @param activeEffect defines the effect that should be unbound from.
  55809. * @returns true if unbound, otherwise false
  55810. */
  55811. PBRSubSurfaceConfiguration.prototype.unbind = function (activeEffect) {
  55812. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  55813. activeEffect.setTexture("refractionSampler", null);
  55814. return true;
  55815. }
  55816. return false;
  55817. };
  55818. /**
  55819. * Returns the texture used for refraction or null if none is used.
  55820. * @param scene defines the scene the material belongs to.
  55821. * @returns - Refraction texture if present. If no refraction texture and refraction
  55822. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55823. */
  55824. PBRSubSurfaceConfiguration.prototype._getRefractionTexture = function (scene) {
  55825. if (this._refractionTexture) {
  55826. return this._refractionTexture;
  55827. }
  55828. if (this._isRefractionEnabled) {
  55829. return scene.environmentTexture;
  55830. }
  55831. return null;
  55832. };
  55833. Object.defineProperty(PBRSubSurfaceConfiguration.prototype, "disableAlphaBlending", {
  55834. /**
  55835. * Returns true if alpha blending should be disabled.
  55836. */
  55837. get: function () {
  55838. return this.isRefractionEnabled && this._linkRefractionWithTransparency;
  55839. },
  55840. enumerable: true,
  55841. configurable: true
  55842. });
  55843. /**
  55844. * Fills the list of render target textures.
  55845. * @param renderTargets the list of render targets to update
  55846. */
  55847. PBRSubSurfaceConfiguration.prototype.fillRenderTargetTextures = function (renderTargets) {
  55848. if (_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  55849. renderTargets.push(this._refractionTexture);
  55850. }
  55851. };
  55852. /**
  55853. * Checks to see if a texture is used in the material.
  55854. * @param texture - Base texture to use.
  55855. * @returns - Boolean specifying if a texture is used in the material.
  55856. */
  55857. PBRSubSurfaceConfiguration.prototype.hasTexture = function (texture) {
  55858. if (this._thicknessTexture === texture) {
  55859. return true;
  55860. }
  55861. if (this._refractionTexture === texture) {
  55862. return true;
  55863. }
  55864. return false;
  55865. };
  55866. /**
  55867. * Gets a boolean indicating that current material needs to register RTT
  55868. * @returns true if this uses a render target otherwise false.
  55869. */
  55870. PBRSubSurfaceConfiguration.prototype.hasRenderTargetTextures = function () {
  55871. if (_materialFlags__WEBPACK_IMPORTED_MODULE_3__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  55872. return true;
  55873. }
  55874. return false;
  55875. };
  55876. /**
  55877. * Returns an array of the actively used textures.
  55878. * @param activeTextures Array of BaseTextures
  55879. */
  55880. PBRSubSurfaceConfiguration.prototype.getActiveTextures = function (activeTextures) {
  55881. if (this._thicknessTexture) {
  55882. activeTextures.push(this._thicknessTexture);
  55883. }
  55884. if (this._refractionTexture) {
  55885. activeTextures.push(this._refractionTexture);
  55886. }
  55887. };
  55888. /**
  55889. * Returns the animatable textures.
  55890. * @param animatables Array of animatable textures.
  55891. */
  55892. PBRSubSurfaceConfiguration.prototype.getAnimatables = function (animatables) {
  55893. if (this._thicknessTexture && this._thicknessTexture.animations && this._thicknessTexture.animations.length > 0) {
  55894. animatables.push(this._thicknessTexture);
  55895. }
  55896. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  55897. animatables.push(this._refractionTexture);
  55898. }
  55899. };
  55900. /**
  55901. * Disposes the resources of the material.
  55902. * @param forceDisposeTextures - Forces the disposal of all textures.
  55903. */
  55904. PBRSubSurfaceConfiguration.prototype.dispose = function (forceDisposeTextures) {
  55905. if (forceDisposeTextures) {
  55906. if (this._thicknessTexture) {
  55907. this._thicknessTexture.dispose();
  55908. }
  55909. if (this._refractionTexture) {
  55910. this._refractionTexture.dispose();
  55911. }
  55912. }
  55913. };
  55914. /**
  55915. * Get the current class name of the texture useful for serialization or dynamic coding.
  55916. * @returns "PBRSubSurfaceConfiguration"
  55917. */
  55918. PBRSubSurfaceConfiguration.prototype.getClassName = function () {
  55919. return "PBRSubSurfaceConfiguration";
  55920. };
  55921. /**
  55922. * Add fallbacks to the effect fallbacks list.
  55923. * @param defines defines the Base texture to use.
  55924. * @param fallbacks defines the current fallback list.
  55925. * @param currentRank defines the current fallback rank.
  55926. * @returns the new fallback rank.
  55927. */
  55928. PBRSubSurfaceConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  55929. if (defines.SS_SCATERRING) {
  55930. fallbacks.addFallback(currentRank++, "SS_SCATERRING");
  55931. }
  55932. if (defines.SS_TRANSLUCENCY) {
  55933. fallbacks.addFallback(currentRank++, "SS_TRANSLUCENCY");
  55934. }
  55935. return currentRank;
  55936. };
  55937. /**
  55938. * Add the required uniforms to the current list.
  55939. * @param uniforms defines the current uniform list.
  55940. */
  55941. PBRSubSurfaceConfiguration.AddUniforms = function (uniforms) {
  55942. uniforms.push("vDiffusionDistance", "vTintColor", "vSubSurfaceIntensity", "vRefractionMicrosurfaceInfos", "vRefractionInfos", "vThicknessInfos", "vThicknessParam", "refractionMatrix", "thicknessMatrix");
  55943. };
  55944. /**
  55945. * Add the required samplers to the current list.
  55946. * @param samplers defines the current sampler list.
  55947. */
  55948. PBRSubSurfaceConfiguration.AddSamplers = function (samplers) {
  55949. samplers.push("thicknessSampler", "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh");
  55950. };
  55951. /**
  55952. * Add the required uniforms to the current buffer.
  55953. * @param uniformBuffer defines the current uniform buffer.
  55954. */
  55955. PBRSubSurfaceConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  55956. uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  55957. uniformBuffer.addUniform("vRefractionInfos", 4);
  55958. uniformBuffer.addUniform("refractionMatrix", 16);
  55959. uniformBuffer.addUniform("vThicknessInfos", 2);
  55960. uniformBuffer.addUniform("thicknessMatrix", 16);
  55961. uniformBuffer.addUniform("vThicknessParam", 2);
  55962. uniformBuffer.addUniform("vDiffusionDistance", 3);
  55963. uniformBuffer.addUniform("vTintColor", 4);
  55964. uniformBuffer.addUniform("vSubSurfaceIntensity", 3);
  55965. };
  55966. /**
  55967. * Makes a duplicate of the current configuration into another one.
  55968. * @param configuration define the config where to copy the info
  55969. */
  55970. PBRSubSurfaceConfiguration.prototype.copyTo = function (configuration) {
  55971. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return configuration; }, this);
  55972. };
  55973. /**
  55974. * Serializes this Sub Surface configuration.
  55975. * @returns - An object with the serialized config.
  55976. */
  55977. PBRSubSurfaceConfiguration.prototype.serialize = function () {
  55978. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55979. };
  55980. /**
  55981. * Parses a Sub Surface Configuration from a serialized object.
  55982. * @param source - Serialized object.
  55983. */
  55984. PBRSubSurfaceConfiguration.prototype.parse = function (source) {
  55985. var _this = this;
  55986. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  55987. };
  55988. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55989. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55990. ], PBRSubSurfaceConfiguration.prototype, "_isRefractionEnabled", void 0);
  55991. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55992. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55993. ], PBRSubSurfaceConfiguration.prototype, "isRefractionEnabled", void 0);
  55994. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55995. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55996. ], PBRSubSurfaceConfiguration.prototype, "_isTranslucencyEnabled", void 0);
  55997. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55998. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  55999. ], PBRSubSurfaceConfiguration.prototype, "isTranslucencyEnabled", void 0);
  56000. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56001. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56002. ], PBRSubSurfaceConfiguration.prototype, "_isScatteringEnabled", void 0);
  56003. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56004. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56005. ], PBRSubSurfaceConfiguration.prototype, "refractionIntensity", void 0);
  56006. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56007. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56008. ], PBRSubSurfaceConfiguration.prototype, "translucencyIntensity", void 0);
  56009. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56010. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56011. ], PBRSubSurfaceConfiguration.prototype, "scatteringIntensity", void 0);
  56012. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56013. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  56014. ], PBRSubSurfaceConfiguration.prototype, "_thicknessTexture", void 0);
  56015. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56017. ], PBRSubSurfaceConfiguration.prototype, "thicknessTexture", void 0);
  56018. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  56020. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56021. ], PBRSubSurfaceConfiguration.prototype, "refractionTexture", void 0);
  56022. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56023. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56024. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56025. ], PBRSubSurfaceConfiguration.prototype, "indexOfRefraction", void 0);
  56026. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56027. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56028. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56029. ], PBRSubSurfaceConfiguration.prototype, "invertRefractionY", void 0);
  56030. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  56032. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56033. ], PBRSubSurfaceConfiguration.prototype, "linkRefractionWithTransparency", void 0);
  56034. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56035. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56036. ], PBRSubSurfaceConfiguration.prototype, "minimumThickness", void 0);
  56037. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56038. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56039. ], PBRSubSurfaceConfiguration.prototype, "maximumThickness", void 0);
  56040. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56041. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  56042. ], PBRSubSurfaceConfiguration.prototype, "tintColor", void 0);
  56043. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56044. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56045. ], PBRSubSurfaceConfiguration.prototype, "tintColorAtDistance", void 0);
  56046. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56047. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  56048. ], PBRSubSurfaceConfiguration.prototype, "diffusionDistance", void 0);
  56049. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56050. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  56051. ], PBRSubSurfaceConfiguration.prototype, "_useMaskFromThicknessTexture", void 0);
  56052. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56053. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  56054. ], PBRSubSurfaceConfiguration.prototype, "useMaskFromThicknessTexture", void 0);
  56055. return PBRSubSurfaceConfiguration;
  56056. }());
  56057. /***/ }),
  56058. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  56059. /*!********************************************************!*\
  56060. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  56061. \********************************************************/
  56062. /*! exports provided: _DDSTextureLoader */
  56063. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56064. "use strict";
  56065. __webpack_require__.r(__webpack_exports__);
  56066. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  56067. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  56068. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  56069. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  56070. /**
  56071. * Implementation of the DDS Texture Loader.
  56072. * @hidden
  56073. */
  56074. var _DDSTextureLoader = /** @class */ (function () {
  56075. function _DDSTextureLoader() {
  56076. /**
  56077. * Defines wether the loader supports cascade loading the different faces.
  56078. */
  56079. this.supportCascades = true;
  56080. }
  56081. /**
  56082. * This returns if the loader support the current file information.
  56083. * @param extension defines the file extension of the file being loaded
  56084. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56085. * @param fallback defines the fallback internal texture if any
  56086. * @param isBase64 defines whether the texture is encoded as a base64
  56087. * @param isBuffer defines whether the texture data are stored as a buffer
  56088. * @returns true if the loader can load the specified file
  56089. */
  56090. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  56091. return extension.indexOf(".dds") === 0;
  56092. };
  56093. /**
  56094. * Transform the url before loading if required.
  56095. * @param rootUrl the url of the texture
  56096. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56097. * @returns the transformed texture
  56098. */
  56099. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  56100. return rootUrl;
  56101. };
  56102. /**
  56103. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56104. * @param rootUrl the url of the texture
  56105. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56106. * @returns the fallback texture
  56107. */
  56108. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  56109. return null;
  56110. };
  56111. /**
  56112. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56113. * @param data contains the texture data
  56114. * @param texture defines the BabylonJS internal texture
  56115. * @param createPolynomials will be true if polynomials have been requested
  56116. * @param onLoad defines the callback to trigger once the texture is ready
  56117. * @param onError defines the callback to trigger in case of error
  56118. */
  56119. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  56120. var engine = texture.getEngine();
  56121. var info;
  56122. var loadMipmap = false;
  56123. if (Array.isArray(imgs)) {
  56124. for (var index = 0; index < imgs.length; index++) {
  56125. var data_1 = imgs[index];
  56126. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  56127. texture.width = info.width;
  56128. texture.height = info.height;
  56129. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  56130. engine._unpackFlipY(info.isCompressed);
  56131. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  56132. if (!info.isFourCC && info.mipmapCount === 1) {
  56133. engine.generateMipMapsForCubemap(texture);
  56134. }
  56135. }
  56136. }
  56137. else {
  56138. var data = imgs;
  56139. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  56140. texture.width = info.width;
  56141. texture.height = info.height;
  56142. if (createPolynomials) {
  56143. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  56144. }
  56145. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  56146. engine._unpackFlipY(info.isCompressed);
  56147. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  56148. if (!info.isFourCC && info.mipmapCount === 1) {
  56149. engine.generateMipMapsForCubemap(texture);
  56150. }
  56151. }
  56152. engine._setCubeMapTextureParams(loadMipmap);
  56153. texture.isReady = true;
  56154. if (onLoad) {
  56155. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  56156. }
  56157. };
  56158. /**
  56159. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56160. * @param data contains the texture data
  56161. * @param texture defines the BabylonJS internal texture
  56162. * @param callback defines the method to call once ready to upload
  56163. */
  56164. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  56165. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  56166. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  56167. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  56168. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  56169. });
  56170. };
  56171. return _DDSTextureLoader;
  56172. }());
  56173. // Register the loader.
  56174. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  56175. /***/ }),
  56176. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  56177. /*!********************************************************!*\
  56178. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  56179. \********************************************************/
  56180. /*! exports provided: _ENVTextureLoader */
  56181. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56182. "use strict";
  56183. __webpack_require__.r(__webpack_exports__);
  56184. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  56185. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  56186. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  56187. /**
  56188. * Implementation of the ENV Texture Loader.
  56189. * @hidden
  56190. */
  56191. var _ENVTextureLoader = /** @class */ (function () {
  56192. function _ENVTextureLoader() {
  56193. /**
  56194. * Defines wether the loader supports cascade loading the different faces.
  56195. */
  56196. this.supportCascades = false;
  56197. }
  56198. /**
  56199. * This returns if the loader support the current file information.
  56200. * @param extension defines the file extension of the file being loaded
  56201. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56202. * @param fallback defines the fallback internal texture if any
  56203. * @param isBase64 defines whether the texture is encoded as a base64
  56204. * @param isBuffer defines whether the texture data are stored as a buffer
  56205. * @returns true if the loader can load the specified file
  56206. */
  56207. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  56208. return extension.indexOf(".env") === 0;
  56209. };
  56210. /**
  56211. * Transform the url before loading if required.
  56212. * @param rootUrl the url of the texture
  56213. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56214. * @returns the transformed texture
  56215. */
  56216. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  56217. return rootUrl;
  56218. };
  56219. /**
  56220. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56221. * @param rootUrl the url of the texture
  56222. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56223. * @returns the fallback texture
  56224. */
  56225. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  56226. return null;
  56227. };
  56228. /**
  56229. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56230. * @param data contains the texture data
  56231. * @param texture defines the BabylonJS internal texture
  56232. * @param createPolynomials will be true if polynomials have been requested
  56233. * @param onLoad defines the callback to trigger once the texture is ready
  56234. * @param onError defines the callback to trigger in case of error
  56235. */
  56236. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  56237. if (Array.isArray(data)) {
  56238. return;
  56239. }
  56240. data = data;
  56241. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  56242. if (info) {
  56243. texture.width = info.width;
  56244. texture.height = info.width;
  56245. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  56246. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  56247. texture.isReady = true;
  56248. if (onLoad) {
  56249. onLoad();
  56250. }
  56251. });
  56252. }
  56253. else if (onError) {
  56254. onError("Can not parse the environment file", null);
  56255. }
  56256. };
  56257. /**
  56258. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56259. * @param data contains the texture data
  56260. * @param texture defines the BabylonJS internal texture
  56261. * @param callback defines the method to call once ready to upload
  56262. */
  56263. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  56264. throw ".env not supported in 2d.";
  56265. };
  56266. return _ENVTextureLoader;
  56267. }());
  56268. // Register the loader.
  56269. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  56270. /***/ }),
  56271. /***/ "./Materials/Textures/Loaders/index.ts":
  56272. /*!*********************************************!*\
  56273. !*** ./Materials/Textures/Loaders/index.ts ***!
  56274. \*********************************************/
  56275. /*! exports provided: _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader */
  56276. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56277. "use strict";
  56278. __webpack_require__.r(__webpack_exports__);
  56279. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  56280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  56281. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  56282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  56283. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  56284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  56285. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  56286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  56287. /***/ }),
  56288. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  56289. /*!********************************************************!*\
  56290. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  56291. \********************************************************/
  56292. /*! exports provided: _KTXTextureLoader */
  56293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56294. "use strict";
  56295. __webpack_require__.r(__webpack_exports__);
  56296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  56297. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  56298. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  56299. /**
  56300. * Implementation of the KTX Texture Loader.
  56301. * @hidden
  56302. */
  56303. var _KTXTextureLoader = /** @class */ (function () {
  56304. function _KTXTextureLoader() {
  56305. /**
  56306. * Defines wether the loader supports cascade loading the different faces.
  56307. */
  56308. this.supportCascades = false;
  56309. }
  56310. /**
  56311. * This returns if the loader support the current file information.
  56312. * @param extension defines the file extension of the file being loaded
  56313. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56314. * @param fallback defines the fallback internal texture if any
  56315. * @param isBase64 defines whether the texture is encoded as a base64
  56316. * @param isBuffer defines whether the texture data are stored as a buffer
  56317. * @returns true if the loader can load the specified file
  56318. */
  56319. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  56320. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  56321. return true;
  56322. }
  56323. return false;
  56324. };
  56325. /**
  56326. * Transform the url before loading if required.
  56327. * @param rootUrl the url of the texture
  56328. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56329. * @returns the transformed texture
  56330. */
  56331. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  56332. var lastDot = rootUrl.lastIndexOf('.');
  56333. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  56334. // Already transformed
  56335. return rootUrl;
  56336. }
  56337. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  56338. };
  56339. /**
  56340. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56341. * @param rootUrl the url of the texture
  56342. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56343. * @returns the fallback texture
  56344. */
  56345. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  56346. // remove the format appended to the rootUrl in the original createCubeTexture call.
  56347. var exp = new RegExp("" + textureFormatInUse + "$");
  56348. return rootUrl.replace(exp, "");
  56349. };
  56350. /**
  56351. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56352. * @param data contains the texture data
  56353. * @param texture defines the BabylonJS internal texture
  56354. * @param createPolynomials will be true if polynomials have been requested
  56355. * @param onLoad defines the callback to trigger once the texture is ready
  56356. * @param onError defines the callback to trigger in case of error
  56357. */
  56358. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  56359. if (Array.isArray(data)) {
  56360. return;
  56361. }
  56362. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  56363. texture._invertVScale = !texture.invertY;
  56364. var engine = texture.getEngine();
  56365. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  56366. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  56367. engine._unpackFlipY(true);
  56368. ktx.uploadLevels(texture, texture.generateMipMaps);
  56369. texture.width = ktx.pixelWidth;
  56370. texture.height = ktx.pixelHeight;
  56371. engine._setCubeMapTextureParams(loadMipmap);
  56372. texture.isReady = true;
  56373. };
  56374. /**
  56375. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56376. * @param data contains the texture data
  56377. * @param texture defines the BabylonJS internal texture
  56378. * @param callback defines the method to call once ready to upload
  56379. */
  56380. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  56381. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  56382. texture._invertVScale = !texture.invertY;
  56383. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  56384. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  56385. ktx.uploadLevels(texture, texture.generateMipMaps);
  56386. }, ktx.isInvalid);
  56387. };
  56388. return _KTXTextureLoader;
  56389. }());
  56390. // Register the loader.
  56391. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  56392. /***/ }),
  56393. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  56394. /*!********************************************************!*\
  56395. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  56396. \********************************************************/
  56397. /*! exports provided: _TGATextureLoader */
  56398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56399. "use strict";
  56400. __webpack_require__.r(__webpack_exports__);
  56401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  56402. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  56403. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  56404. /**
  56405. * Implementation of the TGA Texture Loader.
  56406. * @hidden
  56407. */
  56408. var _TGATextureLoader = /** @class */ (function () {
  56409. function _TGATextureLoader() {
  56410. /**
  56411. * Defines wether the loader supports cascade loading the different faces.
  56412. */
  56413. this.supportCascades = false;
  56414. }
  56415. /**
  56416. * This returns if the loader support the current file information.
  56417. * @param extension defines the file extension of the file being loaded
  56418. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56419. * @param fallback defines the fallback internal texture if any
  56420. * @param isBase64 defines whether the texture is encoded as a base64
  56421. * @param isBuffer defines whether the texture data are stored as a buffer
  56422. * @returns true if the loader can load the specified file
  56423. */
  56424. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  56425. return extension.indexOf(".tga") === 0;
  56426. };
  56427. /**
  56428. * Transform the url before loading if required.
  56429. * @param rootUrl the url of the texture
  56430. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56431. * @returns the transformed texture
  56432. */
  56433. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  56434. return rootUrl;
  56435. };
  56436. /**
  56437. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56438. * @param rootUrl the url of the texture
  56439. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56440. * @returns the fallback texture
  56441. */
  56442. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  56443. return null;
  56444. };
  56445. /**
  56446. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56447. * @param data contains the texture data
  56448. * @param texture defines the BabylonJS internal texture
  56449. * @param createPolynomials will be true if polynomials have been requested
  56450. * @param onLoad defines the callback to trigger once the texture is ready
  56451. * @param onError defines the callback to trigger in case of error
  56452. */
  56453. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  56454. throw ".env not supported in Cube.";
  56455. };
  56456. /**
  56457. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56458. * @param data contains the texture data
  56459. * @param texture defines the BabylonJS internal texture
  56460. * @param callback defines the method to call once ready to upload
  56461. */
  56462. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  56463. var uintData = new Uint8Array(data);
  56464. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  56465. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  56466. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  56467. });
  56468. };
  56469. return _TGATextureLoader;
  56470. }());
  56471. // Register the loader.
  56472. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  56473. /***/ }),
  56474. /***/ "./Materials/Textures/MultiviewRenderTarget.ts":
  56475. /*!*****************************************************!*\
  56476. !*** ./Materials/Textures/MultiviewRenderTarget.ts ***!
  56477. \*****************************************************/
  56478. /*! exports provided: MultiviewRenderTarget */
  56479. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56480. "use strict";
  56481. __webpack_require__.r(__webpack_exports__);
  56482. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiviewRenderTarget", function() { return MultiviewRenderTarget; });
  56483. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56484. /* harmony import */ var _Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56485. /* harmony import */ var _Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  56486. /**
  56487. * Renders to multiple views with a single draw call
  56488. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  56489. */
  56490. var MultiviewRenderTarget = /** @class */ (function (_super) {
  56491. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiviewRenderTarget, _super);
  56492. /**
  56493. * Creates a multiview render target
  56494. * @param scene scene used with the render target
  56495. * @param size the size of the render target (used for each view)
  56496. */
  56497. function MultiviewRenderTarget(scene, size) {
  56498. if (size === void 0) { size = 512; }
  56499. var _this = _super.call(this, "multiview rtt", size, scene, false, true, _Textures_internalTexture__WEBPACK_IMPORTED_MODULE_2__["InternalTexture"].DATASOURCE_UNKNOWN, false, undefined, false, false, true, undefined, true) || this;
  56500. var internalTexture = scene.getEngine().createMultiviewRenderTargetTexture(_this.getRenderWidth(), _this.getRenderHeight());
  56501. internalTexture.isMultiview = true;
  56502. _this._texture = internalTexture;
  56503. return _this;
  56504. }
  56505. /**
  56506. * @hidden
  56507. * @param faceIndex the face index, if its a cube texture
  56508. */
  56509. MultiviewRenderTarget.prototype._bindFrameBuffer = function (faceIndex) {
  56510. if (faceIndex === void 0) { faceIndex = 0; }
  56511. if (!this._texture) {
  56512. return;
  56513. }
  56514. this.getScene().getEngine().bindMultiviewFramebuffer(this._texture);
  56515. };
  56516. /**
  56517. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  56518. * @returns the view count
  56519. */
  56520. MultiviewRenderTarget.prototype.getViewCount = function () {
  56521. return 2;
  56522. };
  56523. return MultiviewRenderTarget;
  56524. }(_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__["RenderTargetTexture"]));
  56525. /***/ }),
  56526. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  56527. /*!*******************************************************************!*\
  56528. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  56529. \*******************************************************************/
  56530. /*! exports provided: CustomProceduralTexture */
  56531. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56532. "use strict";
  56533. __webpack_require__.r(__webpack_exports__);
  56534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  56535. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56536. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  56537. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  56538. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56539. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  56540. /* harmony import */ var _Misc_webRequest__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Misc/webRequest */ "./Misc/webRequest.ts");
  56541. /**
  56542. * 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.
  56543. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56544. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56545. */
  56546. var CustomProceduralTexture = /** @class */ (function (_super) {
  56547. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  56548. /**
  56549. * Instantiates a new Custom Procedural Texture.
  56550. * 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.
  56551. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56552. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56553. * @param name Define the name of the texture
  56554. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56555. * @param size Define the size of the texture to create
  56556. * @param scene Define the scene the texture belongs to
  56557. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56558. * @param generateMipMaps Define if the texture should creates mip maps or not
  56559. */
  56560. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  56561. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  56562. _this._animate = true;
  56563. _this._time = 0;
  56564. _this._texturePath = texturePath;
  56565. //Try to load json
  56566. _this._loadJson(texturePath);
  56567. _this.refreshRate = 1;
  56568. return _this;
  56569. }
  56570. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  56571. var _this = this;
  56572. var noConfigFile = function () {
  56573. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  56574. try {
  56575. _this.setFragment(_this._texturePath);
  56576. }
  56577. catch (ex) {
  56578. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  56579. }
  56580. };
  56581. var configFileUrl = jsonUrl + "/config.json";
  56582. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_5__["WebRequest"]();
  56583. xhr.open("GET", configFileUrl);
  56584. xhr.addEventListener("load", function () {
  56585. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  56586. try {
  56587. _this._config = JSON.parse(xhr.response);
  56588. _this.updateShaderUniforms();
  56589. _this.updateTextures();
  56590. _this.setFragment(_this._texturePath + "/custom");
  56591. _this._animate = _this._config.animate;
  56592. _this.refreshRate = _this._config.refreshrate;
  56593. }
  56594. catch (ex) {
  56595. noConfigFile();
  56596. }
  56597. }
  56598. else {
  56599. noConfigFile();
  56600. }
  56601. }, false);
  56602. xhr.addEventListener("error", function () {
  56603. noConfigFile();
  56604. }, false);
  56605. try {
  56606. xhr.send();
  56607. }
  56608. catch (ex) {
  56609. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  56610. }
  56611. };
  56612. /**
  56613. * Is the texture ready to be used ? (rendered at least once)
  56614. * @returns true if ready, otherwise, false.
  56615. */
  56616. CustomProceduralTexture.prototype.isReady = function () {
  56617. if (!_super.prototype.isReady.call(this)) {
  56618. return false;
  56619. }
  56620. for (var name in this._textures) {
  56621. var texture = this._textures[name];
  56622. if (!texture.isReady()) {
  56623. return false;
  56624. }
  56625. }
  56626. return true;
  56627. };
  56628. /**
  56629. * Render the texture to its associated render target.
  56630. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56631. */
  56632. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  56633. var scene = this.getScene();
  56634. if (this._animate && scene) {
  56635. this._time += scene.getAnimationRatio() * 0.03;
  56636. this.updateShaderUniforms();
  56637. }
  56638. _super.prototype.render.call(this, useCameraPostProcess);
  56639. };
  56640. /**
  56641. * Update the list of dependant textures samplers in the shader.
  56642. */
  56643. CustomProceduralTexture.prototype.updateTextures = function () {
  56644. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  56645. 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()));
  56646. }
  56647. };
  56648. /**
  56649. * Update the uniform values of the procedural texture in the shader.
  56650. */
  56651. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  56652. if (this._config) {
  56653. for (var j = 0; j < this._config.uniforms.length; j++) {
  56654. var uniform = this._config.uniforms[j];
  56655. switch (uniform.type) {
  56656. case "float":
  56657. this.setFloat(uniform.name, uniform.value);
  56658. break;
  56659. case "color3":
  56660. this.setColor3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](uniform.r, uniform.g, uniform.b));
  56661. break;
  56662. case "color4":
  56663. this.setColor4(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  56664. break;
  56665. case "vector2":
  56666. this.setVector2(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](uniform.x, uniform.y));
  56667. break;
  56668. case "vector3":
  56669. this.setVector3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](uniform.x, uniform.y, uniform.z));
  56670. break;
  56671. }
  56672. }
  56673. }
  56674. this.setFloat("time", this._time);
  56675. };
  56676. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  56677. /**
  56678. * Define if the texture animates or not.
  56679. */
  56680. get: function () {
  56681. return this._animate;
  56682. },
  56683. set: function (value) {
  56684. this._animate = value;
  56685. },
  56686. enumerable: true,
  56687. configurable: true
  56688. });
  56689. return CustomProceduralTexture;
  56690. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_4__["ProceduralTexture"]));
  56691. /***/ }),
  56692. /***/ "./Materials/Textures/Procedurals/index.ts":
  56693. /*!*************************************************!*\
  56694. !*** ./Materials/Textures/Procedurals/index.ts ***!
  56695. \*************************************************/
  56696. /*! exports provided: ProceduralTexture, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  56697. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56698. "use strict";
  56699. __webpack_require__.r(__webpack_exports__);
  56700. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  56701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  56702. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  56703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  56704. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  56705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  56706. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  56707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  56708. /***/ }),
  56709. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  56710. /*!******************************************************************!*\
  56711. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  56712. \******************************************************************/
  56713. /*! exports provided: NoiseProceduralTexture */
  56714. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56715. "use strict";
  56716. __webpack_require__.r(__webpack_exports__);
  56717. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  56718. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56719. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  56720. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  56721. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  56722. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  56723. /**
  56724. * Class used to generate noise procedural textures
  56725. */
  56726. var NoiseProceduralTexture = /** @class */ (function (_super) {
  56727. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  56728. /**
  56729. * Creates a new NoiseProceduralTexture
  56730. * @param name defines the name fo the texture
  56731. * @param size defines the size of the texture (default is 256)
  56732. * @param scene defines the hosting scene
  56733. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56734. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56735. */
  56736. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  56737. if (size === void 0) { size = 256; }
  56738. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  56739. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  56740. _this._time = 0;
  56741. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56742. _this.brightness = 0.2;
  56743. /** Defines the number of octaves to process */
  56744. _this.octaves = 3;
  56745. /** Defines the level of persistence (0.8 by default) */
  56746. _this.persistence = 0.8;
  56747. /** Gets or sets animation speed factor (default is 1) */
  56748. _this.animationSpeedFactor = 1;
  56749. _this.autoClear = false;
  56750. _this._updateShaderUniforms();
  56751. return _this;
  56752. }
  56753. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  56754. var scene = this.getScene();
  56755. if (!scene) {
  56756. return;
  56757. }
  56758. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  56759. this.setFloat("brightness", this.brightness);
  56760. this.setFloat("persistence", this.persistence);
  56761. this.setFloat("timeScale", this._time);
  56762. };
  56763. NoiseProceduralTexture.prototype._getDefines = function () {
  56764. return "#define OCTAVES " + (this.octaves | 0);
  56765. };
  56766. /** Generate the current state of the procedural texture */
  56767. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  56768. this._updateShaderUniforms();
  56769. _super.prototype.render.call(this, useCameraPostProcess);
  56770. };
  56771. /**
  56772. * Serializes this noise procedural texture
  56773. * @returns a serialized noise procedural texture object
  56774. */
  56775. NoiseProceduralTexture.prototype.serialize = function () {
  56776. var serializationObject = {};
  56777. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  56778. serializationObject.brightness = this.brightness;
  56779. serializationObject.octaves = this.octaves;
  56780. serializationObject.persistence = this.persistence;
  56781. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  56782. serializationObject.size = this.getSize().width;
  56783. serializationObject.generateMipMaps = this._generateMipMaps;
  56784. return serializationObject;
  56785. };
  56786. /**
  56787. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56788. * @param parsedTexture defines parsed texture data
  56789. * @param scene defines the current scene
  56790. * @param rootUrl defines the root URL containing noise procedural texture information
  56791. * @returns a parsed NoiseProceduralTexture
  56792. */
  56793. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  56794. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  56795. texture.brightness = parsedTexture.brightness;
  56796. texture.octaves = parsedTexture.octaves;
  56797. texture.persistence = parsedTexture.persistence;
  56798. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  56799. return texture;
  56800. };
  56801. return NoiseProceduralTexture;
  56802. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  56803. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  56804. /***/ }),
  56805. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  56806. /*!*************************************************************!*\
  56807. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  56808. \*************************************************************/
  56809. /*! exports provided: ProceduralTexture */
  56810. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56811. "use strict";
  56812. __webpack_require__.r(__webpack_exports__);
  56813. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  56814. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56815. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  56816. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  56817. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  56818. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  56819. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  56820. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56821. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56822. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  56823. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  56824. /**
  56825. * 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.
  56826. * This is the base class of any Procedural texture and contains most of the shareable code.
  56827. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  56828. */
  56829. var ProceduralTexture = /** @class */ (function (_super) {
  56830. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  56831. /**
  56832. * Instantiates a new procedural texture.
  56833. * 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.
  56834. * This is the base class of any Procedural texture and contains most of the shareable code.
  56835. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  56836. * @param name Define the name of the texture
  56837. * @param size Define the size of the texture to create
  56838. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  56839. * @param scene Define the scene the texture belongs to
  56840. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56841. * @param generateMipMaps Define if the texture should creates mip maps or not
  56842. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  56843. */
  56844. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  56845. if (fallbackTexture === void 0) { fallbackTexture = null; }
  56846. if (generateMipMaps === void 0) { generateMipMaps = true; }
  56847. if (isCube === void 0) { isCube = false; }
  56848. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  56849. _this.isCube = isCube;
  56850. /**
  56851. * Define if the texture is enabled or not (disabled texture will not render)
  56852. */
  56853. _this.isEnabled = true;
  56854. /**
  56855. * Define if the texture must be cleared before rendering (default is true)
  56856. */
  56857. _this.autoClear = true;
  56858. /**
  56859. * Event raised when the texture is generated
  56860. */
  56861. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  56862. /** @hidden */
  56863. _this._textures = {};
  56864. _this._currentRefreshId = -1;
  56865. _this._refreshRate = 1;
  56866. _this._vertexBuffers = {};
  56867. _this._uniforms = new Array();
  56868. _this._samplers = new Array();
  56869. _this._floats = {};
  56870. _this._ints = {};
  56871. _this._floatsArrays = {};
  56872. _this._colors3 = {};
  56873. _this._colors4 = {};
  56874. _this._vectors2 = {};
  56875. _this._vectors3 = {};
  56876. _this._matrices = {};
  56877. _this._fallbackTextureUsed = false;
  56878. _this._cachedDefines = "";
  56879. _this._contentUpdateId = -1;
  56880. scene = _this.getScene();
  56881. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  56882. if (!component) {
  56883. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  56884. scene._addComponent(component);
  56885. }
  56886. scene.proceduralTextures.push(_this);
  56887. _this._engine = scene.getEngine();
  56888. _this.name = name;
  56889. _this.isRenderTarget = true;
  56890. _this._size = size;
  56891. _this._generateMipMaps = generateMipMaps;
  56892. _this.setFragment(fragment);
  56893. _this._fallbackTexture = fallbackTexture;
  56894. if (isCube) {
  56895. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  56896. _this.setFloat("face", 0);
  56897. }
  56898. else {
  56899. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  56900. }
  56901. // VBO
  56902. var vertices = [];
  56903. vertices.push(1, 1);
  56904. vertices.push(-1, 1);
  56905. vertices.push(-1, -1);
  56906. vertices.push(1, -1);
  56907. _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);
  56908. _this._createIndexBuffer();
  56909. return _this;
  56910. }
  56911. /**
  56912. * The effect that is created when initializing the post process.
  56913. * @returns The created effect corrisponding the the postprocess.
  56914. */
  56915. ProceduralTexture.prototype.getEffect = function () {
  56916. return this._effect;
  56917. };
  56918. /**
  56919. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  56920. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  56921. */
  56922. ProceduralTexture.prototype.getContent = function () {
  56923. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  56924. return this._contentData;
  56925. }
  56926. this._contentData = this.readPixels(0, 0, this._contentData);
  56927. this._contentUpdateId = this._currentRefreshId;
  56928. return this._contentData;
  56929. };
  56930. ProceduralTexture.prototype._createIndexBuffer = function () {
  56931. var engine = this._engine;
  56932. // Indices
  56933. var indices = [];
  56934. indices.push(0);
  56935. indices.push(1);
  56936. indices.push(2);
  56937. indices.push(0);
  56938. indices.push(2);
  56939. indices.push(3);
  56940. this._indexBuffer = engine.createIndexBuffer(indices);
  56941. };
  56942. /** @hidden */
  56943. ProceduralTexture.prototype._rebuild = function () {
  56944. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  56945. if (vb) {
  56946. vb._rebuild();
  56947. }
  56948. this._createIndexBuffer();
  56949. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  56950. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  56951. }
  56952. };
  56953. /**
  56954. * Resets the texture in order to recreate its associated resources.
  56955. * This can be called in case of context loss
  56956. */
  56957. ProceduralTexture.prototype.reset = function () {
  56958. if (this._effect === undefined) {
  56959. return;
  56960. }
  56961. var engine = this._engine;
  56962. engine._releaseEffect(this._effect);
  56963. };
  56964. ProceduralTexture.prototype._getDefines = function () {
  56965. return "";
  56966. };
  56967. /**
  56968. * Is the texture ready to be used ? (rendered at least once)
  56969. * @returns true if ready, otherwise, false.
  56970. */
  56971. ProceduralTexture.prototype.isReady = function () {
  56972. var _this = this;
  56973. var engine = this._engine;
  56974. var shaders;
  56975. if (!this._fragment) {
  56976. return false;
  56977. }
  56978. if (this._fallbackTextureUsed) {
  56979. return true;
  56980. }
  56981. var defines = this._getDefines();
  56982. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  56983. return true;
  56984. }
  56985. if (this._fragment.fragmentElement !== undefined) {
  56986. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  56987. }
  56988. else {
  56989. shaders = { vertex: "procedural", fragment: this._fragment };
  56990. }
  56991. this._cachedDefines = defines;
  56992. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  56993. _this.releaseInternalTexture();
  56994. if (_this._fallbackTexture) {
  56995. _this._texture = _this._fallbackTexture._texture;
  56996. if (_this._texture) {
  56997. _this._texture.incrementReferences();
  56998. }
  56999. }
  57000. _this._fallbackTextureUsed = true;
  57001. });
  57002. return this._effect.isReady();
  57003. };
  57004. /**
  57005. * Resets the refresh counter of the texture and start bak from scratch.
  57006. * Could be useful to regenerate the texture if it is setup to render only once.
  57007. */
  57008. ProceduralTexture.prototype.resetRefreshCounter = function () {
  57009. this._currentRefreshId = -1;
  57010. };
  57011. /**
  57012. * Set the fragment shader to use in order to render the texture.
  57013. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  57014. */
  57015. ProceduralTexture.prototype.setFragment = function (fragment) {
  57016. this._fragment = fragment;
  57017. };
  57018. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  57019. /**
  57020. * Define the refresh rate of the texture or the rendering frequency.
  57021. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  57022. */
  57023. get: function () {
  57024. return this._refreshRate;
  57025. },
  57026. set: function (value) {
  57027. this._refreshRate = value;
  57028. this.resetRefreshCounter();
  57029. },
  57030. enumerable: true,
  57031. configurable: true
  57032. });
  57033. /** @hidden */
  57034. ProceduralTexture.prototype._shouldRender = function () {
  57035. if (!this.isEnabled || !this.isReady() || !this._texture) {
  57036. if (this._texture) {
  57037. this._texture.isReady = false;
  57038. }
  57039. return false;
  57040. }
  57041. if (this._fallbackTextureUsed) {
  57042. return false;
  57043. }
  57044. if (this._currentRefreshId === -1) { // At least render once
  57045. this._currentRefreshId = 1;
  57046. return true;
  57047. }
  57048. if (this.refreshRate === this._currentRefreshId) {
  57049. this._currentRefreshId = 1;
  57050. return true;
  57051. }
  57052. this._currentRefreshId++;
  57053. return false;
  57054. };
  57055. /**
  57056. * Get the size the texture is rendering at.
  57057. * @returns the size (texture is always squared)
  57058. */
  57059. ProceduralTexture.prototype.getRenderSize = function () {
  57060. return this._size;
  57061. };
  57062. /**
  57063. * Resize the texture to new value.
  57064. * @param size Define the new size the texture should have
  57065. * @param generateMipMaps Define whether the new texture should create mip maps
  57066. */
  57067. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  57068. if (this._fallbackTextureUsed) {
  57069. return;
  57070. }
  57071. this.releaseInternalTexture();
  57072. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  57073. // Update properties
  57074. this._size = size;
  57075. this._generateMipMaps = generateMipMaps;
  57076. };
  57077. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  57078. if (this._uniforms.indexOf(uniformName) === -1) {
  57079. this._uniforms.push(uniformName);
  57080. }
  57081. };
  57082. /**
  57083. * Set a texture in the shader program used to render.
  57084. * @param name Define the name of the uniform samplers as defined in the shader
  57085. * @param texture Define the texture to bind to this sampler
  57086. * @return the texture itself allowing "fluent" like uniform updates
  57087. */
  57088. ProceduralTexture.prototype.setTexture = function (name, texture) {
  57089. if (this._samplers.indexOf(name) === -1) {
  57090. this._samplers.push(name);
  57091. }
  57092. this._textures[name] = texture;
  57093. return this;
  57094. };
  57095. /**
  57096. * Set a float in the shader.
  57097. * @param name Define the name of the uniform as defined in the shader
  57098. * @param value Define the value to give to the uniform
  57099. * @return the texture itself allowing "fluent" like uniform updates
  57100. */
  57101. ProceduralTexture.prototype.setFloat = function (name, value) {
  57102. this._checkUniform(name);
  57103. this._floats[name] = value;
  57104. return this;
  57105. };
  57106. /**
  57107. * Set a int in the shader.
  57108. * @param name Define the name of the uniform as defined in the shader
  57109. * @param value Define the value to give to the uniform
  57110. * @return the texture itself allowing "fluent" like uniform updates
  57111. */
  57112. ProceduralTexture.prototype.setInt = function (name, value) {
  57113. this._checkUniform(name);
  57114. this._ints[name] = value;
  57115. return this;
  57116. };
  57117. /**
  57118. * Set an array of floats in the shader.
  57119. * @param name Define the name of the uniform as defined in the shader
  57120. * @param value Define the value to give to the uniform
  57121. * @return the texture itself allowing "fluent" like uniform updates
  57122. */
  57123. ProceduralTexture.prototype.setFloats = function (name, value) {
  57124. this._checkUniform(name);
  57125. this._floatsArrays[name] = value;
  57126. return this;
  57127. };
  57128. /**
  57129. * Set a vec3 in the shader from a Color3.
  57130. * @param name Define the name of the uniform as defined in the shader
  57131. * @param value Define the value to give to the uniform
  57132. * @return the texture itself allowing "fluent" like uniform updates
  57133. */
  57134. ProceduralTexture.prototype.setColor3 = function (name, value) {
  57135. this._checkUniform(name);
  57136. this._colors3[name] = value;
  57137. return this;
  57138. };
  57139. /**
  57140. * Set a vec4 in the shader from a Color4.
  57141. * @param name Define the name of the uniform as defined in the shader
  57142. * @param value Define the value to give to the uniform
  57143. * @return the texture itself allowing "fluent" like uniform updates
  57144. */
  57145. ProceduralTexture.prototype.setColor4 = function (name, value) {
  57146. this._checkUniform(name);
  57147. this._colors4[name] = value;
  57148. return this;
  57149. };
  57150. /**
  57151. * Set a vec2 in the shader from a Vector2.
  57152. * @param name Define the name of the uniform as defined in the shader
  57153. * @param value Define the value to give to the uniform
  57154. * @return the texture itself allowing "fluent" like uniform updates
  57155. */
  57156. ProceduralTexture.prototype.setVector2 = function (name, value) {
  57157. this._checkUniform(name);
  57158. this._vectors2[name] = value;
  57159. return this;
  57160. };
  57161. /**
  57162. * Set a vec3 in the shader from a Vector3.
  57163. * @param name Define the name of the uniform as defined in the shader
  57164. * @param value Define the value to give to the uniform
  57165. * @return the texture itself allowing "fluent" like uniform updates
  57166. */
  57167. ProceduralTexture.prototype.setVector3 = function (name, value) {
  57168. this._checkUniform(name);
  57169. this._vectors3[name] = value;
  57170. return this;
  57171. };
  57172. /**
  57173. * Set a mat4 in the shader from a MAtrix.
  57174. * @param name Define the name of the uniform as defined in the shader
  57175. * @param value Define the value to give to the uniform
  57176. * @return the texture itself allowing "fluent" like uniform updates
  57177. */
  57178. ProceduralTexture.prototype.setMatrix = function (name, value) {
  57179. this._checkUniform(name);
  57180. this._matrices[name] = value;
  57181. return this;
  57182. };
  57183. /**
  57184. * Render the texture to its associated render target.
  57185. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57186. */
  57187. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  57188. var scene = this.getScene();
  57189. if (!scene) {
  57190. return;
  57191. }
  57192. var engine = this._engine;
  57193. // Render
  57194. engine.enableEffect(this._effect);
  57195. engine.setState(false);
  57196. // Texture
  57197. for (var name in this._textures) {
  57198. this._effect.setTexture(name, this._textures[name]);
  57199. }
  57200. // Float
  57201. for (name in this._ints) {
  57202. this._effect.setInt(name, this._ints[name]);
  57203. }
  57204. // Float
  57205. for (name in this._floats) {
  57206. this._effect.setFloat(name, this._floats[name]);
  57207. }
  57208. // Floats
  57209. for (name in this._floatsArrays) {
  57210. this._effect.setArray(name, this._floatsArrays[name]);
  57211. }
  57212. // Color3
  57213. for (name in this._colors3) {
  57214. this._effect.setColor3(name, this._colors3[name]);
  57215. }
  57216. // Color4
  57217. for (name in this._colors4) {
  57218. var color = this._colors4[name];
  57219. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  57220. }
  57221. // Vector2
  57222. for (name in this._vectors2) {
  57223. this._effect.setVector2(name, this._vectors2[name]);
  57224. }
  57225. // Vector3
  57226. for (name in this._vectors3) {
  57227. this._effect.setVector3(name, this._vectors3[name]);
  57228. }
  57229. // Matrix
  57230. for (name in this._matrices) {
  57231. this._effect.setMatrix(name, this._matrices[name]);
  57232. }
  57233. if (!this._texture) {
  57234. return;
  57235. }
  57236. if (this.isCube) {
  57237. for (var face = 0; face < 6; face++) {
  57238. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  57239. // VBOs
  57240. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  57241. this._effect.setFloat("face", face);
  57242. // Clear
  57243. if (this.autoClear) {
  57244. engine.clear(scene.clearColor, true, false, false);
  57245. }
  57246. // Draw order
  57247. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  57248. // Mipmaps
  57249. if (face === 5) {
  57250. engine.generateMipMapsForCubemap(this._texture);
  57251. }
  57252. }
  57253. }
  57254. else {
  57255. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  57256. // VBOs
  57257. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  57258. // Clear
  57259. if (this.autoClear) {
  57260. engine.clear(scene.clearColor, true, false, false);
  57261. }
  57262. // Draw order
  57263. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  57264. }
  57265. // Unbind
  57266. engine.unBindFramebuffer(this._texture, this.isCube);
  57267. if (this.onGenerated) {
  57268. this.onGenerated();
  57269. }
  57270. this.onGeneratedObservable.notifyObservers(this);
  57271. };
  57272. /**
  57273. * Clone the texture.
  57274. * @returns the cloned texture
  57275. */
  57276. ProceduralTexture.prototype.clone = function () {
  57277. var textureSize = this.getSize();
  57278. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  57279. // Base texture
  57280. newTexture.hasAlpha = this.hasAlpha;
  57281. newTexture.level = this.level;
  57282. // RenderTarget Texture
  57283. newTexture.coordinatesMode = this.coordinatesMode;
  57284. return newTexture;
  57285. };
  57286. /**
  57287. * Dispose the texture and release its asoociated resources.
  57288. */
  57289. ProceduralTexture.prototype.dispose = function () {
  57290. var scene = this.getScene();
  57291. if (!scene) {
  57292. return;
  57293. }
  57294. var index = scene.proceduralTextures.indexOf(this);
  57295. if (index >= 0) {
  57296. scene.proceduralTextures.splice(index, 1);
  57297. }
  57298. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  57299. if (vertexBuffer) {
  57300. vertexBuffer.dispose();
  57301. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  57302. }
  57303. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  57304. this._indexBuffer = null;
  57305. }
  57306. _super.prototype.dispose.call(this);
  57307. };
  57308. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57309. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57310. ], ProceduralTexture.prototype, "isEnabled", void 0);
  57311. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57312. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57313. ], ProceduralTexture.prototype, "autoClear", void 0);
  57314. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57315. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57316. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  57317. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57319. ], ProceduralTexture.prototype, "_size", void 0);
  57320. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  57321. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  57322. ], ProceduralTexture.prototype, "refreshRate", null);
  57323. return ProceduralTexture;
  57324. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  57325. /***/ }),
  57326. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  57327. /*!***************************************************************************!*\
  57328. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  57329. \***************************************************************************/
  57330. /*! exports provided: ProceduralTextureSceneComponent */
  57331. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57332. "use strict";
  57333. __webpack_require__.r(__webpack_exports__);
  57334. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  57335. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  57336. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  57337. /**
  57338. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  57339. * in a given scene.
  57340. */
  57341. var ProceduralTextureSceneComponent = /** @class */ (function () {
  57342. /**
  57343. * Creates a new instance of the component for the given scene
  57344. * @param scene Defines the scene to register the component in
  57345. */
  57346. function ProceduralTextureSceneComponent(scene) {
  57347. /**
  57348. * The component name helpfull to identify the component in the list of scene components.
  57349. */
  57350. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  57351. this.scene = scene;
  57352. this.scene.proceduralTextures = new Array();
  57353. scene.layers = new Array();
  57354. }
  57355. /**
  57356. * Registers the component in a given scene
  57357. */
  57358. ProceduralTextureSceneComponent.prototype.register = function () {
  57359. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  57360. };
  57361. /**
  57362. * Rebuilds the elements related to this component in case of
  57363. * context lost for instance.
  57364. */
  57365. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  57366. // Nothing to do here.
  57367. };
  57368. /**
  57369. * Disposes the component and the associated ressources.
  57370. */
  57371. ProceduralTextureSceneComponent.prototype.dispose = function () {
  57372. // Nothing to do here.
  57373. };
  57374. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  57375. if (this.scene.proceduralTexturesEnabled) {
  57376. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  57377. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  57378. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  57379. if (proceduralTexture._shouldRender()) {
  57380. proceduralTexture.render();
  57381. }
  57382. }
  57383. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  57384. }
  57385. };
  57386. return ProceduralTextureSceneComponent;
  57387. }());
  57388. /***/ }),
  57389. /***/ "./Materials/Textures/baseTexture.ts":
  57390. /*!*******************************************!*\
  57391. !*** ./Materials/Textures/baseTexture.ts ***!
  57392. \*******************************************/
  57393. /*! exports provided: BaseTexture */
  57394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57395. "use strict";
  57396. __webpack_require__.r(__webpack_exports__);
  57397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  57398. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57399. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  57400. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  57401. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  57402. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  57403. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57404. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  57405. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57406. /**
  57407. * Base class of all the textures in babylon.
  57408. * It groups all the common properties the materials, post process, lights... might need
  57409. * in order to make a correct use of the texture.
  57410. */
  57411. var BaseTexture = /** @class */ (function () {
  57412. /**
  57413. * Instantiates a new BaseTexture.
  57414. * Base class of all the textures in babylon.
  57415. * It groups all the common properties the materials, post process, lights... might need
  57416. * in order to make a correct use of the texture.
  57417. * @param scene Define the scene the texture blongs to
  57418. */
  57419. function BaseTexture(scene) {
  57420. /**
  57421. * Gets or sets an object used to store user defined information.
  57422. */
  57423. this.metadata = null;
  57424. /**
  57425. * For internal use only. Please do not use.
  57426. */
  57427. this.reservedDataStore = null;
  57428. this._hasAlpha = false;
  57429. /**
  57430. * Defines if the alpha value should be determined via the rgb values.
  57431. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  57432. */
  57433. this.getAlphaFromRGB = false;
  57434. /**
  57435. * Intensity or strength of the texture.
  57436. * It is commonly used by materials to fine tune the intensity of the texture
  57437. */
  57438. this.level = 1;
  57439. /**
  57440. * Define the UV chanel to use starting from 0 and defaulting to 0.
  57441. * This is part of the texture as textures usually maps to one uv set.
  57442. */
  57443. this.coordinatesIndex = 0;
  57444. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  57445. /**
  57446. * | Value | Type | Description |
  57447. * | ----- | ------------------ | ----------- |
  57448. * | 0 | CLAMP_ADDRESSMODE | |
  57449. * | 1 | WRAP_ADDRESSMODE | |
  57450. * | 2 | MIRROR_ADDRESSMODE | |
  57451. */
  57452. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  57453. /**
  57454. * | Value | Type | Description |
  57455. * | ----- | ------------------ | ----------- |
  57456. * | 0 | CLAMP_ADDRESSMODE | |
  57457. * | 1 | WRAP_ADDRESSMODE | |
  57458. * | 2 | MIRROR_ADDRESSMODE | |
  57459. */
  57460. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  57461. /**
  57462. * | Value | Type | Description |
  57463. * | ----- | ------------------ | ----------- |
  57464. * | 0 | CLAMP_ADDRESSMODE | |
  57465. * | 1 | WRAP_ADDRESSMODE | |
  57466. * | 2 | MIRROR_ADDRESSMODE | |
  57467. */
  57468. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  57469. /**
  57470. * With compliant hardware and browser (supporting anisotropic filtering)
  57471. * this defines the level of anisotropic filtering in the texture.
  57472. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  57473. */
  57474. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  57475. /**
  57476. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  57477. * HDR texture are usually stored in linear space.
  57478. * This only impacts the PBR and Background materials
  57479. */
  57480. this.gammaSpace = true;
  57481. /**
  57482. * Is Z inverted in the texture (useful in a cube texture).
  57483. */
  57484. this.invertZ = false;
  57485. /**
  57486. * @hidden
  57487. */
  57488. this.lodLevelInAlpha = false;
  57489. /**
  57490. * Define if the texture is a render target.
  57491. */
  57492. this.isRenderTarget = false;
  57493. /**
  57494. * Define the list of animation attached to the texture.
  57495. */
  57496. this.animations = new Array();
  57497. /**
  57498. * An event triggered when the texture is disposed.
  57499. */
  57500. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  57501. /**
  57502. * Define the current state of the loading sequence when in delayed load mode.
  57503. */
  57504. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  57505. this._cachedSize = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  57506. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  57507. if (this._scene) {
  57508. this.uniqueId = this._scene.getUniqueId();
  57509. this._scene.addTexture(this);
  57510. }
  57511. this._uid = null;
  57512. }
  57513. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  57514. get: function () {
  57515. return this._hasAlpha;
  57516. },
  57517. /**
  57518. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  57519. */
  57520. set: function (value) {
  57521. if (this._hasAlpha === value) {
  57522. return;
  57523. }
  57524. this._hasAlpha = value;
  57525. if (this._scene) {
  57526. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag);
  57527. }
  57528. },
  57529. enumerable: true,
  57530. configurable: true
  57531. });
  57532. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  57533. get: function () {
  57534. return this._coordinatesMode;
  57535. },
  57536. /**
  57537. * How a texture is mapped.
  57538. *
  57539. * | Value | Type | Description |
  57540. * | ----- | ----------------------------------- | ----------- |
  57541. * | 0 | EXPLICIT_MODE | |
  57542. * | 1 | SPHERICAL_MODE | |
  57543. * | 2 | PLANAR_MODE | |
  57544. * | 3 | CUBIC_MODE | |
  57545. * | 4 | PROJECTION_MODE | |
  57546. * | 5 | SKYBOX_MODE | |
  57547. * | 6 | INVCUBIC_MODE | |
  57548. * | 7 | EQUIRECTANGULAR_MODE | |
  57549. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  57550. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  57551. */
  57552. set: function (value) {
  57553. if (this._coordinatesMode === value) {
  57554. return;
  57555. }
  57556. this._coordinatesMode = value;
  57557. if (this._scene) {
  57558. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  57559. }
  57560. },
  57561. enumerable: true,
  57562. configurable: true
  57563. });
  57564. Object.defineProperty(BaseTexture.prototype, "isCube", {
  57565. /**
  57566. * Define if the texture is a cube texture or if false a 2d texture.
  57567. */
  57568. get: function () {
  57569. if (!this._texture) {
  57570. return false;
  57571. }
  57572. return this._texture.isCube;
  57573. },
  57574. set: function (value) {
  57575. if (!this._texture) {
  57576. return;
  57577. }
  57578. this._texture.isCube = value;
  57579. },
  57580. enumerable: true,
  57581. configurable: true
  57582. });
  57583. Object.defineProperty(BaseTexture.prototype, "is3D", {
  57584. /**
  57585. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  57586. */
  57587. get: function () {
  57588. if (!this._texture) {
  57589. return false;
  57590. }
  57591. return this._texture.is3D;
  57592. },
  57593. set: function (value) {
  57594. if (!this._texture) {
  57595. return;
  57596. }
  57597. this._texture.is3D = value;
  57598. },
  57599. enumerable: true,
  57600. configurable: true
  57601. });
  57602. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  57603. /**
  57604. * Gets whether or not the texture contains RGBD data.
  57605. */
  57606. get: function () {
  57607. return this._texture != null && this._texture._isRGBD;
  57608. },
  57609. enumerable: true,
  57610. configurable: true
  57611. });
  57612. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  57613. /**
  57614. * Are mip maps generated for this texture or not.
  57615. */
  57616. get: function () {
  57617. return false;
  57618. },
  57619. enumerable: true,
  57620. configurable: true
  57621. });
  57622. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  57623. /**
  57624. * With prefiltered texture, defined the offset used during the prefiltering steps.
  57625. */
  57626. get: function () {
  57627. if (this._texture) {
  57628. return this._texture._lodGenerationOffset;
  57629. }
  57630. return 0.0;
  57631. },
  57632. set: function (value) {
  57633. if (this._texture) {
  57634. this._texture._lodGenerationOffset = value;
  57635. }
  57636. },
  57637. enumerable: true,
  57638. configurable: true
  57639. });
  57640. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  57641. /**
  57642. * With prefiltered texture, defined the scale used during the prefiltering steps.
  57643. */
  57644. get: function () {
  57645. if (this._texture) {
  57646. return this._texture._lodGenerationScale;
  57647. }
  57648. return 0.0;
  57649. },
  57650. set: function (value) {
  57651. if (this._texture) {
  57652. this._texture._lodGenerationScale = value;
  57653. }
  57654. },
  57655. enumerable: true,
  57656. configurable: true
  57657. });
  57658. Object.defineProperty(BaseTexture.prototype, "uid", {
  57659. /**
  57660. * Define the unique id of the texture in the scene.
  57661. */
  57662. get: function () {
  57663. if (!this._uid) {
  57664. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].RandomId();
  57665. }
  57666. return this._uid;
  57667. },
  57668. enumerable: true,
  57669. configurable: true
  57670. });
  57671. /**
  57672. * Return a string representation of the texture.
  57673. * @returns the texture as a string
  57674. */
  57675. BaseTexture.prototype.toString = function () {
  57676. return this.name;
  57677. };
  57678. /**
  57679. * Get the class name of the texture.
  57680. * @returns "BaseTexture"
  57681. */
  57682. BaseTexture.prototype.getClassName = function () {
  57683. return "BaseTexture";
  57684. };
  57685. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  57686. /**
  57687. * Callback triggered when the texture has been disposed.
  57688. * Kept for back compatibility, you can use the onDisposeObservable instead.
  57689. */
  57690. set: function (callback) {
  57691. if (this._onDisposeObserver) {
  57692. this.onDisposeObservable.remove(this._onDisposeObserver);
  57693. }
  57694. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  57695. },
  57696. enumerable: true,
  57697. configurable: true
  57698. });
  57699. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  57700. /**
  57701. * Define if the texture is preventinga material to render or not.
  57702. * If not and the texture is not ready, the engine will use a default black texture instead.
  57703. */
  57704. get: function () {
  57705. return true;
  57706. },
  57707. enumerable: true,
  57708. configurable: true
  57709. });
  57710. /**
  57711. * Get the scene the texture belongs to.
  57712. * @returns the scene or null if undefined
  57713. */
  57714. BaseTexture.prototype.getScene = function () {
  57715. return this._scene;
  57716. };
  57717. /**
  57718. * Get the texture transform matrix used to offset tile the texture for istance.
  57719. * @returns the transformation matrix
  57720. */
  57721. BaseTexture.prototype.getTextureMatrix = function () {
  57722. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  57723. };
  57724. /**
  57725. * Get the texture reflection matrix used to rotate/transform the reflection.
  57726. * @returns the reflection matrix
  57727. */
  57728. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  57729. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  57730. };
  57731. /**
  57732. * Get the underlying lower level texture from Babylon.
  57733. * @returns the insternal texture
  57734. */
  57735. BaseTexture.prototype.getInternalTexture = function () {
  57736. return this._texture;
  57737. };
  57738. /**
  57739. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  57740. * @returns true if ready or not blocking
  57741. */
  57742. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  57743. return !this.isBlocking || this.isReady();
  57744. };
  57745. /**
  57746. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  57747. * @returns true if fully ready
  57748. */
  57749. BaseTexture.prototype.isReady = function () {
  57750. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  57751. this.delayLoad();
  57752. return false;
  57753. }
  57754. if (this._texture) {
  57755. return this._texture.isReady;
  57756. }
  57757. return false;
  57758. };
  57759. /**
  57760. * Get the size of the texture.
  57761. * @returns the texture size.
  57762. */
  57763. BaseTexture.prototype.getSize = function () {
  57764. if (this._texture) {
  57765. if (this._texture.width) {
  57766. this._cachedSize.width = this._texture.width;
  57767. this._cachedSize.height = this._texture.height;
  57768. return this._cachedSize;
  57769. }
  57770. if (this._texture._size) {
  57771. this._cachedSize.width = this._texture._size;
  57772. this._cachedSize.height = this._texture._size;
  57773. return this._cachedSize;
  57774. }
  57775. }
  57776. return this._cachedSize;
  57777. };
  57778. /**
  57779. * Get the base size of the texture.
  57780. * It can be different from the size if the texture has been resized for POT for instance
  57781. * @returns the base size
  57782. */
  57783. BaseTexture.prototype.getBaseSize = function () {
  57784. if (!this.isReady() || !this._texture) {
  57785. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  57786. }
  57787. if (this._texture._size) {
  57788. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture._size, this._texture._size);
  57789. }
  57790. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  57791. };
  57792. /**
  57793. * Update the sampling mode of the texture.
  57794. * Default is Trilinear mode.
  57795. *
  57796. * | Value | Type | Description |
  57797. * | ----- | ------------------ | ----------- |
  57798. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  57799. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  57800. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  57801. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  57802. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  57803. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  57804. * | 7 | NEAREST_LINEAR | |
  57805. * | 8 | NEAREST_NEAREST | |
  57806. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  57807. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  57808. * | 11 | LINEAR_LINEAR | |
  57809. * | 12 | LINEAR_NEAREST | |
  57810. *
  57811. * > _mag_: magnification filter (close to the viewer)
  57812. * > _min_: minification filter (far from the viewer)
  57813. * > _mip_: filter used between mip map levels
  57814. *@param samplingMode Define the new sampling mode of the texture
  57815. */
  57816. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  57817. if (!this._texture) {
  57818. return;
  57819. }
  57820. var scene = this.getScene();
  57821. if (!scene) {
  57822. return;
  57823. }
  57824. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  57825. };
  57826. /**
  57827. * Scales the texture if is `canRescale()`
  57828. * @param ratio the resize factor we want to use to rescale
  57829. */
  57830. BaseTexture.prototype.scale = function (ratio) {
  57831. };
  57832. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  57833. /**
  57834. * Get if the texture can rescale.
  57835. */
  57836. get: function () {
  57837. return false;
  57838. },
  57839. enumerable: true,
  57840. configurable: true
  57841. });
  57842. /** @hidden */
  57843. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling, invertY) {
  57844. if (!this._scene) {
  57845. return null;
  57846. }
  57847. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  57848. for (var index = 0; index < texturesCache.length; index++) {
  57849. var texturesCacheEntry = texturesCache[index];
  57850. if (invertY === undefined || invertY === texturesCacheEntry.invertY) {
  57851. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  57852. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  57853. texturesCacheEntry.incrementReferences();
  57854. return texturesCacheEntry;
  57855. }
  57856. }
  57857. }
  57858. }
  57859. return null;
  57860. };
  57861. /** @hidden */
  57862. BaseTexture.prototype._rebuild = function () {
  57863. };
  57864. /**
  57865. * Triggers the load sequence in delayed load mode.
  57866. */
  57867. BaseTexture.prototype.delayLoad = function () {
  57868. };
  57869. /**
  57870. * Clones the texture.
  57871. * @returns the cloned texture
  57872. */
  57873. BaseTexture.prototype.clone = function () {
  57874. return null;
  57875. };
  57876. Object.defineProperty(BaseTexture.prototype, "textureType", {
  57877. /**
  57878. * Get the texture underlying type (INT, FLOAT...)
  57879. */
  57880. get: function () {
  57881. if (!this._texture) {
  57882. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  57883. }
  57884. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  57885. },
  57886. enumerable: true,
  57887. configurable: true
  57888. });
  57889. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  57890. /**
  57891. * Get the texture underlying format (RGB, RGBA...)
  57892. */
  57893. get: function () {
  57894. if (!this._texture) {
  57895. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  57896. }
  57897. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  57898. },
  57899. enumerable: true,
  57900. configurable: true
  57901. });
  57902. /**
  57903. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  57904. * This will returns an RGBA array buffer containing either in values (0-255) or
  57905. * float values (0-1) depending of the underlying buffer type.
  57906. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  57907. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  57908. * @param buffer defines a user defined buffer to fill with data (can be null)
  57909. * @returns The Array buffer containing the pixels data.
  57910. */
  57911. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  57912. if (faceIndex === void 0) { faceIndex = 0; }
  57913. if (level === void 0) { level = 0; }
  57914. if (buffer === void 0) { buffer = null; }
  57915. if (!this._texture) {
  57916. return null;
  57917. }
  57918. var size = this.getSize();
  57919. var width = size.width;
  57920. var height = size.height;
  57921. var scene = this.getScene();
  57922. if (!scene) {
  57923. return null;
  57924. }
  57925. var engine = scene.getEngine();
  57926. if (level != 0) {
  57927. width = width / Math.pow(2, level);
  57928. height = height / Math.pow(2, level);
  57929. width = Math.round(width);
  57930. height = Math.round(height);
  57931. }
  57932. if (this._texture.isCube) {
  57933. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  57934. }
  57935. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  57936. };
  57937. /**
  57938. * Release and destroy the underlying lower level texture aka internalTexture.
  57939. */
  57940. BaseTexture.prototype.releaseInternalTexture = function () {
  57941. if (this._texture) {
  57942. this._texture.dispose();
  57943. this._texture = null;
  57944. }
  57945. };
  57946. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  57947. /**
  57948. * Get the polynomial representation of the texture data.
  57949. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  57950. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  57951. */
  57952. get: function () {
  57953. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  57954. return null;
  57955. }
  57956. if (!this._texture._sphericalPolynomial) {
  57957. this._texture._sphericalPolynomial =
  57958. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  57959. }
  57960. return this._texture._sphericalPolynomial;
  57961. },
  57962. set: function (value) {
  57963. if (this._texture) {
  57964. this._texture._sphericalPolynomial = value;
  57965. }
  57966. },
  57967. enumerable: true,
  57968. configurable: true
  57969. });
  57970. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  57971. /** @hidden */
  57972. get: function () {
  57973. if (this._texture) {
  57974. return this._texture._lodTextureHigh;
  57975. }
  57976. return null;
  57977. },
  57978. enumerable: true,
  57979. configurable: true
  57980. });
  57981. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  57982. /** @hidden */
  57983. get: function () {
  57984. if (this._texture) {
  57985. return this._texture._lodTextureMid;
  57986. }
  57987. return null;
  57988. },
  57989. enumerable: true,
  57990. configurable: true
  57991. });
  57992. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  57993. /** @hidden */
  57994. get: function () {
  57995. if (this._texture) {
  57996. return this._texture._lodTextureLow;
  57997. }
  57998. return null;
  57999. },
  58000. enumerable: true,
  58001. configurable: true
  58002. });
  58003. /**
  58004. * Dispose the texture and release its associated resources.
  58005. */
  58006. BaseTexture.prototype.dispose = function () {
  58007. if (!this._scene) {
  58008. return;
  58009. }
  58010. // Animations
  58011. this._scene.stopAnimation(this);
  58012. // Remove from scene
  58013. this._scene._removePendingData(this);
  58014. var index = this._scene.textures.indexOf(this);
  58015. if (index >= 0) {
  58016. this._scene.textures.splice(index, 1);
  58017. }
  58018. this._scene.onTextureRemovedObservable.notifyObservers(this);
  58019. if (this._texture === undefined) {
  58020. return;
  58021. }
  58022. // Release
  58023. this.releaseInternalTexture();
  58024. // Callback
  58025. this.onDisposeObservable.notifyObservers(this);
  58026. this.onDisposeObservable.clear();
  58027. };
  58028. /**
  58029. * Serialize the texture into a JSON representation that can be parsed later on.
  58030. * @returns the JSON representation of the texture
  58031. */
  58032. BaseTexture.prototype.serialize = function () {
  58033. if (!this.name) {
  58034. return null;
  58035. }
  58036. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  58037. // Animations
  58038. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  58039. return serializationObject;
  58040. };
  58041. /**
  58042. * Helper function to be called back once a list of texture contains only ready textures.
  58043. * @param textures Define the list of textures to wait for
  58044. * @param callback Define the callback triggered once the entire list will be ready
  58045. */
  58046. BaseTexture.WhenAllReady = function (textures, callback) {
  58047. var numRemaining = textures.length;
  58048. if (numRemaining === 0) {
  58049. callback();
  58050. return;
  58051. }
  58052. var _loop_1 = function () {
  58053. texture = textures[i];
  58054. if (texture.isReady()) {
  58055. if (--numRemaining === 0) {
  58056. callback();
  58057. }
  58058. }
  58059. else {
  58060. onLoadObservable = texture.onLoadObservable;
  58061. var onLoadCallback_1 = function () {
  58062. onLoadObservable.removeCallback(onLoadCallback_1);
  58063. if (--numRemaining === 0) {
  58064. callback();
  58065. }
  58066. };
  58067. onLoadObservable.add(onLoadCallback_1);
  58068. }
  58069. };
  58070. var texture, onLoadObservable;
  58071. for (var i = 0; i < textures.length; i++) {
  58072. _loop_1();
  58073. }
  58074. };
  58075. /**
  58076. * Default anisotropic filtering level for the application.
  58077. * It is set to 4 as a good tradeoff between perf and quality.
  58078. */
  58079. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  58080. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58081. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58082. ], BaseTexture.prototype, "uniqueId", void 0);
  58083. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58084. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58085. ], BaseTexture.prototype, "name", void 0);
  58086. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58087. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58088. ], BaseTexture.prototype, "metadata", void 0);
  58089. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58090. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  58091. ], BaseTexture.prototype, "_hasAlpha", void 0);
  58092. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58093. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58094. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  58095. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58096. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58097. ], BaseTexture.prototype, "level", void 0);
  58098. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58099. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58100. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  58101. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58102. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  58103. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  58104. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58105. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58106. ], BaseTexture.prototype, "wrapU", void 0);
  58107. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58109. ], BaseTexture.prototype, "wrapV", void 0);
  58110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58112. ], BaseTexture.prototype, "wrapR", void 0);
  58113. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58114. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58115. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  58116. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58117. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58118. ], BaseTexture.prototype, "isCube", null);
  58119. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58121. ], BaseTexture.prototype, "is3D", null);
  58122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58124. ], BaseTexture.prototype, "gammaSpace", void 0);
  58125. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58126. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58127. ], BaseTexture.prototype, "invertZ", void 0);
  58128. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58129. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58130. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  58131. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58133. ], BaseTexture.prototype, "lodGenerationOffset", null);
  58134. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58136. ], BaseTexture.prototype, "lodGenerationScale", null);
  58137. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58138. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  58139. ], BaseTexture.prototype, "isRenderTarget", void 0);
  58140. return BaseTexture;
  58141. }());
  58142. /***/ }),
  58143. /***/ "./Materials/Textures/colorGradingTexture.ts":
  58144. /*!***************************************************!*\
  58145. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  58146. \***************************************************/
  58147. /*! exports provided: ColorGradingTexture */
  58148. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58149. "use strict";
  58150. __webpack_require__.r(__webpack_exports__);
  58151. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  58152. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58153. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58154. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  58155. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58156. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  58157. /**
  58158. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58159. * It can help converting any input color in a desired output one. This can then be used to create effects
  58160. * from sepia, black and white to sixties or futuristic rendering...
  58161. *
  58162. * The only supported format is currently 3dl.
  58163. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58164. */
  58165. var ColorGradingTexture = /** @class */ (function (_super) {
  58166. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  58167. /**
  58168. * Instantiates a ColorGradingTexture from the following parameters.
  58169. *
  58170. * @param url The location of the color gradind data (currently only supporting 3dl)
  58171. * @param scene The scene the texture will be used in
  58172. */
  58173. function ColorGradingTexture(url, scene) {
  58174. var _this = _super.call(this, scene) || this;
  58175. if (!url) {
  58176. return _this;
  58177. }
  58178. _this._engine = scene.getEngine();
  58179. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  58180. _this.name = url;
  58181. _this.url = url;
  58182. _this.hasAlpha = false;
  58183. _this.isCube = false;
  58184. _this.is3D = _this._engine.webGLVersion > 1;
  58185. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  58186. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  58187. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  58188. _this.anisotropicFilteringLevel = 1;
  58189. _this._texture = _this._getFromCache(url, true);
  58190. if (!_this._texture) {
  58191. if (!scene.useDelayedTextureLoading) {
  58192. _this.loadTexture();
  58193. }
  58194. else {
  58195. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58196. }
  58197. }
  58198. return _this;
  58199. }
  58200. /**
  58201. * Returns the texture matrix used in most of the material.
  58202. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58203. */
  58204. ColorGradingTexture.prototype.getTextureMatrix = function () {
  58205. return this._textureMatrix;
  58206. };
  58207. /**
  58208. * Occurs when the file being loaded is a .3dl LUT file.
  58209. */
  58210. ColorGradingTexture.prototype.load3dlTexture = function () {
  58211. var engine = this._engine;
  58212. var texture;
  58213. if (engine.webGLVersion === 1) {
  58214. 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);
  58215. }
  58216. else {
  58217. 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);
  58218. }
  58219. this._texture = texture;
  58220. var callback = function (text) {
  58221. if (typeof text !== "string") {
  58222. return;
  58223. }
  58224. var data = null;
  58225. var tempData = null;
  58226. var line;
  58227. var lines = text.split('\n');
  58228. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  58229. var maxColor = 0;
  58230. for (var i = 0; i < lines.length; i++) {
  58231. line = lines[i];
  58232. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  58233. continue;
  58234. }
  58235. if (line.indexOf('#') === 0) {
  58236. continue;
  58237. }
  58238. var words = line.split(" ");
  58239. if (size === 0) {
  58240. // Number of space + one
  58241. size = words.length;
  58242. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  58243. tempData = new Float32Array(size * size * size * 4);
  58244. continue;
  58245. }
  58246. if (size != 0) {
  58247. var r = Math.max(parseInt(words[0]), 0);
  58248. var g = Math.max(parseInt(words[1]), 0);
  58249. var b = Math.max(parseInt(words[2]), 0);
  58250. maxColor = Math.max(r, maxColor);
  58251. maxColor = Math.max(g, maxColor);
  58252. maxColor = Math.max(b, maxColor);
  58253. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  58254. if (tempData) {
  58255. tempData[pixelStorageIndex + 0] = r;
  58256. tempData[pixelStorageIndex + 1] = g;
  58257. tempData[pixelStorageIndex + 2] = b;
  58258. }
  58259. // Keep for reference in case of back compat problems.
  58260. // pixelIndexSlice++;
  58261. // if (pixelIndexSlice % size == 0) {
  58262. // pixelIndexH++;
  58263. // pixelIndexSlice = 0;
  58264. // if (pixelIndexH % size == 0) {
  58265. // pixelIndexW++;
  58266. // pixelIndexH = 0;
  58267. // }
  58268. // }
  58269. pixelIndexH++;
  58270. if (pixelIndexH % size == 0) {
  58271. pixelIndexSlice++;
  58272. pixelIndexH = 0;
  58273. if (pixelIndexSlice % size == 0) {
  58274. pixelIndexW++;
  58275. pixelIndexSlice = 0;
  58276. }
  58277. }
  58278. }
  58279. }
  58280. if (tempData && data) {
  58281. for (var i = 0; i < tempData.length; i++) {
  58282. if (i > 0 && (i + 1) % 4 === 0) {
  58283. data[i] = 255;
  58284. }
  58285. else {
  58286. var value = tempData[i];
  58287. data[i] = (value / maxColor * 255);
  58288. }
  58289. }
  58290. }
  58291. if (texture.is3D) {
  58292. texture.updateSize(size, size, size);
  58293. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  58294. }
  58295. else {
  58296. texture.updateSize(size * size, size);
  58297. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  58298. }
  58299. };
  58300. var scene = this.getScene();
  58301. if (scene) {
  58302. scene._loadFile(this.url, callback);
  58303. }
  58304. else {
  58305. this._engine._loadFile(this.url, callback);
  58306. }
  58307. return this._texture;
  58308. };
  58309. /**
  58310. * Starts the loading process of the texture.
  58311. */
  58312. ColorGradingTexture.prototype.loadTexture = function () {
  58313. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  58314. this.load3dlTexture();
  58315. }
  58316. };
  58317. /**
  58318. * Clones the color gradind texture.
  58319. */
  58320. ColorGradingTexture.prototype.clone = function () {
  58321. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  58322. // Base texture
  58323. newTexture.level = this.level;
  58324. return newTexture;
  58325. };
  58326. /**
  58327. * Called during delayed load for textures.
  58328. */
  58329. ColorGradingTexture.prototype.delayLoad = function () {
  58330. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  58331. return;
  58332. }
  58333. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  58334. this._texture = this._getFromCache(this.url, true);
  58335. if (!this._texture) {
  58336. this.loadTexture();
  58337. }
  58338. };
  58339. /**
  58340. * Parses a color grading texture serialized by Babylon.
  58341. * @param parsedTexture The texture information being parsedTexture
  58342. * @param scene The scene to load the texture in
  58343. * @param rootUrl The root url of the data assets to load
  58344. * @return A color gradind texture
  58345. */
  58346. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  58347. var texture = null;
  58348. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  58349. texture = new ColorGradingTexture(parsedTexture.name, scene);
  58350. texture.name = parsedTexture.name;
  58351. texture.level = parsedTexture.level;
  58352. }
  58353. return texture;
  58354. };
  58355. /**
  58356. * Serializes the LUT texture to json format.
  58357. */
  58358. ColorGradingTexture.prototype.serialize = function () {
  58359. if (!this.name) {
  58360. return null;
  58361. }
  58362. var serializationObject = {};
  58363. serializationObject.name = this.name;
  58364. serializationObject.level = this.level;
  58365. serializationObject.customType = "BABYLON.ColorGradingTexture";
  58366. return serializationObject;
  58367. };
  58368. /**
  58369. * Empty line regex stored for GC.
  58370. */
  58371. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  58372. return ColorGradingTexture;
  58373. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  58374. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  58375. /***/ }),
  58376. /***/ "./Materials/Textures/cubeTexture.ts":
  58377. /*!*******************************************!*\
  58378. !*** ./Materials/Textures/cubeTexture.ts ***!
  58379. \*******************************************/
  58380. /*! exports provided: CubeTexture */
  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__, "CubeTexture", function() { return CubeTexture; });
  58385. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58386. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  58387. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58388. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58389. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  58390. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58391. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58392. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  58393. /**
  58394. * Class for creating a cube texture
  58395. */
  58396. var CubeTexture = /** @class */ (function (_super) {
  58397. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  58398. /**
  58399. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  58400. * as prefiltered data.
  58401. * @param rootUrl defines the url of the texture or the root name of the six images
  58402. * @param scene defines the scene the texture is attached to
  58403. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  58404. * @param noMipmap defines if mipmaps should be created or not
  58405. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  58406. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  58407. * @param onError defines a callback triggered in case of error during load
  58408. * @param format defines the internal format to use for the texture once loaded
  58409. * @param prefiltered defines whether or not the texture is created from prefiltered data
  58410. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  58411. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  58412. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58413. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58414. * @return the cube texture
  58415. */
  58416. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  58417. if (extensions === void 0) { extensions = null; }
  58418. if (noMipmap === void 0) { noMipmap = false; }
  58419. if (files === void 0) { files = null; }
  58420. if (onLoad === void 0) { onLoad = null; }
  58421. if (onError === void 0) { onError = null; }
  58422. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  58423. if (prefiltered === void 0) { prefiltered = false; }
  58424. if (forcedExtension === void 0) { forcedExtension = null; }
  58425. if (createPolynomials === void 0) { createPolynomials = false; }
  58426. if (lodScale === void 0) { lodScale = 0.8; }
  58427. if (lodOffset === void 0) { lodOffset = 0; }
  58428. var _this = _super.call(this, scene) || this;
  58429. /**
  58430. * Gets or sets the center of the bounding box associated with the cube texture.
  58431. * It must define where the camera used to render the texture was set
  58432. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  58433. */
  58434. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  58435. _this._rotationY = 0;
  58436. /** @hidden */
  58437. _this._prefiltered = false;
  58438. _this.name = rootUrl;
  58439. _this.url = rootUrl;
  58440. _this._noMipmap = noMipmap;
  58441. _this.hasAlpha = false;
  58442. _this._format = format;
  58443. _this.isCube = true;
  58444. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  58445. _this._createPolynomials = createPolynomials;
  58446. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  58447. if (!rootUrl && !files) {
  58448. return _this;
  58449. }
  58450. var lastDot = rootUrl.lastIndexOf(".");
  58451. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  58452. var isDDS = (extension === ".dds");
  58453. var isEnv = (extension === ".env");
  58454. if (isEnv) {
  58455. _this.gammaSpace = false;
  58456. _this._prefiltered = false;
  58457. }
  58458. else {
  58459. _this._prefiltered = prefiltered;
  58460. if (prefiltered) {
  58461. _this.gammaSpace = false;
  58462. }
  58463. }
  58464. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  58465. if (!files) {
  58466. if (!isEnv && !isDDS && !extensions) {
  58467. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  58468. }
  58469. files = [];
  58470. if (extensions) {
  58471. for (var index = 0; index < extensions.length; index++) {
  58472. files.push(rootUrl + extensions[index]);
  58473. }
  58474. }
  58475. }
  58476. _this._files = files;
  58477. if (!_this._texture) {
  58478. if (!scene.useDelayedTextureLoading) {
  58479. if (prefiltered) {
  58480. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  58481. }
  58482. else {
  58483. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  58484. }
  58485. }
  58486. else {
  58487. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58488. }
  58489. }
  58490. else if (onLoad) {
  58491. if (_this._texture.isReady) {
  58492. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  58493. }
  58494. else {
  58495. _this._texture.onLoadedObservable.add(onLoad);
  58496. }
  58497. }
  58498. return _this;
  58499. }
  58500. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  58501. /**
  58502. * Returns the bounding box size
  58503. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  58504. */
  58505. get: function () {
  58506. return this._boundingBoxSize;
  58507. },
  58508. /**
  58509. * Gets or sets the size of the bounding box associated with the cube texture
  58510. * When defined, the cubemap will switch to local mode
  58511. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58512. * @example https://www.babylonjs-playground.com/#RNASML
  58513. */
  58514. set: function (value) {
  58515. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  58516. return;
  58517. }
  58518. this._boundingBoxSize = value;
  58519. var scene = this.getScene();
  58520. if (scene) {
  58521. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  58522. }
  58523. },
  58524. enumerable: true,
  58525. configurable: true
  58526. });
  58527. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  58528. /**
  58529. * Gets texture matrix rotation angle around Y axis radians.
  58530. */
  58531. get: function () {
  58532. return this._rotationY;
  58533. },
  58534. /**
  58535. * Sets texture matrix rotation angle around Y axis in radians.
  58536. */
  58537. set: function (value) {
  58538. this._rotationY = value;
  58539. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  58540. },
  58541. enumerable: true,
  58542. configurable: true
  58543. });
  58544. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  58545. /**
  58546. * Are mip maps generated for this texture or not.
  58547. */
  58548. get: function () {
  58549. return this._noMipmap;
  58550. },
  58551. enumerable: true,
  58552. configurable: true
  58553. });
  58554. /**
  58555. * Creates a cube texture from an array of image urls
  58556. * @param files defines an array of image urls
  58557. * @param scene defines the hosting scene
  58558. * @param noMipmap specifies if mip maps are not used
  58559. * @returns a cube texture
  58560. */
  58561. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  58562. var rootUrlKey = "";
  58563. files.forEach(function (url) { return rootUrlKey += url; });
  58564. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  58565. };
  58566. /**
  58567. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  58568. * @param url defines the url of the prefiltered texture
  58569. * @param scene defines the scene the texture is attached to
  58570. * @param forcedExtension defines the extension of the file if different from the url
  58571. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  58572. * @return the prefiltered texture
  58573. */
  58574. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  58575. if (forcedExtension === void 0) { forcedExtension = null; }
  58576. if (createPolynomials === void 0) { createPolynomials = true; }
  58577. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  58578. };
  58579. /**
  58580. * Get the current class name of the texture useful for serialization or dynamic coding.
  58581. * @returns "CubeTexture"
  58582. */
  58583. CubeTexture.prototype.getClassName = function () {
  58584. return "CubeTexture";
  58585. };
  58586. /**
  58587. * Update the url (and optional buffer) of this texture if url was null during construction.
  58588. * @param url the url of the texture
  58589. * @param forcedExtension defines the extension to use
  58590. * @param onLoad callback called when the texture is loaded (defaults to null)
  58591. */
  58592. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  58593. if (this.url) {
  58594. this.releaseInternalTexture();
  58595. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  58596. }
  58597. this.url = url;
  58598. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  58599. this._prefiltered = false;
  58600. if (onLoad) {
  58601. this._delayedOnLoad = onLoad;
  58602. }
  58603. this.delayLoad(forcedExtension);
  58604. };
  58605. /**
  58606. * Delays loading of the cube texture
  58607. * @param forcedExtension defines the extension to use
  58608. */
  58609. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  58610. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  58611. return;
  58612. }
  58613. var scene = this.getScene();
  58614. if (!scene) {
  58615. return;
  58616. }
  58617. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  58618. this._texture = this._getFromCache(this.url, this._noMipmap);
  58619. if (!this._texture) {
  58620. if (this._prefiltered) {
  58621. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  58622. }
  58623. else {
  58624. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, undefined, this._format, forcedExtension);
  58625. }
  58626. }
  58627. };
  58628. /**
  58629. * Returns the reflection texture matrix
  58630. * @returns the reflection texture matrix
  58631. */
  58632. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  58633. return this._textureMatrix;
  58634. };
  58635. /**
  58636. * Sets the reflection texture matrix
  58637. * @param value Reflection texture matrix
  58638. */
  58639. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  58640. var _this = this;
  58641. if (value.updateFlag === this._textureMatrix.updateFlag) {
  58642. return;
  58643. }
  58644. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  58645. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  58646. }
  58647. this._textureMatrix = value;
  58648. };
  58649. /**
  58650. * Parses text to create a cube texture
  58651. * @param parsedTexture define the serialized text to read from
  58652. * @param scene defines the hosting scene
  58653. * @param rootUrl defines the root url of the cube texture
  58654. * @returns a cube texture
  58655. */
  58656. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  58657. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  58658. var prefiltered = false;
  58659. if (parsedTexture.prefiltered) {
  58660. prefiltered = parsedTexture.prefiltered;
  58661. }
  58662. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  58663. }, parsedTexture, scene);
  58664. // Local Cubemaps
  58665. if (parsedTexture.boundingBoxPosition) {
  58666. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  58667. }
  58668. if (parsedTexture.boundingBoxSize) {
  58669. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  58670. }
  58671. // Animations
  58672. if (parsedTexture.animations) {
  58673. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  58674. var parsedAnimation = parsedTexture.animations[animationIndex];
  58675. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  58676. if (internalClass) {
  58677. texture.animations.push(internalClass.Parse(parsedAnimation));
  58678. }
  58679. }
  58680. }
  58681. return texture;
  58682. };
  58683. /**
  58684. * Makes a clone, or deep copy, of the cube texture
  58685. * @returns a new cube texture
  58686. */
  58687. CubeTexture.prototype.clone = function () {
  58688. var _this = this;
  58689. var scene = this.getScene();
  58690. var uniqueId = 0;
  58691. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  58692. if (!scene) {
  58693. return _this;
  58694. }
  58695. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  58696. uniqueId = cubeTexture.uniqueId;
  58697. return cubeTexture;
  58698. }, this);
  58699. newCubeTexture.uniqueId = uniqueId;
  58700. return newCubeTexture;
  58701. };
  58702. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58703. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  58704. ], CubeTexture.prototype, "rotationY", null);
  58705. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  58706. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMatrix"])("textureMatrix")
  58707. ], CubeTexture.prototype, "_textureMatrix", void 0);
  58708. return CubeTexture;
  58709. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  58710. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  58711. // Some exporters relies on Tools.Instantiate
  58712. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.CubeTexture"] = CubeTexture;
  58713. /***/ }),
  58714. /***/ "./Materials/Textures/dynamicTexture.ts":
  58715. /*!**********************************************!*\
  58716. !*** ./Materials/Textures/dynamicTexture.ts ***!
  58717. \**********************************************/
  58718. /*! exports provided: DynamicTexture */
  58719. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58720. "use strict";
  58721. __webpack_require__.r(__webpack_exports__);
  58722. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  58723. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58724. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  58725. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58726. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58727. /**
  58728. * A class extending Texture allowing drawing on a texture
  58729. * @see http://doc.babylonjs.com/how_to/dynamictexture
  58730. */
  58731. var DynamicTexture = /** @class */ (function (_super) {
  58732. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  58733. /**
  58734. * Creates a DynamicTexture
  58735. * @param name defines the name of the texture
  58736. * @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
  58737. * @param scene defines the scene where you want the texture
  58738. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  58739. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  58740. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  58741. */
  58742. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  58743. if (scene === void 0) { scene = null; }
  58744. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  58745. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  58746. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  58747. _this.name = name;
  58748. _this._engine = _this.getScene().getEngine();
  58749. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  58750. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  58751. _this._generateMipMaps = generateMipMaps;
  58752. if (options.getContext) {
  58753. _this._canvas = options;
  58754. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  58755. }
  58756. else {
  58757. _this._canvas = document.createElement("canvas");
  58758. if (options.width || options.width === 0) {
  58759. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  58760. }
  58761. else {
  58762. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  58763. }
  58764. }
  58765. var textureSize = _this.getSize();
  58766. _this._canvas.width = textureSize.width;
  58767. _this._canvas.height = textureSize.height;
  58768. _this._context = _this._canvas.getContext("2d");
  58769. return _this;
  58770. }
  58771. /**
  58772. * Get the current class name of the texture useful for serialization or dynamic coding.
  58773. * @returns "DynamicTexture"
  58774. */
  58775. DynamicTexture.prototype.getClassName = function () {
  58776. return "DynamicTexture";
  58777. };
  58778. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  58779. /**
  58780. * Gets the current state of canRescale
  58781. */
  58782. get: function () {
  58783. return true;
  58784. },
  58785. enumerable: true,
  58786. configurable: true
  58787. });
  58788. DynamicTexture.prototype._recreate = function (textureSize) {
  58789. this._canvas.width = textureSize.width;
  58790. this._canvas.height = textureSize.height;
  58791. this.releaseInternalTexture();
  58792. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  58793. };
  58794. /**
  58795. * Scales the texture
  58796. * @param ratio the scale factor to apply to both width and height
  58797. */
  58798. DynamicTexture.prototype.scale = function (ratio) {
  58799. var textureSize = this.getSize();
  58800. textureSize.width *= ratio;
  58801. textureSize.height *= ratio;
  58802. this._recreate(textureSize);
  58803. };
  58804. /**
  58805. * Resizes the texture
  58806. * @param width the new width
  58807. * @param height the new height
  58808. */
  58809. DynamicTexture.prototype.scaleTo = function (width, height) {
  58810. var textureSize = this.getSize();
  58811. textureSize.width = width;
  58812. textureSize.height = height;
  58813. this._recreate(textureSize);
  58814. };
  58815. /**
  58816. * Gets the context of the canvas used by the texture
  58817. * @returns the canvas context of the dynamic texture
  58818. */
  58819. DynamicTexture.prototype.getContext = function () {
  58820. return this._context;
  58821. };
  58822. /**
  58823. * Clears the texture
  58824. */
  58825. DynamicTexture.prototype.clear = function () {
  58826. var size = this.getSize();
  58827. this._context.fillRect(0, 0, size.width, size.height);
  58828. };
  58829. /**
  58830. * Updates the texture
  58831. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  58832. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  58833. */
  58834. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  58835. if (premulAlpha === void 0) { premulAlpha = false; }
  58836. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  58837. };
  58838. /**
  58839. * Draws text onto the texture
  58840. * @param text defines the text to be drawn
  58841. * @param x defines the placement of the text from the left
  58842. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  58843. * @param font defines the font to be used with font-style, font-size, font-name
  58844. * @param color defines the color used for the text
  58845. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  58846. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  58847. * @param update defines whether texture is immediately update (default is true)
  58848. */
  58849. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  58850. if (update === void 0) { update = true; }
  58851. var size = this.getSize();
  58852. if (clearColor) {
  58853. this._context.fillStyle = clearColor;
  58854. this._context.fillRect(0, 0, size.width, size.height);
  58855. }
  58856. this._context.font = font;
  58857. if (x === null || x === undefined) {
  58858. var textSize = this._context.measureText(text);
  58859. x = (size.width - textSize.width) / 2;
  58860. }
  58861. if (y === null || y === undefined) {
  58862. var fontSize = parseInt((font.replace(/\D/g, '')));
  58863. y = (size.height / 2) + (fontSize / 3.65);
  58864. }
  58865. this._context.fillStyle = color;
  58866. this._context.fillText(text, x, y);
  58867. if (update) {
  58868. this.update(invertY);
  58869. }
  58870. };
  58871. /**
  58872. * Clones the texture
  58873. * @returns the clone of the texture.
  58874. */
  58875. DynamicTexture.prototype.clone = function () {
  58876. var scene = this.getScene();
  58877. if (!scene) {
  58878. return this;
  58879. }
  58880. var textureSize = this.getSize();
  58881. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  58882. // Base texture
  58883. newTexture.hasAlpha = this.hasAlpha;
  58884. newTexture.level = this.level;
  58885. // Dynamic Texture
  58886. newTexture.wrapU = this.wrapU;
  58887. newTexture.wrapV = this.wrapV;
  58888. return newTexture;
  58889. };
  58890. /**
  58891. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  58892. * @returns a serialized dynamic texture object
  58893. */
  58894. DynamicTexture.prototype.serialize = function () {
  58895. var scene = this.getScene();
  58896. if (scene && !scene.isReady()) {
  58897. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  58898. }
  58899. var serializationObject = _super.prototype.serialize.call(this);
  58900. serializationObject.base64String = this._canvas.toDataURL();
  58901. serializationObject.invertY = this._invertY;
  58902. serializationObject.samplingMode = this.samplingMode;
  58903. return serializationObject;
  58904. };
  58905. /** @hidden */
  58906. DynamicTexture.prototype._rebuild = function () {
  58907. this.update();
  58908. };
  58909. return DynamicTexture;
  58910. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  58911. /***/ }),
  58912. /***/ "./Materials/Textures/equiRectangularCubeTexture.ts":
  58913. /*!**********************************************************!*\
  58914. !*** ./Materials/Textures/equiRectangularCubeTexture.ts ***!
  58915. \**********************************************************/
  58916. /*! exports provided: EquiRectangularCubeTexture */
  58917. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58918. "use strict";
  58919. __webpack_require__.r(__webpack_exports__);
  58920. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return EquiRectangularCubeTexture; });
  58921. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58922. /* harmony import */ var _Misc_HighDynamicRange_panoramaToCubemap__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  58923. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  58924. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  58925. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  58926. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58927. /**
  58928. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58929. */
  58930. var EquiRectangularCubeTexture = /** @class */ (function (_super) {
  58931. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](EquiRectangularCubeTexture, _super);
  58932. /**
  58933. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58934. * @param url The location of the image
  58935. * @param scene The scene the texture will be used in
  58936. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58937. * @param noMipmap Forces to not generate the mipmap if true
  58938. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58939. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58940. * @param onLoad — defines a callback called when texture is loaded
  58941. * @param onError — defines a callback called if there is an error
  58942. */
  58943. function EquiRectangularCubeTexture(url, scene, size, noMipmap, gammaSpace, onLoad, onError) {
  58944. if (noMipmap === void 0) { noMipmap = false; }
  58945. if (gammaSpace === void 0) { gammaSpace = true; }
  58946. if (onLoad === void 0) { onLoad = null; }
  58947. if (onError === void 0) { onError = null; }
  58948. var _this = _super.call(this, scene) || this;
  58949. _this._onLoad = null;
  58950. _this._onError = null;
  58951. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58952. _this.coordinatesMode = _texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  58953. if (!url) {
  58954. throw new Error('Image url is not set');
  58955. }
  58956. _this.name = url;
  58957. _this.url = url;
  58958. _this._size = size;
  58959. _this._noMipmap = noMipmap;
  58960. _this.gammaSpace = gammaSpace;
  58961. _this._onLoad = onLoad;
  58962. _this._onError = onError;
  58963. _this.hasAlpha = false;
  58964. _this.isCube = true;
  58965. _this._texture = _this._getFromCache(url, _this._noMipmap);
  58966. if (!_this._texture) {
  58967. if (!scene.useDelayedTextureLoading) {
  58968. _this.loadImage(_this.loadTexture.bind(_this), _this._onError);
  58969. }
  58970. else {
  58971. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  58972. }
  58973. }
  58974. else if (onLoad) {
  58975. if (_this._texture.isReady) {
  58976. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].SetImmediate(function () { return onLoad(); });
  58977. }
  58978. else {
  58979. _this._texture.onLoadedObservable.add(onLoad);
  58980. }
  58981. }
  58982. return _this;
  58983. }
  58984. /**
  58985. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58986. */
  58987. EquiRectangularCubeTexture.prototype.loadImage = function (loadTextureCallback, onError) {
  58988. var _this = this;
  58989. var canvas = document.createElement('canvas');
  58990. var image = new Image();
  58991. image.addEventListener('load', function () {
  58992. _this._width = image.width;
  58993. _this._height = image.height;
  58994. canvas.width = _this._width;
  58995. canvas.height = _this._height;
  58996. var ctx = canvas.getContext('2d');
  58997. ctx.drawImage(image, 0, 0);
  58998. var imageData = ctx.getImageData(0, 0, image.width, image.height);
  58999. _this._buffer = imageData.data.buffer;
  59000. canvas.remove();
  59001. loadTextureCallback();
  59002. });
  59003. image.addEventListener('error', function (error) {
  59004. if (onError) {
  59005. onError(_this.getClassName() + " could not be loaded", error);
  59006. }
  59007. });
  59008. image.src = this.url;
  59009. };
  59010. /**
  59011. * Convert the image buffer into a cubemap and create a CubeTexture.
  59012. */
  59013. EquiRectangularCubeTexture.prototype.loadTexture = function () {
  59014. var _this = this;
  59015. var scene = this.getScene();
  59016. var callback = function () {
  59017. var imageData = _this.getFloat32ArrayFromArrayBuffer(_this._buffer);
  59018. // Extract the raw linear data.
  59019. var data = _Misc_HighDynamicRange_panoramaToCubemap__WEBPACK_IMPORTED_MODULE_1__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(imageData, _this._width, _this._height, _this._size);
  59020. var results = [];
  59021. // Push each faces.
  59022. for (var i = 0; i < 6; i++) {
  59023. var dataFace = data[EquiRectangularCubeTexture._FacesMapping[i]];
  59024. results.push(dataFace);
  59025. }
  59026. return results;
  59027. };
  59028. if (!scene) {
  59029. return;
  59030. }
  59031. this._texture = scene
  59032. .getEngine()
  59033. .createRawCubeTextureFromUrl(this.url, scene, this._size, _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTUREFORMAT_RGB, scene.getEngine().getCaps().textureFloat
  59034. ? _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTURETYPE_FLOAT
  59035. : _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].TEXTURETYPE_UNSIGNED_INTEGER, this._noMipmap, callback, null, this._onLoad, this._onError);
  59036. };
  59037. /**
  59038. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59039. * @param buffer The ArrayBuffer that should be converted.
  59040. * @returns The buffer as Float32Array.
  59041. */
  59042. EquiRectangularCubeTexture.prototype.getFloat32ArrayFromArrayBuffer = function (buffer) {
  59043. var dataView = new DataView(buffer);
  59044. var floatImageData = new Float32Array((buffer.byteLength * 3) / 4);
  59045. var k = 0;
  59046. for (var i = 0; i < buffer.byteLength; i++) {
  59047. // We drop the transparency channel, because we do not need/want it
  59048. if ((i + 1) % 4 !== 0) {
  59049. floatImageData[k++] = dataView.getUint8(i) / 255;
  59050. }
  59051. }
  59052. return floatImageData;
  59053. };
  59054. /**
  59055. * Get the current class name of the texture useful for serialization or dynamic coding.
  59056. * @returns "EquiRectangularCubeTexture"
  59057. */
  59058. EquiRectangularCubeTexture.prototype.getClassName = function () {
  59059. return "EquiRectangularCubeTexture";
  59060. };
  59061. /**
  59062. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59063. * @returns A clone of the current EquiRectangularCubeTexture.
  59064. */
  59065. EquiRectangularCubeTexture.prototype.clone = function () {
  59066. var scene = this.getScene();
  59067. if (!scene) {
  59068. return this;
  59069. }
  59070. var newTexture = new EquiRectangularCubeTexture(this.url, scene, this._size, this._noMipmap, this.gammaSpace);
  59071. // Base texture
  59072. newTexture.level = this.level;
  59073. newTexture.wrapU = this.wrapU;
  59074. newTexture.wrapV = this.wrapV;
  59075. newTexture.coordinatesIndex = this.coordinatesIndex;
  59076. newTexture.coordinatesMode = this.coordinatesMode;
  59077. return newTexture;
  59078. };
  59079. /** The six faces of the cube. */
  59080. EquiRectangularCubeTexture._FacesMapping = ['right', 'left', 'up', 'down', 'front', 'back'];
  59081. return EquiRectangularCubeTexture;
  59082. }(_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  59083. /***/ }),
  59084. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  59085. /*!**********************************************!*\
  59086. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  59087. \**********************************************/
  59088. /*! exports provided: HDRCubeTexture */
  59089. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59090. "use strict";
  59091. __webpack_require__.r(__webpack_exports__);
  59092. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  59093. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59094. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  59095. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  59096. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  59097. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59098. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59099. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  59100. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  59101. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  59102. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  59103. /**
  59104. * This represents a texture coming from an HDR input.
  59105. *
  59106. * The only supported format is currently panorama picture stored in RGBE format.
  59107. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59108. */
  59109. var HDRCubeTexture = /** @class */ (function (_super) {
  59110. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  59111. /**
  59112. * Instantiates an HDRTexture from the following parameters.
  59113. *
  59114. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59115. * @param scene The scene the texture will be used in
  59116. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59117. * @param noMipmap Forces to not generate the mipmap if true
  59118. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59119. * @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)
  59120. * @param reserved Reserved flag for internal use.
  59121. */
  59122. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  59123. if (noMipmap === void 0) { noMipmap = false; }
  59124. if (generateHarmonics === void 0) { generateHarmonics = true; }
  59125. if (gammaSpace === void 0) { gammaSpace = false; }
  59126. if (reserved === void 0) { reserved = false; }
  59127. if (onLoad === void 0) { onLoad = null; }
  59128. if (onError === void 0) { onError = null; }
  59129. var _this = _super.call(this, scene) || this;
  59130. _this._generateHarmonics = true;
  59131. _this._onLoad = null;
  59132. _this._onError = null;
  59133. /**
  59134. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59135. */
  59136. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  59137. _this._isBlocking = true;
  59138. _this._rotationY = 0;
  59139. /**
  59140. * Gets or sets the center of the bounding box associated with the cube texture
  59141. * It must define where the camera used to render the texture was set
  59142. */
  59143. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  59144. if (!url) {
  59145. return _this;
  59146. }
  59147. _this.name = url;
  59148. _this.url = url;
  59149. _this.hasAlpha = false;
  59150. _this.isCube = true;
  59151. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  59152. _this._onLoad = onLoad;
  59153. _this._onError = onError;
  59154. _this.gammaSpace = gammaSpace;
  59155. _this._noMipmap = noMipmap;
  59156. _this._size = size;
  59157. _this._texture = _this._getFromCache(url, _this._noMipmap);
  59158. if (!_this._texture) {
  59159. if (!scene.useDelayedTextureLoading) {
  59160. _this.loadTexture();
  59161. }
  59162. else {
  59163. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  59164. }
  59165. }
  59166. else if (onLoad) {
  59167. if (_this._texture.isReady) {
  59168. _Misc_tools__WEBPACK_IMPORTED_MODULE_9__["Tools"].SetImmediate(function () { return onLoad(); });
  59169. }
  59170. else {
  59171. _this._texture.onLoadedObservable.add(onLoad);
  59172. }
  59173. }
  59174. return _this;
  59175. }
  59176. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  59177. /**
  59178. * Gets wether or not the texture is blocking during loading.
  59179. */
  59180. get: function () {
  59181. return this._isBlocking;
  59182. },
  59183. /**
  59184. * Sets wether or not the texture is blocking during loading.
  59185. */
  59186. set: function (value) {
  59187. this._isBlocking = value;
  59188. },
  59189. enumerable: true,
  59190. configurable: true
  59191. });
  59192. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  59193. /**
  59194. * Gets texture matrix rotation angle around Y axis radians.
  59195. */
  59196. get: function () {
  59197. return this._rotationY;
  59198. },
  59199. /**
  59200. * Sets texture matrix rotation angle around Y axis in radians.
  59201. */
  59202. set: function (value) {
  59203. this._rotationY = value;
  59204. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  59205. },
  59206. enumerable: true,
  59207. configurable: true
  59208. });
  59209. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  59210. get: function () {
  59211. return this._boundingBoxSize;
  59212. },
  59213. /**
  59214. * Gets or sets the size of the bounding box associated with the cube texture
  59215. * When defined, the cubemap will switch to local mode
  59216. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59217. * @example https://www.babylonjs-playground.com/#RNASML
  59218. */
  59219. set: function (value) {
  59220. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  59221. return;
  59222. }
  59223. this._boundingBoxSize = value;
  59224. var scene = this.getScene();
  59225. if (scene) {
  59226. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  59227. }
  59228. },
  59229. enumerable: true,
  59230. configurable: true
  59231. });
  59232. /**
  59233. * Get the current class name of the texture useful for serialization or dynamic coding.
  59234. * @returns "HDRCubeTexture"
  59235. */
  59236. HDRCubeTexture.prototype.getClassName = function () {
  59237. return "HDRCubeTexture";
  59238. };
  59239. /**
  59240. * Occurs when the file is raw .hdr file.
  59241. */
  59242. HDRCubeTexture.prototype.loadTexture = function () {
  59243. var _this = this;
  59244. var callback = function (buffer) {
  59245. _this.lodGenerationOffset = 0.0;
  59246. _this.lodGenerationScale = 0.8;
  59247. var scene = _this.getScene();
  59248. if (!scene) {
  59249. return null;
  59250. }
  59251. // Extract the raw linear data.
  59252. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  59253. // Generate harmonics if needed.
  59254. if (_this._generateHarmonics) {
  59255. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  59256. _this.sphericalPolynomial = sphericalPolynomial;
  59257. }
  59258. var results = [];
  59259. var byteArray = null;
  59260. // Push each faces.
  59261. for (var j = 0; j < 6; j++) {
  59262. // Create uintarray fallback.
  59263. if (!scene.getEngine().getCaps().textureFloat) {
  59264. // 3 channels of 1 bytes per pixel in bytes.
  59265. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  59266. byteArray = new Uint8Array(byteBuffer);
  59267. }
  59268. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  59269. // If special cases.
  59270. if (_this.gammaSpace || byteArray) {
  59271. for (var i = 0; i < _this._size * _this._size; i++) {
  59272. // Put in gamma space if requested.
  59273. if (_this.gammaSpace) {
  59274. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  59275. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  59276. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  59277. }
  59278. // Convert to int texture for fallback.
  59279. if (byteArray) {
  59280. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  59281. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  59282. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  59283. // May use luminance instead if the result is not accurate.
  59284. var max = Math.max(Math.max(r, g), b);
  59285. if (max > 255) {
  59286. var scale = 255 / max;
  59287. r *= scale;
  59288. g *= scale;
  59289. b *= scale;
  59290. }
  59291. byteArray[(i * 3) + 0] = r;
  59292. byteArray[(i * 3) + 1] = g;
  59293. byteArray[(i * 3) + 2] = b;
  59294. }
  59295. }
  59296. }
  59297. if (byteArray) {
  59298. results.push(byteArray);
  59299. }
  59300. else {
  59301. results.push(dataFace);
  59302. }
  59303. }
  59304. return results;
  59305. };
  59306. var scene = this.getScene();
  59307. if (scene) {
  59308. 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);
  59309. }
  59310. };
  59311. HDRCubeTexture.prototype.clone = function () {
  59312. var scene = this.getScene();
  59313. if (!scene) {
  59314. return this;
  59315. }
  59316. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  59317. // Base texture
  59318. newTexture.level = this.level;
  59319. newTexture.wrapU = this.wrapU;
  59320. newTexture.wrapV = this.wrapV;
  59321. newTexture.coordinatesIndex = this.coordinatesIndex;
  59322. newTexture.coordinatesMode = this.coordinatesMode;
  59323. return newTexture;
  59324. };
  59325. // Methods
  59326. HDRCubeTexture.prototype.delayLoad = function () {
  59327. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  59328. return;
  59329. }
  59330. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  59331. this._texture = this._getFromCache(this.url, this._noMipmap);
  59332. if (!this._texture) {
  59333. this.loadTexture();
  59334. }
  59335. };
  59336. /**
  59337. * Get the texture reflection matrix used to rotate/transform the reflection.
  59338. * @returns the reflection matrix
  59339. */
  59340. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  59341. return this._textureMatrix;
  59342. };
  59343. /**
  59344. * Set the texture reflection matrix used to rotate/transform the reflection.
  59345. * @param value Define the reflection matrix to set
  59346. */
  59347. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  59348. var _this = this;
  59349. this._textureMatrix = value;
  59350. if (value.updateFlag === this._textureMatrix.updateFlag) {
  59351. return;
  59352. }
  59353. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  59354. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  59355. }
  59356. };
  59357. /**
  59358. * Parses a JSON representation of an HDR Texture in order to create the texture
  59359. * @param parsedTexture Define the JSON representation
  59360. * @param scene Define the scene the texture should be created in
  59361. * @param rootUrl Define the root url in case we need to load relative dependencies
  59362. * @returns the newly created texture after parsing
  59363. */
  59364. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  59365. var texture = null;
  59366. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  59367. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  59368. texture.name = parsedTexture.name;
  59369. texture.hasAlpha = parsedTexture.hasAlpha;
  59370. texture.level = parsedTexture.level;
  59371. texture.coordinatesMode = parsedTexture.coordinatesMode;
  59372. texture.isBlocking = parsedTexture.isBlocking;
  59373. }
  59374. if (texture) {
  59375. if (parsedTexture.boundingBoxPosition) {
  59376. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  59377. }
  59378. if (parsedTexture.boundingBoxSize) {
  59379. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  59380. }
  59381. if (parsedTexture.rotationY) {
  59382. texture.rotationY = parsedTexture.rotationY;
  59383. }
  59384. }
  59385. return texture;
  59386. };
  59387. HDRCubeTexture.prototype.serialize = function () {
  59388. if (!this.name) {
  59389. return null;
  59390. }
  59391. var serializationObject = {};
  59392. serializationObject.name = this.name;
  59393. serializationObject.hasAlpha = this.hasAlpha;
  59394. serializationObject.isCube = true;
  59395. serializationObject.level = this.level;
  59396. serializationObject.size = this._size;
  59397. serializationObject.coordinatesMode = this.coordinatesMode;
  59398. serializationObject.useInGammaSpace = this.gammaSpace;
  59399. serializationObject.generateHarmonics = this._generateHarmonics;
  59400. serializationObject.customType = "BABYLON.HDRCubeTexture";
  59401. serializationObject.noMipmap = this._noMipmap;
  59402. serializationObject.isBlocking = this._isBlocking;
  59403. serializationObject.rotationY = this._rotationY;
  59404. return serializationObject;
  59405. };
  59406. HDRCubeTexture._facesMapping = [
  59407. "right",
  59408. "left",
  59409. "up",
  59410. "down",
  59411. "front",
  59412. "back"
  59413. ];
  59414. return HDRCubeTexture;
  59415. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  59416. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  59417. /***/ }),
  59418. /***/ "./Materials/Textures/index.ts":
  59419. /*!*************************************!*\
  59420. !*** ./Materials/Textures/index.ts ***!
  59421. \*************************************/
  59422. /*! exports provided: BaseTexture, CubeTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, MirrorTexture, MultiRenderTarget, RenderTargetTexture, Texture, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  59423. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59424. "use strict";
  59425. __webpack_require__.r(__webpack_exports__);
  59426. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  59427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  59428. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  59429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  59430. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  59431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  59432. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  59433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  59434. /* harmony import */ var _equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./equiRectangularCubeTexture */ "./Materials/Textures/equiRectangularCubeTexture.ts");
  59435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_4__["EquiRectangularCubeTexture"]; });
  59436. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  59437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_5__["HDRCubeTexture"]; });
  59438. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  59439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_6__["InternalTexture"]; });
  59440. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  59441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_DDSTextureLoader"]; });
  59442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_ENVTextureLoader"]; });
  59443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_KTXTextureLoader"]; });
  59444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_TGATextureLoader"]; });
  59445. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  59446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__["MirrorTexture"]; });
  59447. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  59448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__["MultiRenderTarget"]; });
  59449. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  59450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTexture"]; });
  59451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["CustomProceduralTexture"]; });
  59452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["NoiseProceduralTexture"]; });
  59453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTextureSceneComponent"]; });
  59454. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  59455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__["RawCubeTexture"]; });
  59456. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  59457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_12__["RawTexture"]; });
  59458. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  59459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  59460. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  59461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_14__["RefractionTexture"]; });
  59462. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  59463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__["RenderTargetTexture"]; });
  59464. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  59465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_16__["Texture"]; });
  59466. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  59467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_17__["VideoTexture"]; });
  59468. /***/ }),
  59469. /***/ "./Materials/Textures/internalTexture.ts":
  59470. /*!***********************************************!*\
  59471. !*** ./Materials/Textures/internalTexture.ts ***!
  59472. \***********************************************/
  59473. /*! exports provided: InternalTexture */
  59474. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59475. "use strict";
  59476. __webpack_require__.r(__webpack_exports__);
  59477. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  59478. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  59479. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  59480. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59481. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  59482. /**
  59483. * Class used to store data associated with WebGL texture data for the engine
  59484. * This class should not be used directly
  59485. */
  59486. var InternalTexture = /** @class */ (function () {
  59487. /**
  59488. * Creates a new InternalTexture
  59489. * @param engine defines the engine to use
  59490. * @param dataSource defines the type of data that will be used
  59491. * @param delayAllocation if the texture allocation should be delayed (default: false)
  59492. */
  59493. function InternalTexture(engine, dataSource, delayAllocation) {
  59494. if (delayAllocation === void 0) { delayAllocation = false; }
  59495. /**
  59496. * Observable called when the texture is loaded
  59497. */
  59498. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  59499. // Private
  59500. /** @hidden */
  59501. this._invertVScale = false;
  59502. /** @hidden */
  59503. this._associatedChannel = -1;
  59504. /** @hidden */
  59505. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  59506. /** @hidden */
  59507. this._comparisonFunction = 0;
  59508. /** @hidden */
  59509. this._sphericalPolynomial = null;
  59510. /** @hidden */
  59511. this._lodGenerationScale = 0;
  59512. /** @hidden */
  59513. this._lodGenerationOffset = 0;
  59514. /** @hidden */
  59515. this._isRGBD = false;
  59516. /** @hidden */
  59517. this._references = 1;
  59518. this._engine = engine;
  59519. this._dataSource = dataSource;
  59520. if (!delayAllocation) {
  59521. this._webGLTexture = engine._createTexture();
  59522. }
  59523. }
  59524. /**
  59525. * Gets the Engine the texture belongs to.
  59526. * @returns The babylon engine
  59527. */
  59528. InternalTexture.prototype.getEngine = function () {
  59529. return this._engine;
  59530. };
  59531. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  59532. /**
  59533. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  59534. */
  59535. get: function () {
  59536. return this._dataSource;
  59537. },
  59538. enumerable: true,
  59539. configurable: true
  59540. });
  59541. /**
  59542. * Increments the number of references (ie. the number of Texture that point to it)
  59543. */
  59544. InternalTexture.prototype.incrementReferences = function () {
  59545. this._references++;
  59546. };
  59547. /**
  59548. * Change the size of the texture (not the size of the content)
  59549. * @param width defines the new width
  59550. * @param height defines the new height
  59551. * @param depth defines the new depth (1 by default)
  59552. */
  59553. InternalTexture.prototype.updateSize = function (width, height, depth) {
  59554. if (depth === void 0) { depth = 1; }
  59555. this.width = width;
  59556. this.height = height;
  59557. this.depth = depth;
  59558. this.baseWidth = width;
  59559. this.baseHeight = height;
  59560. this.baseDepth = depth;
  59561. this._size = width * height * depth;
  59562. };
  59563. /** @hidden */
  59564. InternalTexture.prototype._rebuild = function () {
  59565. var _this = this;
  59566. var proxy;
  59567. this.isReady = false;
  59568. this._cachedCoordinatesMode = null;
  59569. this._cachedWrapU = null;
  59570. this._cachedWrapV = null;
  59571. this._cachedAnisotropicFilteringLevel = null;
  59572. switch (this._dataSource) {
  59573. case InternalTexture.DATASOURCE_TEMP:
  59574. return;
  59575. case InternalTexture.DATASOURCE_URL:
  59576. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  59577. proxy._swapAndDie(_this);
  59578. _this.isReady = true;
  59579. }, null, this._buffer, undefined, this.format);
  59580. return;
  59581. case InternalTexture.DATASOURCE_RAW:
  59582. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  59583. proxy._swapAndDie(this);
  59584. this.isReady = true;
  59585. return;
  59586. case InternalTexture.DATASOURCE_RAW3D:
  59587. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  59588. proxy._swapAndDie(this);
  59589. this.isReady = true;
  59590. return;
  59591. case InternalTexture.DATASOURCE_DYNAMIC:
  59592. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  59593. proxy._swapAndDie(this);
  59594. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  59595. // The engine will make sure to update content so no need to flag it as isReady = true
  59596. return;
  59597. case InternalTexture.DATASOURCE_RENDERTARGET:
  59598. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  59599. options.generateDepthBuffer = this._generateDepthBuffer;
  59600. options.generateMipMaps = this.generateMipMaps;
  59601. options.generateStencilBuffer = this._generateStencilBuffer;
  59602. options.samplingMode = this.samplingMode;
  59603. options.type = this.type;
  59604. if (this.isCube) {
  59605. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  59606. }
  59607. else {
  59608. var size = {
  59609. width: this.width,
  59610. height: this.height
  59611. };
  59612. proxy = this._engine.createRenderTargetTexture(size, options);
  59613. }
  59614. proxy._swapAndDie(this);
  59615. this.isReady = true;
  59616. return;
  59617. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  59618. var depthTextureOptions = {
  59619. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  59620. comparisonFunction: this._comparisonFunction,
  59621. generateStencil: this._generateStencilBuffer,
  59622. isCube: this.isCube
  59623. };
  59624. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  59625. proxy._swapAndDie(this);
  59626. this.isReady = true;
  59627. return;
  59628. case InternalTexture.DATASOURCE_CUBE:
  59629. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  59630. proxy._swapAndDie(_this);
  59631. _this.isReady = true;
  59632. }, null, this.format, this._extension);
  59633. return;
  59634. case InternalTexture.DATASOURCE_CUBERAW:
  59635. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  59636. proxy._swapAndDie(this);
  59637. this.isReady = true;
  59638. return;
  59639. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  59640. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  59641. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  59642. proxy._swapAndDie(_this);
  59643. _this.isReady = true;
  59644. });
  59645. return;
  59646. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  59647. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  59648. if (proxy) {
  59649. proxy._swapAndDie(_this);
  59650. }
  59651. _this.isReady = true;
  59652. }, null, this.format, this._extension);
  59653. proxy._sphericalPolynomial = this._sphericalPolynomial;
  59654. return;
  59655. }
  59656. };
  59657. /** @hidden */
  59658. InternalTexture.prototype._swapAndDie = function (target) {
  59659. target._webGLTexture = this._webGLTexture;
  59660. target._isRGBD = this._isRGBD;
  59661. if (this._framebuffer) {
  59662. target._framebuffer = this._framebuffer;
  59663. }
  59664. if (this._depthStencilBuffer) {
  59665. target._depthStencilBuffer = this._depthStencilBuffer;
  59666. }
  59667. if (this._lodTextureHigh) {
  59668. if (target._lodTextureHigh) {
  59669. target._lodTextureHigh.dispose();
  59670. }
  59671. target._lodTextureHigh = this._lodTextureHigh;
  59672. }
  59673. if (this._lodTextureMid) {
  59674. if (target._lodTextureMid) {
  59675. target._lodTextureMid.dispose();
  59676. }
  59677. target._lodTextureMid = this._lodTextureMid;
  59678. }
  59679. if (this._lodTextureLow) {
  59680. if (target._lodTextureLow) {
  59681. target._lodTextureLow.dispose();
  59682. }
  59683. target._lodTextureLow = this._lodTextureLow;
  59684. }
  59685. var cache = this._engine.getLoadedTexturesCache();
  59686. var index = cache.indexOf(this);
  59687. if (index !== -1) {
  59688. cache.splice(index, 1);
  59689. }
  59690. };
  59691. /**
  59692. * Dispose the current allocated resources
  59693. */
  59694. InternalTexture.prototype.dispose = function () {
  59695. if (!this._webGLTexture) {
  59696. return;
  59697. }
  59698. this._references--;
  59699. if (this._references === 0) {
  59700. this._engine._releaseTexture(this);
  59701. this._webGLTexture = null;
  59702. }
  59703. };
  59704. /** hidden */
  59705. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  59706. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("environmentTextureTools");
  59707. };
  59708. /**
  59709. * The source of the texture data is unknown
  59710. */
  59711. InternalTexture.DATASOURCE_UNKNOWN = 0;
  59712. /**
  59713. * Texture data comes from an URL
  59714. */
  59715. InternalTexture.DATASOURCE_URL = 1;
  59716. /**
  59717. * Texture data is only used for temporary storage
  59718. */
  59719. InternalTexture.DATASOURCE_TEMP = 2;
  59720. /**
  59721. * Texture data comes from raw data (ArrayBuffer)
  59722. */
  59723. InternalTexture.DATASOURCE_RAW = 3;
  59724. /**
  59725. * Texture content is dynamic (video or dynamic texture)
  59726. */
  59727. InternalTexture.DATASOURCE_DYNAMIC = 4;
  59728. /**
  59729. * Texture content is generated by rendering to it
  59730. */
  59731. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  59732. /**
  59733. * Texture content is part of a multi render target process
  59734. */
  59735. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  59736. /**
  59737. * Texture data comes from a cube data file
  59738. */
  59739. InternalTexture.DATASOURCE_CUBE = 7;
  59740. /**
  59741. * Texture data comes from a raw cube data
  59742. */
  59743. InternalTexture.DATASOURCE_CUBERAW = 8;
  59744. /**
  59745. * Texture data come from a prefiltered cube data file
  59746. */
  59747. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  59748. /**
  59749. * Texture content is raw 3D data
  59750. */
  59751. InternalTexture.DATASOURCE_RAW3D = 10;
  59752. /**
  59753. * Texture content is a depth texture
  59754. */
  59755. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  59756. /**
  59757. * Texture data comes from a raw cube data encoded with RGBD
  59758. */
  59759. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  59760. return InternalTexture;
  59761. }());
  59762. /***/ }),
  59763. /***/ "./Materials/Textures/mirrorTexture.ts":
  59764. /*!*********************************************!*\
  59765. !*** ./Materials/Textures/mirrorTexture.ts ***!
  59766. \*********************************************/
  59767. /*! exports provided: MirrorTexture */
  59768. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59769. "use strict";
  59770. __webpack_require__.r(__webpack_exports__);
  59771. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  59772. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59773. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  59774. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59775. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  59776. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  59777. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  59778. /**
  59779. * Mirror texture can be used to simulate the view from a mirror in a scene.
  59780. * It will dynamically be rendered every frame to adapt to the camera point of view.
  59781. * You can then easily use it as a reflectionTexture on a flat surface.
  59782. * In case the surface is not a plane, please consider relying on reflection probes.
  59783. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  59784. */
  59785. var MirrorTexture = /** @class */ (function (_super) {
  59786. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  59787. /**
  59788. * Instantiates a Mirror Texture.
  59789. * Mirror texture can be used to simulate the view from a mirror in a scene.
  59790. * It will dynamically be rendered every frame to adapt to the camera point of view.
  59791. * You can then easily use it as a reflectionTexture on a flat surface.
  59792. * In case the surface is not a plane, please consider relying on reflection probes.
  59793. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  59794. * @param name
  59795. * @param size
  59796. * @param scene
  59797. * @param generateMipMaps
  59798. * @param type
  59799. * @param samplingMode
  59800. * @param generateDepthBuffer
  59801. */
  59802. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  59803. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  59804. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  59805. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  59806. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  59807. _this.scene = scene;
  59808. /**
  59809. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  59810. * 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.
  59811. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  59812. */
  59813. _this.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  59814. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  59815. _this._mirrorMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  59816. _this._adaptiveBlurKernel = 0;
  59817. _this._blurKernelX = 0;
  59818. _this._blurKernelY = 0;
  59819. _this._blurRatio = 1.0;
  59820. _this.ignoreCameraViewport = true;
  59821. _this._updateGammaSpace();
  59822. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  59823. _this._updateGammaSpace;
  59824. });
  59825. _this.onBeforeRenderObservable.add(function () {
  59826. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  59827. _this._savedViewMatrix = scene.getViewMatrix();
  59828. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  59829. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  59830. scene.clipPlane = _this.mirrorPlane;
  59831. scene.getEngine().cullBackFaces = false;
  59832. scene._mirroredCameraPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  59833. });
  59834. _this.onAfterRenderObservable.add(function () {
  59835. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  59836. scene.getEngine().cullBackFaces = true;
  59837. scene._mirroredCameraPosition = null;
  59838. delete scene.clipPlane;
  59839. });
  59840. return _this;
  59841. }
  59842. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  59843. get: function () {
  59844. return this._blurRatio;
  59845. },
  59846. /**
  59847. * Define the blur ratio used to blur the reflection if needed.
  59848. */
  59849. set: function (value) {
  59850. if (this._blurRatio === value) {
  59851. return;
  59852. }
  59853. this._blurRatio = value;
  59854. this._preparePostProcesses();
  59855. },
  59856. enumerable: true,
  59857. configurable: true
  59858. });
  59859. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  59860. /**
  59861. * Define the adaptive blur kernel used to blur the reflection if needed.
  59862. * This will autocompute the closest best match for the `blurKernel`
  59863. */
  59864. set: function (value) {
  59865. this._adaptiveBlurKernel = value;
  59866. this._autoComputeBlurKernel();
  59867. },
  59868. enumerable: true,
  59869. configurable: true
  59870. });
  59871. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  59872. /**
  59873. * Define the blur kernel used to blur the reflection if needed.
  59874. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  59875. */
  59876. set: function (value) {
  59877. this.blurKernelX = value;
  59878. this.blurKernelY = value;
  59879. },
  59880. enumerable: true,
  59881. configurable: true
  59882. });
  59883. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  59884. get: function () {
  59885. return this._blurKernelX;
  59886. },
  59887. /**
  59888. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  59889. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  59890. */
  59891. set: function (value) {
  59892. if (this._blurKernelX === value) {
  59893. return;
  59894. }
  59895. this._blurKernelX = value;
  59896. this._preparePostProcesses();
  59897. },
  59898. enumerable: true,
  59899. configurable: true
  59900. });
  59901. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  59902. get: function () {
  59903. return this._blurKernelY;
  59904. },
  59905. /**
  59906. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  59907. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  59908. */
  59909. set: function (value) {
  59910. if (this._blurKernelY === value) {
  59911. return;
  59912. }
  59913. this._blurKernelY = value;
  59914. this._preparePostProcesses();
  59915. },
  59916. enumerable: true,
  59917. configurable: true
  59918. });
  59919. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  59920. var engine = this.getScene().getEngine();
  59921. var dw = this.getRenderWidth() / engine.getRenderWidth();
  59922. var dh = this.getRenderHeight() / engine.getRenderHeight();
  59923. this.blurKernelX = this._adaptiveBlurKernel * dw;
  59924. this.blurKernelY = this._adaptiveBlurKernel * dh;
  59925. };
  59926. MirrorTexture.prototype._onRatioRescale = function () {
  59927. if (this._sizeRatio) {
  59928. this.resize(this._initialSizeParameter);
  59929. if (!this._adaptiveBlurKernel) {
  59930. this._preparePostProcesses();
  59931. }
  59932. }
  59933. if (this._adaptiveBlurKernel) {
  59934. this._autoComputeBlurKernel();
  59935. }
  59936. };
  59937. MirrorTexture.prototype._updateGammaSpace = function () {
  59938. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  59939. };
  59940. MirrorTexture.prototype._preparePostProcesses = function () {
  59941. this.clearPostProcesses(true);
  59942. if (this._blurKernelX && this._blurKernelY) {
  59943. var engine = this.getScene().getEngine();
  59944. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  59945. 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);
  59946. this._blurX.autoClear = false;
  59947. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  59948. this._blurX.inputTexture = this._texture;
  59949. }
  59950. else {
  59951. this._blurX.alwaysForcePOT = true;
  59952. }
  59953. 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);
  59954. this._blurY.autoClear = false;
  59955. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  59956. this.addPostProcess(this._blurX);
  59957. this.addPostProcess(this._blurY);
  59958. }
  59959. else {
  59960. if (this._blurY) {
  59961. this.removePostProcess(this._blurY);
  59962. this._blurY.dispose();
  59963. this._blurY = null;
  59964. }
  59965. if (this._blurX) {
  59966. this.removePostProcess(this._blurX);
  59967. this._blurX.dispose();
  59968. this._blurX = null;
  59969. }
  59970. }
  59971. };
  59972. /**
  59973. * Clone the mirror texture.
  59974. * @returns the cloned texture
  59975. */
  59976. MirrorTexture.prototype.clone = function () {
  59977. var scene = this.getScene();
  59978. if (!scene) {
  59979. return this;
  59980. }
  59981. var textureSize = this.getSize();
  59982. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  59983. // Base texture
  59984. newTexture.hasAlpha = this.hasAlpha;
  59985. newTexture.level = this.level;
  59986. // Mirror Texture
  59987. newTexture.mirrorPlane = this.mirrorPlane.clone();
  59988. if (this.renderList) {
  59989. newTexture.renderList = this.renderList.slice(0);
  59990. }
  59991. return newTexture;
  59992. };
  59993. /**
  59994. * Serialize the texture to a JSON representation you could use in Parse later on
  59995. * @returns the serialized JSON representation
  59996. */
  59997. MirrorTexture.prototype.serialize = function () {
  59998. if (!this.name) {
  59999. return null;
  60000. }
  60001. var serializationObject = _super.prototype.serialize.call(this);
  60002. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  60003. return serializationObject;
  60004. };
  60005. /**
  60006. * Dispose the texture and release its associated resources.
  60007. */
  60008. MirrorTexture.prototype.dispose = function () {
  60009. _super.prototype.dispose.call(this);
  60010. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  60011. };
  60012. return MirrorTexture;
  60013. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  60014. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  60015. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  60016. };
  60017. /***/ }),
  60018. /***/ "./Materials/Textures/multiRenderTarget.ts":
  60019. /*!*************************************************!*\
  60020. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  60021. \*************************************************/
  60022. /*! exports provided: MultiRenderTarget */
  60023. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60024. "use strict";
  60025. __webpack_require__.r(__webpack_exports__);
  60026. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  60027. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60028. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60029. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  60030. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60031. /**
  60032. * A multi render target, like a render target provides the ability to render to a texture.
  60033. * Unlike the render target, it can render to several draw buffers in one draw.
  60034. * This is specially interesting in deferred rendering or for any effects requiring more than
  60035. * just one color from a single pass.
  60036. */
  60037. var MultiRenderTarget = /** @class */ (function (_super) {
  60038. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  60039. /**
  60040. * Instantiate a new multi render target texture.
  60041. * A multi render target, like a render target provides the ability to render to a texture.
  60042. * Unlike the render target, it can render to several draw buffers in one draw.
  60043. * This is specially interesting in deferred rendering or for any effects requiring more than
  60044. * just one color from a single pass.
  60045. * @param name Define the name of the texture
  60046. * @param size Define the size of the buffers to render to
  60047. * @param count Define the number of target we are rendering into
  60048. * @param scene Define the scene the texture belongs to
  60049. * @param options Define the options used to create the multi render target
  60050. */
  60051. function MultiRenderTarget(name, size, count, scene, options) {
  60052. var _this = this;
  60053. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  60054. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  60055. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  60056. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  60057. _this._engine = scene.getEngine();
  60058. if (!_this.isSupported) {
  60059. _this.dispose();
  60060. return;
  60061. }
  60062. var types = [];
  60063. var samplingModes = [];
  60064. for (var i = 0; i < count; i++) {
  60065. if (options && options.types && options.types[i] !== undefined) {
  60066. types.push(options.types[i]);
  60067. }
  60068. else {
  60069. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  60070. }
  60071. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  60072. samplingModes.push(options.samplingModes[i]);
  60073. }
  60074. else {
  60075. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  60076. }
  60077. }
  60078. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  60079. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  60080. _this._size = size;
  60081. _this._multiRenderTargetOptions = {
  60082. samplingModes: samplingModes,
  60083. generateMipMaps: generateMipMaps,
  60084. generateDepthBuffer: generateDepthBuffer,
  60085. generateStencilBuffer: generateStencilBuffer,
  60086. generateDepthTexture: generateDepthTexture,
  60087. types: types,
  60088. textureCount: count
  60089. };
  60090. _this._createInternalTextures();
  60091. _this._createTextures();
  60092. return _this;
  60093. }
  60094. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  60095. /**
  60096. * Get if draw buffers are currently supported by the used hardware and browser.
  60097. */
  60098. get: function () {
  60099. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  60100. },
  60101. enumerable: true,
  60102. configurable: true
  60103. });
  60104. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  60105. /**
  60106. * Get the list of textures generated by the multi render target.
  60107. */
  60108. get: function () {
  60109. return this._textures;
  60110. },
  60111. enumerable: true,
  60112. configurable: true
  60113. });
  60114. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  60115. /**
  60116. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  60117. */
  60118. get: function () {
  60119. return this._textures[this._textures.length - 1];
  60120. },
  60121. enumerable: true,
  60122. configurable: true
  60123. });
  60124. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  60125. /**
  60126. * Set the wrapping mode on U of all the textures we are rendering to.
  60127. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  60128. */
  60129. set: function (wrap) {
  60130. if (this._textures) {
  60131. for (var i = 0; i < this._textures.length; i++) {
  60132. this._textures[i].wrapU = wrap;
  60133. }
  60134. }
  60135. },
  60136. enumerable: true,
  60137. configurable: true
  60138. });
  60139. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  60140. /**
  60141. * Set the wrapping mode on V of all the textures we are rendering to.
  60142. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  60143. */
  60144. set: function (wrap) {
  60145. if (this._textures) {
  60146. for (var i = 0; i < this._textures.length; i++) {
  60147. this._textures[i].wrapV = wrap;
  60148. }
  60149. }
  60150. },
  60151. enumerable: true,
  60152. configurable: true
  60153. });
  60154. /** @hidden */
  60155. MultiRenderTarget.prototype._rebuild = function () {
  60156. this.releaseInternalTextures();
  60157. this._createInternalTextures();
  60158. for (var i = 0; i < this._internalTextures.length; i++) {
  60159. var texture = this._textures[i];
  60160. texture._texture = this._internalTextures[i];
  60161. }
  60162. // Keeps references to frame buffer and stencil/depth buffer
  60163. this._texture = this._internalTextures[0];
  60164. };
  60165. MultiRenderTarget.prototype._createInternalTextures = function () {
  60166. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  60167. };
  60168. MultiRenderTarget.prototype._createTextures = function () {
  60169. this._textures = [];
  60170. for (var i = 0; i < this._internalTextures.length; i++) {
  60171. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  60172. texture._texture = this._internalTextures[i];
  60173. this._textures.push(texture);
  60174. }
  60175. // Keeps references to frame buffer and stencil/depth buffer
  60176. this._texture = this._internalTextures[0];
  60177. };
  60178. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  60179. /**
  60180. * Define the number of samples used if MSAA is enabled.
  60181. */
  60182. get: function () {
  60183. return this._samples;
  60184. },
  60185. set: function (value) {
  60186. if (this._samples === value) {
  60187. return;
  60188. }
  60189. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  60190. },
  60191. enumerable: true,
  60192. configurable: true
  60193. });
  60194. /**
  60195. * Resize all the textures in the multi render target.
  60196. * Be carrefull as it will recreate all the data in the new texture.
  60197. * @param size Define the new size
  60198. */
  60199. MultiRenderTarget.prototype.resize = function (size) {
  60200. this.releaseInternalTextures();
  60201. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  60202. this._createInternalTextures();
  60203. };
  60204. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  60205. var _this = this;
  60206. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  60207. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  60208. });
  60209. };
  60210. /**
  60211. * Dispose the render targets and their associated resources
  60212. */
  60213. MultiRenderTarget.prototype.dispose = function () {
  60214. this.releaseInternalTextures();
  60215. _super.prototype.dispose.call(this);
  60216. };
  60217. /**
  60218. * Release all the underlying texture used as draw buffers.
  60219. */
  60220. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  60221. if (!this._internalTextures) {
  60222. return;
  60223. }
  60224. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  60225. if (this._internalTextures[i] !== undefined) {
  60226. this._internalTextures[i].dispose();
  60227. this._internalTextures.splice(i, 1);
  60228. }
  60229. }
  60230. };
  60231. return MultiRenderTarget;
  60232. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  60233. /***/ }),
  60234. /***/ "./Materials/Textures/rawCubeTexture.ts":
  60235. /*!**********************************************!*\
  60236. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  60237. \**********************************************/
  60238. /*! exports provided: RawCubeTexture */
  60239. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60240. "use strict";
  60241. __webpack_require__.r(__webpack_exports__);
  60242. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  60243. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60244. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  60245. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  60246. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  60247. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  60248. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60249. /**
  60250. * Raw cube texture where the raw buffers are passed in
  60251. */
  60252. var RawCubeTexture = /** @class */ (function (_super) {
  60253. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  60254. /**
  60255. * Creates a cube texture where the raw buffers are passed in.
  60256. * @param scene defines the scene the texture is attached to
  60257. * @param data defines the array of data to use to create each face
  60258. * @param size defines the size of the textures
  60259. * @param format defines the format of the data
  60260. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  60261. * @param generateMipMaps defines if the engine should generate the mip levels
  60262. * @param invertY defines if data must be stored with Y axis inverted
  60263. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  60264. * @param compression defines the compression used (null by default)
  60265. */
  60266. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  60267. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  60268. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60269. if (generateMipMaps === void 0) { generateMipMaps = false; }
  60270. if (invertY === void 0) { invertY = false; }
  60271. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60272. if (compression === void 0) { compression = null; }
  60273. var _this = _super.call(this, "", scene) || this;
  60274. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  60275. return _this;
  60276. }
  60277. /**
  60278. * Updates the raw cube texture.
  60279. * @param data defines the data to store
  60280. * @param format defines the data format
  60281. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60282. * @param invertY defines if data must be stored with Y axis inverted
  60283. * @param compression defines the compression used (null by default)
  60284. * @param level defines which level of the texture to update
  60285. */
  60286. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  60287. if (compression === void 0) { compression = null; }
  60288. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  60289. };
  60290. /**
  60291. * Updates a raw cube texture with RGBD encoded data.
  60292. * @param data defines the array of data [mipmap][face] to use to create each face
  60293. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  60294. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  60295. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  60296. * @returns a promsie that resolves when the operation is complete
  60297. */
  60298. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  60299. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  60300. if (lodScale === void 0) { lodScale = 0.8; }
  60301. if (lodOffset === void 0) { lodOffset = 0; }
  60302. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  60303. };
  60304. /**
  60305. * Clones the raw cube texture.
  60306. * @return a new cube texture
  60307. */
  60308. RawCubeTexture.prototype.clone = function () {
  60309. var _this = this;
  60310. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  60311. var scene = _this.getScene();
  60312. var internalTexture = _this._texture;
  60313. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  60314. if (internalTexture.dataSource === _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  60315. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  60316. }
  60317. return texture;
  60318. }, this);
  60319. };
  60320. /** @hidden */
  60321. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  60322. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  60323. internalTexture._bufferViewArrayArray = data;
  60324. internalTexture._lodGenerationScale = lodScale;
  60325. internalTexture._lodGenerationOffset = lodOffset;
  60326. internalTexture._sphericalPolynomial = sphericalPolynomial;
  60327. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  60328. internalTexture.isReady = true;
  60329. });
  60330. };
  60331. return RawCubeTexture;
  60332. }(_Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  60333. /***/ }),
  60334. /***/ "./Materials/Textures/rawTexture.ts":
  60335. /*!******************************************!*\
  60336. !*** ./Materials/Textures/rawTexture.ts ***!
  60337. \******************************************/
  60338. /*! exports provided: RawTexture */
  60339. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60340. "use strict";
  60341. __webpack_require__.r(__webpack_exports__);
  60342. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  60343. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60344. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60345. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60346. /**
  60347. * Raw texture can help creating a texture directly from an array of data.
  60348. * This can be super useful if you either get the data from an uncompressed source or
  60349. * if you wish to create your texture pixel by pixel.
  60350. */
  60351. var RawTexture = /** @class */ (function (_super) {
  60352. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  60353. /**
  60354. * Instantiates a new RawTexture.
  60355. * Raw texture can help creating a texture directly from an array of data.
  60356. * This can be super useful if you either get the data from an uncompressed source or
  60357. * if you wish to create your texture pixel by pixel.
  60358. * @param data define the array of data to use to create the texture
  60359. * @param width define the width of the texture
  60360. * @param height define the height of the texture
  60361. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  60362. * @param scene define the scene the texture belongs to
  60363. * @param generateMipMaps define whether mip maps should be generated or not
  60364. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60365. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60366. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  60367. */
  60368. function RawTexture(data, width, height,
  60369. /**
  60370. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  60371. */
  60372. format, scene, generateMipMaps, invertY, samplingMode, type) {
  60373. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60374. if (invertY === void 0) { invertY = false; }
  60375. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60376. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60377. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  60378. _this.format = format;
  60379. _this._engine = scene.getEngine();
  60380. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  60381. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  60382. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  60383. return _this;
  60384. }
  60385. /**
  60386. * Updates the texture underlying data.
  60387. * @param data Define the new data of the texture
  60388. */
  60389. RawTexture.prototype.update = function (data) {
  60390. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  60391. };
  60392. /**
  60393. * Creates a luminance texture from some data.
  60394. * @param data Define the texture data
  60395. * @param width Define the width of the texture
  60396. * @param height Define the height of the texture
  60397. * @param scene Define the scene the texture belongs to
  60398. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60399. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60400. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60401. * @returns the luminance texture
  60402. */
  60403. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  60404. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60405. if (invertY === void 0) { invertY = false; }
  60406. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60407. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  60408. };
  60409. /**
  60410. * Creates a luminance alpha texture from some data.
  60411. * @param data Define the texture data
  60412. * @param width Define the width of the texture
  60413. * @param height Define the height of the texture
  60414. * @param scene Define the scene the texture belongs to
  60415. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60416. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60417. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60418. * @returns the luminance alpha texture
  60419. */
  60420. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  60421. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60422. if (invertY === void 0) { invertY = false; }
  60423. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60424. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  60425. };
  60426. /**
  60427. * Creates an alpha texture from some data.
  60428. * @param data Define the texture data
  60429. * @param width Define the width of the texture
  60430. * @param height Define the height of the texture
  60431. * @param scene Define the scene the texture belongs to
  60432. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60433. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60434. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60435. * @returns the alpha texture
  60436. */
  60437. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  60438. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60439. if (invertY === void 0) { invertY = false; }
  60440. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60441. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  60442. };
  60443. /**
  60444. * Creates a RGB texture from some data.
  60445. * @param data Define the texture data
  60446. * @param width Define the width of the texture
  60447. * @param height Define the height of the texture
  60448. * @param scene Define the scene the texture belongs to
  60449. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60450. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60451. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60452. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  60453. * @returns the RGB alpha texture
  60454. */
  60455. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  60456. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60457. if (invertY === void 0) { invertY = false; }
  60458. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60459. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60460. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  60461. };
  60462. /**
  60463. * Creates a RGBA texture from some data.
  60464. * @param data Define the texture data
  60465. * @param width Define the width of the texture
  60466. * @param height Define the height of the texture
  60467. * @param scene Define the scene the texture belongs to
  60468. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60469. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60470. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60471. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  60472. * @returns the RGBA texture
  60473. */
  60474. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  60475. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60476. if (invertY === void 0) { invertY = false; }
  60477. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  60478. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60479. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  60480. };
  60481. /**
  60482. * Creates a R texture from some data.
  60483. * @param data Define the texture data
  60484. * @param width Define the width of the texture
  60485. * @param height Define the height of the texture
  60486. * @param scene Define the scene the texture belongs to
  60487. * @param generateMipMaps Define whether or not to create mip maps for the texture
  60488. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  60489. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  60490. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  60491. * @returns the R texture
  60492. */
  60493. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  60494. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60495. if (invertY === void 0) { invertY = false; }
  60496. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  60497. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  60498. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  60499. };
  60500. return RawTexture;
  60501. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  60502. /***/ }),
  60503. /***/ "./Materials/Textures/rawTexture3D.ts":
  60504. /*!********************************************!*\
  60505. !*** ./Materials/Textures/rawTexture3D.ts ***!
  60506. \********************************************/
  60507. /*! exports provided: RawTexture3D */
  60508. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60509. "use strict";
  60510. __webpack_require__.r(__webpack_exports__);
  60511. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  60512. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60513. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60514. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60515. /**
  60516. * Class used to store 3D textures containing user data
  60517. */
  60518. var RawTexture3D = /** @class */ (function (_super) {
  60519. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  60520. /**
  60521. * Create a new RawTexture3D
  60522. * @param data defines the data of the texture
  60523. * @param width defines the width of the texture
  60524. * @param height defines the height of the texture
  60525. * @param depth defines the depth of the texture
  60526. * @param format defines the texture format to use
  60527. * @param scene defines the hosting scene
  60528. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  60529. * @param invertY defines if texture must be stored with Y axis inverted
  60530. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60531. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  60532. */
  60533. function RawTexture3D(data, width, height, depth,
  60534. /** Gets or sets the texture format to use */
  60535. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  60536. if (generateMipMaps === void 0) { generateMipMaps = true; }
  60537. if (invertY === void 0) { invertY = false; }
  60538. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  60539. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60540. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  60541. _this.format = format;
  60542. _this._engine = scene.getEngine();
  60543. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  60544. _this.is3D = true;
  60545. return _this;
  60546. }
  60547. /**
  60548. * Update the texture with new data
  60549. * @param data defines the data to store in the texture
  60550. */
  60551. RawTexture3D.prototype.update = function (data) {
  60552. if (!this._texture) {
  60553. return;
  60554. }
  60555. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  60556. };
  60557. return RawTexture3D;
  60558. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  60559. /***/ }),
  60560. /***/ "./Materials/Textures/refractionTexture.ts":
  60561. /*!*************************************************!*\
  60562. !*** ./Materials/Textures/refractionTexture.ts ***!
  60563. \*************************************************/
  60564. /*! exports provided: RefractionTexture */
  60565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60566. "use strict";
  60567. __webpack_require__.r(__webpack_exports__);
  60568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  60569. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60570. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  60571. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  60572. /**
  60573. * Creates a refraction texture used by refraction channel of the standard material.
  60574. * It is like a mirror but to see through a material.
  60575. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60576. */
  60577. var RefractionTexture = /** @class */ (function (_super) {
  60578. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  60579. /**
  60580. * Creates a refraction texture used by refraction channel of the standard material.
  60581. * It is like a mirror but to see through a material.
  60582. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60583. * @param name Define the texture name
  60584. * @param size Define the size of the underlying texture
  60585. * @param scene Define the scene the refraction belongs to
  60586. * @param generateMipMaps Define if we need to generate mips level for the refraction
  60587. */
  60588. function RefractionTexture(name, size, scene, generateMipMaps) {
  60589. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  60590. /**
  60591. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  60592. * 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.
  60593. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  60594. */
  60595. _this.refractionPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  60596. /**
  60597. * Define how deep under the surface we should see.
  60598. */
  60599. _this.depth = 2.0;
  60600. _this.onBeforeRenderObservable.add(function () {
  60601. scene.clipPlane = _this.refractionPlane;
  60602. });
  60603. _this.onAfterRenderObservable.add(function () {
  60604. delete scene.clipPlane;
  60605. });
  60606. return _this;
  60607. }
  60608. /**
  60609. * Clone the refraction texture.
  60610. * @returns the cloned texture
  60611. */
  60612. RefractionTexture.prototype.clone = function () {
  60613. var scene = this.getScene();
  60614. if (!scene) {
  60615. return this;
  60616. }
  60617. var textureSize = this.getSize();
  60618. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  60619. // Base texture
  60620. newTexture.hasAlpha = this.hasAlpha;
  60621. newTexture.level = this.level;
  60622. // Refraction Texture
  60623. newTexture.refractionPlane = this.refractionPlane.clone();
  60624. if (this.renderList) {
  60625. newTexture.renderList = this.renderList.slice(0);
  60626. }
  60627. newTexture.depth = this.depth;
  60628. return newTexture;
  60629. };
  60630. /**
  60631. * Serialize the texture to a JSON representation you could use in Parse later on
  60632. * @returns the serialized JSON representation
  60633. */
  60634. RefractionTexture.prototype.serialize = function () {
  60635. if (!this.name) {
  60636. return null;
  60637. }
  60638. var serializationObject = _super.prototype.serialize.call(this);
  60639. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  60640. serializationObject.depth = this.depth;
  60641. return serializationObject;
  60642. };
  60643. return RefractionTexture;
  60644. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  60645. /***/ }),
  60646. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  60647. /*!***********************************************************!*\
  60648. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  60649. \***********************************************************/
  60650. /*! exports provided: RenderTargetCreationOptions */
  60651. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60652. "use strict";
  60653. __webpack_require__.r(__webpack_exports__);
  60654. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  60655. /**
  60656. * Define options used to create a render target texture
  60657. */
  60658. var RenderTargetCreationOptions = /** @class */ (function () {
  60659. function RenderTargetCreationOptions() {
  60660. }
  60661. return RenderTargetCreationOptions;
  60662. }());
  60663. /***/ }),
  60664. /***/ "./Materials/Textures/renderTargetTexture.ts":
  60665. /*!***************************************************!*\
  60666. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  60667. \***************************************************/
  60668. /*! exports provided: RenderTargetTexture */
  60669. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60670. "use strict";
  60671. __webpack_require__.r(__webpack_exports__);
  60672. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  60673. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  60674. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  60675. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  60676. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  60677. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  60678. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  60679. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  60680. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  60681. /**
  60682. * This Helps creating a texture that will be created from a camera in your scene.
  60683. * It is basically a dynamic texture that could be used to create special effects for instance.
  60684. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  60685. */
  60686. var RenderTargetTexture = /** @class */ (function (_super) {
  60687. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  60688. /**
  60689. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  60690. * or used a shadow, depth texture...
  60691. * @param name The friendly name of the texture
  60692. * @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)
  60693. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  60694. * @param generateMipMaps True if mip maps need to be generated after render.
  60695. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  60696. * @param type The type of the buffer in the RTT (int, half float, float...)
  60697. * @param isCube True if a cube texture needs to be created
  60698. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  60699. * @param generateDepthBuffer True to generate a depth buffer
  60700. * @param generateStencilBuffer True to generate a stencil buffer
  60701. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  60702. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  60703. * @param delayAllocation if the texture allocation should be delayed (default: false)
  60704. */
  60705. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  60706. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  60707. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  60708. if (isCube === void 0) { isCube = false; }
  60709. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  60710. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  60711. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  60712. if (isMulti === void 0) { isMulti = false; }
  60713. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  60714. if (delayAllocation === void 0) { delayAllocation = false; }
  60715. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  60716. _this.isCube = isCube;
  60717. /**
  60718. * Define if particles should be rendered in your texture.
  60719. */
  60720. _this.renderParticles = true;
  60721. /**
  60722. * Define if sprites should be rendered in your texture.
  60723. */
  60724. _this.renderSprites = false;
  60725. /**
  60726. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  60727. */
  60728. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].PROJECTION_MODE;
  60729. /**
  60730. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  60731. */
  60732. _this.ignoreCameraViewport = false;
  60733. /**
  60734. * An event triggered when the texture is unbind.
  60735. */
  60736. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60737. /**
  60738. * An event triggered when the texture is unbind.
  60739. */
  60740. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60741. /**
  60742. * An event triggered before rendering the texture
  60743. */
  60744. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60745. /**
  60746. * An event triggered after rendering the texture
  60747. */
  60748. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60749. /**
  60750. * An event triggered after the texture clear
  60751. */
  60752. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  60753. _this._currentRefreshId = -1;
  60754. _this._refreshRate = 1;
  60755. _this._samples = 1;
  60756. /**
  60757. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  60758. * It must define where the camera used to render the texture is set
  60759. */
  60760. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  60761. scene = _this.getScene();
  60762. if (!scene) {
  60763. return _this;
  60764. }
  60765. _this.renderList = new Array();
  60766. _this._engine = scene.getEngine();
  60767. _this.name = name;
  60768. _this.isRenderTarget = true;
  60769. _this._initialSizeParameter = size;
  60770. _this._processSizeParameter(size);
  60771. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  60772. });
  60773. _this._generateMipMaps = generateMipMaps ? true : false;
  60774. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  60775. // Rendering groups
  60776. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__["RenderingManager"](scene);
  60777. _this._renderingManager._useSceneAutoClearSetup = true;
  60778. if (isMulti) {
  60779. return _this;
  60780. }
  60781. _this._renderTargetOptions = {
  60782. generateMipMaps: generateMipMaps,
  60783. type: type,
  60784. format: format,
  60785. samplingMode: samplingMode,
  60786. generateDepthBuffer: generateDepthBuffer,
  60787. generateStencilBuffer: generateStencilBuffer
  60788. };
  60789. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].NEAREST_SAMPLINGMODE) {
  60790. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  60791. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  60792. }
  60793. if (!delayAllocation) {
  60794. if (isCube) {
  60795. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  60796. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].INVCUBIC_MODE;
  60797. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  60798. }
  60799. else {
  60800. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  60801. }
  60802. }
  60803. return _this;
  60804. }
  60805. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  60806. /**
  60807. * Use this list to define the list of mesh you want to render.
  60808. */
  60809. get: function () {
  60810. return this._renderList;
  60811. },
  60812. set: function (value) {
  60813. this._renderList = value;
  60814. if (this._renderList) {
  60815. this._hookArray(this._renderList);
  60816. }
  60817. },
  60818. enumerable: true,
  60819. configurable: true
  60820. });
  60821. RenderTargetTexture.prototype._hookArray = function (array) {
  60822. var _this = this;
  60823. var oldPush = array.push;
  60824. array.push = function () {
  60825. var items = [];
  60826. for (var _i = 0; _i < arguments.length; _i++) {
  60827. items[_i] = arguments[_i];
  60828. }
  60829. var wasEmpty = array.length === 0;
  60830. var result = oldPush.apply(array, items);
  60831. if (wasEmpty) {
  60832. _this.getScene().meshes.forEach(function (mesh) {
  60833. mesh._markSubMeshesAsLightDirty();
  60834. });
  60835. }
  60836. return result;
  60837. };
  60838. var oldSplice = array.splice;
  60839. array.splice = function (index, deleteCount) {
  60840. var deleted = oldSplice.apply(array, [index, deleteCount]);
  60841. if (array.length === 0) {
  60842. _this.getScene().meshes.forEach(function (mesh) {
  60843. mesh._markSubMeshesAsLightDirty();
  60844. });
  60845. }
  60846. return deleted;
  60847. };
  60848. };
  60849. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  60850. /**
  60851. * Set a after unbind callback in the texture.
  60852. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  60853. */
  60854. set: function (callback) {
  60855. if (this._onAfterUnbindObserver) {
  60856. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  60857. }
  60858. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  60859. },
  60860. enumerable: true,
  60861. configurable: true
  60862. });
  60863. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  60864. /**
  60865. * Set a before render callback in the texture.
  60866. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  60867. */
  60868. set: function (callback) {
  60869. if (this._onBeforeRenderObserver) {
  60870. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  60871. }
  60872. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  60873. },
  60874. enumerable: true,
  60875. configurable: true
  60876. });
  60877. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  60878. /**
  60879. * Set a after render callback in the texture.
  60880. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  60881. */
  60882. set: function (callback) {
  60883. if (this._onAfterRenderObserver) {
  60884. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  60885. }
  60886. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  60887. },
  60888. enumerable: true,
  60889. configurable: true
  60890. });
  60891. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  60892. /**
  60893. * Set a clear callback in the texture.
  60894. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  60895. */
  60896. set: function (callback) {
  60897. if (this._onClearObserver) {
  60898. this.onClearObservable.remove(this._onClearObserver);
  60899. }
  60900. this._onClearObserver = this.onClearObservable.add(callback);
  60901. },
  60902. enumerable: true,
  60903. configurable: true
  60904. });
  60905. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  60906. /**
  60907. * Gets render target creation options that were used.
  60908. */
  60909. get: function () {
  60910. return this._renderTargetOptions;
  60911. },
  60912. enumerable: true,
  60913. configurable: true
  60914. });
  60915. RenderTargetTexture.prototype._onRatioRescale = function () {
  60916. if (this._sizeRatio) {
  60917. this.resize(this._initialSizeParameter);
  60918. }
  60919. };
  60920. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  60921. get: function () {
  60922. return this._boundingBoxSize;
  60923. },
  60924. /**
  60925. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  60926. * When defined, the cubemap will switch to local mode
  60927. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60928. * @example https://www.babylonjs-playground.com/#RNASML
  60929. */
  60930. set: function (value) {
  60931. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  60932. return;
  60933. }
  60934. this._boundingBoxSize = value;
  60935. var scene = this.getScene();
  60936. if (scene) {
  60937. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  60938. }
  60939. },
  60940. enumerable: true,
  60941. configurable: true
  60942. });
  60943. /**
  60944. * Creates a depth stencil texture.
  60945. * This is only available in WebGL 2 or with the depth texture extension available.
  60946. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  60947. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  60948. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  60949. */
  60950. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  60951. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  60952. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  60953. if (generateStencil === void 0) { generateStencil = false; }
  60954. if (!this.getScene()) {
  60955. return;
  60956. }
  60957. var engine = this.getScene().getEngine();
  60958. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  60959. bilinearFiltering: bilinearFiltering,
  60960. comparisonFunction: comparisonFunction,
  60961. generateStencil: generateStencil,
  60962. isCube: this.isCube
  60963. });
  60964. engine.setFrameBufferDepthStencilTexture(this);
  60965. };
  60966. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  60967. if (size.ratio) {
  60968. this._sizeRatio = size.ratio;
  60969. this._size = {
  60970. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  60971. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  60972. };
  60973. }
  60974. else {
  60975. this._size = size;
  60976. }
  60977. };
  60978. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  60979. /**
  60980. * Define the number of samples to use in case of MSAA.
  60981. * It defaults to one meaning no MSAA has been enabled.
  60982. */
  60983. get: function () {
  60984. return this._samples;
  60985. },
  60986. set: function (value) {
  60987. if (this._samples === value) {
  60988. return;
  60989. }
  60990. var scene = this.getScene();
  60991. if (!scene) {
  60992. return;
  60993. }
  60994. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  60995. },
  60996. enumerable: true,
  60997. configurable: true
  60998. });
  60999. /**
  61000. * Resets the refresh counter of the texture and start bak from scratch.
  61001. * Could be useful to regenerate the texture if it is setup to render only once.
  61002. */
  61003. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  61004. this._currentRefreshId = -1;
  61005. };
  61006. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  61007. /**
  61008. * Define the refresh rate of the texture or the rendering frequency.
  61009. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  61010. */
  61011. get: function () {
  61012. return this._refreshRate;
  61013. },
  61014. set: function (value) {
  61015. this._refreshRate = value;
  61016. this.resetRefreshCounter();
  61017. },
  61018. enumerable: true,
  61019. configurable: true
  61020. });
  61021. /**
  61022. * Adds a post process to the render target rendering passes.
  61023. * @param postProcess define the post process to add
  61024. */
  61025. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  61026. if (!this._postProcessManager) {
  61027. var scene = this.getScene();
  61028. if (!scene) {
  61029. return;
  61030. }
  61031. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__["PostProcessManager"](scene);
  61032. this._postProcesses = new Array();
  61033. }
  61034. this._postProcesses.push(postProcess);
  61035. this._postProcesses[0].autoClear = false;
  61036. };
  61037. /**
  61038. * Clear all the post processes attached to the render target
  61039. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  61040. */
  61041. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  61042. if (dispose === void 0) { dispose = false; }
  61043. if (!this._postProcesses) {
  61044. return;
  61045. }
  61046. if (dispose) {
  61047. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  61048. var postProcess = _a[_i];
  61049. postProcess.dispose();
  61050. }
  61051. }
  61052. this._postProcesses = [];
  61053. };
  61054. /**
  61055. * Remove one of the post process from the list of attached post processes to the texture
  61056. * @param postProcess define the post process to remove from the list
  61057. */
  61058. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  61059. if (!this._postProcesses) {
  61060. return;
  61061. }
  61062. var index = this._postProcesses.indexOf(postProcess);
  61063. if (index === -1) {
  61064. return;
  61065. }
  61066. this._postProcesses.splice(index, 1);
  61067. if (this._postProcesses.length > 0) {
  61068. this._postProcesses[0].autoClear = false;
  61069. }
  61070. };
  61071. /** @hidden */
  61072. RenderTargetTexture.prototype._shouldRender = function () {
  61073. if (this._currentRefreshId === -1) { // At least render once
  61074. this._currentRefreshId = 1;
  61075. return true;
  61076. }
  61077. if (this.refreshRate === this._currentRefreshId) {
  61078. this._currentRefreshId = 1;
  61079. return true;
  61080. }
  61081. this._currentRefreshId++;
  61082. return false;
  61083. };
  61084. /**
  61085. * Gets the actual render size of the texture.
  61086. * @returns the width of the render size
  61087. */
  61088. RenderTargetTexture.prototype.getRenderSize = function () {
  61089. return this.getRenderWidth();
  61090. };
  61091. /**
  61092. * Gets the actual render width of the texture.
  61093. * @returns the width of the render size
  61094. */
  61095. RenderTargetTexture.prototype.getRenderWidth = function () {
  61096. if (this._size.width) {
  61097. return this._size.width;
  61098. }
  61099. return this._size;
  61100. };
  61101. /**
  61102. * Gets the actual render height of the texture.
  61103. * @returns the height of the render size
  61104. */
  61105. RenderTargetTexture.prototype.getRenderHeight = function () {
  61106. if (this._size.width) {
  61107. return this._size.height;
  61108. }
  61109. return this._size;
  61110. };
  61111. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  61112. /**
  61113. * Get if the texture can be rescaled or not.
  61114. */
  61115. get: function () {
  61116. return true;
  61117. },
  61118. enumerable: true,
  61119. configurable: true
  61120. });
  61121. /**
  61122. * Resize the texture using a ratio.
  61123. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  61124. */
  61125. RenderTargetTexture.prototype.scale = function (ratio) {
  61126. var newSize = this.getRenderSize() * ratio;
  61127. this.resize(newSize);
  61128. };
  61129. /**
  61130. * Get the texture reflection matrix used to rotate/transform the reflection.
  61131. * @returns the reflection matrix
  61132. */
  61133. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  61134. if (this.isCube) {
  61135. return this._textureMatrix;
  61136. }
  61137. return _super.prototype.getReflectionTextureMatrix.call(this);
  61138. };
  61139. /**
  61140. * Resize the texture to a new desired size.
  61141. * Be carrefull as it will recreate all the data in the new texture.
  61142. * @param size Define the new size. It can be:
  61143. * - a number for squared texture,
  61144. * - an object containing { width: number, height: number }
  61145. * - or an object containing a ratio { ratio: number }
  61146. */
  61147. RenderTargetTexture.prototype.resize = function (size) {
  61148. var wasCube = this.isCube;
  61149. this.releaseInternalTexture();
  61150. var scene = this.getScene();
  61151. if (!scene) {
  61152. return;
  61153. }
  61154. this._processSizeParameter(size);
  61155. if (wasCube) {
  61156. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  61157. }
  61158. else {
  61159. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  61160. }
  61161. };
  61162. /**
  61163. * Renders all the objects from the render list into the texture.
  61164. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  61165. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  61166. */
  61167. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  61168. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  61169. if (dumpForDebug === void 0) { dumpForDebug = false; }
  61170. var scene = this.getScene();
  61171. if (!scene) {
  61172. return;
  61173. }
  61174. var engine = scene.getEngine();
  61175. if (this.useCameraPostProcesses !== undefined) {
  61176. useCameraPostProcess = this.useCameraPostProcesses;
  61177. }
  61178. if (this._waitingRenderList) {
  61179. this.renderList = [];
  61180. for (var index = 0; index < this._waitingRenderList.length; index++) {
  61181. var id = this._waitingRenderList[index];
  61182. var mesh_1 = scene.getMeshByID(id);
  61183. if (mesh_1) {
  61184. this.renderList.push(mesh_1);
  61185. }
  61186. }
  61187. delete this._waitingRenderList;
  61188. }
  61189. // Is predicate defined?
  61190. if (this.renderListPredicate) {
  61191. if (this.renderList) {
  61192. this.renderList.length = 0; // Clear previous renderList
  61193. }
  61194. else {
  61195. this.renderList = [];
  61196. }
  61197. var scene = this.getScene();
  61198. if (!scene) {
  61199. return;
  61200. }
  61201. var sceneMeshes = scene.meshes;
  61202. for (var index = 0; index < sceneMeshes.length; index++) {
  61203. var mesh = sceneMeshes[index];
  61204. if (this.renderListPredicate(mesh)) {
  61205. this.renderList.push(mesh);
  61206. }
  61207. }
  61208. }
  61209. this.onBeforeBindObservable.notifyObservers(this);
  61210. // Set custom projection.
  61211. // Needs to be before binding to prevent changing the aspect ratio.
  61212. var camera;
  61213. if (this.activeCamera) {
  61214. camera = this.activeCamera;
  61215. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  61216. if (this.activeCamera !== scene.activeCamera) {
  61217. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  61218. }
  61219. }
  61220. else {
  61221. camera = scene.activeCamera;
  61222. if (camera) {
  61223. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  61224. }
  61225. }
  61226. // Prepare renderingManager
  61227. this._renderingManager.reset();
  61228. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  61229. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  61230. var sceneRenderId = scene.getRenderId();
  61231. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  61232. var mesh = currentRenderList[meshIndex];
  61233. if (mesh) {
  61234. if (!mesh.isReady(this.refreshRate === 0)) {
  61235. this.resetRefreshCounter();
  61236. continue;
  61237. }
  61238. mesh._preActivateForIntermediateRendering(sceneRenderId);
  61239. var isMasked = void 0;
  61240. if (!this.renderList && camera) {
  61241. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  61242. }
  61243. else {
  61244. isMasked = false;
  61245. }
  61246. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  61247. mesh._activate(sceneRenderId);
  61248. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  61249. var subMesh = mesh.subMeshes[subIndex];
  61250. scene._activeIndices.addCount(subMesh.indexCount, false);
  61251. this._renderingManager.dispatch(subMesh, mesh);
  61252. }
  61253. }
  61254. }
  61255. }
  61256. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  61257. var particleSystem = scene.particleSystems[particleIndex];
  61258. var emitter = particleSystem.emitter;
  61259. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  61260. continue;
  61261. }
  61262. if (currentRenderList.indexOf(emitter) >= 0) {
  61263. this._renderingManager.dispatchParticles(particleSystem);
  61264. }
  61265. }
  61266. if (this.isCube) {
  61267. for (var face = 0; face < 6; face++) {
  61268. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  61269. scene.incrementRenderId();
  61270. scene.resetCachedMaterial();
  61271. }
  61272. }
  61273. else {
  61274. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  61275. }
  61276. this.onAfterUnbindObservable.notifyObservers(this);
  61277. if (scene.activeCamera) {
  61278. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  61279. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  61280. }
  61281. engine.setViewport(scene.activeCamera.viewport);
  61282. }
  61283. scene.resetCachedMaterial();
  61284. };
  61285. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  61286. var minimum = 128;
  61287. var x = renderDimension * scale;
  61288. var curved = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  61289. // Ensure we don't exceed the render dimension (while staying POT)
  61290. return Math.min(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].FloorPOT(renderDimension), curved);
  61291. };
  61292. /**
  61293. * @hidden
  61294. * @param faceIndex face index to bind to if this is a cubetexture
  61295. */
  61296. RenderTargetTexture.prototype._bindFrameBuffer = function (faceIndex) {
  61297. if (faceIndex === void 0) { faceIndex = 0; }
  61298. var scene = this.getScene();
  61299. if (!scene) {
  61300. return;
  61301. }
  61302. var engine = scene.getEngine();
  61303. if (this._texture) {
  61304. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  61305. }
  61306. };
  61307. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  61308. var _this = this;
  61309. if (!this._texture) {
  61310. return;
  61311. }
  61312. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  61313. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  61314. });
  61315. };
  61316. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  61317. var scene = this.getScene();
  61318. if (!scene) {
  61319. return;
  61320. }
  61321. var engine = scene.getEngine();
  61322. if (!this._texture) {
  61323. return;
  61324. }
  61325. // Bind
  61326. if (this._postProcessManager) {
  61327. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  61328. }
  61329. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  61330. this._bindFrameBuffer(faceIndex);
  61331. }
  61332. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  61333. // Clear
  61334. if (this.onClearObservable.hasObservers()) {
  61335. this.onClearObservable.notifyObservers(engine);
  61336. }
  61337. else {
  61338. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  61339. }
  61340. if (!this._doNotChangeAspectRatio) {
  61341. scene.updateTransformMatrix(true);
  61342. }
  61343. // Before Camera Draw
  61344. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  61345. var step = _a[_i];
  61346. step.action(this);
  61347. }
  61348. // Render
  61349. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  61350. // After Camera Draw
  61351. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  61352. var step = _c[_b];
  61353. step.action(this);
  61354. }
  61355. if (this._postProcessManager) {
  61356. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  61357. }
  61358. else if (useCameraPostProcess) {
  61359. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  61360. }
  61361. if (!this._doNotChangeAspectRatio) {
  61362. scene.updateTransformMatrix(true);
  61363. }
  61364. // Dump ?
  61365. if (dumpForDebug) {
  61366. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  61367. }
  61368. // Unbind
  61369. if (!this.isCube || faceIndex === 5) {
  61370. if (this.isCube) {
  61371. if (faceIndex === 5) {
  61372. engine.generateMipMapsForCubemap(this._texture);
  61373. }
  61374. }
  61375. this.unbindFrameBuffer(engine, faceIndex);
  61376. }
  61377. else {
  61378. this.onAfterRenderObservable.notifyObservers(faceIndex);
  61379. }
  61380. };
  61381. /**
  61382. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  61383. * This allowed control for front to back rendering or reversly depending of the special needs.
  61384. *
  61385. * @param renderingGroupId The rendering group id corresponding to its index
  61386. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  61387. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  61388. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  61389. */
  61390. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  61391. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  61392. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  61393. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  61394. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  61395. };
  61396. /**
  61397. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  61398. *
  61399. * @param renderingGroupId The rendering group id corresponding to its index
  61400. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61401. */
  61402. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  61403. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  61404. this._renderingManager._useSceneAutoClearSetup = false;
  61405. };
  61406. /**
  61407. * Clones the texture.
  61408. * @returns the cloned texture
  61409. */
  61410. RenderTargetTexture.prototype.clone = function () {
  61411. var textureSize = this.getSize();
  61412. 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);
  61413. // Base texture
  61414. newTexture.hasAlpha = this.hasAlpha;
  61415. newTexture.level = this.level;
  61416. // RenderTarget Texture
  61417. newTexture.coordinatesMode = this.coordinatesMode;
  61418. if (this.renderList) {
  61419. newTexture.renderList = this.renderList.slice(0);
  61420. }
  61421. return newTexture;
  61422. };
  61423. /**
  61424. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  61425. * @returns The JSON representation of the texture
  61426. */
  61427. RenderTargetTexture.prototype.serialize = function () {
  61428. if (!this.name) {
  61429. return null;
  61430. }
  61431. var serializationObject = _super.prototype.serialize.call(this);
  61432. serializationObject.renderTargetSize = this.getRenderSize();
  61433. serializationObject.renderList = [];
  61434. if (this.renderList) {
  61435. for (var index = 0; index < this.renderList.length; index++) {
  61436. serializationObject.renderList.push(this.renderList[index].id);
  61437. }
  61438. }
  61439. return serializationObject;
  61440. };
  61441. /**
  61442. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  61443. */
  61444. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  61445. var objBuffer = this.getInternalTexture();
  61446. var scene = this.getScene();
  61447. if (objBuffer && scene) {
  61448. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  61449. }
  61450. };
  61451. /**
  61452. * Dispose the texture and release its associated resources.
  61453. */
  61454. RenderTargetTexture.prototype.dispose = function () {
  61455. if (this._postProcessManager) {
  61456. this._postProcessManager.dispose();
  61457. this._postProcessManager = null;
  61458. }
  61459. this.clearPostProcesses(true);
  61460. if (this._resizeObserver) {
  61461. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  61462. this._resizeObserver = null;
  61463. }
  61464. this.renderList = null;
  61465. // Remove from custom render targets
  61466. var scene = this.getScene();
  61467. if (!scene) {
  61468. return;
  61469. }
  61470. var index = scene.customRenderTargets.indexOf(this);
  61471. if (index >= 0) {
  61472. scene.customRenderTargets.splice(index, 1);
  61473. }
  61474. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  61475. var camera = _a[_i];
  61476. index = camera.customRenderTargets.indexOf(this);
  61477. if (index >= 0) {
  61478. camera.customRenderTargets.splice(index, 1);
  61479. }
  61480. }
  61481. _super.prototype.dispose.call(this);
  61482. };
  61483. /** @hidden */
  61484. RenderTargetTexture.prototype._rebuild = function () {
  61485. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  61486. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  61487. }
  61488. if (this._postProcessManager) {
  61489. this._postProcessManager._rebuild();
  61490. }
  61491. };
  61492. /**
  61493. * Clear the info related to rendering groups preventing retention point in material dispose.
  61494. */
  61495. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  61496. if (this._renderingManager) {
  61497. this._renderingManager.freeRenderingGroups();
  61498. }
  61499. };
  61500. /**
  61501. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  61502. * @returns the view count
  61503. */
  61504. RenderTargetTexture.prototype.getViewCount = function () {
  61505. return 1;
  61506. };
  61507. /**
  61508. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  61509. */
  61510. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  61511. /**
  61512. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  61513. */
  61514. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  61515. /**
  61516. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  61517. * the central point of your effect and can save a lot of performances.
  61518. */
  61519. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  61520. return RenderTargetTexture;
  61521. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  61522. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  61523. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  61524. };
  61525. /***/ }),
  61526. /***/ "./Materials/Textures/texture.ts":
  61527. /*!***************************************!*\
  61528. !*** ./Materials/Textures/texture.ts ***!
  61529. \***************************************/
  61530. /*! exports provided: Texture */
  61531. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61532. "use strict";
  61533. __webpack_require__.r(__webpack_exports__);
  61534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  61535. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61536. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  61537. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  61538. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  61539. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  61540. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  61541. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  61542. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  61543. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  61544. /**
  61545. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  61546. * @see http://doc.babylonjs.com/babylon101/materials#texture
  61547. */
  61548. var Texture = /** @class */ (function (_super) {
  61549. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  61550. /**
  61551. * Instantiates a new texture.
  61552. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  61553. * @see http://doc.babylonjs.com/babylon101/materials#texture
  61554. * @param url define the url of the picture to load as a texture
  61555. * @param scene define the scene the texture will belong to
  61556. * @param noMipmap define if the texture will require mip maps or not
  61557. * @param invertY define if the texture needs to be inverted on the y axis during loading
  61558. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  61559. * @param onLoad define a callback triggered when the texture has been loaded
  61560. * @param onError define a callback triggered when an error occurred during the loading session
  61561. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  61562. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  61563. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  61564. */
  61565. function Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  61566. if (noMipmap === void 0) { noMipmap = false; }
  61567. if (invertY === void 0) { invertY = true; }
  61568. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  61569. if (onLoad === void 0) { onLoad = null; }
  61570. if (onError === void 0) { onError = null; }
  61571. if (buffer === void 0) { buffer = null; }
  61572. if (deleteBuffer === void 0) { deleteBuffer = false; }
  61573. var _this = _super.call(this, scene) || this;
  61574. /**
  61575. * Define an offset on the texture to offset the u coordinates of the UVs
  61576. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  61577. */
  61578. _this.uOffset = 0;
  61579. /**
  61580. * Define an offset on the texture to offset the v coordinates of the UVs
  61581. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  61582. */
  61583. _this.vOffset = 0;
  61584. /**
  61585. * Define an offset on the texture to scale the u coordinates of the UVs
  61586. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  61587. */
  61588. _this.uScale = 1.0;
  61589. /**
  61590. * Define an offset on the texture to scale the v coordinates of the UVs
  61591. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  61592. */
  61593. _this.vScale = 1.0;
  61594. /**
  61595. * Define an offset on the texture to rotate around the u coordinates of the UVs
  61596. * @see http://doc.babylonjs.com/how_to/more_materials
  61597. */
  61598. _this.uAng = 0;
  61599. /**
  61600. * Define an offset on the texture to rotate around the v coordinates of the UVs
  61601. * @see http://doc.babylonjs.com/how_to/more_materials
  61602. */
  61603. _this.vAng = 0;
  61604. /**
  61605. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  61606. * @see http://doc.babylonjs.com/how_to/more_materials
  61607. */
  61608. _this.wAng = 0;
  61609. /**
  61610. * Defines the center of rotation (U)
  61611. */
  61612. _this.uRotationCenter = 0.5;
  61613. /**
  61614. * Defines the center of rotation (V)
  61615. */
  61616. _this.vRotationCenter = 0.5;
  61617. /**
  61618. * Defines the center of rotation (W)
  61619. */
  61620. _this.wRotationCenter = 0.5;
  61621. /** @hidden */
  61622. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  61623. /**
  61624. * Observable triggered once the texture has been loaded.
  61625. */
  61626. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  61627. _this._isBlocking = true;
  61628. _this.name = url || "";
  61629. _this.url = url;
  61630. _this._noMipmap = noMipmap;
  61631. _this._invertY = invertY;
  61632. _this._initialSamplingMode = samplingMode;
  61633. _this._buffer = buffer;
  61634. _this._deleteBuffer = deleteBuffer;
  61635. if (format) {
  61636. _this._format = format;
  61637. }
  61638. scene = _this.getScene();
  61639. if (!scene) {
  61640. return _this;
  61641. }
  61642. scene.getEngine().onBeforeTextureInitObservable.notifyObservers(_this);
  61643. var load = function () {
  61644. if (_this._texture && _this._texture._invertVScale) {
  61645. _this.vScale = -1;
  61646. }
  61647. if (_this.onLoadObservable.hasObservers()) {
  61648. _this.onLoadObservable.notifyObservers(_this);
  61649. }
  61650. if (onLoad) {
  61651. onLoad();
  61652. }
  61653. if (!_this.isBlocking && scene) {
  61654. scene.resetCachedMaterial();
  61655. }
  61656. };
  61657. if (!_this.url) {
  61658. _this._delayedOnLoad = load;
  61659. _this._delayedOnError = onError;
  61660. return _this;
  61661. }
  61662. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode, invertY);
  61663. if (!_this._texture) {
  61664. if (!scene.useDelayedTextureLoading) {
  61665. _this._texture = scene.getEngine().createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  61666. if (deleteBuffer) {
  61667. delete _this._buffer;
  61668. }
  61669. }
  61670. else {
  61671. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  61672. _this._delayedOnLoad = load;
  61673. _this._delayedOnError = onError;
  61674. }
  61675. }
  61676. else {
  61677. if (_this._texture.isReady) {
  61678. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(function () { return load(); });
  61679. }
  61680. else {
  61681. _this._texture.onLoadedObservable.add(load);
  61682. }
  61683. }
  61684. return _this;
  61685. }
  61686. Object.defineProperty(Texture.prototype, "noMipmap", {
  61687. /**
  61688. * Are mip maps generated for this texture or not.
  61689. */
  61690. get: function () {
  61691. return this._noMipmap;
  61692. },
  61693. enumerable: true,
  61694. configurable: true
  61695. });
  61696. Object.defineProperty(Texture.prototype, "isBlocking", {
  61697. get: function () {
  61698. return this._isBlocking;
  61699. },
  61700. /**
  61701. * Is the texture preventing material to render while loading.
  61702. * If false, a default texture will be used instead of the loading one during the preparation step.
  61703. */
  61704. set: function (value) {
  61705. this._isBlocking = value;
  61706. },
  61707. enumerable: true,
  61708. configurable: true
  61709. });
  61710. Object.defineProperty(Texture.prototype, "samplingMode", {
  61711. /**
  61712. * Get the current sampling mode associated with the texture.
  61713. */
  61714. get: function () {
  61715. if (!this._texture) {
  61716. return this._initialSamplingMode;
  61717. }
  61718. return this._texture.samplingMode;
  61719. },
  61720. enumerable: true,
  61721. configurable: true
  61722. });
  61723. Object.defineProperty(Texture.prototype, "invertY", {
  61724. /**
  61725. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  61726. */
  61727. get: function () {
  61728. return this._invertY;
  61729. },
  61730. enumerable: true,
  61731. configurable: true
  61732. });
  61733. /**
  61734. * Update the url (and optional buffer) of this texture if url was null during construction.
  61735. * @param url the url of the texture
  61736. * @param buffer the buffer of the texture (defaults to null)
  61737. * @param onLoad callback called when the texture is loaded (defaults to null)
  61738. */
  61739. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  61740. if (buffer === void 0) { buffer = null; }
  61741. if (this.url) {
  61742. this.releaseInternalTexture();
  61743. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  61744. }
  61745. this.url = url;
  61746. this._buffer = buffer;
  61747. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  61748. if (onLoad) {
  61749. this._delayedOnLoad = onLoad;
  61750. }
  61751. this.delayLoad();
  61752. };
  61753. /**
  61754. * Finish the loading sequence of a texture flagged as delayed load.
  61755. * @hidden
  61756. */
  61757. Texture.prototype.delayLoad = function () {
  61758. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  61759. return;
  61760. }
  61761. var scene = this.getScene();
  61762. if (!scene) {
  61763. return;
  61764. }
  61765. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  61766. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode, this._invertY);
  61767. if (!this._texture) {
  61768. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  61769. if (this._deleteBuffer) {
  61770. delete this._buffer;
  61771. }
  61772. }
  61773. else {
  61774. if (this._delayedOnLoad) {
  61775. if (this._texture.isReady) {
  61776. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(this._delayedOnLoad);
  61777. }
  61778. else {
  61779. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  61780. }
  61781. }
  61782. }
  61783. this._delayedOnLoad = null;
  61784. this._delayedOnError = null;
  61785. };
  61786. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  61787. x *= this.uScale;
  61788. y *= this.vScale;
  61789. x -= this.uRotationCenter * this.uScale;
  61790. y -= this.vRotationCenter * this.vScale;
  61791. z -= this.wRotationCenter;
  61792. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  61793. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  61794. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  61795. t.z += this.wRotationCenter;
  61796. };
  61797. /**
  61798. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  61799. * @returns the transform matrix of the texture.
  61800. */
  61801. Texture.prototype.getTextureMatrix = function () {
  61802. var _this = this;
  61803. if (this.uOffset === this._cachedUOffset &&
  61804. this.vOffset === this._cachedVOffset &&
  61805. this.uScale === this._cachedUScale &&
  61806. this.vScale === this._cachedVScale &&
  61807. this.uAng === this._cachedUAng &&
  61808. this.vAng === this._cachedVAng &&
  61809. this.wAng === this._cachedWAng) {
  61810. return this._cachedTextureMatrix;
  61811. }
  61812. this._cachedUOffset = this.uOffset;
  61813. this._cachedVOffset = this.vOffset;
  61814. this._cachedUScale = this.uScale;
  61815. this._cachedVScale = this.vScale;
  61816. this._cachedUAng = this.uAng;
  61817. this._cachedVAng = this.vAng;
  61818. this._cachedWAng = this.wAng;
  61819. if (!this._cachedTextureMatrix) {
  61820. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  61821. this._rowGenerationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  61822. this._t0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  61823. this._t1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  61824. this._t2 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  61825. }
  61826. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  61827. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  61828. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  61829. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  61830. this._t1.subtractInPlace(this._t0);
  61831. this._t2.subtractInPlace(this._t0);
  61832. _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);
  61833. var scene = this.getScene();
  61834. if (!scene) {
  61835. return this._cachedTextureMatrix;
  61836. }
  61837. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  61838. return mat.hasTexture(_this);
  61839. });
  61840. return this._cachedTextureMatrix;
  61841. };
  61842. /**
  61843. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  61844. * @returns The reflection texture transform
  61845. */
  61846. Texture.prototype.getReflectionTextureMatrix = function () {
  61847. var _this = this;
  61848. var scene = this.getScene();
  61849. if (!scene) {
  61850. return this._cachedTextureMatrix;
  61851. }
  61852. if (this.uOffset === this._cachedUOffset &&
  61853. this.vOffset === this._cachedVOffset &&
  61854. this.uScale === this._cachedUScale &&
  61855. this.vScale === this._cachedVScale &&
  61856. this.coordinatesMode === this._cachedCoordinatesMode) {
  61857. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  61858. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  61859. return this._cachedTextureMatrix;
  61860. }
  61861. }
  61862. else {
  61863. return this._cachedTextureMatrix;
  61864. }
  61865. }
  61866. if (!this._cachedTextureMatrix) {
  61867. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  61868. }
  61869. if (!this._projectionModeMatrix) {
  61870. this._projectionModeMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  61871. }
  61872. this._cachedUOffset = this.uOffset;
  61873. this._cachedVOffset = this.vOffset;
  61874. this._cachedUScale = this.uScale;
  61875. this._cachedVScale = this.vScale;
  61876. this._cachedCoordinatesMode = this.coordinatesMode;
  61877. switch (this.coordinatesMode) {
  61878. case Texture.PLANAR_MODE:
  61879. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  61880. this._cachedTextureMatrix[0] = this.uScale;
  61881. this._cachedTextureMatrix[5] = this.vScale;
  61882. this._cachedTextureMatrix[12] = this.uOffset;
  61883. this._cachedTextureMatrix[13] = this.vOffset;
  61884. break;
  61885. case Texture.PROJECTION_MODE:
  61886. _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);
  61887. var projectionMatrix = scene.getProjectionMatrix();
  61888. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  61889. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  61890. break;
  61891. default:
  61892. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  61893. break;
  61894. }
  61895. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  61896. return (mat.getActiveTextures().indexOf(_this) !== -1);
  61897. });
  61898. return this._cachedTextureMatrix;
  61899. };
  61900. /**
  61901. * Clones the texture.
  61902. * @returns the cloned texture
  61903. */
  61904. Texture.prototype.clone = function () {
  61905. var _this = this;
  61906. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  61907. return new Texture(_this._texture ? _this._texture.url : null, _this.getScene(), _this._noMipmap, _this._invertY, _this.samplingMode, undefined, undefined, _this._texture ? _this._texture._buffer : undefined);
  61908. }, this);
  61909. };
  61910. /**
  61911. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  61912. * @returns The JSON representation of the texture
  61913. */
  61914. Texture.prototype.serialize = function () {
  61915. var serializationObject = _super.prototype.serialize.call(this);
  61916. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  61917. serializationObject.base64String = this._buffer;
  61918. serializationObject.name = serializationObject.name.replace("data:", "");
  61919. }
  61920. serializationObject.invertY = this._invertY;
  61921. serializationObject.samplingMode = this.samplingMode;
  61922. return serializationObject;
  61923. };
  61924. /**
  61925. * Get the current class name of the texture useful for serialization or dynamic coding.
  61926. * @returns "Texture"
  61927. */
  61928. Texture.prototype.getClassName = function () {
  61929. return "Texture";
  61930. };
  61931. /**
  61932. * Dispose the texture and release its associated resources.
  61933. */
  61934. Texture.prototype.dispose = function () {
  61935. _super.prototype.dispose.call(this);
  61936. this.onLoadObservable.clear();
  61937. this._delayedOnLoad = null;
  61938. this._delayedOnError = null;
  61939. };
  61940. /**
  61941. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  61942. * @param parsedTexture Define the JSON representation of the texture
  61943. * @param scene Define the scene the parsed texture should be instantiated in
  61944. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61945. * @returns The parsed texture if successful
  61946. */
  61947. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  61948. if (parsedTexture.customType) {
  61949. var customTexture = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Instantiate(parsedTexture.customType);
  61950. // Update Sampling Mode
  61951. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  61952. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  61953. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  61954. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  61955. }
  61956. }
  61957. return parsedCustomTexture;
  61958. }
  61959. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  61960. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  61961. }
  61962. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  61963. return null;
  61964. }
  61965. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  61966. var generateMipMaps = true;
  61967. if (parsedTexture.noMipmap) {
  61968. generateMipMaps = false;
  61969. }
  61970. if (parsedTexture.mirrorPlane) {
  61971. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  61972. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  61973. mirrorTexture.mirrorPlane = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"].FromArray(parsedTexture.mirrorPlane);
  61974. return mirrorTexture;
  61975. }
  61976. else if (parsedTexture.isRenderTarget) {
  61977. var renderTargetTexture = null;
  61978. if (parsedTexture.isCube) {
  61979. // Search for an existing reflection probe (which contains a cube render target texture)
  61980. if (scene.reflectionProbes) {
  61981. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  61982. var probe = scene.reflectionProbes[index];
  61983. if (probe.name === parsedTexture.name) {
  61984. return probe.cubeTexture;
  61985. }
  61986. }
  61987. }
  61988. }
  61989. else {
  61990. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  61991. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  61992. }
  61993. return renderTargetTexture;
  61994. }
  61995. else {
  61996. var texture;
  61997. if (parsedTexture.base64String) {
  61998. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  61999. }
  62000. else {
  62001. var url = rootUrl + parsedTexture.name;
  62002. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  62003. url = parsedTexture.url;
  62004. }
  62005. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  62006. }
  62007. return texture;
  62008. }
  62009. }, parsedTexture, scene);
  62010. // Update Sampling Mode
  62011. if (parsedTexture.samplingMode) {
  62012. var sampling = parsedTexture.samplingMode;
  62013. if (texture && texture.samplingMode !== sampling) {
  62014. texture.updateSamplingMode(sampling);
  62015. }
  62016. }
  62017. // Animations
  62018. if (texture && parsedTexture.animations) {
  62019. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  62020. var parsedAnimation = parsedTexture.animations[animationIndex];
  62021. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  62022. if (internalClass) {
  62023. texture.animations.push(internalClass.Parse(parsedAnimation));
  62024. }
  62025. }
  62026. }
  62027. return texture;
  62028. };
  62029. /**
  62030. * Creates a texture from its base 64 representation.
  62031. * @param data Define the base64 payload without the data: prefix
  62032. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  62033. * @param scene Define the scene the texture should belong to
  62034. * @param noMipmap Forces the texture to not create mip map information if true
  62035. * @param invertY define if the texture needs to be inverted on the y axis during loading
  62036. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  62037. * @param onLoad define a callback triggered when the texture has been loaded
  62038. * @param onError define a callback triggered when an error occurred during the loading session
  62039. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  62040. * @returns the created texture
  62041. */
  62042. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  62043. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  62044. if (onLoad === void 0) { onLoad = null; }
  62045. if (onError === void 0) { onError = null; }
  62046. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  62047. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  62048. };
  62049. /**
  62050. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  62051. * @param data Define the base64 payload without the data: prefix
  62052. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  62053. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  62054. * @param scene Define the scene the texture should belong to
  62055. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  62056. * @param noMipmap Forces the texture to not create mip map information if true
  62057. * @param invertY define if the texture needs to be inverted on the y axis during loading
  62058. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  62059. * @param onLoad define a callback triggered when the texture has been loaded
  62060. * @param onError define a callback triggered when an error occurred during the loading session
  62061. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  62062. * @returns the created texture
  62063. */
  62064. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  62065. if (deleteBuffer === void 0) { deleteBuffer = false; }
  62066. if (noMipmap === void 0) { noMipmap = false; }
  62067. if (invertY === void 0) { invertY = true; }
  62068. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  62069. if (onLoad === void 0) { onLoad = null; }
  62070. if (onError === void 0) { onError = null; }
  62071. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  62072. if (name.substr(0, 5) !== "data:") {
  62073. name = "data:" + name;
  62074. }
  62075. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  62076. };
  62077. /** @hidden */
  62078. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  62079. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("CubeTexture");
  62080. };
  62081. /** @hidden */
  62082. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  62083. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("MirrorTexture");
  62084. };
  62085. /** @hidden */
  62086. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  62087. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("RenderTargetTexture");
  62088. };
  62089. /** nearest is mag = nearest and min = nearest and mip = linear */
  62090. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  62091. /** nearest is mag = nearest and min = nearest and mip = linear */
  62092. 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
  62093. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62094. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  62095. /** Bilinear is mag = linear and min = linear and mip = nearest */
  62096. 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
  62097. /** Trilinear is mag = linear and min = linear and mip = linear */
  62098. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  62099. /** Trilinear is mag = linear and min = linear and mip = linear */
  62100. 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
  62101. /** mag = nearest and min = nearest and mip = nearest */
  62102. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  62103. /** mag = nearest and min = linear and mip = nearest */
  62104. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  62105. /** mag = nearest and min = linear and mip = linear */
  62106. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  62107. /** mag = nearest and min = linear and mip = none */
  62108. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR;
  62109. /** mag = nearest and min = nearest and mip = none */
  62110. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST;
  62111. /** mag = linear and min = nearest and mip = nearest */
  62112. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  62113. /** mag = linear and min = nearest and mip = linear */
  62114. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  62115. /** mag = linear and min = linear and mip = none */
  62116. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR;
  62117. /** mag = linear and min = nearest and mip = none */
  62118. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST;
  62119. /** Explicit coordinates mode */
  62120. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  62121. /** Spherical coordinates mode */
  62122. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SPHERICAL_MODE;
  62123. /** Planar coordinates mode */
  62124. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PLANAR_MODE;
  62125. /** Cubic coordinates mode */
  62126. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CUBIC_MODE;
  62127. /** Projection coordinates mode */
  62128. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PROJECTION_MODE;
  62129. /** Inverse Cubic coordinates mode */
  62130. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SKYBOX_MODE;
  62131. /** Inverse Cubic coordinates mode */
  62132. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_INVCUBIC_MODE;
  62133. /** Equirectangular coordinates mode */
  62134. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  62135. /** Equirectangular Fixed coordinates mode */
  62136. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  62137. /** Equirectangular Fixed Mirrored coordinates mode */
  62138. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  62139. /** Texture is not repeating outside of 0..1 UVs */
  62140. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  62141. /** Texture is repeating outside of 0..1 UVs */
  62142. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  62143. /** Texture is repeating and mirrored */
  62144. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  62145. /**
  62146. * 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
  62147. */
  62148. Texture.UseSerializedUrlIfAny = false;
  62149. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62150. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62151. ], Texture.prototype, "url", void 0);
  62152. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62153. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62154. ], Texture.prototype, "uOffset", void 0);
  62155. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62156. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62157. ], Texture.prototype, "vOffset", void 0);
  62158. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62159. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62160. ], Texture.prototype, "uScale", void 0);
  62161. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62162. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62163. ], Texture.prototype, "vScale", void 0);
  62164. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62165. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62166. ], Texture.prototype, "uAng", void 0);
  62167. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62168. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62169. ], Texture.prototype, "vAng", void 0);
  62170. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62171. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62172. ], Texture.prototype, "wAng", void 0);
  62173. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62174. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62175. ], Texture.prototype, "uRotationCenter", void 0);
  62176. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62177. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62178. ], Texture.prototype, "vRotationCenter", void 0);
  62179. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62180. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62181. ], Texture.prototype, "wRotationCenter", void 0);
  62182. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62183. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62184. ], Texture.prototype, "isBlocking", null);
  62185. return Texture;
  62186. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]));
  62187. // References the dependencies.
  62188. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  62189. /***/ }),
  62190. /***/ "./Materials/Textures/videoTexture.ts":
  62191. /*!********************************************!*\
  62192. !*** ./Materials/Textures/videoTexture.ts ***!
  62193. \********************************************/
  62194. /*! exports provided: VideoTexture */
  62195. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62196. "use strict";
  62197. __webpack_require__.r(__webpack_exports__);
  62198. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  62199. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62200. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  62201. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  62202. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  62203. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  62204. /**
  62205. * If you want to display a video in your scene, this is the special texture for that.
  62206. * This special texture works similar to other textures, with the exception of a few parameters.
  62207. * @see https://doc.babylonjs.com/how_to/video_texture
  62208. */
  62209. var VideoTexture = /** @class */ (function (_super) {
  62210. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  62211. /**
  62212. * Creates a video texture.
  62213. * If you want to display a video in your scene, this is the special texture for that.
  62214. * This special texture works similar to other textures, with the exception of a few parameters.
  62215. * @see https://doc.babylonjs.com/how_to/video_texture
  62216. * @param name optional name, will detect from video source, if not defined
  62217. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  62218. * @param scene is obviously the current scene.
  62219. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  62220. * @param invertY is false by default but can be used to invert video on Y axis
  62221. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  62222. * @param settings allows finer control over video usage
  62223. */
  62224. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  62225. if (generateMipMaps === void 0) { generateMipMaps = false; }
  62226. if (invertY === void 0) { invertY = false; }
  62227. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  62228. if (settings === void 0) { settings = {
  62229. autoPlay: true,
  62230. loop: true,
  62231. autoUpdateTexture: true,
  62232. }; }
  62233. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  62234. _this._onUserActionRequestedObservable = null;
  62235. _this._stillImageCaptured = false;
  62236. _this._displayingPosterTexture = false;
  62237. _this._createInternalTexture = function () {
  62238. if (_this._texture != null) {
  62239. if (_this._displayingPosterTexture) {
  62240. _this._texture.dispose();
  62241. _this._displayingPosterTexture = false;
  62242. }
  62243. else {
  62244. return;
  62245. }
  62246. }
  62247. if (!_this._engine.needPOTTextures ||
  62248. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  62249. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  62250. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  62251. }
  62252. else {
  62253. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  62254. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  62255. _this._generateMipMaps = false;
  62256. }
  62257. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  62258. if (!_this.video.autoplay && !_this._settings.poster) {
  62259. var oldHandler_1 = _this.video.onplaying;
  62260. var error_1 = false;
  62261. var oldMuted_1 = _this.video.muted;
  62262. _this.video.muted = true;
  62263. _this.video.onplaying = function () {
  62264. _this.video.muted = oldMuted_1;
  62265. _this.video.onplaying = oldHandler_1;
  62266. _this._texture.isReady = true;
  62267. _this._updateInternalTexture();
  62268. if (!error_1) {
  62269. _this.video.pause();
  62270. }
  62271. if (_this.onLoadObservable.hasObservers()) {
  62272. _this.onLoadObservable.notifyObservers(_this);
  62273. }
  62274. };
  62275. var playing = _this.video.play();
  62276. if (playing) {
  62277. playing.then(function () {
  62278. // Everything is good.
  62279. })
  62280. .catch(function () {
  62281. error_1 = true;
  62282. // On Chrome for instance, new policies might prevent playing without user interaction.
  62283. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  62284. _this._onUserActionRequestedObservable.notifyObservers(_this);
  62285. }
  62286. });
  62287. }
  62288. else {
  62289. _this.video.onplaying = oldHandler_1;
  62290. _this._texture.isReady = true;
  62291. _this._updateInternalTexture();
  62292. if (_this.onLoadObservable.hasObservers()) {
  62293. _this.onLoadObservable.notifyObservers(_this);
  62294. }
  62295. }
  62296. }
  62297. else {
  62298. _this._texture.isReady = true;
  62299. _this._updateInternalTexture();
  62300. if (_this.onLoadObservable.hasObservers()) {
  62301. _this.onLoadObservable.notifyObservers(_this);
  62302. }
  62303. }
  62304. };
  62305. _this.reset = function () {
  62306. if (_this._texture == null) {
  62307. return;
  62308. }
  62309. if (!_this._displayingPosterTexture) {
  62310. _this._texture.dispose();
  62311. _this._texture = null;
  62312. }
  62313. };
  62314. _this._updateInternalTexture = function () {
  62315. if (_this._texture == null || !_this._texture.isReady) {
  62316. return;
  62317. }
  62318. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  62319. return;
  62320. }
  62321. if (_this._displayingPosterTexture) {
  62322. return;
  62323. }
  62324. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  62325. };
  62326. _this._engine = _this.getScene().getEngine();
  62327. _this._generateMipMaps = generateMipMaps;
  62328. _this._initialSamplingMode = samplingMode;
  62329. _this.autoUpdateTexture = settings.autoUpdateTexture;
  62330. _this.name = name || _this._getName(src);
  62331. _this.video = _this._getVideo(src);
  62332. _this._settings = settings;
  62333. if (settings.poster) {
  62334. _this.video.poster = settings.poster;
  62335. }
  62336. if (settings.autoPlay !== undefined) {
  62337. _this.video.autoplay = settings.autoPlay;
  62338. }
  62339. if (settings.loop !== undefined) {
  62340. _this.video.loop = settings.loop;
  62341. }
  62342. _this.video.setAttribute("playsinline", "");
  62343. _this.video.addEventListener("paused", _this._updateInternalTexture);
  62344. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  62345. _this.video.addEventListener("emptied", _this.reset);
  62346. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  62347. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  62348. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  62349. if (settings.poster &&
  62350. (!settings.autoPlay || !videoHasEnoughData)) {
  62351. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  62352. _this._displayingPosterTexture = true;
  62353. }
  62354. else if (videoHasEnoughData) {
  62355. _this._createInternalTexture();
  62356. }
  62357. return _this;
  62358. }
  62359. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  62360. /**
  62361. * Event triggerd when a dom action is required by the user to play the video.
  62362. * This happens due to recent changes in browser policies preventing video to auto start.
  62363. */
  62364. get: function () {
  62365. if (!this._onUserActionRequestedObservable) {
  62366. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  62367. }
  62368. return this._onUserActionRequestedObservable;
  62369. },
  62370. enumerable: true,
  62371. configurable: true
  62372. });
  62373. VideoTexture.prototype._getName = function (src) {
  62374. if (src instanceof HTMLVideoElement) {
  62375. return src.currentSrc;
  62376. }
  62377. if (typeof src === "object") {
  62378. return src.toString();
  62379. }
  62380. return src;
  62381. };
  62382. VideoTexture.prototype._getVideo = function (src) {
  62383. if (src instanceof HTMLVideoElement) {
  62384. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  62385. return src;
  62386. }
  62387. var video = document.createElement("video");
  62388. if (typeof src === "string") {
  62389. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  62390. video.src = src;
  62391. }
  62392. else {
  62393. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  62394. src.forEach(function (url) {
  62395. var source = document.createElement("source");
  62396. source.src = url;
  62397. video.appendChild(source);
  62398. });
  62399. }
  62400. return video;
  62401. };
  62402. /**
  62403. * @hidden Internal method to initiate `update`.
  62404. */
  62405. VideoTexture.prototype._rebuild = function () {
  62406. this.update();
  62407. };
  62408. /**
  62409. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  62410. */
  62411. VideoTexture.prototype.update = function () {
  62412. if (!this.autoUpdateTexture) {
  62413. // Expecting user to call `updateTexture` manually
  62414. return;
  62415. }
  62416. this.updateTexture(true);
  62417. };
  62418. /**
  62419. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  62420. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  62421. */
  62422. VideoTexture.prototype.updateTexture = function (isVisible) {
  62423. if (!isVisible) {
  62424. return;
  62425. }
  62426. if (this.video.paused && this._stillImageCaptured) {
  62427. return;
  62428. }
  62429. this._stillImageCaptured = true;
  62430. this._updateInternalTexture();
  62431. };
  62432. /**
  62433. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  62434. * @param url New url.
  62435. */
  62436. VideoTexture.prototype.updateURL = function (url) {
  62437. this.video.src = url;
  62438. };
  62439. /**
  62440. * Dispose the texture and release its associated resources.
  62441. */
  62442. VideoTexture.prototype.dispose = function () {
  62443. _super.prototype.dispose.call(this);
  62444. if (this._onUserActionRequestedObservable) {
  62445. this._onUserActionRequestedObservable.clear();
  62446. this._onUserActionRequestedObservable = null;
  62447. }
  62448. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  62449. this.video.removeEventListener("paused", this._updateInternalTexture);
  62450. this.video.removeEventListener("seeked", this._updateInternalTexture);
  62451. this.video.removeEventListener("emptied", this.reset);
  62452. this.video.pause();
  62453. };
  62454. /**
  62455. * Creates a video texture straight from a stream.
  62456. * @param scene Define the scene the texture should be created in
  62457. * @param stream Define the stream the texture should be created from
  62458. * @returns The created video texture as a promise
  62459. */
  62460. VideoTexture.CreateFromStreamAsync = function (scene, stream) {
  62461. var video = document.createElement("video");
  62462. video.setAttribute('autoplay', '');
  62463. video.setAttribute('muted', 'true');
  62464. video.setAttribute('playsinline', '');
  62465. video.muted = true;
  62466. if (video.mozSrcObject !== undefined) {
  62467. // hack for Firefox < 19
  62468. video.mozSrcObject = stream;
  62469. }
  62470. else {
  62471. if (typeof video.srcObject == "object") {
  62472. video.srcObject = stream;
  62473. }
  62474. else {
  62475. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  62476. video.src = (window.URL && window.URL.createObjectURL(stream));
  62477. }
  62478. }
  62479. return new Promise(function (resolve) {
  62480. var onPlaying = function () {
  62481. resolve(new VideoTexture("video", video, scene, true, true));
  62482. video.removeEventListener("playing", onPlaying);
  62483. };
  62484. video.addEventListener("playing", onPlaying);
  62485. video.play();
  62486. });
  62487. };
  62488. /**
  62489. * Creates a video texture straight from your WebCam video feed.
  62490. * @param scene Define the scene the texture should be created in
  62491. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  62492. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  62493. * @returns The created video texture as a promise
  62494. */
  62495. VideoTexture.CreateFromWebCamAsync = function (scene, constraints, audioConstaints) {
  62496. var _this = this;
  62497. if (audioConstaints === void 0) { audioConstaints = false; }
  62498. var constraintsDeviceId;
  62499. if (constraints && constraints.deviceId) {
  62500. constraintsDeviceId = {
  62501. exact: constraints.deviceId,
  62502. };
  62503. }
  62504. if (navigator.mediaDevices) {
  62505. return navigator.mediaDevices.getUserMedia({
  62506. video: constraints,
  62507. audio: audioConstaints
  62508. })
  62509. .then(function (stream) {
  62510. return _this.CreateFromStreamAsync(scene, stream);
  62511. });
  62512. }
  62513. else {
  62514. navigator.getUserMedia =
  62515. navigator.getUserMedia ||
  62516. navigator.webkitGetUserMedia ||
  62517. navigator.mozGetUserMedia ||
  62518. navigator.msGetUserMedia;
  62519. if (navigator.getUserMedia) {
  62520. navigator.getUserMedia({
  62521. video: {
  62522. deviceId: constraintsDeviceId,
  62523. width: {
  62524. min: (constraints && constraints.minWidth) || 256,
  62525. max: (constraints && constraints.maxWidth) || 640,
  62526. },
  62527. height: {
  62528. min: (constraints && constraints.minHeight) || 256,
  62529. max: (constraints && constraints.maxHeight) || 480,
  62530. },
  62531. },
  62532. audio: audioConstaints
  62533. }, function (stream) {
  62534. return _this.CreateFromStreamAsync(scene, stream);
  62535. }, function (e) {
  62536. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  62537. });
  62538. }
  62539. }
  62540. return Promise.reject("No support for userMedia on this device");
  62541. };
  62542. /**
  62543. * Creates a video texture straight from your WebCam video feed.
  62544. * @param scene Define the scene the texture should be created in
  62545. * @param onReady Define a callback to triggered once the texture will be ready
  62546. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  62547. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  62548. */
  62549. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints, audioConstaints) {
  62550. if (audioConstaints === void 0) { audioConstaints = false; }
  62551. this.CreateFromWebCamAsync(scene, constraints, audioConstaints)
  62552. .then(function (videoTexture) {
  62553. if (onReady) {
  62554. onReady(videoTexture);
  62555. }
  62556. })
  62557. .catch(function (err) {
  62558. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  62559. });
  62560. };
  62561. return VideoTexture;
  62562. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  62563. /***/ }),
  62564. /***/ "./Materials/colorCurves.ts":
  62565. /*!**********************************!*\
  62566. !*** ./Materials/colorCurves.ts ***!
  62567. \**********************************/
  62568. /*! exports provided: ColorCurves */
  62569. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62570. "use strict";
  62571. __webpack_require__.r(__webpack_exports__);
  62572. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  62573. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62574. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  62575. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  62576. /**
  62577. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  62578. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  62579. * 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;
  62580. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  62581. */
  62582. var ColorCurves = /** @class */ (function () {
  62583. function ColorCurves() {
  62584. this._dirty = true;
  62585. this._tempColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62586. this._globalCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62587. this._highlightsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62588. this._midtonesCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62589. this._shadowsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62590. this._positiveCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62591. this._negativeCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  62592. this._globalHue = 30;
  62593. this._globalDensity = 0;
  62594. this._globalSaturation = 0;
  62595. this._globalExposure = 0;
  62596. this._highlightsHue = 30;
  62597. this._highlightsDensity = 0;
  62598. this._highlightsSaturation = 0;
  62599. this._highlightsExposure = 0;
  62600. this._midtonesHue = 30;
  62601. this._midtonesDensity = 0;
  62602. this._midtonesSaturation = 0;
  62603. this._midtonesExposure = 0;
  62604. this._shadowsHue = 30;
  62605. this._shadowsDensity = 0;
  62606. this._shadowsSaturation = 0;
  62607. this._shadowsExposure = 0;
  62608. }
  62609. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  62610. /**
  62611. * Gets the global Hue value.
  62612. * 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).
  62613. */
  62614. get: function () {
  62615. return this._globalHue;
  62616. },
  62617. /**
  62618. * Sets the global Hue value.
  62619. * 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).
  62620. */
  62621. set: function (value) {
  62622. this._globalHue = value;
  62623. this._dirty = true;
  62624. },
  62625. enumerable: true,
  62626. configurable: true
  62627. });
  62628. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  62629. /**
  62630. * Gets the global Density value.
  62631. * 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.
  62632. * Values less than zero provide a filter of opposite hue.
  62633. */
  62634. get: function () {
  62635. return this._globalDensity;
  62636. },
  62637. /**
  62638. * Sets the global Density value.
  62639. * 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.
  62640. * Values less than zero provide a filter of opposite hue.
  62641. */
  62642. set: function (value) {
  62643. this._globalDensity = value;
  62644. this._dirty = true;
  62645. },
  62646. enumerable: true,
  62647. configurable: true
  62648. });
  62649. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  62650. /**
  62651. * Gets the global Saturation value.
  62652. * 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.
  62653. */
  62654. get: function () {
  62655. return this._globalSaturation;
  62656. },
  62657. /**
  62658. * Sets the global Saturation value.
  62659. * 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.
  62660. */
  62661. set: function (value) {
  62662. this._globalSaturation = value;
  62663. this._dirty = true;
  62664. },
  62665. enumerable: true,
  62666. configurable: true
  62667. });
  62668. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  62669. /**
  62670. * Gets the global Exposure value.
  62671. * 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.
  62672. */
  62673. get: function () {
  62674. return this._globalExposure;
  62675. },
  62676. /**
  62677. * Sets the global Exposure value.
  62678. * 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.
  62679. */
  62680. set: function (value) {
  62681. this._globalExposure = value;
  62682. this._dirty = true;
  62683. },
  62684. enumerable: true,
  62685. configurable: true
  62686. });
  62687. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  62688. /**
  62689. * Gets the highlights Hue value.
  62690. * 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).
  62691. */
  62692. get: function () {
  62693. return this._highlightsHue;
  62694. },
  62695. /**
  62696. * Sets the highlights Hue value.
  62697. * 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).
  62698. */
  62699. set: function (value) {
  62700. this._highlightsHue = value;
  62701. this._dirty = true;
  62702. },
  62703. enumerable: true,
  62704. configurable: true
  62705. });
  62706. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  62707. /**
  62708. * Gets the highlights Density value.
  62709. * 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.
  62710. * Values less than zero provide a filter of opposite hue.
  62711. */
  62712. get: function () {
  62713. return this._highlightsDensity;
  62714. },
  62715. /**
  62716. * Sets the highlights Density value.
  62717. * 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.
  62718. * Values less than zero provide a filter of opposite hue.
  62719. */
  62720. set: function (value) {
  62721. this._highlightsDensity = value;
  62722. this._dirty = true;
  62723. },
  62724. enumerable: true,
  62725. configurable: true
  62726. });
  62727. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  62728. /**
  62729. * Gets the highlights Saturation value.
  62730. * 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.
  62731. */
  62732. get: function () {
  62733. return this._highlightsSaturation;
  62734. },
  62735. /**
  62736. * Sets the highlights Saturation value.
  62737. * 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.
  62738. */
  62739. set: function (value) {
  62740. this._highlightsSaturation = value;
  62741. this._dirty = true;
  62742. },
  62743. enumerable: true,
  62744. configurable: true
  62745. });
  62746. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  62747. /**
  62748. * Gets the highlights Exposure value.
  62749. * 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.
  62750. */
  62751. get: function () {
  62752. return this._highlightsExposure;
  62753. },
  62754. /**
  62755. * Sets the highlights Exposure value.
  62756. * 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.
  62757. */
  62758. set: function (value) {
  62759. this._highlightsExposure = value;
  62760. this._dirty = true;
  62761. },
  62762. enumerable: true,
  62763. configurable: true
  62764. });
  62765. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  62766. /**
  62767. * Gets the midtones Hue value.
  62768. * 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).
  62769. */
  62770. get: function () {
  62771. return this._midtonesHue;
  62772. },
  62773. /**
  62774. * Sets the midtones Hue value.
  62775. * 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).
  62776. */
  62777. set: function (value) {
  62778. this._midtonesHue = value;
  62779. this._dirty = true;
  62780. },
  62781. enumerable: true,
  62782. configurable: true
  62783. });
  62784. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  62785. /**
  62786. * Gets the midtones Density value.
  62787. * 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.
  62788. * Values less than zero provide a filter of opposite hue.
  62789. */
  62790. get: function () {
  62791. return this._midtonesDensity;
  62792. },
  62793. /**
  62794. * Sets the midtones Density value.
  62795. * 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.
  62796. * Values less than zero provide a filter of opposite hue.
  62797. */
  62798. set: function (value) {
  62799. this._midtonesDensity = value;
  62800. this._dirty = true;
  62801. },
  62802. enumerable: true,
  62803. configurable: true
  62804. });
  62805. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  62806. /**
  62807. * Gets the midtones Saturation value.
  62808. * 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.
  62809. */
  62810. get: function () {
  62811. return this._midtonesSaturation;
  62812. },
  62813. /**
  62814. * Sets the midtones Saturation value.
  62815. * 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.
  62816. */
  62817. set: function (value) {
  62818. this._midtonesSaturation = value;
  62819. this._dirty = true;
  62820. },
  62821. enumerable: true,
  62822. configurable: true
  62823. });
  62824. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  62825. /**
  62826. * Gets the midtones Exposure value.
  62827. * 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.
  62828. */
  62829. get: function () {
  62830. return this._midtonesExposure;
  62831. },
  62832. /**
  62833. * Sets the midtones Exposure value.
  62834. * 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.
  62835. */
  62836. set: function (value) {
  62837. this._midtonesExposure = value;
  62838. this._dirty = true;
  62839. },
  62840. enumerable: true,
  62841. configurable: true
  62842. });
  62843. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  62844. /**
  62845. * Gets the shadows Hue value.
  62846. * 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).
  62847. */
  62848. get: function () {
  62849. return this._shadowsHue;
  62850. },
  62851. /**
  62852. * Sets the shadows Hue value.
  62853. * 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).
  62854. */
  62855. set: function (value) {
  62856. this._shadowsHue = value;
  62857. this._dirty = true;
  62858. },
  62859. enumerable: true,
  62860. configurable: true
  62861. });
  62862. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  62863. /**
  62864. * Gets the shadows Density value.
  62865. * 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.
  62866. * Values less than zero provide a filter of opposite hue.
  62867. */
  62868. get: function () {
  62869. return this._shadowsDensity;
  62870. },
  62871. /**
  62872. * Sets the shadows Density value.
  62873. * 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.
  62874. * Values less than zero provide a filter of opposite hue.
  62875. */
  62876. set: function (value) {
  62877. this._shadowsDensity = value;
  62878. this._dirty = true;
  62879. },
  62880. enumerable: true,
  62881. configurable: true
  62882. });
  62883. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  62884. /**
  62885. * Gets the shadows Saturation value.
  62886. * 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.
  62887. */
  62888. get: function () {
  62889. return this._shadowsSaturation;
  62890. },
  62891. /**
  62892. * Sets the shadows Saturation value.
  62893. * 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.
  62894. */
  62895. set: function (value) {
  62896. this._shadowsSaturation = value;
  62897. this._dirty = true;
  62898. },
  62899. enumerable: true,
  62900. configurable: true
  62901. });
  62902. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  62903. /**
  62904. * Gets the shadows Exposure value.
  62905. * 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.
  62906. */
  62907. get: function () {
  62908. return this._shadowsExposure;
  62909. },
  62910. /**
  62911. * Sets the shadows Exposure value.
  62912. * 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.
  62913. */
  62914. set: function (value) {
  62915. this._shadowsExposure = value;
  62916. this._dirty = true;
  62917. },
  62918. enumerable: true,
  62919. configurable: true
  62920. });
  62921. /**
  62922. * Returns the class name
  62923. * @returns The class name
  62924. */
  62925. ColorCurves.prototype.getClassName = function () {
  62926. return "ColorCurves";
  62927. };
  62928. /**
  62929. * Binds the color curves to the shader.
  62930. * @param colorCurves The color curve to bind
  62931. * @param effect The effect to bind to
  62932. * @param positiveUniform The positive uniform shader parameter
  62933. * @param neutralUniform The neutral uniform shader parameter
  62934. * @param negativeUniform The negative uniform shader parameter
  62935. */
  62936. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  62937. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  62938. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  62939. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  62940. if (colorCurves._dirty) {
  62941. colorCurves._dirty = false;
  62942. // Fill in global info.
  62943. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  62944. // Compute highlights info.
  62945. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  62946. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  62947. // Compute midtones info.
  62948. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  62949. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  62950. // Compute shadows info.
  62951. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  62952. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  62953. // Compute deltas (neutral is midtones).
  62954. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  62955. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  62956. }
  62957. if (effect) {
  62958. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  62959. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  62960. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  62961. }
  62962. };
  62963. /**
  62964. * Prepare the list of uniforms associated with the ColorCurves effects.
  62965. * @param uniformsList The list of uniforms used in the effect
  62966. */
  62967. ColorCurves.PrepareUniforms = function (uniformsList) {
  62968. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  62969. };
  62970. /**
  62971. * Returns color grading data based on a hue, density, saturation and exposure value.
  62972. * @param filterHue The hue of the color filter.
  62973. * @param filterDensity The density of the color filter.
  62974. * @param saturation The saturation.
  62975. * @param exposure The exposure.
  62976. * @param result The result data container.
  62977. */
  62978. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  62979. if (hue == null) {
  62980. return;
  62981. }
  62982. hue = ColorCurves.clamp(hue, 0, 360);
  62983. density = ColorCurves.clamp(density, -100, 100);
  62984. saturation = ColorCurves.clamp(saturation, -100, 100);
  62985. exposure = ColorCurves.clamp(exposure, -100, 100);
  62986. // Remap the slider/config filter density with non-linear mapping and also scale by half
  62987. // so that the maximum filter density is only 50% control. This provides fine control
  62988. // for small values and reasonable range.
  62989. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  62990. density *= 0.5;
  62991. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  62992. if (density < 0) {
  62993. density *= -1;
  62994. hue = (hue + 180) % 360;
  62995. }
  62996. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  62997. result.scaleToRef(2, result);
  62998. result.a = 1 + 0.01 * saturation;
  62999. };
  63000. /**
  63001. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  63002. * @param value The input slider value in range [-100,100].
  63003. * @returns Adjusted value.
  63004. */
  63005. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  63006. value /= 100;
  63007. var x = Math.abs(value);
  63008. x = Math.pow(x, 2);
  63009. if (value < 0) {
  63010. x *= -1;
  63011. }
  63012. x *= 100;
  63013. return x;
  63014. };
  63015. /**
  63016. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  63017. * @param hue The hue (H) input.
  63018. * @param saturation The saturation (S) input.
  63019. * @param brightness The brightness (B) input.
  63020. * @result An RGBA color represented as Vector4.
  63021. */
  63022. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  63023. var h = ColorCurves.clamp(hue, 0, 360);
  63024. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  63025. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  63026. if (s === 0) {
  63027. result.r = v;
  63028. result.g = v;
  63029. result.b = v;
  63030. }
  63031. else {
  63032. // sector 0 to 5
  63033. h /= 60;
  63034. var i = Math.floor(h);
  63035. // fractional part of h
  63036. var f = h - i;
  63037. var p = v * (1 - s);
  63038. var q = v * (1 - s * f);
  63039. var t = v * (1 - s * (1 - f));
  63040. switch (i) {
  63041. case 0:
  63042. result.r = v;
  63043. result.g = t;
  63044. result.b = p;
  63045. break;
  63046. case 1:
  63047. result.r = q;
  63048. result.g = v;
  63049. result.b = p;
  63050. break;
  63051. case 2:
  63052. result.r = p;
  63053. result.g = v;
  63054. result.b = t;
  63055. break;
  63056. case 3:
  63057. result.r = p;
  63058. result.g = q;
  63059. result.b = v;
  63060. break;
  63061. case 4:
  63062. result.r = t;
  63063. result.g = p;
  63064. result.b = v;
  63065. break;
  63066. default: // case 5:
  63067. result.r = v;
  63068. result.g = p;
  63069. result.b = q;
  63070. break;
  63071. }
  63072. }
  63073. result.a = 1;
  63074. };
  63075. /**
  63076. * Returns a value clamped between min and max
  63077. * @param value The value to clamp
  63078. * @param min The minimum of value
  63079. * @param max The maximum of value
  63080. * @returns The clamped value.
  63081. */
  63082. ColorCurves.clamp = function (value, min, max) {
  63083. return Math.min(Math.max(value, min), max);
  63084. };
  63085. /**
  63086. * Clones the current color curve instance.
  63087. * @return The cloned curves
  63088. */
  63089. ColorCurves.prototype.clone = function () {
  63090. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  63091. };
  63092. /**
  63093. * Serializes the current color curve instance to a json representation.
  63094. * @return a JSON representation
  63095. */
  63096. ColorCurves.prototype.serialize = function () {
  63097. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  63098. };
  63099. /**
  63100. * Parses the color curve from a json representation.
  63101. * @param source the JSON source to parse
  63102. * @return The parsed curves
  63103. */
  63104. ColorCurves.Parse = function (source) {
  63105. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  63106. };
  63107. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63109. ], ColorCurves.prototype, "_globalHue", void 0);
  63110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63112. ], ColorCurves.prototype, "_globalDensity", void 0);
  63113. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63114. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63115. ], ColorCurves.prototype, "_globalSaturation", void 0);
  63116. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63117. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63118. ], ColorCurves.prototype, "_globalExposure", void 0);
  63119. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63120. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63121. ], ColorCurves.prototype, "_highlightsHue", void 0);
  63122. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63123. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63124. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  63125. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63126. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63127. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  63128. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63129. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63130. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  63131. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63132. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63133. ], ColorCurves.prototype, "_midtonesHue", void 0);
  63134. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63135. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63136. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  63137. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63138. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63139. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  63140. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63141. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63142. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  63143. return ColorCurves;
  63144. }());
  63145. // References the dependencies.
  63146. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  63147. /***/ }),
  63148. /***/ "./Materials/effect.ts":
  63149. /*!*****************************!*\
  63150. !*** ./Materials/effect.ts ***!
  63151. \*****************************/
  63152. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  63153. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63154. "use strict";
  63155. __webpack_require__.r(__webpack_exports__);
  63156. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  63157. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  63158. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  63159. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  63160. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  63161. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  63162. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  63163. /**
  63164. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  63165. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  63166. */
  63167. var EffectFallbacks = /** @class */ (function () {
  63168. function EffectFallbacks() {
  63169. this._defines = {};
  63170. this._currentRank = 32;
  63171. this._maxRank = -1;
  63172. }
  63173. /**
  63174. * Removes the fallback from the bound mesh.
  63175. */
  63176. EffectFallbacks.prototype.unBindMesh = function () {
  63177. this._mesh = null;
  63178. };
  63179. /**
  63180. * Adds a fallback on the specified property.
  63181. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  63182. * @param define The name of the define in the shader
  63183. */
  63184. EffectFallbacks.prototype.addFallback = function (rank, define) {
  63185. if (!this._defines[rank]) {
  63186. if (rank < this._currentRank) {
  63187. this._currentRank = rank;
  63188. }
  63189. if (rank > this._maxRank) {
  63190. this._maxRank = rank;
  63191. }
  63192. this._defines[rank] = new Array();
  63193. }
  63194. this._defines[rank].push(define);
  63195. };
  63196. /**
  63197. * Sets the mesh to use CPU skinning when needing to fallback.
  63198. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  63199. * @param mesh The mesh to use the fallbacks.
  63200. */
  63201. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  63202. this._mesh = mesh;
  63203. if (rank < this._currentRank) {
  63204. this._currentRank = rank;
  63205. }
  63206. if (rank > this._maxRank) {
  63207. this._maxRank = rank;
  63208. }
  63209. };
  63210. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  63211. /**
  63212. * Checks to see if more fallbacks are still availible.
  63213. */
  63214. get: function () {
  63215. return this._currentRank <= this._maxRank;
  63216. },
  63217. enumerable: true,
  63218. configurable: true
  63219. });
  63220. /**
  63221. * Removes the defines that shoould be removed when falling back.
  63222. * @param currentDefines defines the current define statements for the shader.
  63223. * @param effect defines the current effect we try to compile
  63224. * @returns The resulting defines with defines of the current rank removed.
  63225. */
  63226. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  63227. // First we try to switch to CPU skinning
  63228. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
  63229. this._mesh.computeBonesUsingShaders = false;
  63230. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  63231. effect._bonesComputationForcedToCPU = true;
  63232. var scene = this._mesh.getScene();
  63233. for (var index = 0; index < scene.meshes.length; index++) {
  63234. var otherMesh = scene.meshes[index];
  63235. if (!otherMesh.material) {
  63236. continue;
  63237. }
  63238. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  63239. continue;
  63240. }
  63241. if (otherMesh.material.getEffect() === effect) {
  63242. otherMesh.computeBonesUsingShaders = false;
  63243. }
  63244. else if (otherMesh.subMeshes) {
  63245. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  63246. var subMesh = _a[_i];
  63247. var subMeshEffect = subMesh.effect;
  63248. if (subMeshEffect === effect) {
  63249. otherMesh.computeBonesUsingShaders = false;
  63250. break;
  63251. }
  63252. }
  63253. }
  63254. }
  63255. }
  63256. else {
  63257. var currentFallbacks = this._defines[this._currentRank];
  63258. if (currentFallbacks) {
  63259. for (var index = 0; index < currentFallbacks.length; index++) {
  63260. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  63261. }
  63262. }
  63263. this._currentRank++;
  63264. }
  63265. return currentDefines;
  63266. };
  63267. return EffectFallbacks;
  63268. }());
  63269. /**
  63270. * Options to be used when creating an effect.
  63271. */
  63272. var EffectCreationOptions = /** @class */ (function () {
  63273. function EffectCreationOptions() {
  63274. }
  63275. return EffectCreationOptions;
  63276. }());
  63277. /**
  63278. * Effect containing vertex and fragment shader that can be executed on an object.
  63279. */
  63280. var Effect = /** @class */ (function () {
  63281. /**
  63282. * Instantiates an effect.
  63283. * An effect can be used to create/manage/execute vertex and fragment shaders.
  63284. * @param baseName Name of the effect.
  63285. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  63286. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  63287. * @param samplers List of sampler variables that will be passed to the shader.
  63288. * @param engine Engine to be used to render the effect
  63289. * @param defines Define statements to be added to the shader.
  63290. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  63291. * @param onCompiled Callback that will be called when the shader is compiled.
  63292. * @param onError Callback that will be called if an error occurs during shader compilation.
  63293. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  63294. */
  63295. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  63296. if (samplers === void 0) { samplers = null; }
  63297. if (defines === void 0) { defines = null; }
  63298. if (fallbacks === void 0) { fallbacks = null; }
  63299. if (onCompiled === void 0) { onCompiled = null; }
  63300. if (onError === void 0) { onError = null; }
  63301. var _this = this;
  63302. /**
  63303. * Unique ID of the effect.
  63304. */
  63305. this.uniqueId = 0;
  63306. /**
  63307. * Observable that will be called when the shader is compiled.
  63308. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  63309. */
  63310. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  63311. /**
  63312. * Observable that will be called if an error occurs during shader compilation.
  63313. */
  63314. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  63315. /** @hidden */
  63316. this._bonesComputationForcedToCPU = false;
  63317. this._uniformBuffersNames = {};
  63318. this._isReady = false;
  63319. this._compilationError = "";
  63320. this.name = baseName;
  63321. if (attributesNamesOrOptions.attributes) {
  63322. var options = attributesNamesOrOptions;
  63323. this._engine = uniformsNamesOrEngine;
  63324. this._attributesNames = options.attributes;
  63325. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  63326. this._samplers = options.samplers.slice();
  63327. this.defines = options.defines;
  63328. this.onError = options.onError;
  63329. this.onCompiled = options.onCompiled;
  63330. this._fallbacks = options.fallbacks;
  63331. this._indexParameters = options.indexParameters;
  63332. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  63333. if (options.uniformBuffersNames) {
  63334. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  63335. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  63336. }
  63337. }
  63338. }
  63339. else {
  63340. this._engine = engine;
  63341. this.defines = (defines == null ? "" : defines);
  63342. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  63343. this._samplers = samplers ? samplers.slice() : [];
  63344. this._attributesNames = attributesNamesOrOptions;
  63345. this.onError = onError;
  63346. this.onCompiled = onCompiled;
  63347. this._indexParameters = indexParameters;
  63348. this._fallbacks = fallbacks;
  63349. }
  63350. this.uniqueId = Effect._uniqueIdSeed++;
  63351. var vertexSource;
  63352. var fragmentSource;
  63353. if (baseName.vertexElement) {
  63354. vertexSource = document.getElementById(baseName.vertexElement);
  63355. if (!vertexSource) {
  63356. vertexSource = baseName.vertexElement;
  63357. }
  63358. }
  63359. else {
  63360. vertexSource = baseName.vertex || baseName;
  63361. }
  63362. if (baseName.fragmentElement) {
  63363. fragmentSource = document.getElementById(baseName.fragmentElement);
  63364. if (!fragmentSource) {
  63365. fragmentSource = baseName.fragmentElement;
  63366. }
  63367. }
  63368. else {
  63369. fragmentSource = baseName.fragment || baseName;
  63370. }
  63371. this._loadVertexShader(vertexSource, function (vertexCode) {
  63372. _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
  63373. _this._processShaderConversion(vertexCodeWithIncludes, false, function (migratedVertexCode) {
  63374. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  63375. _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
  63376. _this._processShaderConversion(fragmentCodeWithIncludes, true, function (migratedFragmentCode) {
  63377. if (baseName) {
  63378. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  63379. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  63380. _this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  63381. _this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  63382. }
  63383. else {
  63384. _this._vertexSourceCode = migratedVertexCode;
  63385. _this._fragmentSourceCode = migratedFragmentCode;
  63386. }
  63387. _this._prepareEffect();
  63388. });
  63389. });
  63390. });
  63391. });
  63392. });
  63393. });
  63394. }
  63395. Object.defineProperty(Effect.prototype, "onBindObservable", {
  63396. /**
  63397. * Observable that will be called when effect is bound.
  63398. */
  63399. get: function () {
  63400. if (!this._onBindObservable) {
  63401. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  63402. }
  63403. return this._onBindObservable;
  63404. },
  63405. enumerable: true,
  63406. configurable: true
  63407. });
  63408. Object.defineProperty(Effect.prototype, "key", {
  63409. /**
  63410. * Unique key for this effect
  63411. */
  63412. get: function () {
  63413. return this._key;
  63414. },
  63415. enumerable: true,
  63416. configurable: true
  63417. });
  63418. /**
  63419. * If the effect has been compiled and prepared.
  63420. * @returns if the effect is compiled and prepared.
  63421. */
  63422. Effect.prototype.isReady = function () {
  63423. if (!this._isReady && this._program && this._program.isParallelCompiled) {
  63424. return this._engine._isProgramCompiled(this._program);
  63425. }
  63426. return this._isReady;
  63427. };
  63428. /**
  63429. * The engine the effect was initialized with.
  63430. * @returns the engine.
  63431. */
  63432. Effect.prototype.getEngine = function () {
  63433. return this._engine;
  63434. };
  63435. /**
  63436. * The compiled webGL program for the effect
  63437. * @returns the webGL program.
  63438. */
  63439. Effect.prototype.getProgram = function () {
  63440. return this._program;
  63441. };
  63442. /**
  63443. * The set of names of attribute variables for the shader.
  63444. * @returns An array of attribute names.
  63445. */
  63446. Effect.prototype.getAttributesNames = function () {
  63447. return this._attributesNames;
  63448. };
  63449. /**
  63450. * Returns the attribute at the given index.
  63451. * @param index The index of the attribute.
  63452. * @returns The location of the attribute.
  63453. */
  63454. Effect.prototype.getAttributeLocation = function (index) {
  63455. return this._attributes[index];
  63456. };
  63457. /**
  63458. * Returns the attribute based on the name of the variable.
  63459. * @param name of the attribute to look up.
  63460. * @returns the attribute location.
  63461. */
  63462. Effect.prototype.getAttributeLocationByName = function (name) {
  63463. var index = this._attributesNames.indexOf(name);
  63464. return this._attributes[index];
  63465. };
  63466. /**
  63467. * The number of attributes.
  63468. * @returns the numnber of attributes.
  63469. */
  63470. Effect.prototype.getAttributesCount = function () {
  63471. return this._attributes.length;
  63472. };
  63473. /**
  63474. * Gets the index of a uniform variable.
  63475. * @param uniformName of the uniform to look up.
  63476. * @returns the index.
  63477. */
  63478. Effect.prototype.getUniformIndex = function (uniformName) {
  63479. return this._uniformsNames.indexOf(uniformName);
  63480. };
  63481. /**
  63482. * Returns the attribute based on the name of the variable.
  63483. * @param uniformName of the uniform to look up.
  63484. * @returns the location of the uniform.
  63485. */
  63486. Effect.prototype.getUniform = function (uniformName) {
  63487. return this._uniforms[this._uniformsNames.indexOf(uniformName)];
  63488. };
  63489. /**
  63490. * Returns an array of sampler variable names
  63491. * @returns The array of sampler variable neames.
  63492. */
  63493. Effect.prototype.getSamplers = function () {
  63494. return this._samplers;
  63495. };
  63496. /**
  63497. * The error from the last compilation.
  63498. * @returns the error string.
  63499. */
  63500. Effect.prototype.getCompilationError = function () {
  63501. return this._compilationError;
  63502. };
  63503. /**
  63504. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  63505. * @param func The callback to be used.
  63506. */
  63507. Effect.prototype.executeWhenCompiled = function (func) {
  63508. var _this = this;
  63509. if (this.isReady()) {
  63510. func(this);
  63511. return;
  63512. }
  63513. this.onCompileObservable.add(function (effect) {
  63514. func(effect);
  63515. });
  63516. if (!this._program || this._program.isParallelCompiled) {
  63517. setTimeout(function () {
  63518. _this._checkIsReady();
  63519. }, 16);
  63520. }
  63521. };
  63522. Effect.prototype._checkIsReady = function () {
  63523. var _this = this;
  63524. if (this.isReady()) {
  63525. return;
  63526. }
  63527. setTimeout(function () {
  63528. _this._checkIsReady();
  63529. }, 16);
  63530. };
  63531. /** @hidden */
  63532. Effect.prototype._loadVertexShader = function (vertex, callback) {
  63533. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  63534. // DOM element ?
  63535. if (vertex instanceof HTMLElement) {
  63536. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  63537. callback(vertexCode);
  63538. return;
  63539. }
  63540. }
  63541. // Base64 encoded ?
  63542. if (vertex.substr(0, 7) === "base64:") {
  63543. var vertexBinary = window.atob(vertex.substr(7));
  63544. callback(vertexBinary);
  63545. return;
  63546. }
  63547. // Is in local store ?
  63548. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  63549. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  63550. return;
  63551. }
  63552. var vertexShaderUrl;
  63553. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  63554. vertexShaderUrl = vertex;
  63555. }
  63556. else {
  63557. vertexShaderUrl = Effect.ShadersRepository + vertex;
  63558. }
  63559. // Vertex shader
  63560. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  63561. };
  63562. /** @hidden */
  63563. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  63564. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  63565. // DOM element ?
  63566. if (fragment instanceof HTMLElement) {
  63567. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  63568. callback(fragmentCode);
  63569. return;
  63570. }
  63571. }
  63572. // Base64 encoded ?
  63573. if (fragment.substr(0, 7) === "base64:") {
  63574. var fragmentBinary = window.atob(fragment.substr(7));
  63575. callback(fragmentBinary);
  63576. return;
  63577. }
  63578. // Is in local store ?
  63579. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  63580. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  63581. return;
  63582. }
  63583. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  63584. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  63585. return;
  63586. }
  63587. var fragmentShaderUrl;
  63588. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  63589. fragmentShaderUrl = fragment;
  63590. }
  63591. else {
  63592. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  63593. }
  63594. // Fragment shader
  63595. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  63596. };
  63597. /** @hidden */
  63598. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  63599. // Rebuild shaders source code
  63600. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  63601. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  63602. vertexCode = prefix + vertexCode;
  63603. fragmentCode = prefix + fragmentCode;
  63604. // Number lines of shaders source code
  63605. var i = 2;
  63606. var regex = /\n/gm;
  63607. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  63608. i = 2;
  63609. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  63610. // Dump shaders name and formatted source code
  63611. if (this.name.vertexElement) {
  63612. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  63613. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  63614. }
  63615. else if (this.name.vertex) {
  63616. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  63617. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  63618. }
  63619. else {
  63620. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  63621. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  63622. }
  63623. };
  63624. Effect.prototype._processShaderConversion = function (sourceCode, isFragment, callback) {
  63625. var preparedSourceCode = this._processPrecision(sourceCode);
  63626. if (this._engine.webGLVersion == 1) {
  63627. callback(preparedSourceCode);
  63628. return;
  63629. }
  63630. // Already converted
  63631. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  63632. callback(preparedSourceCode.replace("#version 300 es", ""));
  63633. return;
  63634. }
  63635. var hasDrawBuffersExtension = preparedSourceCode.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  63636. // Remove extensions
  63637. // #extension GL_OES_standard_derivatives : enable
  63638. // #extension GL_EXT_shader_texture_lod : enable
  63639. // #extension GL_EXT_frag_depth : enable
  63640. // #extension GL_EXT_draw_buffers : require
  63641. var regex = /#extension.+(GL_OVR_multiview|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  63642. var result = preparedSourceCode.replace(regex, "");
  63643. // Migrate to GLSL v300
  63644. result = result.replace(/varying(?![\n\r])\s/g, isFragment ? "in " : "out ");
  63645. result = result.replace(/attribute[ \t]/g, "in ");
  63646. result = result.replace(/[ \t]attribute/g, " in");
  63647. result = result.replace(/texture2D\s*\(/g, "texture(");
  63648. if (isFragment) {
  63649. result = result.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  63650. result = result.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  63651. result = result.replace(/textureCube\s*\(/g, "texture(");
  63652. result = result.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  63653. result = result.replace(/gl_FragColor/g, "glFragColor");
  63654. result = result.replace(/gl_FragData/g, "glFragData");
  63655. result = result.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  63656. }
  63657. // Add multiview setup to top of file when defined
  63658. var hasMultiviewExtension = this.defines.indexOf("#define MULTIVIEW\n") !== -1;
  63659. if (hasMultiviewExtension && !isFragment) {
  63660. result = "#extension GL_OVR_multiview : require\nlayout (num_views = 2) in;\n" + result;
  63661. }
  63662. callback(result);
  63663. };
  63664. Effect.prototype._processIncludes = function (sourceCode, callback) {
  63665. var _this = this;
  63666. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  63667. var match = regex.exec(sourceCode);
  63668. var returnValue = new String(sourceCode);
  63669. while (match != null) {
  63670. var includeFile = match[1];
  63671. // Uniform declaration
  63672. if (includeFile.indexOf("__decl__") !== -1) {
  63673. includeFile = includeFile.replace(/__decl__/, "");
  63674. if (this._engine.supportsUniformBuffers) {
  63675. includeFile = includeFile.replace(/Vertex/, "Ubo");
  63676. includeFile = includeFile.replace(/Fragment/, "Ubo");
  63677. }
  63678. includeFile = includeFile + "Declaration";
  63679. }
  63680. if (Effect.IncludesShadersStore[includeFile]) {
  63681. // Substitution
  63682. var includeContent = Effect.IncludesShadersStore[includeFile];
  63683. if (match[2]) {
  63684. var splits = match[3].split(",");
  63685. for (var index = 0; index < splits.length; index += 2) {
  63686. var source = new RegExp(splits[index], "g");
  63687. var dest = splits[index + 1];
  63688. includeContent = includeContent.replace(source, dest);
  63689. }
  63690. }
  63691. if (match[4]) {
  63692. var indexString = match[5];
  63693. if (indexString.indexOf("..") !== -1) {
  63694. var indexSplits = indexString.split("..");
  63695. var minIndex = parseInt(indexSplits[0]);
  63696. var maxIndex = parseInt(indexSplits[1]);
  63697. var sourceIncludeContent = includeContent.slice(0);
  63698. includeContent = "";
  63699. if (isNaN(maxIndex)) {
  63700. maxIndex = this._indexParameters[indexSplits[1]];
  63701. }
  63702. for (var i = minIndex; i < maxIndex; i++) {
  63703. if (!this._engine.supportsUniformBuffers) {
  63704. // Ubo replacement
  63705. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  63706. return p1 + "{X}";
  63707. });
  63708. }
  63709. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  63710. }
  63711. }
  63712. else {
  63713. if (!this._engine.supportsUniformBuffers) {
  63714. // Ubo replacement
  63715. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  63716. return p1 + "{X}";
  63717. });
  63718. }
  63719. includeContent = includeContent.replace(/\{X\}/g, indexString);
  63720. }
  63721. }
  63722. // Replace
  63723. returnValue = returnValue.replace(match[0], includeContent);
  63724. }
  63725. else {
  63726. var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
  63727. this._engine._loadFile(includeShaderUrl, function (fileContent) {
  63728. Effect.IncludesShadersStore[includeFile] = fileContent;
  63729. _this._processIncludes(returnValue, callback);
  63730. });
  63731. return;
  63732. }
  63733. match = regex.exec(sourceCode);
  63734. }
  63735. callback(returnValue);
  63736. };
  63737. Effect.prototype._processPrecision = function (source) {
  63738. var shouldUseHighPrecisionShader = this._engine._shouldUseHighPrecisionShader;
  63739. if (source.indexOf("precision highp float") === -1) {
  63740. if (!shouldUseHighPrecisionShader) {
  63741. source = "precision mediump float;\n" + source;
  63742. }
  63743. else {
  63744. source = "precision highp float;\n" + source;
  63745. }
  63746. }
  63747. else {
  63748. if (!shouldUseHighPrecisionShader) { // Moving highp to mediump
  63749. source = source.replace("precision highp float", "precision mediump float");
  63750. }
  63751. }
  63752. return source;
  63753. };
  63754. /**
  63755. * Recompiles the webGL program
  63756. * @param vertexSourceCode The source code for the vertex shader.
  63757. * @param fragmentSourceCode The source code for the fragment shader.
  63758. * @param onCompiled Callback called when completed.
  63759. * @param onError Callback called on error.
  63760. * @hidden
  63761. */
  63762. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  63763. var _this = this;
  63764. this._isReady = false;
  63765. this._vertexSourceCodeOverride = vertexSourceCode;
  63766. this._fragmentSourceCodeOverride = fragmentSourceCode;
  63767. this.onError = function (effect, error) {
  63768. if (onError) {
  63769. onError(error);
  63770. }
  63771. };
  63772. this.onCompiled = function () {
  63773. var scenes = _this.getEngine().scenes;
  63774. for (var i = 0; i < scenes.length; i++) {
  63775. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_AllDirtyFlag);
  63776. }
  63777. if (onCompiled) {
  63778. onCompiled(_this._program);
  63779. }
  63780. };
  63781. this._fallbacks = null;
  63782. this._prepareEffect();
  63783. };
  63784. /**
  63785. * Gets the uniform locations of the the specified variable names
  63786. * @param names THe names of the variables to lookup.
  63787. * @returns Array of locations in the same order as variable names.
  63788. */
  63789. Effect.prototype.getSpecificUniformLocations = function (names) {
  63790. var engine = this._engine;
  63791. return engine.getUniforms(this._program, names);
  63792. };
  63793. /**
  63794. * Prepares the effect
  63795. * @hidden
  63796. */
  63797. Effect.prototype._prepareEffect = function () {
  63798. var _this = this;
  63799. var attributesNames = this._attributesNames;
  63800. var defines = this.defines;
  63801. var fallbacks = this._fallbacks;
  63802. this._valueCache = {};
  63803. var previousProgram = this._program;
  63804. try {
  63805. var engine_1 = this._engine;
  63806. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  63807. this._program = engine_1.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
  63808. }
  63809. else {
  63810. this._program = engine_1.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
  63811. }
  63812. this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
  63813. engine_1._executeWhenProgramIsCompiled(this._program, function () {
  63814. if (engine_1.supportsUniformBuffers) {
  63815. for (var name in _this._uniformBuffersNames) {
  63816. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  63817. }
  63818. }
  63819. _this._uniforms = engine_1.getUniforms(_this._program, _this._uniformsNames);
  63820. _this._attributes = engine_1.getAttributes(_this._program, attributesNames);
  63821. var index;
  63822. for (index = 0; index < _this._samplers.length; index++) {
  63823. var sampler = _this.getUniform(_this._samplers[index]);
  63824. if (sampler == null) {
  63825. _this._samplers.splice(index, 1);
  63826. index--;
  63827. }
  63828. }
  63829. engine_1.bindSamplers(_this);
  63830. _this._compilationError = "";
  63831. _this._isReady = true;
  63832. if (_this.onCompiled) {
  63833. _this.onCompiled(_this);
  63834. }
  63835. _this.onCompileObservable.notifyObservers(_this);
  63836. _this.onCompileObservable.clear();
  63837. // Unbind mesh reference in fallbacks
  63838. if (_this._fallbacks) {
  63839. _this._fallbacks.unBindMesh();
  63840. }
  63841. if (previousProgram) {
  63842. _this.getEngine()._deleteProgram(previousProgram);
  63843. }
  63844. });
  63845. if (this._program.isParallelCompiled) {
  63846. this._checkIsReady();
  63847. }
  63848. }
  63849. catch (e) {
  63850. this._compilationError = e.message;
  63851. // Let's go through fallbacks then
  63852. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  63853. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  63854. return " " + uniform;
  63855. }));
  63856. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  63857. return " " + attribute;
  63858. }));
  63859. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  63860. if (previousProgram) {
  63861. this._program = previousProgram;
  63862. this._isReady = true;
  63863. if (this.onError) {
  63864. this.onError(this, this._compilationError);
  63865. }
  63866. this.onErrorObservable.notifyObservers(this);
  63867. }
  63868. if (fallbacks && fallbacks.isMoreFallbacks) {
  63869. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  63870. this.defines = fallbacks.reduce(this.defines, this);
  63871. this._prepareEffect();
  63872. }
  63873. else { // Sorry we did everything we can
  63874. if (this.onError) {
  63875. this.onError(this, this._compilationError);
  63876. }
  63877. this.onErrorObservable.notifyObservers(this);
  63878. this.onErrorObservable.clear();
  63879. // Unbind mesh reference in fallbacks
  63880. if (this._fallbacks) {
  63881. this._fallbacks.unBindMesh();
  63882. }
  63883. }
  63884. }
  63885. };
  63886. Object.defineProperty(Effect.prototype, "isSupported", {
  63887. /**
  63888. * Checks if the effect is supported. (Must be called after compilation)
  63889. */
  63890. get: function () {
  63891. return this._compilationError === "";
  63892. },
  63893. enumerable: true,
  63894. configurable: true
  63895. });
  63896. /**
  63897. * Binds a texture to the engine to be used as output of the shader.
  63898. * @param channel Name of the output variable.
  63899. * @param texture Texture to bind.
  63900. * @hidden
  63901. */
  63902. Effect.prototype._bindTexture = function (channel, texture) {
  63903. this._engine._bindTexture(this._samplers.indexOf(channel), texture);
  63904. };
  63905. /**
  63906. * Sets a texture on the engine to be used in the shader.
  63907. * @param channel Name of the sampler variable.
  63908. * @param texture Texture to set.
  63909. */
  63910. Effect.prototype.setTexture = function (channel, texture) {
  63911. this._engine.setTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  63912. };
  63913. /**
  63914. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  63915. * @param channel Name of the sampler variable.
  63916. * @param texture Texture to set.
  63917. */
  63918. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  63919. this._engine.setDepthStencilTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  63920. };
  63921. /**
  63922. * Sets an array of textures on the engine to be used in the shader.
  63923. * @param channel Name of the variable.
  63924. * @param textures Textures to set.
  63925. */
  63926. Effect.prototype.setTextureArray = function (channel, textures) {
  63927. if (this._samplers.indexOf(channel + "Ex") === -1) {
  63928. var initialPos = this._samplers.indexOf(channel);
  63929. for (var index = 1; index < textures.length; index++) {
  63930. this._samplers.splice(initialPos + index, 0, channel + "Ex");
  63931. }
  63932. }
  63933. this._engine.setTextureArray(this._samplers.indexOf(channel), this.getUniform(channel), textures);
  63934. };
  63935. /**
  63936. * 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)
  63937. * @param channel Name of the sampler variable.
  63938. * @param postProcess Post process to get the input texture from.
  63939. */
  63940. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  63941. this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
  63942. };
  63943. /**
  63944. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  63945. * 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)
  63946. * @param channel Name of the sampler variable.
  63947. * @param postProcess Post process to get the output texture from.
  63948. */
  63949. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  63950. this._engine.setTextureFromPostProcessOutput(this._samplers.indexOf(channel), postProcess);
  63951. };
  63952. /** @hidden */
  63953. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  63954. var cache = this._valueCache[uniformName];
  63955. var flag = matrix.updateFlag;
  63956. if (cache !== undefined && cache === flag) {
  63957. return false;
  63958. }
  63959. this._valueCache[uniformName] = flag;
  63960. return true;
  63961. };
  63962. /** @hidden */
  63963. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  63964. var cache = this._valueCache[uniformName];
  63965. if (!cache) {
  63966. cache = [x, y];
  63967. this._valueCache[uniformName] = cache;
  63968. return true;
  63969. }
  63970. var changed = false;
  63971. if (cache[0] !== x) {
  63972. cache[0] = x;
  63973. changed = true;
  63974. }
  63975. if (cache[1] !== y) {
  63976. cache[1] = y;
  63977. changed = true;
  63978. }
  63979. return changed;
  63980. };
  63981. /** @hidden */
  63982. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  63983. var cache = this._valueCache[uniformName];
  63984. if (!cache) {
  63985. cache = [x, y, z];
  63986. this._valueCache[uniformName] = cache;
  63987. return true;
  63988. }
  63989. var changed = false;
  63990. if (cache[0] !== x) {
  63991. cache[0] = x;
  63992. changed = true;
  63993. }
  63994. if (cache[1] !== y) {
  63995. cache[1] = y;
  63996. changed = true;
  63997. }
  63998. if (cache[2] !== z) {
  63999. cache[2] = z;
  64000. changed = true;
  64001. }
  64002. return changed;
  64003. };
  64004. /** @hidden */
  64005. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  64006. var cache = this._valueCache[uniformName];
  64007. if (!cache) {
  64008. cache = [x, y, z, w];
  64009. this._valueCache[uniformName] = cache;
  64010. return true;
  64011. }
  64012. var changed = false;
  64013. if (cache[0] !== x) {
  64014. cache[0] = x;
  64015. changed = true;
  64016. }
  64017. if (cache[1] !== y) {
  64018. cache[1] = y;
  64019. changed = true;
  64020. }
  64021. if (cache[2] !== z) {
  64022. cache[2] = z;
  64023. changed = true;
  64024. }
  64025. if (cache[3] !== w) {
  64026. cache[3] = w;
  64027. changed = true;
  64028. }
  64029. return changed;
  64030. };
  64031. /**
  64032. * Binds a buffer to a uniform.
  64033. * @param buffer Buffer to bind.
  64034. * @param name Name of the uniform variable to bind to.
  64035. */
  64036. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  64037. var bufferName = this._uniformBuffersNames[name];
  64038. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  64039. return;
  64040. }
  64041. Effect._baseCache[bufferName] = buffer;
  64042. this._engine.bindUniformBufferBase(buffer, bufferName);
  64043. };
  64044. /**
  64045. * Binds block to a uniform.
  64046. * @param blockName Name of the block to bind.
  64047. * @param index Index to bind.
  64048. */
  64049. Effect.prototype.bindUniformBlock = function (blockName, index) {
  64050. this._engine.bindUniformBlock(this._program, blockName, index);
  64051. };
  64052. /**
  64053. * Sets an interger value on a uniform variable.
  64054. * @param uniformName Name of the variable.
  64055. * @param value Value to be set.
  64056. * @returns this effect.
  64057. */
  64058. Effect.prototype.setInt = function (uniformName, value) {
  64059. var cache = this._valueCache[uniformName];
  64060. if (cache !== undefined && cache === value) {
  64061. return this;
  64062. }
  64063. this._valueCache[uniformName] = value;
  64064. this._engine.setInt(this.getUniform(uniformName), value);
  64065. return this;
  64066. };
  64067. /**
  64068. * Sets an int array on a uniform variable.
  64069. * @param uniformName Name of the variable.
  64070. * @param array array to be set.
  64071. * @returns this effect.
  64072. */
  64073. Effect.prototype.setIntArray = function (uniformName, array) {
  64074. this._valueCache[uniformName] = null;
  64075. this._engine.setIntArray(this.getUniform(uniformName), array);
  64076. return this;
  64077. };
  64078. /**
  64079. * 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)
  64080. * @param uniformName Name of the variable.
  64081. * @param array array to be set.
  64082. * @returns this effect.
  64083. */
  64084. Effect.prototype.setIntArray2 = function (uniformName, array) {
  64085. this._valueCache[uniformName] = null;
  64086. this._engine.setIntArray2(this.getUniform(uniformName), array);
  64087. return this;
  64088. };
  64089. /**
  64090. * 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)
  64091. * @param uniformName Name of the variable.
  64092. * @param array array to be set.
  64093. * @returns this effect.
  64094. */
  64095. Effect.prototype.setIntArray3 = function (uniformName, array) {
  64096. this._valueCache[uniformName] = null;
  64097. this._engine.setIntArray3(this.getUniform(uniformName), array);
  64098. return this;
  64099. };
  64100. /**
  64101. * 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)
  64102. * @param uniformName Name of the variable.
  64103. * @param array array to be set.
  64104. * @returns this effect.
  64105. */
  64106. Effect.prototype.setIntArray4 = function (uniformName, array) {
  64107. this._valueCache[uniformName] = null;
  64108. this._engine.setIntArray4(this.getUniform(uniformName), array);
  64109. return this;
  64110. };
  64111. /**
  64112. * Sets an float array on a uniform variable.
  64113. * @param uniformName Name of the variable.
  64114. * @param array array to be set.
  64115. * @returns this effect.
  64116. */
  64117. Effect.prototype.setFloatArray = function (uniformName, array) {
  64118. this._valueCache[uniformName] = null;
  64119. this._engine.setFloatArray(this.getUniform(uniformName), array);
  64120. return this;
  64121. };
  64122. /**
  64123. * 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)
  64124. * @param uniformName Name of the variable.
  64125. * @param array array to be set.
  64126. * @returns this effect.
  64127. */
  64128. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  64129. this._valueCache[uniformName] = null;
  64130. this._engine.setFloatArray2(this.getUniform(uniformName), array);
  64131. return this;
  64132. };
  64133. /**
  64134. * 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)
  64135. * @param uniformName Name of the variable.
  64136. * @param array array to be set.
  64137. * @returns this effect.
  64138. */
  64139. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  64140. this._valueCache[uniformName] = null;
  64141. this._engine.setFloatArray3(this.getUniform(uniformName), array);
  64142. return this;
  64143. };
  64144. /**
  64145. * 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)
  64146. * @param uniformName Name of the variable.
  64147. * @param array array to be set.
  64148. * @returns this effect.
  64149. */
  64150. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  64151. this._valueCache[uniformName] = null;
  64152. this._engine.setFloatArray4(this.getUniform(uniformName), array);
  64153. return this;
  64154. };
  64155. /**
  64156. * Sets an array on a uniform variable.
  64157. * @param uniformName Name of the variable.
  64158. * @param array array to be set.
  64159. * @returns this effect.
  64160. */
  64161. Effect.prototype.setArray = function (uniformName, array) {
  64162. this._valueCache[uniformName] = null;
  64163. this._engine.setArray(this.getUniform(uniformName), array);
  64164. return this;
  64165. };
  64166. /**
  64167. * 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)
  64168. * @param uniformName Name of the variable.
  64169. * @param array array to be set.
  64170. * @returns this effect.
  64171. */
  64172. Effect.prototype.setArray2 = function (uniformName, array) {
  64173. this._valueCache[uniformName] = null;
  64174. this._engine.setArray2(this.getUniform(uniformName), array);
  64175. return this;
  64176. };
  64177. /**
  64178. * 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)
  64179. * @param uniformName Name of the variable.
  64180. * @param array array to be set.
  64181. * @returns this effect.
  64182. */
  64183. Effect.prototype.setArray3 = function (uniformName, array) {
  64184. this._valueCache[uniformName] = null;
  64185. this._engine.setArray3(this.getUniform(uniformName), array);
  64186. return this;
  64187. };
  64188. /**
  64189. * 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)
  64190. * @param uniformName Name of the variable.
  64191. * @param array array to be set.
  64192. * @returns this effect.
  64193. */
  64194. Effect.prototype.setArray4 = function (uniformName, array) {
  64195. this._valueCache[uniformName] = null;
  64196. this._engine.setArray4(this.getUniform(uniformName), array);
  64197. return this;
  64198. };
  64199. /**
  64200. * Sets matrices on a uniform variable.
  64201. * @param uniformName Name of the variable.
  64202. * @param matrices matrices to be set.
  64203. * @returns this effect.
  64204. */
  64205. Effect.prototype.setMatrices = function (uniformName, matrices) {
  64206. if (!matrices) {
  64207. return this;
  64208. }
  64209. this._valueCache[uniformName] = null;
  64210. this._engine.setMatrices(this.getUniform(uniformName), matrices);
  64211. return this;
  64212. };
  64213. /**
  64214. * Sets matrix on a uniform variable.
  64215. * @param uniformName Name of the variable.
  64216. * @param matrix matrix to be set.
  64217. * @returns this effect.
  64218. */
  64219. Effect.prototype.setMatrix = function (uniformName, matrix) {
  64220. if (this._cacheMatrix(uniformName, matrix)) {
  64221. this._engine.setMatrix(this.getUniform(uniformName), matrix);
  64222. }
  64223. return this;
  64224. };
  64225. /**
  64226. * 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)
  64227. * @param uniformName Name of the variable.
  64228. * @param matrix matrix to be set.
  64229. * @returns this effect.
  64230. */
  64231. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  64232. this._valueCache[uniformName] = null;
  64233. this._engine.setMatrix3x3(this.getUniform(uniformName), matrix);
  64234. return this;
  64235. };
  64236. /**
  64237. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  64238. * @param uniformName Name of the variable.
  64239. * @param matrix matrix to be set.
  64240. * @returns this effect.
  64241. */
  64242. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  64243. this._valueCache[uniformName] = null;
  64244. this._engine.setMatrix2x2(this.getUniform(uniformName), matrix);
  64245. return this;
  64246. };
  64247. /**
  64248. * Sets a float on a uniform variable.
  64249. * @param uniformName Name of the variable.
  64250. * @param value value to be set.
  64251. * @returns this effect.
  64252. */
  64253. Effect.prototype.setFloat = function (uniformName, value) {
  64254. var cache = this._valueCache[uniformName];
  64255. if (cache !== undefined && cache === value) {
  64256. return this;
  64257. }
  64258. this._valueCache[uniformName] = value;
  64259. this._engine.setFloat(this.getUniform(uniformName), value);
  64260. return this;
  64261. };
  64262. /**
  64263. * Sets a boolean on a uniform variable.
  64264. * @param uniformName Name of the variable.
  64265. * @param bool value to be set.
  64266. * @returns this effect.
  64267. */
  64268. Effect.prototype.setBool = function (uniformName, bool) {
  64269. var cache = this._valueCache[uniformName];
  64270. if (cache !== undefined && cache === bool) {
  64271. return this;
  64272. }
  64273. this._valueCache[uniformName] = bool;
  64274. this._engine.setBool(this.getUniform(uniformName), bool ? 1 : 0);
  64275. return this;
  64276. };
  64277. /**
  64278. * Sets a Vector2 on a uniform variable.
  64279. * @param uniformName Name of the variable.
  64280. * @param vector2 vector2 to be set.
  64281. * @returns this effect.
  64282. */
  64283. Effect.prototype.setVector2 = function (uniformName, vector2) {
  64284. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  64285. this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
  64286. }
  64287. return this;
  64288. };
  64289. /**
  64290. * Sets a float2 on a uniform variable.
  64291. * @param uniformName Name of the variable.
  64292. * @param x First float in float2.
  64293. * @param y Second float in float2.
  64294. * @returns this effect.
  64295. */
  64296. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  64297. if (this._cacheFloat2(uniformName, x, y)) {
  64298. this._engine.setFloat2(this.getUniform(uniformName), x, y);
  64299. }
  64300. return this;
  64301. };
  64302. /**
  64303. * Sets a Vector3 on a uniform variable.
  64304. * @param uniformName Name of the variable.
  64305. * @param vector3 Value to be set.
  64306. * @returns this effect.
  64307. */
  64308. Effect.prototype.setVector3 = function (uniformName, vector3) {
  64309. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  64310. this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
  64311. }
  64312. return this;
  64313. };
  64314. /**
  64315. * Sets a float3 on a uniform variable.
  64316. * @param uniformName Name of the variable.
  64317. * @param x First float in float3.
  64318. * @param y Second float in float3.
  64319. * @param z Third float in float3.
  64320. * @returns this effect.
  64321. */
  64322. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  64323. if (this._cacheFloat3(uniformName, x, y, z)) {
  64324. this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
  64325. }
  64326. return this;
  64327. };
  64328. /**
  64329. * Sets a Vector4 on a uniform variable.
  64330. * @param uniformName Name of the variable.
  64331. * @param vector4 Value to be set.
  64332. * @returns this effect.
  64333. */
  64334. Effect.prototype.setVector4 = function (uniformName, vector4) {
  64335. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  64336. this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
  64337. }
  64338. return this;
  64339. };
  64340. /**
  64341. * Sets a float4 on a uniform variable.
  64342. * @param uniformName Name of the variable.
  64343. * @param x First float in float4.
  64344. * @param y Second float in float4.
  64345. * @param z Third float in float4.
  64346. * @param w Fourth float in float4.
  64347. * @returns this effect.
  64348. */
  64349. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  64350. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  64351. this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
  64352. }
  64353. return this;
  64354. };
  64355. /**
  64356. * Sets a Color3 on a uniform variable.
  64357. * @param uniformName Name of the variable.
  64358. * @param color3 Value to be set.
  64359. * @returns this effect.
  64360. */
  64361. Effect.prototype.setColor3 = function (uniformName, color3) {
  64362. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  64363. this._engine.setColor3(this.getUniform(uniformName), color3);
  64364. }
  64365. return this;
  64366. };
  64367. /**
  64368. * Sets a Color4 on a uniform variable.
  64369. * @param uniformName Name of the variable.
  64370. * @param color3 Value to be set.
  64371. * @param alpha Alpha value to be set.
  64372. * @returns this effect.
  64373. */
  64374. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  64375. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  64376. this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
  64377. }
  64378. return this;
  64379. };
  64380. /**
  64381. * Sets a Color4 on a uniform variable
  64382. * @param uniformName defines the name of the variable
  64383. * @param color4 defines the value to be set
  64384. * @returns this effect.
  64385. */
  64386. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  64387. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  64388. this._engine.setDirectColor4(this.getUniform(uniformName), color4);
  64389. }
  64390. return this;
  64391. };
  64392. /**
  64393. * This function will add a new shader to the shader store
  64394. * @param name the name of the shader
  64395. * @param pixelShader optional pixel shader content
  64396. * @param vertexShader optional vertex shader content
  64397. */
  64398. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  64399. if (pixelShader) {
  64400. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  64401. }
  64402. if (vertexShader) {
  64403. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  64404. }
  64405. };
  64406. /**
  64407. * Resets the cache of effects.
  64408. */
  64409. Effect.ResetCache = function () {
  64410. Effect._baseCache = {};
  64411. };
  64412. /**
  64413. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  64414. */
  64415. Effect.ShadersRepository = "src/Shaders/";
  64416. Effect._uniqueIdSeed = 0;
  64417. Effect._baseCache = {};
  64418. /**
  64419. * Store of each shader (The can be looked up using effect.key)
  64420. */
  64421. Effect.ShadersStore = {};
  64422. /**
  64423. * Store of each included file for a shader (The can be looked up using effect.key)
  64424. */
  64425. Effect.IncludesShadersStore = {};
  64426. return Effect;
  64427. }());
  64428. /***/ }),
  64429. /***/ "./Materials/fresnelParameters.ts":
  64430. /*!****************************************!*\
  64431. !*** ./Materials/fresnelParameters.ts ***!
  64432. \****************************************/
  64433. /*! exports provided: FresnelParameters */
  64434. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64435. "use strict";
  64436. __webpack_require__.r(__webpack_exports__);
  64437. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  64438. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  64439. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64440. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  64441. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64442. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  64443. /**
  64444. * This represents all the required information to add a fresnel effect on a material:
  64445. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  64446. */
  64447. var FresnelParameters = /** @class */ (function () {
  64448. function FresnelParameters() {
  64449. this._isEnabled = true;
  64450. /**
  64451. * Define the color used on edges (grazing angle)
  64452. */
  64453. this.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  64454. /**
  64455. * Define the color used on center
  64456. */
  64457. this.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  64458. /**
  64459. * Define bias applied to computed fresnel term
  64460. */
  64461. this.bias = 0;
  64462. /**
  64463. * Defined the power exponent applied to fresnel term
  64464. */
  64465. this.power = 1;
  64466. }
  64467. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  64468. /**
  64469. * Define if the fresnel effect is enable or not.
  64470. */
  64471. get: function () {
  64472. return this._isEnabled;
  64473. },
  64474. set: function (value) {
  64475. if (this._isEnabled === value) {
  64476. return;
  64477. }
  64478. this._isEnabled = value;
  64479. _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);
  64480. },
  64481. enumerable: true,
  64482. configurable: true
  64483. });
  64484. /**
  64485. * Clones the current fresnel and its valuues
  64486. * @returns a clone fresnel configuration
  64487. */
  64488. FresnelParameters.prototype.clone = function () {
  64489. var newFresnelParameters = new FresnelParameters();
  64490. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  64491. return newFresnelParameters;
  64492. };
  64493. /**
  64494. * Serializes the current fresnel parameters to a JSON representation.
  64495. * @return the JSON serialization
  64496. */
  64497. FresnelParameters.prototype.serialize = function () {
  64498. var serializationObject = {};
  64499. serializationObject.isEnabled = this.isEnabled;
  64500. serializationObject.leftColor = this.leftColor.asArray();
  64501. serializationObject.rightColor = this.rightColor.asArray();
  64502. serializationObject.bias = this.bias;
  64503. serializationObject.power = this.power;
  64504. return serializationObject;
  64505. };
  64506. /**
  64507. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  64508. * @param parsedFresnelParameters Define the JSON representation
  64509. * @returns the parsed parameters
  64510. */
  64511. FresnelParameters.Parse = function (parsedFresnelParameters) {
  64512. var fresnelParameters = new FresnelParameters();
  64513. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  64514. fresnelParameters.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  64515. fresnelParameters.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  64516. fresnelParameters.bias = parsedFresnelParameters.bias;
  64517. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  64518. return fresnelParameters;
  64519. };
  64520. return FresnelParameters;
  64521. }());
  64522. // References the dependencies.
  64523. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  64524. /***/ }),
  64525. /***/ "./Materials/imageProcessingConfiguration.ts":
  64526. /*!***************************************************!*\
  64527. !*** ./Materials/imageProcessingConfiguration.ts ***!
  64528. \***************************************************/
  64529. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  64530. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64531. "use strict";
  64532. __webpack_require__.r(__webpack_exports__);
  64533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  64534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  64535. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64536. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  64537. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  64538. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  64539. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64540. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  64541. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  64542. /**
  64543. * @hidden
  64544. */
  64545. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  64546. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  64547. function ImageProcessingConfigurationDefines() {
  64548. var _this = _super.call(this) || this;
  64549. _this.IMAGEPROCESSING = false;
  64550. _this.VIGNETTE = false;
  64551. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  64552. _this.VIGNETTEBLENDMODEOPAQUE = false;
  64553. _this.TONEMAPPING = false;
  64554. _this.TONEMAPPING_ACES = false;
  64555. _this.CONTRAST = false;
  64556. _this.COLORCURVES = false;
  64557. _this.COLORGRADING = false;
  64558. _this.COLORGRADING3D = false;
  64559. _this.SAMPLER3DGREENDEPTH = false;
  64560. _this.SAMPLER3DBGRMAP = false;
  64561. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  64562. _this.EXPOSURE = false;
  64563. _this.rebuild();
  64564. return _this;
  64565. }
  64566. return ImageProcessingConfigurationDefines;
  64567. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  64568. /**
  64569. * This groups together the common properties used for image processing either in direct forward pass
  64570. * or through post processing effect depending on the use of the image processing pipeline in your scene
  64571. * or not.
  64572. */
  64573. var ImageProcessingConfiguration = /** @class */ (function () {
  64574. function ImageProcessingConfiguration() {
  64575. /**
  64576. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  64577. */
  64578. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  64579. this._colorCurvesEnabled = false;
  64580. this._colorGradingEnabled = false;
  64581. this._colorGradingWithGreenDepth = true;
  64582. this._colorGradingBGR = true;
  64583. /** @hidden */
  64584. this._exposure = 1.0;
  64585. this._toneMappingEnabled = false;
  64586. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  64587. this._contrast = 1.0;
  64588. /**
  64589. * Vignette stretch size.
  64590. */
  64591. this.vignetteStretch = 0;
  64592. /**
  64593. * Vignette centre X Offset.
  64594. */
  64595. this.vignetteCentreX = 0;
  64596. /**
  64597. * Vignette centre Y Offset.
  64598. */
  64599. this.vignetteCentreY = 0;
  64600. /**
  64601. * Vignette weight or intensity of the vignette effect.
  64602. */
  64603. this.vignetteWeight = 1.5;
  64604. /**
  64605. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  64606. * if vignetteEnabled is set to true.
  64607. */
  64608. this.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  64609. /**
  64610. * Camera field of view used by the Vignette effect.
  64611. */
  64612. this.vignetteCameraFov = 0.5;
  64613. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  64614. this._vignetteEnabled = false;
  64615. this._applyByPostProcess = false;
  64616. this._isEnabled = true;
  64617. /**
  64618. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  64619. */
  64620. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  64621. }
  64622. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  64623. /**
  64624. * Gets wether the color curves effect is enabled.
  64625. */
  64626. get: function () {
  64627. return this._colorCurvesEnabled;
  64628. },
  64629. /**
  64630. * Sets wether the color curves effect is enabled.
  64631. */
  64632. set: function (value) {
  64633. if (this._colorCurvesEnabled === value) {
  64634. return;
  64635. }
  64636. this._colorCurvesEnabled = value;
  64637. this._updateParameters();
  64638. },
  64639. enumerable: true,
  64640. configurable: true
  64641. });
  64642. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  64643. /**
  64644. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  64645. */
  64646. get: function () {
  64647. return this._colorGradingTexture;
  64648. },
  64649. /**
  64650. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  64651. */
  64652. set: function (value) {
  64653. if (this._colorGradingTexture === value) {
  64654. return;
  64655. }
  64656. this._colorGradingTexture = value;
  64657. this._updateParameters();
  64658. },
  64659. enumerable: true,
  64660. configurable: true
  64661. });
  64662. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  64663. /**
  64664. * Gets wether the color grading effect is enabled.
  64665. */
  64666. get: function () {
  64667. return this._colorGradingEnabled;
  64668. },
  64669. /**
  64670. * Sets wether the color grading effect is enabled.
  64671. */
  64672. set: function (value) {
  64673. if (this._colorGradingEnabled === value) {
  64674. return;
  64675. }
  64676. this._colorGradingEnabled = value;
  64677. this._updateParameters();
  64678. },
  64679. enumerable: true,
  64680. configurable: true
  64681. });
  64682. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  64683. /**
  64684. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  64685. */
  64686. get: function () {
  64687. return this._colorGradingWithGreenDepth;
  64688. },
  64689. /**
  64690. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  64691. */
  64692. set: function (value) {
  64693. if (this._colorGradingWithGreenDepth === value) {
  64694. return;
  64695. }
  64696. this._colorGradingWithGreenDepth = value;
  64697. this._updateParameters();
  64698. },
  64699. enumerable: true,
  64700. configurable: true
  64701. });
  64702. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  64703. /**
  64704. * Gets wether the color grading texture contains BGR values.
  64705. */
  64706. get: function () {
  64707. return this._colorGradingBGR;
  64708. },
  64709. /**
  64710. * Sets wether the color grading texture contains BGR values.
  64711. */
  64712. set: function (value) {
  64713. if (this._colorGradingBGR === value) {
  64714. return;
  64715. }
  64716. this._colorGradingBGR = value;
  64717. this._updateParameters();
  64718. },
  64719. enumerable: true,
  64720. configurable: true
  64721. });
  64722. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  64723. /**
  64724. * Gets the Exposure used in the effect.
  64725. */
  64726. get: function () {
  64727. return this._exposure;
  64728. },
  64729. /**
  64730. * Sets the Exposure used in the effect.
  64731. */
  64732. set: function (value) {
  64733. if (this._exposure === value) {
  64734. return;
  64735. }
  64736. this._exposure = value;
  64737. this._updateParameters();
  64738. },
  64739. enumerable: true,
  64740. configurable: true
  64741. });
  64742. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  64743. /**
  64744. * Gets wether the tone mapping effect is enabled.
  64745. */
  64746. get: function () {
  64747. return this._toneMappingEnabled;
  64748. },
  64749. /**
  64750. * Sets wether the tone mapping effect is enabled.
  64751. */
  64752. set: function (value) {
  64753. if (this._toneMappingEnabled === value) {
  64754. return;
  64755. }
  64756. this._toneMappingEnabled = value;
  64757. this._updateParameters();
  64758. },
  64759. enumerable: true,
  64760. configurable: true
  64761. });
  64762. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  64763. /**
  64764. * Gets the type of tone mapping effect.
  64765. */
  64766. get: function () {
  64767. return this._toneMappingType;
  64768. },
  64769. /**
  64770. * Sets the type of tone mapping effect used in BabylonJS.
  64771. */
  64772. set: function (value) {
  64773. if (this._toneMappingType === value) {
  64774. return;
  64775. }
  64776. this._toneMappingType = value;
  64777. this._updateParameters();
  64778. },
  64779. enumerable: true,
  64780. configurable: true
  64781. });
  64782. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  64783. /**
  64784. * Gets the contrast used in the effect.
  64785. */
  64786. get: function () {
  64787. return this._contrast;
  64788. },
  64789. /**
  64790. * Sets the contrast used in the effect.
  64791. */
  64792. set: function (value) {
  64793. if (this._contrast === value) {
  64794. return;
  64795. }
  64796. this._contrast = value;
  64797. this._updateParameters();
  64798. },
  64799. enumerable: true,
  64800. configurable: true
  64801. });
  64802. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  64803. /**
  64804. * Gets the vignette blend mode allowing different kind of effect.
  64805. */
  64806. get: function () {
  64807. return this._vignetteBlendMode;
  64808. },
  64809. /**
  64810. * Sets the vignette blend mode allowing different kind of effect.
  64811. */
  64812. set: function (value) {
  64813. if (this._vignetteBlendMode === value) {
  64814. return;
  64815. }
  64816. this._vignetteBlendMode = value;
  64817. this._updateParameters();
  64818. },
  64819. enumerable: true,
  64820. configurable: true
  64821. });
  64822. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  64823. /**
  64824. * Gets wether the vignette effect is enabled.
  64825. */
  64826. get: function () {
  64827. return this._vignetteEnabled;
  64828. },
  64829. /**
  64830. * Sets wether the vignette effect is enabled.
  64831. */
  64832. set: function (value) {
  64833. if (this._vignetteEnabled === value) {
  64834. return;
  64835. }
  64836. this._vignetteEnabled = value;
  64837. this._updateParameters();
  64838. },
  64839. enumerable: true,
  64840. configurable: true
  64841. });
  64842. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  64843. /**
  64844. * Gets wether the image processing is applied through a post process or not.
  64845. */
  64846. get: function () {
  64847. return this._applyByPostProcess;
  64848. },
  64849. /**
  64850. * Sets wether the image processing is applied through a post process or not.
  64851. */
  64852. set: function (value) {
  64853. if (this._applyByPostProcess === value) {
  64854. return;
  64855. }
  64856. this._applyByPostProcess = value;
  64857. this._updateParameters();
  64858. },
  64859. enumerable: true,
  64860. configurable: true
  64861. });
  64862. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  64863. /**
  64864. * Gets wether the image processing is enabled or not.
  64865. */
  64866. get: function () {
  64867. return this._isEnabled;
  64868. },
  64869. /**
  64870. * Sets wether the image processing is enabled or not.
  64871. */
  64872. set: function (value) {
  64873. if (this._isEnabled === value) {
  64874. return;
  64875. }
  64876. this._isEnabled = value;
  64877. this._updateParameters();
  64878. },
  64879. enumerable: true,
  64880. configurable: true
  64881. });
  64882. /**
  64883. * Method called each time the image processing information changes requires to recompile the effect.
  64884. */
  64885. ImageProcessingConfiguration.prototype._updateParameters = function () {
  64886. this.onUpdateParameters.notifyObservers(this);
  64887. };
  64888. /**
  64889. * Gets the current class name.
  64890. * @return "ImageProcessingConfiguration"
  64891. */
  64892. ImageProcessingConfiguration.prototype.getClassName = function () {
  64893. return "ImageProcessingConfiguration";
  64894. };
  64895. /**
  64896. * Prepare the list of uniforms associated with the Image Processing effects.
  64897. * @param uniforms The list of uniforms used in the effect
  64898. * @param defines the list of defines currently in use
  64899. */
  64900. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  64901. if (defines.EXPOSURE) {
  64902. uniforms.push("exposureLinear");
  64903. }
  64904. if (defines.CONTRAST) {
  64905. uniforms.push("contrast");
  64906. }
  64907. if (defines.COLORGRADING) {
  64908. uniforms.push("colorTransformSettings");
  64909. }
  64910. if (defines.VIGNETTE) {
  64911. uniforms.push("vInverseScreenSize");
  64912. uniforms.push("vignetteSettings1");
  64913. uniforms.push("vignetteSettings2");
  64914. }
  64915. if (defines.COLORCURVES) {
  64916. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  64917. }
  64918. };
  64919. /**
  64920. * Prepare the list of samplers associated with the Image Processing effects.
  64921. * @param samplersList The list of uniforms used in the effect
  64922. * @param defines the list of defines currently in use
  64923. */
  64924. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  64925. if (defines.COLORGRADING) {
  64926. samplersList.push("txColorTransform");
  64927. }
  64928. };
  64929. /**
  64930. * Prepare the list of defines associated to the shader.
  64931. * @param defines the list of defines to complete
  64932. * @param forPostProcess Define if we are currently in post process mode or not
  64933. */
  64934. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  64935. if (forPostProcess === void 0) { forPostProcess = false; }
  64936. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  64937. defines.VIGNETTE = false;
  64938. defines.TONEMAPPING = false;
  64939. defines.TONEMAPPING_ACES = false;
  64940. defines.CONTRAST = false;
  64941. defines.EXPOSURE = false;
  64942. defines.COLORCURVES = false;
  64943. defines.COLORGRADING = false;
  64944. defines.COLORGRADING3D = false;
  64945. defines.IMAGEPROCESSING = false;
  64946. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  64947. return;
  64948. }
  64949. defines.VIGNETTE = this.vignetteEnabled;
  64950. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  64951. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  64952. defines.TONEMAPPING = this.toneMappingEnabled;
  64953. switch (this._toneMappingType) {
  64954. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  64955. defines.TONEMAPPING_ACES = true;
  64956. break;
  64957. default:
  64958. defines.TONEMAPPING_ACES = false;
  64959. break;
  64960. }
  64961. defines.CONTRAST = (this.contrast !== 1.0);
  64962. defines.EXPOSURE = (this.exposure !== 1.0);
  64963. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  64964. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  64965. if (defines.COLORGRADING) {
  64966. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  64967. }
  64968. else {
  64969. defines.COLORGRADING3D = false;
  64970. }
  64971. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  64972. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  64973. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  64974. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  64975. };
  64976. /**
  64977. * Returns true if all the image processing information are ready.
  64978. * @returns True if ready, otherwise, false
  64979. */
  64980. ImageProcessingConfiguration.prototype.isReady = function () {
  64981. // Color Grading texure can not be none blocking.
  64982. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  64983. };
  64984. /**
  64985. * Binds the image processing to the shader.
  64986. * @param effect The effect to bind to
  64987. * @param aspectRatio Define the current aspect ratio of the effect
  64988. */
  64989. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  64990. if (aspectRatio === void 0) { aspectRatio = 1; }
  64991. // Color Curves
  64992. if (this._colorCurvesEnabled && this.colorCurves) {
  64993. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  64994. }
  64995. // Vignette
  64996. if (this._vignetteEnabled) {
  64997. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  64998. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  64999. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  65000. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  65001. var vignetteScaleX = vignetteScaleY * aspectRatio;
  65002. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  65003. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  65004. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  65005. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  65006. var vignettePower = -2.0 * this.vignetteWeight;
  65007. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  65008. }
  65009. // Exposure
  65010. effect.setFloat("exposureLinear", this.exposure);
  65011. // Contrast
  65012. effect.setFloat("contrast", this.contrast);
  65013. // Color transform settings
  65014. if (this.colorGradingTexture) {
  65015. effect.setTexture("txColorTransform", this.colorGradingTexture);
  65016. var textureSize = this.colorGradingTexture.getSize().height;
  65017. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  65018. 0.5 / textureSize, // textureOffset
  65019. textureSize, // textureSize
  65020. this.colorGradingTexture.level // weight
  65021. );
  65022. }
  65023. };
  65024. /**
  65025. * Clones the current image processing instance.
  65026. * @return The cloned image processing
  65027. */
  65028. ImageProcessingConfiguration.prototype.clone = function () {
  65029. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  65030. };
  65031. /**
  65032. * Serializes the current image processing instance to a json representation.
  65033. * @return a JSON representation
  65034. */
  65035. ImageProcessingConfiguration.prototype.serialize = function () {
  65036. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  65037. };
  65038. /**
  65039. * Parses the image processing from a json representation.
  65040. * @param source the JSON source to parse
  65041. * @return The parsed image processing
  65042. */
  65043. ImageProcessingConfiguration.Parse = function (source) {
  65044. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  65045. };
  65046. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  65047. /**
  65048. * Used to apply the vignette as a mix with the pixel color.
  65049. */
  65050. get: function () {
  65051. return this._VIGNETTEMODE_MULTIPLY;
  65052. },
  65053. enumerable: true,
  65054. configurable: true
  65055. });
  65056. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  65057. /**
  65058. * Used to apply the vignette as a replacement of the pixel color.
  65059. */
  65060. get: function () {
  65061. return this._VIGNETTEMODE_OPAQUE;
  65062. },
  65063. enumerable: true,
  65064. configurable: true
  65065. });
  65066. /**
  65067. * Default tone mapping applied in BabylonJS.
  65068. */
  65069. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  65070. /**
  65071. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  65072. * to other engines rendering to increase portability.
  65073. */
  65074. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  65075. // Static constants associated to the image processing.
  65076. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  65077. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  65078. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65079. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  65080. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  65081. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65082. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65083. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  65084. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65085. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  65086. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  65087. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65088. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65089. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  65090. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65091. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65092. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  65093. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65094. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65095. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  65096. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65097. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65098. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  65099. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65100. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65101. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  65102. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65103. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65104. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  65105. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65106. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65107. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  65108. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65109. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65110. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  65111. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65113. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  65114. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65115. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65116. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  65117. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65118. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65119. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  65120. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65121. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  65122. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  65123. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65124. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65125. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  65126. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65127. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65128. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  65129. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65130. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65131. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  65132. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65133. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65134. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  65135. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  65136. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  65137. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  65138. return ImageProcessingConfiguration;
  65139. }());
  65140. // References the dependencies.
  65141. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  65142. /***/ }),
  65143. /***/ "./Materials/index.ts":
  65144. /*!****************************!*\
  65145. !*** ./Materials/index.ts ***!
  65146. \****************************/
  65147. /*! exports provided: ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, MirrorTexture, MultiRenderTarget, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, BackgroundMaterial, PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  65148. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65149. "use strict";
  65150. __webpack_require__.r(__webpack_exports__);
  65151. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  65152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  65153. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  65154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  65155. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  65156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  65157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  65158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  65159. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  65160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  65161. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  65162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  65163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  65164. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  65165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  65166. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  65167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  65168. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  65169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  65170. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  65171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  65172. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  65173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterialDefines"]; });
  65174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  65175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  65176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  65177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  65178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  65179. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  65180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  65181. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  65182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  65183. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  65184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  65185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  65186. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  65187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  65188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  65189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["EquiRectangularCubeTexture"]; });
  65190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  65191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  65192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  65193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  65194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  65195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  65196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  65197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  65198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  65199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  65200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  65201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  65202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  65203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  65204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  65205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  65206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  65207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  65208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  65209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  65210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  65211. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  65212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  65213. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  65214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  65215. /***/ }),
  65216. /***/ "./Materials/material.ts":
  65217. /*!*******************************!*\
  65218. !*** ./Materials/material.ts ***!
  65219. \*******************************/
  65220. /*! exports provided: Material */
  65221. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65222. "use strict";
  65223. __webpack_require__.r(__webpack_exports__);
  65224. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  65225. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  65226. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  65227. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  65228. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  65229. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  65230. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  65231. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  65232. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  65233. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  65234. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  65235. /**
  65236. * Base class for the main features of a material in Babylon.js
  65237. */
  65238. var Material = /** @class */ (function () {
  65239. /**
  65240. * Creates a material instance
  65241. * @param name defines the name of the material
  65242. * @param scene defines the scene to reference
  65243. * @param doNotAdd specifies if the material should be added to the scene
  65244. */
  65245. function Material(name, scene, doNotAdd) {
  65246. /**
  65247. * Gets or sets user defined metadata
  65248. */
  65249. this.metadata = null;
  65250. /**
  65251. * For internal use only. Please do not use.
  65252. */
  65253. this.reservedDataStore = null;
  65254. /**
  65255. * Specifies if the ready state should be checked on each call
  65256. */
  65257. this.checkReadyOnEveryCall = false;
  65258. /**
  65259. * Specifies if the ready state should be checked once
  65260. */
  65261. this.checkReadyOnlyOnce = false;
  65262. /**
  65263. * The state of the material
  65264. */
  65265. this.state = "";
  65266. /**
  65267. * The alpha value of the material
  65268. */
  65269. this._alpha = 1.0;
  65270. /**
  65271. * Specifies if back face culling is enabled
  65272. */
  65273. this._backFaceCulling = true;
  65274. /**
  65275. * Specifies if the material should be serialized
  65276. */
  65277. this.doNotSerialize = false;
  65278. /**
  65279. * @hidden
  65280. */
  65281. this._storeEffectOnSubMeshes = false;
  65282. /**
  65283. * An event triggered when the material is disposed
  65284. */
  65285. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  65286. /**
  65287. * Stores the value of the alpha mode
  65288. */
  65289. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  65290. /**
  65291. * Stores the state of the need depth pre-pass value
  65292. */
  65293. this._needDepthPrePass = false;
  65294. /**
  65295. * Specifies if depth writing should be disabled
  65296. */
  65297. this.disableDepthWrite = false;
  65298. /**
  65299. * Specifies if depth writing should be forced
  65300. */
  65301. this.forceDepthWrite = false;
  65302. /**
  65303. * Specifies if there should be a separate pass for culling
  65304. */
  65305. this.separateCullingPass = false;
  65306. /**
  65307. * Stores the state specifing if fog should be enabled
  65308. */
  65309. this._fogEnabled = true;
  65310. /**
  65311. * Stores the size of points
  65312. */
  65313. this.pointSize = 1.0;
  65314. /**
  65315. * Stores the z offset value
  65316. */
  65317. this.zOffset = 0;
  65318. /**
  65319. * @hidden
  65320. * Specifies if the material was previously ready
  65321. */
  65322. this._wasPreviouslyReady = false;
  65323. /**
  65324. * Stores the fill mode state
  65325. */
  65326. this._fillMode = Material.TriangleFillMode;
  65327. /** @hidden */
  65328. this._indexInSceneMaterialArray = -1;
  65329. this.name = name;
  65330. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  65331. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  65332. this.uniqueId = this._scene.getUniqueId();
  65333. if (this._scene.useRightHandedSystem) {
  65334. this.sideOrientation = Material.ClockWiseSideOrientation;
  65335. }
  65336. else {
  65337. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  65338. }
  65339. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__["UniformBuffer"](this._scene.getEngine());
  65340. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  65341. if (!doNotAdd) {
  65342. this._scene.addMaterial(this);
  65343. }
  65344. if (this._scene.useMaterialMeshMap) {
  65345. this.meshMap = {};
  65346. }
  65347. }
  65348. Object.defineProperty(Material.prototype, "alpha", {
  65349. /**
  65350. * Gets the alpha value of the material
  65351. */
  65352. get: function () {
  65353. return this._alpha;
  65354. },
  65355. /**
  65356. * Sets the alpha value of the material
  65357. */
  65358. set: function (value) {
  65359. if (this._alpha === value) {
  65360. return;
  65361. }
  65362. this._alpha = value;
  65363. this.markAsDirty(Material.MiscDirtyFlag);
  65364. },
  65365. enumerable: true,
  65366. configurable: true
  65367. });
  65368. Object.defineProperty(Material.prototype, "backFaceCulling", {
  65369. /**
  65370. * Gets the back-face culling state
  65371. */
  65372. get: function () {
  65373. return this._backFaceCulling;
  65374. },
  65375. /**
  65376. * Sets the back-face culling state
  65377. */
  65378. set: function (value) {
  65379. if (this._backFaceCulling === value) {
  65380. return;
  65381. }
  65382. this._backFaceCulling = value;
  65383. this.markAsDirty(Material.TextureDirtyFlag);
  65384. },
  65385. enumerable: true,
  65386. configurable: true
  65387. });
  65388. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  65389. /**
  65390. * Gets a boolean indicating that current material needs to register RTT
  65391. */
  65392. get: function () {
  65393. return false;
  65394. },
  65395. enumerable: true,
  65396. configurable: true
  65397. });
  65398. Object.defineProperty(Material.prototype, "onDispose", {
  65399. /**
  65400. * Called during a dispose event
  65401. */
  65402. set: function (callback) {
  65403. if (this._onDisposeObserver) {
  65404. this.onDisposeObservable.remove(this._onDisposeObserver);
  65405. }
  65406. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  65407. },
  65408. enumerable: true,
  65409. configurable: true
  65410. });
  65411. Object.defineProperty(Material.prototype, "onBindObservable", {
  65412. /**
  65413. * An event triggered when the material is bound
  65414. */
  65415. get: function () {
  65416. if (!this._onBindObservable) {
  65417. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  65418. }
  65419. return this._onBindObservable;
  65420. },
  65421. enumerable: true,
  65422. configurable: true
  65423. });
  65424. Object.defineProperty(Material.prototype, "onBind", {
  65425. /**
  65426. * Called during a bind event
  65427. */
  65428. set: function (callback) {
  65429. if (this._onBindObserver) {
  65430. this.onBindObservable.remove(this._onBindObserver);
  65431. }
  65432. this._onBindObserver = this.onBindObservable.add(callback);
  65433. },
  65434. enumerable: true,
  65435. configurable: true
  65436. });
  65437. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  65438. /**
  65439. * An event triggered when the material is unbound
  65440. */
  65441. get: function () {
  65442. if (!this._onUnBindObservable) {
  65443. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  65444. }
  65445. return this._onUnBindObservable;
  65446. },
  65447. enumerable: true,
  65448. configurable: true
  65449. });
  65450. Object.defineProperty(Material.prototype, "alphaMode", {
  65451. /**
  65452. * Gets the value of the alpha mode
  65453. */
  65454. get: function () {
  65455. return this._alphaMode;
  65456. },
  65457. /**
  65458. * Sets the value of the alpha mode.
  65459. *
  65460. * | Value | Type | Description |
  65461. * | --- | --- | --- |
  65462. * | 0 | ALPHA_DISABLE | |
  65463. * | 1 | ALPHA_ADD | |
  65464. * | 2 | ALPHA_COMBINE | |
  65465. * | 3 | ALPHA_SUBTRACT | |
  65466. * | 4 | ALPHA_MULTIPLY | |
  65467. * | 5 | ALPHA_MAXIMIZED | |
  65468. * | 6 | ALPHA_ONEONE | |
  65469. * | 7 | ALPHA_PREMULTIPLIED | |
  65470. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  65471. * | 9 | ALPHA_INTERPOLATE | |
  65472. * | 10 | ALPHA_SCREENMODE | |
  65473. *
  65474. */
  65475. set: function (value) {
  65476. if (this._alphaMode === value) {
  65477. return;
  65478. }
  65479. this._alphaMode = value;
  65480. this.markAsDirty(Material.TextureDirtyFlag);
  65481. },
  65482. enumerable: true,
  65483. configurable: true
  65484. });
  65485. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  65486. /**
  65487. * Gets the depth pre-pass value
  65488. */
  65489. get: function () {
  65490. return this._needDepthPrePass;
  65491. },
  65492. /**
  65493. * Sets the need depth pre-pass value
  65494. */
  65495. set: function (value) {
  65496. if (this._needDepthPrePass === value) {
  65497. return;
  65498. }
  65499. this._needDepthPrePass = value;
  65500. if (this._needDepthPrePass) {
  65501. this.checkReadyOnEveryCall = true;
  65502. }
  65503. },
  65504. enumerable: true,
  65505. configurable: true
  65506. });
  65507. Object.defineProperty(Material.prototype, "fogEnabled", {
  65508. /**
  65509. * Gets the value of the fog enabled state
  65510. */
  65511. get: function () {
  65512. return this._fogEnabled;
  65513. },
  65514. /**
  65515. * Sets the state for enabling fog
  65516. */
  65517. set: function (value) {
  65518. if (this._fogEnabled === value) {
  65519. return;
  65520. }
  65521. this._fogEnabled = value;
  65522. this.markAsDirty(Material.MiscDirtyFlag);
  65523. },
  65524. enumerable: true,
  65525. configurable: true
  65526. });
  65527. Object.defineProperty(Material.prototype, "wireframe", {
  65528. /**
  65529. * Gets a value specifying if wireframe mode is enabled
  65530. */
  65531. get: function () {
  65532. switch (this._fillMode) {
  65533. case Material.WireFrameFillMode:
  65534. case Material.LineListDrawMode:
  65535. case Material.LineLoopDrawMode:
  65536. case Material.LineStripDrawMode:
  65537. return true;
  65538. }
  65539. return this._scene.forceWireframe;
  65540. },
  65541. /**
  65542. * Sets the state of wireframe mode
  65543. */
  65544. set: function (value) {
  65545. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  65546. },
  65547. enumerable: true,
  65548. configurable: true
  65549. });
  65550. Object.defineProperty(Material.prototype, "pointsCloud", {
  65551. /**
  65552. * Gets the value specifying if point clouds are enabled
  65553. */
  65554. get: function () {
  65555. switch (this._fillMode) {
  65556. case Material.PointFillMode:
  65557. case Material.PointListDrawMode:
  65558. return true;
  65559. }
  65560. return this._scene.forcePointsCloud;
  65561. },
  65562. /**
  65563. * Sets the state of point cloud mode
  65564. */
  65565. set: function (value) {
  65566. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  65567. },
  65568. enumerable: true,
  65569. configurable: true
  65570. });
  65571. Object.defineProperty(Material.prototype, "fillMode", {
  65572. /**
  65573. * Gets the material fill mode
  65574. */
  65575. get: function () {
  65576. return this._fillMode;
  65577. },
  65578. /**
  65579. * Sets the material fill mode
  65580. */
  65581. set: function (value) {
  65582. if (this._fillMode === value) {
  65583. return;
  65584. }
  65585. this._fillMode = value;
  65586. this.markAsDirty(Material.MiscDirtyFlag);
  65587. },
  65588. enumerable: true,
  65589. configurable: true
  65590. });
  65591. /**
  65592. * Returns a string representation of the current material
  65593. * @param fullDetails defines a boolean indicating which levels of logging is desired
  65594. * @returns a string with material information
  65595. */
  65596. Material.prototype.toString = function (fullDetails) {
  65597. var ret = "Name: " + this.name;
  65598. if (fullDetails) {
  65599. }
  65600. return ret;
  65601. };
  65602. /**
  65603. * Gets the class name of the material
  65604. * @returns a string with the class name of the material
  65605. */
  65606. Material.prototype.getClassName = function () {
  65607. return "Material";
  65608. };
  65609. Object.defineProperty(Material.prototype, "isFrozen", {
  65610. /**
  65611. * Specifies if updates for the material been locked
  65612. */
  65613. get: function () {
  65614. return this.checkReadyOnlyOnce;
  65615. },
  65616. enumerable: true,
  65617. configurable: true
  65618. });
  65619. /**
  65620. * Locks updates for the material
  65621. */
  65622. Material.prototype.freeze = function () {
  65623. this.checkReadyOnlyOnce = true;
  65624. };
  65625. /**
  65626. * Unlocks updates for the material
  65627. */
  65628. Material.prototype.unfreeze = function () {
  65629. this.checkReadyOnlyOnce = false;
  65630. };
  65631. /**
  65632. * Specifies if the material is ready to be used
  65633. * @param mesh defines the mesh to check
  65634. * @param useInstances specifies if instances should be used
  65635. * @returns a boolean indicating if the material is ready to be used
  65636. */
  65637. Material.prototype.isReady = function (mesh, useInstances) {
  65638. return true;
  65639. };
  65640. /**
  65641. * Specifies that the submesh is ready to be used
  65642. * @param mesh defines the mesh to check
  65643. * @param subMesh defines which submesh to check
  65644. * @param useInstances specifies that instances should be used
  65645. * @returns a boolean indicating that the submesh is ready or not
  65646. */
  65647. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  65648. return false;
  65649. };
  65650. /**
  65651. * Returns the material effect
  65652. * @returns the effect associated with the material
  65653. */
  65654. Material.prototype.getEffect = function () {
  65655. return this._effect;
  65656. };
  65657. /**
  65658. * Returns the current scene
  65659. * @returns a Scene
  65660. */
  65661. Material.prototype.getScene = function () {
  65662. return this._scene;
  65663. };
  65664. /**
  65665. * Specifies if the material will require alpha blending
  65666. * @returns a boolean specifying if alpha blending is needed
  65667. */
  65668. Material.prototype.needAlphaBlending = function () {
  65669. return (this.alpha < 1.0);
  65670. };
  65671. /**
  65672. * Specifies if the mesh will require alpha blending
  65673. * @param mesh defines the mesh to check
  65674. * @returns a boolean specifying if alpha blending is needed for the mesh
  65675. */
  65676. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  65677. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  65678. };
  65679. /**
  65680. * Specifies if this material should be rendered in alpha test mode
  65681. * @returns a boolean specifying if an alpha test is needed.
  65682. */
  65683. Material.prototype.needAlphaTesting = function () {
  65684. return false;
  65685. };
  65686. /**
  65687. * Gets the texture used for the alpha test
  65688. * @returns the texture to use for alpha testing
  65689. */
  65690. Material.prototype.getAlphaTestTexture = function () {
  65691. return null;
  65692. };
  65693. /**
  65694. * Marks the material to indicate that it needs to be re-calculated
  65695. */
  65696. Material.prototype.markDirty = function () {
  65697. this._wasPreviouslyReady = false;
  65698. };
  65699. /** @hidden */
  65700. Material.prototype._preBind = function (effect, overrideOrientation) {
  65701. if (overrideOrientation === void 0) { overrideOrientation = null; }
  65702. var engine = this._scene.getEngine();
  65703. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  65704. var reverse = orientation === Material.ClockWiseSideOrientation;
  65705. engine.enableEffect(effect ? effect : this._effect);
  65706. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  65707. return reverse;
  65708. };
  65709. /**
  65710. * Binds the material to the mesh
  65711. * @param world defines the world transformation matrix
  65712. * @param mesh defines the mesh to bind the material to
  65713. */
  65714. Material.prototype.bind = function (world, mesh) {
  65715. };
  65716. /**
  65717. * Binds the submesh to the material
  65718. * @param world defines the world transformation matrix
  65719. * @param mesh defines the mesh containing the submesh
  65720. * @param subMesh defines the submesh to bind the material to
  65721. */
  65722. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  65723. };
  65724. /**
  65725. * Binds the world matrix to the material
  65726. * @param world defines the world transformation matrix
  65727. */
  65728. Material.prototype.bindOnlyWorldMatrix = function (world) {
  65729. };
  65730. /**
  65731. * Binds the scene's uniform buffer to the effect.
  65732. * @param effect defines the effect to bind to the scene uniform buffer
  65733. * @param sceneUbo defines the uniform buffer storing scene data
  65734. */
  65735. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  65736. sceneUbo.bindToEffect(effect, "Scene");
  65737. };
  65738. /**
  65739. * Binds the view matrix to the effect
  65740. * @param effect defines the effect to bind the view matrix to
  65741. */
  65742. Material.prototype.bindView = function (effect) {
  65743. if (!this._useUBO) {
  65744. effect.setMatrix("view", this.getScene().getViewMatrix());
  65745. }
  65746. else {
  65747. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  65748. }
  65749. };
  65750. /**
  65751. * Binds the view projection matrix to the effect
  65752. * @param effect defines the effect to bind the view projection matrix to
  65753. */
  65754. Material.prototype.bindViewProjection = function (effect) {
  65755. if (!this._useUBO) {
  65756. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  65757. }
  65758. else {
  65759. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  65760. }
  65761. };
  65762. /**
  65763. * Specifies if material alpha testing should be turned on for the mesh
  65764. * @param mesh defines the mesh to check
  65765. */
  65766. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  65767. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  65768. };
  65769. /**
  65770. * Processes to execute after binding the material to a mesh
  65771. * @param mesh defines the rendered mesh
  65772. */
  65773. Material.prototype._afterBind = function (mesh) {
  65774. this._scene._cachedMaterial = this;
  65775. if (mesh) {
  65776. this._scene._cachedVisibility = mesh.visibility;
  65777. }
  65778. else {
  65779. this._scene._cachedVisibility = 1;
  65780. }
  65781. if (this._onBindObservable && mesh) {
  65782. this._onBindObservable.notifyObservers(mesh);
  65783. }
  65784. if (this.disableDepthWrite) {
  65785. var engine = this._scene.getEngine();
  65786. this._cachedDepthWriteState = engine.getDepthWrite();
  65787. engine.setDepthWrite(false);
  65788. }
  65789. };
  65790. /**
  65791. * Unbinds the material from the mesh
  65792. */
  65793. Material.prototype.unbind = function () {
  65794. if (this._onUnBindObservable) {
  65795. this._onUnBindObservable.notifyObservers(this);
  65796. }
  65797. if (this.disableDepthWrite) {
  65798. var engine = this._scene.getEngine();
  65799. engine.setDepthWrite(this._cachedDepthWriteState);
  65800. }
  65801. };
  65802. /**
  65803. * Gets the active textures from the material
  65804. * @returns an array of textures
  65805. */
  65806. Material.prototype.getActiveTextures = function () {
  65807. return [];
  65808. };
  65809. /**
  65810. * Specifies if the material uses a texture
  65811. * @param texture defines the texture to check against the material
  65812. * @returns a boolean specifying if the material uses the texture
  65813. */
  65814. Material.prototype.hasTexture = function (texture) {
  65815. return false;
  65816. };
  65817. /**
  65818. * Makes a duplicate of the material, and gives it a new name
  65819. * @param name defines the new name for the duplicated material
  65820. * @returns the cloned material
  65821. */
  65822. Material.prototype.clone = function (name) {
  65823. return null;
  65824. };
  65825. /**
  65826. * Gets the meshes bound to the material
  65827. * @returns an array of meshes bound to the material
  65828. */
  65829. Material.prototype.getBindedMeshes = function () {
  65830. var _this = this;
  65831. if (this.meshMap) {
  65832. var result = new Array();
  65833. for (var meshId in this.meshMap) {
  65834. var mesh = this.meshMap[meshId];
  65835. if (mesh) {
  65836. result.push(mesh);
  65837. }
  65838. }
  65839. return result;
  65840. }
  65841. else {
  65842. var meshes = this._scene.meshes;
  65843. return meshes.filter(function (mesh) { return mesh.material === _this; });
  65844. }
  65845. };
  65846. /**
  65847. * Force shader compilation
  65848. * @param mesh defines the mesh associated with this material
  65849. * @param onCompiled defines a function to execute once the material is compiled
  65850. * @param options defines the options to configure the compilation
  65851. */
  65852. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  65853. var _this = this;
  65854. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  65855. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__["BaseSubMesh"]();
  65856. var scene = this.getScene();
  65857. var checkReady = function () {
  65858. if (!_this._scene || !_this._scene.getEngine()) {
  65859. return;
  65860. }
  65861. if (subMesh._materialDefines) {
  65862. subMesh._materialDefines._renderId = -1;
  65863. }
  65864. var clipPlaneState = scene.clipPlane;
  65865. if (localOptions.clipPlane) {
  65866. scene.clipPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"](0, 0, 0, 1);
  65867. }
  65868. if (_this._storeEffectOnSubMeshes) {
  65869. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  65870. if (onCompiled) {
  65871. onCompiled(_this);
  65872. }
  65873. }
  65874. else {
  65875. setTimeout(checkReady, 16);
  65876. }
  65877. }
  65878. else {
  65879. if (_this.isReady()) {
  65880. if (onCompiled) {
  65881. onCompiled(_this);
  65882. }
  65883. }
  65884. else {
  65885. setTimeout(checkReady, 16);
  65886. }
  65887. }
  65888. if (localOptions.clipPlane) {
  65889. scene.clipPlane = clipPlaneState;
  65890. }
  65891. };
  65892. checkReady();
  65893. };
  65894. /**
  65895. * Force shader compilation
  65896. * @param mesh defines the mesh that will use this material
  65897. * @param options defines additional options for compiling the shaders
  65898. * @returns a promise that resolves when the compilation completes
  65899. */
  65900. Material.prototype.forceCompilationAsync = function (mesh, options) {
  65901. var _this = this;
  65902. return new Promise(function (resolve) {
  65903. _this.forceCompilation(mesh, function () {
  65904. resolve();
  65905. }, options);
  65906. });
  65907. };
  65908. /**
  65909. * Marks a define in the material to indicate that it needs to be re-computed
  65910. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  65911. */
  65912. Material.prototype.markAsDirty = function (flag) {
  65913. if (this.getScene().blockMaterialDirtyMechanism) {
  65914. return;
  65915. }
  65916. Material._DirtyCallbackArray.length = 0;
  65917. if (flag & Material.TextureDirtyFlag) {
  65918. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  65919. }
  65920. if (flag & Material.LightDirtyFlag) {
  65921. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  65922. }
  65923. if (flag & Material.FresnelDirtyFlag) {
  65924. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  65925. }
  65926. if (flag & Material.AttributesDirtyFlag) {
  65927. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  65928. }
  65929. if (flag & Material.MiscDirtyFlag) {
  65930. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  65931. }
  65932. if (Material._DirtyCallbackArray.length) {
  65933. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  65934. }
  65935. this.getScene().resetCachedMaterial();
  65936. };
  65937. /**
  65938. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  65939. * @param func defines a function which checks material defines against the submeshes
  65940. */
  65941. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  65942. if (this.getScene().blockMaterialDirtyMechanism) {
  65943. return;
  65944. }
  65945. var meshes = this.getScene().meshes;
  65946. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  65947. var mesh = meshes_1[_i];
  65948. if (!mesh.subMeshes) {
  65949. continue;
  65950. }
  65951. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  65952. var subMesh = _b[_a];
  65953. if (subMesh.getMaterial() !== this) {
  65954. continue;
  65955. }
  65956. if (!subMesh._materialDefines) {
  65957. continue;
  65958. }
  65959. func(subMesh._materialDefines);
  65960. }
  65961. }
  65962. };
  65963. /**
  65964. * Indicates that image processing needs to be re-calculated for all submeshes
  65965. */
  65966. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  65967. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  65968. };
  65969. /**
  65970. * Indicates that textures need to be re-calculated for all submeshes
  65971. */
  65972. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  65973. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  65974. };
  65975. /**
  65976. * Indicates that fresnel needs to be re-calculated for all submeshes
  65977. */
  65978. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  65979. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  65980. };
  65981. /**
  65982. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  65983. */
  65984. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  65985. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  65986. };
  65987. /**
  65988. * Indicates that lights need to be re-calculated for all submeshes
  65989. */
  65990. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  65991. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  65992. };
  65993. /**
  65994. * Indicates that attributes need to be re-calculated for all submeshes
  65995. */
  65996. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  65997. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  65998. };
  65999. /**
  66000. * Indicates that misc needs to be re-calculated for all submeshes
  66001. */
  66002. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  66003. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  66004. };
  66005. /**
  66006. * Indicates that textures and misc need to be re-calculated for all submeshes
  66007. */
  66008. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  66009. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  66010. };
  66011. /**
  66012. * Disposes the material
  66013. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  66014. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  66015. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  66016. */
  66017. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  66018. var scene = this.getScene();
  66019. // Animations
  66020. scene.stopAnimation(this);
  66021. scene.freeProcessedMaterials();
  66022. // Remove from scene
  66023. scene.removeMaterial(this);
  66024. if (notBoundToMesh !== true) {
  66025. // Remove from meshes
  66026. if (this.meshMap) {
  66027. for (var meshId in this.meshMap) {
  66028. var mesh = this.meshMap[meshId];
  66029. if (mesh) {
  66030. mesh.material = null; // will set the entry in the map to undefined
  66031. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  66032. }
  66033. }
  66034. }
  66035. else {
  66036. var meshes = scene.meshes;
  66037. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  66038. var mesh = meshes_2[_i];
  66039. if (mesh.material === this) {
  66040. mesh.material = null;
  66041. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  66042. }
  66043. }
  66044. }
  66045. }
  66046. this._uniformBuffer.dispose();
  66047. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  66048. if (forceDisposeEffect && this._effect) {
  66049. if (!this._storeEffectOnSubMeshes) {
  66050. scene.getEngine()._releaseEffect(this._effect);
  66051. }
  66052. this._effect = null;
  66053. }
  66054. // Callback
  66055. this.onDisposeObservable.notifyObservers(this);
  66056. this.onDisposeObservable.clear();
  66057. if (this._onBindObservable) {
  66058. this._onBindObservable.clear();
  66059. }
  66060. if (this._onUnBindObservable) {
  66061. this._onUnBindObservable.clear();
  66062. }
  66063. };
  66064. /** @hidden */
  66065. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  66066. if (mesh.geometry) {
  66067. var geometry = (mesh.geometry);
  66068. var scene = this.getScene();
  66069. if (this._storeEffectOnSubMeshes) {
  66070. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  66071. var subMesh = _a[_i];
  66072. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  66073. if (forceDisposeEffect && subMesh._materialEffect) {
  66074. scene.getEngine()._releaseEffect(subMesh._materialEffect);
  66075. }
  66076. }
  66077. }
  66078. else {
  66079. geometry._releaseVertexArrayObject(this._effect);
  66080. }
  66081. }
  66082. };
  66083. /**
  66084. * Serializes this material
  66085. * @returns the serialized material object
  66086. */
  66087. Material.prototype.serialize = function () {
  66088. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  66089. };
  66090. /**
  66091. * Creates a material from parsed material data
  66092. * @param parsedMaterial defines parsed material data
  66093. * @param scene defines the hosting scene
  66094. * @param rootUrl defines the root URL to use to load textures
  66095. * @returns a new material
  66096. */
  66097. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  66098. if (!parsedMaterial.customType) {
  66099. parsedMaterial.customType = "BABYLON.StandardMaterial";
  66100. }
  66101. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  66102. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  66103. if (!BABYLON.LegacyPBRMaterial) {
  66104. _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.");
  66105. return null;
  66106. }
  66107. }
  66108. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  66109. return materialType.Parse(parsedMaterial, scene, rootUrl);
  66110. };
  66111. /**
  66112. * Returns the triangle fill mode
  66113. */
  66114. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFillMode;
  66115. /**
  66116. * Returns the wireframe mode
  66117. */
  66118. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_WireFrameFillMode;
  66119. /**
  66120. * Returns the point fill mode
  66121. */
  66122. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointFillMode;
  66123. /**
  66124. * Returns the point list draw mode
  66125. */
  66126. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointListDrawMode;
  66127. /**
  66128. * Returns the line list draw mode
  66129. */
  66130. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineListDrawMode;
  66131. /**
  66132. * Returns the line loop draw mode
  66133. */
  66134. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineLoopDrawMode;
  66135. /**
  66136. * Returns the line strip draw mode
  66137. */
  66138. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineStripDrawMode;
  66139. /**
  66140. * Returns the triangle strip draw mode
  66141. */
  66142. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleStripDrawMode;
  66143. /**
  66144. * Returns the triangle fan draw mode
  66145. */
  66146. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFanDrawMode;
  66147. /**
  66148. * Stores the clock-wise side orientation
  66149. */
  66150. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_ClockWiseSideOrientation;
  66151. /**
  66152. * Stores the counter clock-wise side orientation
  66153. */
  66154. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  66155. /**
  66156. * The dirty texture flag value
  66157. */
  66158. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag;
  66159. /**
  66160. * The dirty light flag value
  66161. */
  66162. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LightDirtyFlag;
  66163. /**
  66164. * The dirty fresnel flag value
  66165. */
  66166. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_FresnelDirtyFlag;
  66167. /**
  66168. * The dirty attribute flag value
  66169. */
  66170. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AttributesDirtyFlag;
  66171. /**
  66172. * The dirty misc flag value
  66173. */
  66174. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_MiscDirtyFlag;
  66175. /**
  66176. * The all dirty flag value
  66177. */
  66178. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AllDirtyFlag;
  66179. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  66180. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  66181. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  66182. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  66183. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  66184. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  66185. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  66186. Material._FresnelDirtyCallBack(defines);
  66187. Material._MiscDirtyCallBack(defines);
  66188. };
  66189. Material._TextureAndMiscDirtyCallBack = function (defines) {
  66190. Material._TextureDirtyCallBack(defines);
  66191. Material._MiscDirtyCallBack(defines);
  66192. };
  66193. Material._DirtyCallbackArray = [];
  66194. Material._RunDirtyCallBacks = function (defines) {
  66195. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  66196. var cb = _a[_i];
  66197. cb(defines);
  66198. }
  66199. };
  66200. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66201. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66202. ], Material.prototype, "id", void 0);
  66203. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66204. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66205. ], Material.prototype, "uniqueId", void 0);
  66206. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66207. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66208. ], Material.prototype, "name", void 0);
  66209. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66210. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66211. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  66212. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66213. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66214. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  66215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66217. ], Material.prototype, "state", void 0);
  66218. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66219. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  66220. ], Material.prototype, "_alpha", void 0);
  66221. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66222. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  66223. ], Material.prototype, "_backFaceCulling", void 0);
  66224. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66225. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66226. ], Material.prototype, "sideOrientation", void 0);
  66227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  66229. ], Material.prototype, "_alphaMode", void 0);
  66230. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66231. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66232. ], Material.prototype, "_needDepthPrePass", void 0);
  66233. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66234. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66235. ], Material.prototype, "disableDepthWrite", void 0);
  66236. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66238. ], Material.prototype, "forceDepthWrite", void 0);
  66239. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66240. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66241. ], Material.prototype, "separateCullingPass", void 0);
  66242. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66243. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  66244. ], Material.prototype, "_fogEnabled", void 0);
  66245. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66246. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66247. ], Material.prototype, "pointSize", void 0);
  66248. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66249. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66250. ], Material.prototype, "zOffset", void 0);
  66251. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66252. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66253. ], Material.prototype, "wireframe", null);
  66254. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66255. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66256. ], Material.prototype, "pointsCloud", null);
  66257. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  66258. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  66259. ], Material.prototype, "fillMode", null);
  66260. return Material;
  66261. }());
  66262. /***/ }),
  66263. /***/ "./Materials/materialDefines.ts":
  66264. /*!**************************************!*\
  66265. !*** ./Materials/materialDefines.ts ***!
  66266. \**************************************/
  66267. /*! exports provided: MaterialDefines */
  66268. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66269. "use strict";
  66270. __webpack_require__.r(__webpack_exports__);
  66271. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  66272. /**
  66273. * Manages the defines for the Material
  66274. */
  66275. var MaterialDefines = /** @class */ (function () {
  66276. function MaterialDefines() {
  66277. this._isDirty = true;
  66278. /** @hidden */
  66279. this._areLightsDirty = true;
  66280. /** @hidden */
  66281. this._areAttributesDirty = true;
  66282. /** @hidden */
  66283. this._areTexturesDirty = true;
  66284. /** @hidden */
  66285. this._areFresnelDirty = true;
  66286. /** @hidden */
  66287. this._areMiscDirty = true;
  66288. /** @hidden */
  66289. this._areImageProcessingDirty = true;
  66290. /** @hidden */
  66291. this._normals = false;
  66292. /** @hidden */
  66293. this._uvs = false;
  66294. /** @hidden */
  66295. this._needNormals = false;
  66296. /** @hidden */
  66297. this._needUVs = false;
  66298. }
  66299. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  66300. /**
  66301. * Specifies if the material needs to be re-calculated
  66302. */
  66303. get: function () {
  66304. return this._isDirty;
  66305. },
  66306. enumerable: true,
  66307. configurable: true
  66308. });
  66309. /**
  66310. * Marks the material to indicate that it has been re-calculated
  66311. */
  66312. MaterialDefines.prototype.markAsProcessed = function () {
  66313. this._isDirty = false;
  66314. this._areAttributesDirty = false;
  66315. this._areTexturesDirty = false;
  66316. this._areFresnelDirty = false;
  66317. this._areLightsDirty = false;
  66318. this._areMiscDirty = false;
  66319. this._areImageProcessingDirty = false;
  66320. };
  66321. /**
  66322. * Marks the material to indicate that it needs to be re-calculated
  66323. */
  66324. MaterialDefines.prototype.markAsUnprocessed = function () {
  66325. this._isDirty = true;
  66326. };
  66327. /**
  66328. * Marks the material to indicate all of its defines need to be re-calculated
  66329. */
  66330. MaterialDefines.prototype.markAllAsDirty = function () {
  66331. this._areTexturesDirty = true;
  66332. this._areAttributesDirty = true;
  66333. this._areLightsDirty = true;
  66334. this._areFresnelDirty = true;
  66335. this._areMiscDirty = true;
  66336. this._areImageProcessingDirty = true;
  66337. this._isDirty = true;
  66338. };
  66339. /**
  66340. * Marks the material to indicate that image processing needs to be re-calculated
  66341. */
  66342. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  66343. this._areImageProcessingDirty = true;
  66344. this._isDirty = true;
  66345. };
  66346. /**
  66347. * Marks the material to indicate the lights need to be re-calculated
  66348. */
  66349. MaterialDefines.prototype.markAsLightDirty = function () {
  66350. this._areLightsDirty = true;
  66351. this._isDirty = true;
  66352. };
  66353. /**
  66354. * Marks the attribute state as changed
  66355. */
  66356. MaterialDefines.prototype.markAsAttributesDirty = function () {
  66357. this._areAttributesDirty = true;
  66358. this._isDirty = true;
  66359. };
  66360. /**
  66361. * Marks the texture state as changed
  66362. */
  66363. MaterialDefines.prototype.markAsTexturesDirty = function () {
  66364. this._areTexturesDirty = true;
  66365. this._isDirty = true;
  66366. };
  66367. /**
  66368. * Marks the fresnel state as changed
  66369. */
  66370. MaterialDefines.prototype.markAsFresnelDirty = function () {
  66371. this._areFresnelDirty = true;
  66372. this._isDirty = true;
  66373. };
  66374. /**
  66375. * Marks the misc state as changed
  66376. */
  66377. MaterialDefines.prototype.markAsMiscDirty = function () {
  66378. this._areMiscDirty = true;
  66379. this._isDirty = true;
  66380. };
  66381. /**
  66382. * Rebuilds the material defines
  66383. */
  66384. MaterialDefines.prototype.rebuild = function () {
  66385. if (this._keys) {
  66386. delete this._keys;
  66387. }
  66388. this._keys = [];
  66389. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  66390. var key = _a[_i];
  66391. if (key[0] === "_") {
  66392. continue;
  66393. }
  66394. this._keys.push(key);
  66395. }
  66396. };
  66397. /**
  66398. * Specifies if two material defines are equal
  66399. * @param other - A material define instance to compare to
  66400. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  66401. */
  66402. MaterialDefines.prototype.isEqual = function (other) {
  66403. if (this._keys.length !== other._keys.length) {
  66404. return false;
  66405. }
  66406. for (var index = 0; index < this._keys.length; index++) {
  66407. var prop = this._keys[index];
  66408. if (this[prop] !== other[prop]) {
  66409. return false;
  66410. }
  66411. }
  66412. return true;
  66413. };
  66414. /**
  66415. * Clones this instance's defines to another instance
  66416. * @param other - material defines to clone values to
  66417. */
  66418. MaterialDefines.prototype.cloneTo = function (other) {
  66419. if (this._keys.length !== other._keys.length) {
  66420. other._keys = this._keys.slice(0);
  66421. }
  66422. for (var index = 0; index < this._keys.length; index++) {
  66423. var prop = this._keys[index];
  66424. other[prop] = this[prop];
  66425. }
  66426. };
  66427. /**
  66428. * Resets the material define values
  66429. */
  66430. MaterialDefines.prototype.reset = function () {
  66431. for (var index = 0; index < this._keys.length; index++) {
  66432. var prop = this._keys[index];
  66433. var type = typeof this[prop];
  66434. switch (type) {
  66435. case "number":
  66436. this[prop] = 0;
  66437. break;
  66438. case "string":
  66439. this[prop] = "";
  66440. break;
  66441. default:
  66442. this[prop] = false;
  66443. break;
  66444. }
  66445. }
  66446. };
  66447. /**
  66448. * Converts the material define values to a string
  66449. * @returns - String of material define information
  66450. */
  66451. MaterialDefines.prototype.toString = function () {
  66452. var result = "";
  66453. for (var index = 0; index < this._keys.length; index++) {
  66454. var prop = this._keys[index];
  66455. var value = this[prop];
  66456. var type = typeof value;
  66457. switch (type) {
  66458. case "number":
  66459. case "string":
  66460. result += "#define " + prop + " " + value + "\n";
  66461. break;
  66462. default:
  66463. if (value) {
  66464. result += "#define " + prop + "\n";
  66465. }
  66466. break;
  66467. }
  66468. }
  66469. return result;
  66470. };
  66471. return MaterialDefines;
  66472. }());
  66473. /***/ }),
  66474. /***/ "./Materials/materialFlags.ts":
  66475. /*!************************************!*\
  66476. !*** ./Materials/materialFlags.ts ***!
  66477. \************************************/
  66478. /*! exports provided: MaterialFlags */
  66479. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66480. "use strict";
  66481. __webpack_require__.r(__webpack_exports__);
  66482. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  66483. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  66484. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  66485. /**
  66486. * This groups all the flags used to control the materials channel.
  66487. */
  66488. var MaterialFlags = /** @class */ (function () {
  66489. function MaterialFlags() {
  66490. }
  66491. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  66492. /**
  66493. * Are diffuse textures enabled in the application.
  66494. */
  66495. get: function () {
  66496. return this._DiffuseTextureEnabled;
  66497. },
  66498. set: function (value) {
  66499. if (this._DiffuseTextureEnabled === value) {
  66500. return;
  66501. }
  66502. this._DiffuseTextureEnabled = value;
  66503. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66504. },
  66505. enumerable: true,
  66506. configurable: true
  66507. });
  66508. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  66509. /**
  66510. * Are ambient textures enabled in the application.
  66511. */
  66512. get: function () {
  66513. return this._AmbientTextureEnabled;
  66514. },
  66515. set: function (value) {
  66516. if (this._AmbientTextureEnabled === value) {
  66517. return;
  66518. }
  66519. this._AmbientTextureEnabled = value;
  66520. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66521. },
  66522. enumerable: true,
  66523. configurable: true
  66524. });
  66525. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  66526. /**
  66527. * Are opacity textures enabled in the application.
  66528. */
  66529. get: function () {
  66530. return this._OpacityTextureEnabled;
  66531. },
  66532. set: function (value) {
  66533. if (this._OpacityTextureEnabled === value) {
  66534. return;
  66535. }
  66536. this._OpacityTextureEnabled = value;
  66537. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66538. },
  66539. enumerable: true,
  66540. configurable: true
  66541. });
  66542. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  66543. /**
  66544. * Are reflection textures enabled in the application.
  66545. */
  66546. get: function () {
  66547. return this._ReflectionTextureEnabled;
  66548. },
  66549. set: function (value) {
  66550. if (this._ReflectionTextureEnabled === value) {
  66551. return;
  66552. }
  66553. this._ReflectionTextureEnabled = value;
  66554. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66555. },
  66556. enumerable: true,
  66557. configurable: true
  66558. });
  66559. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  66560. /**
  66561. * Are emissive textures enabled in the application.
  66562. */
  66563. get: function () {
  66564. return this._EmissiveTextureEnabled;
  66565. },
  66566. set: function (value) {
  66567. if (this._EmissiveTextureEnabled === value) {
  66568. return;
  66569. }
  66570. this._EmissiveTextureEnabled = value;
  66571. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66572. },
  66573. enumerable: true,
  66574. configurable: true
  66575. });
  66576. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  66577. /**
  66578. * Are specular textures enabled in the application.
  66579. */
  66580. get: function () {
  66581. return this._SpecularTextureEnabled;
  66582. },
  66583. set: function (value) {
  66584. if (this._SpecularTextureEnabled === value) {
  66585. return;
  66586. }
  66587. this._SpecularTextureEnabled = value;
  66588. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66589. },
  66590. enumerable: true,
  66591. configurable: true
  66592. });
  66593. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  66594. /**
  66595. * Are bump textures enabled in the application.
  66596. */
  66597. get: function () {
  66598. return this._BumpTextureEnabled;
  66599. },
  66600. set: function (value) {
  66601. if (this._BumpTextureEnabled === value) {
  66602. return;
  66603. }
  66604. this._BumpTextureEnabled = value;
  66605. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66606. },
  66607. enumerable: true,
  66608. configurable: true
  66609. });
  66610. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  66611. /**
  66612. * Are lightmap textures enabled in the application.
  66613. */
  66614. get: function () {
  66615. return this._LightmapTextureEnabled;
  66616. },
  66617. set: function (value) {
  66618. if (this._LightmapTextureEnabled === value) {
  66619. return;
  66620. }
  66621. this._LightmapTextureEnabled = value;
  66622. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66623. },
  66624. enumerable: true,
  66625. configurable: true
  66626. });
  66627. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  66628. /**
  66629. * Are refraction textures enabled in the application.
  66630. */
  66631. get: function () {
  66632. return this._RefractionTextureEnabled;
  66633. },
  66634. set: function (value) {
  66635. if (this._RefractionTextureEnabled === value) {
  66636. return;
  66637. }
  66638. this._RefractionTextureEnabled = value;
  66639. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66640. },
  66641. enumerable: true,
  66642. configurable: true
  66643. });
  66644. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  66645. /**
  66646. * Are color grading textures enabled in the application.
  66647. */
  66648. get: function () {
  66649. return this._ColorGradingTextureEnabled;
  66650. },
  66651. set: function (value) {
  66652. if (this._ColorGradingTextureEnabled === value) {
  66653. return;
  66654. }
  66655. this._ColorGradingTextureEnabled = value;
  66656. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66657. },
  66658. enumerable: true,
  66659. configurable: true
  66660. });
  66661. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  66662. /**
  66663. * Are fresnels enabled in the application.
  66664. */
  66665. get: function () {
  66666. return this._FresnelEnabled;
  66667. },
  66668. set: function (value) {
  66669. if (this._FresnelEnabled === value) {
  66670. return;
  66671. }
  66672. this._FresnelEnabled = value;
  66673. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  66674. },
  66675. enumerable: true,
  66676. configurable: true
  66677. });
  66678. Object.defineProperty(MaterialFlags, "ClearCoatTextureEnabled", {
  66679. /**
  66680. * Are clear coat textures enabled in the application.
  66681. */
  66682. get: function () {
  66683. return this._ClearCoatTextureEnabled;
  66684. },
  66685. set: function (value) {
  66686. if (this._ClearCoatTextureEnabled === value) {
  66687. return;
  66688. }
  66689. this._ClearCoatTextureEnabled = value;
  66690. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66691. },
  66692. enumerable: true,
  66693. configurable: true
  66694. });
  66695. Object.defineProperty(MaterialFlags, "ClearCoatBumpTextureEnabled", {
  66696. /**
  66697. * Are clear coat bump textures enabled in the application.
  66698. */
  66699. get: function () {
  66700. return this._ClearCoatBumpTextureEnabled;
  66701. },
  66702. set: function (value) {
  66703. if (this._ClearCoatBumpTextureEnabled === value) {
  66704. return;
  66705. }
  66706. this._ClearCoatBumpTextureEnabled = value;
  66707. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66708. },
  66709. enumerable: true,
  66710. configurable: true
  66711. });
  66712. Object.defineProperty(MaterialFlags, "ClearCoatTintTextureEnabled", {
  66713. /**
  66714. * Are clear coat tint textures enabled in the application.
  66715. */
  66716. get: function () {
  66717. return this._ClearCoatTintTextureEnabled;
  66718. },
  66719. set: function (value) {
  66720. if (this._ClearCoatTintTextureEnabled === value) {
  66721. return;
  66722. }
  66723. this._ClearCoatTintTextureEnabled = value;
  66724. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66725. },
  66726. enumerable: true,
  66727. configurable: true
  66728. });
  66729. Object.defineProperty(MaterialFlags, "SheenTextureEnabled", {
  66730. /**
  66731. * Are sheen textures enabled in the application.
  66732. */
  66733. get: function () {
  66734. return this._SheenTextureEnabled;
  66735. },
  66736. set: function (value) {
  66737. if (this._SheenTextureEnabled === value) {
  66738. return;
  66739. }
  66740. this._SheenTextureEnabled = value;
  66741. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66742. },
  66743. enumerable: true,
  66744. configurable: true
  66745. });
  66746. Object.defineProperty(MaterialFlags, "AnisotropicTextureEnabled", {
  66747. /**
  66748. * Are anisotropic textures enabled in the application.
  66749. */
  66750. get: function () {
  66751. return this._AnisotropicTextureEnabled;
  66752. },
  66753. set: function (value) {
  66754. if (this._AnisotropicTextureEnabled === value) {
  66755. return;
  66756. }
  66757. this._AnisotropicTextureEnabled = value;
  66758. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66759. },
  66760. enumerable: true,
  66761. configurable: true
  66762. });
  66763. Object.defineProperty(MaterialFlags, "ThicknessTextureEnabled", {
  66764. /**
  66765. * Are thickness textures enabled in the application.
  66766. */
  66767. get: function () {
  66768. return this._ThicknessTextureEnabled;
  66769. },
  66770. set: function (value) {
  66771. if (this._ThicknessTextureEnabled === value) {
  66772. return;
  66773. }
  66774. this._ThicknessTextureEnabled = value;
  66775. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  66776. },
  66777. enumerable: true,
  66778. configurable: true
  66779. });
  66780. // Flags used to enable or disable a type of texture for all Standard Materials
  66781. MaterialFlags._DiffuseTextureEnabled = true;
  66782. MaterialFlags._AmbientTextureEnabled = true;
  66783. MaterialFlags._OpacityTextureEnabled = true;
  66784. MaterialFlags._ReflectionTextureEnabled = true;
  66785. MaterialFlags._EmissiveTextureEnabled = true;
  66786. MaterialFlags._SpecularTextureEnabled = true;
  66787. MaterialFlags._BumpTextureEnabled = true;
  66788. MaterialFlags._LightmapTextureEnabled = true;
  66789. MaterialFlags._RefractionTextureEnabled = true;
  66790. MaterialFlags._ColorGradingTextureEnabled = true;
  66791. MaterialFlags._FresnelEnabled = true;
  66792. MaterialFlags._ClearCoatTextureEnabled = true;
  66793. MaterialFlags._ClearCoatBumpTextureEnabled = true;
  66794. MaterialFlags._ClearCoatTintTextureEnabled = true;
  66795. MaterialFlags._SheenTextureEnabled = true;
  66796. MaterialFlags._AnisotropicTextureEnabled = true;
  66797. MaterialFlags._ThicknessTextureEnabled = true;
  66798. return MaterialFlags;
  66799. }());
  66800. /***/ }),
  66801. /***/ "./Materials/materialHelper.ts":
  66802. /*!*************************************!*\
  66803. !*** ./Materials/materialHelper.ts ***!
  66804. \*************************************/
  66805. /*! exports provided: MaterialHelper */
  66806. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  66807. "use strict";
  66808. __webpack_require__.r(__webpack_exports__);
  66809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  66810. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  66811. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  66812. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  66813. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  66814. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  66815. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  66816. /**
  66817. * "Static Class" containing the most commonly used helper while dealing with material for
  66818. * rendering purpose.
  66819. *
  66820. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66821. *
  66822. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66823. */
  66824. var MaterialHelper = /** @class */ (function () {
  66825. function MaterialHelper() {
  66826. }
  66827. /**
  66828. * Bind the current view position to an effect.
  66829. * @param effect The effect to be bound
  66830. * @param scene The scene the eyes position is used from
  66831. */
  66832. MaterialHelper.BindEyePosition = function (effect, scene) {
  66833. if (scene._forcedViewPosition) {
  66834. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  66835. return;
  66836. }
  66837. var globalPosition = scene.activeCamera.globalPosition;
  66838. if (!globalPosition) {
  66839. // Use WebVRFreecamera's device position as global position is not it's actual position in babylon space
  66840. globalPosition = scene.activeCamera.devicePosition;
  66841. }
  66842. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : globalPosition);
  66843. };
  66844. /**
  66845. * Helps preparing the defines values about the UVs in used in the effect.
  66846. * UVs are shared as much as we can accross channels in the shaders.
  66847. * @param texture The texture we are preparing the UVs for
  66848. * @param defines The defines to update
  66849. * @param key The channel key "diffuse", "specular"... used in the shader
  66850. */
  66851. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  66852. defines._needUVs = true;
  66853. defines[key] = true;
  66854. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  66855. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  66856. if (texture.coordinatesIndex === 0) {
  66857. defines["MAINUV1"] = true;
  66858. }
  66859. else {
  66860. defines["MAINUV2"] = true;
  66861. }
  66862. }
  66863. else {
  66864. defines[key + "DIRECTUV"] = 0;
  66865. }
  66866. };
  66867. /**
  66868. * Binds a texture matrix value to its corrsponding uniform
  66869. * @param texture The texture to bind the matrix for
  66870. * @param uniformBuffer The uniform buffer receivin the data
  66871. * @param key The channel key "diffuse", "specular"... used in the shader
  66872. */
  66873. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  66874. var matrix = texture.getTextureMatrix();
  66875. if (!matrix.isIdentityAs3x2()) {
  66876. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  66877. }
  66878. };
  66879. /**
  66880. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66881. * @param mesh defines the current mesh
  66882. * @param scene defines the current scene
  66883. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66884. * @param pointsCloud defines if point cloud rendering has to be turned on
  66885. * @param fogEnabled defines if fog has to be turned on
  66886. * @param alphaTest defines if alpha testing has to be turned on
  66887. * @param defines defines the current list of defines
  66888. */
  66889. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  66890. if (defines._areMiscDirty) {
  66891. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  66892. defines["POINTSIZE"] = pointsCloud;
  66893. defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && fogEnabled);
  66894. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  66895. defines["ALPHATEST"] = alphaTest;
  66896. }
  66897. };
  66898. /**
  66899. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66900. * @param scene defines the current scene
  66901. * @param engine defines the current engine
  66902. * @param defines specifies the list of active defines
  66903. * @param useInstances defines if instances have to be turned on
  66904. * @param useClipPlane defines if clip plane have to be turned on
  66905. */
  66906. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  66907. if (useClipPlane === void 0) { useClipPlane = null; }
  66908. var changed = false;
  66909. var useClipPlane1 = false;
  66910. var useClipPlane2 = false;
  66911. var useClipPlane3 = false;
  66912. var useClipPlane4 = false;
  66913. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  66914. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  66915. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  66916. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  66917. if (defines["CLIPPLANE"] !== useClipPlane1) {
  66918. defines["CLIPPLANE"] = useClipPlane1;
  66919. changed = true;
  66920. }
  66921. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  66922. defines["CLIPPLANE2"] = useClipPlane2;
  66923. changed = true;
  66924. }
  66925. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  66926. defines["CLIPPLANE3"] = useClipPlane3;
  66927. changed = true;
  66928. }
  66929. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  66930. defines["CLIPPLANE4"] = useClipPlane4;
  66931. changed = true;
  66932. }
  66933. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  66934. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  66935. changed = true;
  66936. }
  66937. if (defines["INSTANCES"] !== useInstances) {
  66938. defines["INSTANCES"] = useInstances;
  66939. changed = true;
  66940. }
  66941. if (changed) {
  66942. defines.markAsUnprocessed();
  66943. }
  66944. };
  66945. /**
  66946. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66947. * @param mesh The mesh containing the geometry data we will draw
  66948. * @param defines The defines to update
  66949. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66950. * @param useBones Precise whether bones should be used or not (override mesh info)
  66951. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66952. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66953. * @returns false if defines are considered not dirty and have not been checked
  66954. */
  66955. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  66956. if (useMorphTargets === void 0) { useMorphTargets = false; }
  66957. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  66958. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  66959. return false;
  66960. }
  66961. defines._normals = defines._needNormals;
  66962. defines._uvs = defines._needUVs;
  66963. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind));
  66964. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind)) {
  66965. defines["TANGENT"] = true;
  66966. }
  66967. if (defines._needUVs) {
  66968. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  66969. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  66970. }
  66971. else {
  66972. defines["UV1"] = false;
  66973. defines["UV2"] = false;
  66974. }
  66975. if (useVertexColor) {
  66976. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  66977. defines["VERTEXCOLOR"] = hasVertexColors;
  66978. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  66979. }
  66980. if (useBones) {
  66981. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  66982. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  66983. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  66984. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  66985. defines["BONETEXTURE"] = true;
  66986. }
  66987. else {
  66988. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  66989. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  66990. }
  66991. }
  66992. else {
  66993. defines["NUM_BONE_INFLUENCERS"] = 0;
  66994. defines["BonesPerMesh"] = 0;
  66995. }
  66996. }
  66997. if (useMorphTargets) {
  66998. var manager = mesh.morphTargetManager;
  66999. if (manager) {
  67000. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  67001. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  67002. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  67003. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  67004. }
  67005. else {
  67006. defines["MORPHTARGETS_TANGENT"] = false;
  67007. defines["MORPHTARGETS_NORMAL"] = false;
  67008. defines["MORPHTARGETS"] = false;
  67009. defines["NUM_MORPH_INFLUENCERS"] = 0;
  67010. }
  67011. }
  67012. return true;
  67013. };
  67014. /**
  67015. * Prepares the defines related to multiview
  67016. * @param scene The scene we are intending to draw
  67017. * @param defines The defines to update
  67018. */
  67019. MaterialHelper.PrepareDefinesForMultiview = function (scene, defines) {
  67020. if (scene.activeCamera) {
  67021. var previousMultiview = defines.MULTIVIEW;
  67022. defines.MULTIVIEW = (scene.activeCamera.outputRenderTarget !== null && scene.activeCamera.outputRenderTarget.getViewCount() > 1);
  67023. if (defines.MULTIVIEW != previousMultiview) {
  67024. defines.markAsUnprocessed();
  67025. }
  67026. }
  67027. };
  67028. /**
  67029. * Prepares the defines related to the light information passed in parameter
  67030. * @param scene The scene we are intending to draw
  67031. * @param mesh The mesh the effect is compiling for
  67032. * @param defines The defines to update
  67033. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  67034. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  67035. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  67036. * @returns true if normals will be required for the rest of the effect
  67037. */
  67038. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  67039. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  67040. if (disableLighting === void 0) { disableLighting = false; }
  67041. if (!defines._areLightsDirty) {
  67042. return defines._needNormals;
  67043. }
  67044. var lightIndex = 0;
  67045. var needNormals = false;
  67046. var needRebuild = false;
  67047. var lightmapMode = false;
  67048. var shadowEnabled = false;
  67049. var specularEnabled = false;
  67050. if (scene.lightsEnabled && !disableLighting) {
  67051. for (var _i = 0, _a = mesh._lightSources; _i < _a.length; _i++) {
  67052. var light = _a[_i];
  67053. needNormals = true;
  67054. if (defines["LIGHT" + lightIndex] === undefined) {
  67055. needRebuild = true;
  67056. }
  67057. defines["LIGHT" + lightIndex] = true;
  67058. defines["SPOTLIGHT" + lightIndex] = false;
  67059. defines["HEMILIGHT" + lightIndex] = false;
  67060. defines["POINTLIGHT" + lightIndex] = false;
  67061. defines["DIRLIGHT" + lightIndex] = false;
  67062. light.prepareLightSpecificDefines(defines, lightIndex);
  67063. // FallOff.
  67064. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  67065. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  67066. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  67067. switch (light.falloffType) {
  67068. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_GLTF:
  67069. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  67070. break;
  67071. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_PHYSICAL:
  67072. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  67073. break;
  67074. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_STANDARD:
  67075. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  67076. break;
  67077. }
  67078. // Specular
  67079. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  67080. specularEnabled = true;
  67081. }
  67082. // Shadows
  67083. defines["SHADOW" + lightIndex] = false;
  67084. defines["SHADOWPCF" + lightIndex] = false;
  67085. defines["SHADOWPCSS" + lightIndex] = false;
  67086. defines["SHADOWPOISSON" + lightIndex] = false;
  67087. defines["SHADOWESM" + lightIndex] = false;
  67088. defines["SHADOWCUBE" + lightIndex] = false;
  67089. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  67090. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  67091. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  67092. var shadowGenerator = light.getShadowGenerator();
  67093. if (shadowGenerator) {
  67094. var shadowMap = shadowGenerator.getShadowMap();
  67095. if (shadowMap) {
  67096. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  67097. shadowEnabled = true;
  67098. shadowGenerator.prepareDefines(defines, lightIndex);
  67099. }
  67100. }
  67101. }
  67102. }
  67103. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_DEFAULT) {
  67104. lightmapMode = true;
  67105. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  67106. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_SHADOWSONLY);
  67107. }
  67108. else {
  67109. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  67110. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  67111. }
  67112. lightIndex++;
  67113. if (lightIndex === maxSimultaneousLights) {
  67114. break;
  67115. }
  67116. }
  67117. }
  67118. defines["SPECULARTERM"] = specularEnabled;
  67119. defines["SHADOWS"] = shadowEnabled;
  67120. // Resetting all other lights if any
  67121. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  67122. if (defines["LIGHT" + index] !== undefined) {
  67123. defines["LIGHT" + index] = false;
  67124. defines["HEMILIGHT" + index] = false;
  67125. defines["POINTLIGHT" + index] = false;
  67126. defines["DIRLIGHT" + index] = false;
  67127. defines["SPOTLIGHT" + index] = false;
  67128. defines["SHADOW" + index] = false;
  67129. defines["SHADOWPCF" + index] = false;
  67130. defines["SHADOWPCSS" + index] = false;
  67131. defines["SHADOWPOISSON" + index] = false;
  67132. defines["SHADOWESM" + index] = false;
  67133. defines["SHADOWCUBE" + index] = false;
  67134. defines["SHADOWLOWQUALITY" + index] = false;
  67135. defines["SHADOWMEDIUMQUALITY" + index] = false;
  67136. }
  67137. }
  67138. var caps = scene.getEngine().getCaps();
  67139. if (defines["SHADOWFLOAT"] === undefined) {
  67140. needRebuild = true;
  67141. }
  67142. defines["SHADOWFLOAT"] = shadowEnabled &&
  67143. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  67144. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  67145. defines["LIGHTMAPEXCLUDED"] = lightmapMode;
  67146. if (needRebuild) {
  67147. defines.rebuild();
  67148. }
  67149. return needNormals;
  67150. };
  67151. /**
  67152. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  67153. * that won t be acctive due to defines being turned off.
  67154. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  67155. * @param samplersList The samplers list
  67156. * @param defines The defines helping in the list generation
  67157. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  67158. */
  67159. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  67160. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  67161. var uniformsList;
  67162. var uniformBuffersList = null;
  67163. if (uniformsListOrOptions.uniformsNames) {
  67164. var options = uniformsListOrOptions;
  67165. uniformsList = options.uniformsNames;
  67166. uniformBuffersList = options.uniformBuffersNames;
  67167. samplersList = options.samplers;
  67168. defines = options.defines;
  67169. maxSimultaneousLights = options.maxSimultaneousLights;
  67170. }
  67171. else {
  67172. uniformsList = uniformsListOrOptions;
  67173. if (!samplersList) {
  67174. samplersList = [];
  67175. }
  67176. }
  67177. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  67178. if (!defines["LIGHT" + lightIndex]) {
  67179. break;
  67180. }
  67181. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  67182. if (uniformBuffersList) {
  67183. uniformBuffersList.push("Light" + lightIndex);
  67184. }
  67185. samplersList.push("shadowSampler" + lightIndex);
  67186. samplersList.push("depthSampler" + lightIndex);
  67187. if (defines["PROJECTEDLIGHTTEXTURE" + lightIndex]) {
  67188. samplersList.push("projectionLightSampler" + lightIndex);
  67189. uniformsList.push("textureProjectionMatrix" + lightIndex);
  67190. }
  67191. }
  67192. if (defines["NUM_MORPH_INFLUENCERS"]) {
  67193. uniformsList.push("morphTargetInfluences");
  67194. }
  67195. };
  67196. /**
  67197. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  67198. * @param defines The defines to update while falling back
  67199. * @param fallbacks The authorized effect fallbacks
  67200. * @param maxSimultaneousLights The maximum number of lights allowed
  67201. * @param rank the current rank of the Effect
  67202. * @returns The newly affected rank
  67203. */
  67204. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  67205. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  67206. if (rank === void 0) { rank = 0; }
  67207. var lightFallbackRank = 0;
  67208. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  67209. if (!defines["LIGHT" + lightIndex]) {
  67210. break;
  67211. }
  67212. if (lightIndex > 0) {
  67213. lightFallbackRank = rank + lightIndex;
  67214. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  67215. }
  67216. if (!defines["SHADOWS"]) {
  67217. if (defines["SHADOW" + lightIndex]) {
  67218. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  67219. }
  67220. if (defines["SHADOWPCF" + lightIndex]) {
  67221. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  67222. }
  67223. if (defines["SHADOWPCSS" + lightIndex]) {
  67224. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  67225. }
  67226. if (defines["SHADOWPOISSON" + lightIndex]) {
  67227. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  67228. }
  67229. if (defines["SHADOWESM" + lightIndex]) {
  67230. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  67231. }
  67232. }
  67233. }
  67234. return lightFallbackRank++;
  67235. };
  67236. /**
  67237. * Prepares the list of attributes required for morph targets according to the effect defines.
  67238. * @param attribs The current list of supported attribs
  67239. * @param mesh The mesh to prepare the morph targets attributes for
  67240. * @param defines The current Defines of the effect
  67241. */
  67242. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  67243. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  67244. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine) {
  67245. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  67246. var manager = mesh.morphTargetManager;
  67247. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  67248. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  67249. for (var index = 0; index < influencers; index++) {
  67250. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind + index);
  67251. if (normal) {
  67252. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind + index);
  67253. }
  67254. if (tangent) {
  67255. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind + index);
  67256. }
  67257. if (attribs.length > maxAttributesCount) {
  67258. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  67259. }
  67260. }
  67261. }
  67262. };
  67263. /**
  67264. * Prepares the list of attributes required for bones according to the effect defines.
  67265. * @param attribs The current list of supported attribs
  67266. * @param mesh The mesh to prepare the bones attributes for
  67267. * @param defines The current Defines of the effect
  67268. * @param fallbacks The current efffect fallback strategy
  67269. */
  67270. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  67271. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  67272. fallbacks.addCPUSkinningFallback(0, mesh);
  67273. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  67274. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  67275. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  67276. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesExtraKind);
  67277. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsExtraKind);
  67278. }
  67279. }
  67280. };
  67281. /**
  67282. * Prepares the list of attributes required for instances according to the effect defines.
  67283. * @param attribs The current list of supported attribs
  67284. * @param defines The current Defines of the effect
  67285. */
  67286. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  67287. if (defines["INSTANCES"]) {
  67288. attribs.push("world0");
  67289. attribs.push("world1");
  67290. attribs.push("world2");
  67291. attribs.push("world3");
  67292. }
  67293. };
  67294. /**
  67295. * Binds the light shadow information to the effect for the given mesh.
  67296. * @param light The light containing the generator
  67297. * @param scene The scene the lights belongs to
  67298. * @param mesh The mesh we are binding the information to render
  67299. * @param lightIndex The light index in the effect used to render the mesh
  67300. * @param effect The effect we are binding the data to
  67301. */
  67302. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  67303. if (light.shadowEnabled && mesh.receiveShadows) {
  67304. var shadowGenerator = light.getShadowGenerator();
  67305. if (shadowGenerator) {
  67306. shadowGenerator.bindShadowLight(lightIndex, effect);
  67307. }
  67308. }
  67309. };
  67310. /**
  67311. * Binds the light information to the effect.
  67312. * @param light The light containing the generator
  67313. * @param effect The effect we are binding the data to
  67314. * @param lightIndex The light index in the effect used to render
  67315. */
  67316. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  67317. light.transferToEffect(effect, lightIndex + "");
  67318. };
  67319. /**
  67320. * Binds the lights information from the scene to the effect for the given mesh.
  67321. * @param scene The scene the lights belongs to
  67322. * @param mesh The mesh we are binding the information to render
  67323. * @param effect The effect we are binding the data to
  67324. * @param defines The generated defines for the effect
  67325. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  67326. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  67327. */
  67328. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  67329. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  67330. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  67331. var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
  67332. for (var i = 0; i < len; i++) {
  67333. var light = mesh._lightSources[i];
  67334. var iAsString = i.toString();
  67335. var scaledIntensity = light.getScaledIntensity();
  67336. light._uniformBuffer.bindToEffect(effect, "Light" + i);
  67337. MaterialHelper.BindLightProperties(light, effect, i);
  67338. light.diffuse.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0]);
  67339. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  67340. if (defines["SPECULARTERM"]) {
  67341. light.specular.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1]);
  67342. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1], iAsString);
  67343. }
  67344. // Shadows
  67345. if (scene.shadowsEnabled) {
  67346. this.BindLightShadow(light, mesh, iAsString, effect);
  67347. }
  67348. light._uniformBuffer.update();
  67349. }
  67350. };
  67351. /**
  67352. * Binds the fog information from the scene to the effect for the given mesh.
  67353. * @param scene The scene the lights belongs to
  67354. * @param mesh The mesh we are binding the information to render
  67355. * @param effect The effect we are binding the data to
  67356. * @param linearSpace Defines if the fog effect is applied in linear space
  67357. */
  67358. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  67359. if (linearSpace === void 0) { linearSpace = false; }
  67360. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  67361. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  67362. // Convert fog color to linear space if used in a linear space computed shader.
  67363. if (linearSpace) {
  67364. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  67365. effect.setColor3("vFogColor", this._tempFogColor);
  67366. }
  67367. else {
  67368. effect.setColor3("vFogColor", scene.fogColor);
  67369. }
  67370. }
  67371. };
  67372. /**
  67373. * Binds the bones information from the mesh to the effect.
  67374. * @param mesh The mesh we are binding the information to render
  67375. * @param effect The effect we are binding the data to
  67376. */
  67377. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  67378. if (!effect || !mesh) {
  67379. return;
  67380. }
  67381. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  67382. mesh.computeBonesUsingShaders = false;
  67383. }
  67384. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  67385. var skeleton = mesh.skeleton;
  67386. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  67387. var boneTexture = skeleton.getTransformMatrixTexture();
  67388. effect.setTexture("boneSampler", boneTexture);
  67389. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  67390. }
  67391. else {
  67392. var matrices = skeleton.getTransformMatrices(mesh);
  67393. if (matrices) {
  67394. effect.setMatrices("mBones", matrices);
  67395. }
  67396. }
  67397. }
  67398. };
  67399. /**
  67400. * Binds the morph targets information from the mesh to the effect.
  67401. * @param abstractMesh The mesh we are binding the information to render
  67402. * @param effect The effect we are binding the data to
  67403. */
  67404. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  67405. var manager = abstractMesh.morphTargetManager;
  67406. if (!abstractMesh || !manager) {
  67407. return;
  67408. }
  67409. effect.setFloatArray("morphTargetInfluences", manager.influences);
  67410. };
  67411. /**
  67412. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  67413. * @param defines The generated defines used in the effect
  67414. * @param effect The effect we are binding the data to
  67415. * @param scene The scene we are willing to render with logarithmic scale for
  67416. */
  67417. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  67418. if (defines["LOGARITHMICDEPTH"]) {
  67419. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  67420. }
  67421. };
  67422. /**
  67423. * Binds the clip plane information from the scene to the effect.
  67424. * @param scene The scene the clip plane information are extracted from
  67425. * @param effect The effect we are binding the data to
  67426. */
  67427. MaterialHelper.BindClipPlane = function (effect, scene) {
  67428. if (scene.clipPlane) {
  67429. var clipPlane = scene.clipPlane;
  67430. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  67431. }
  67432. if (scene.clipPlane2) {
  67433. var clipPlane = scene.clipPlane2;
  67434. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  67435. }
  67436. if (scene.clipPlane3) {
  67437. var clipPlane = scene.clipPlane3;
  67438. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  67439. }
  67440. if (scene.clipPlane4) {
  67441. var clipPlane = scene.clipPlane4;
  67442. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  67443. }
  67444. };
  67445. MaterialHelper._tempFogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  67446. return MaterialHelper;
  67447. }());
  67448. /***/ }),
  67449. /***/ "./Materials/multiMaterial.ts":
  67450. /*!************************************!*\
  67451. !*** ./Materials/multiMaterial.ts ***!
  67452. \************************************/
  67453. /*! exports provided: MultiMaterial */
  67454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67455. "use strict";
  67456. __webpack_require__.r(__webpack_exports__);
  67457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  67458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  67459. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  67460. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  67461. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  67462. /**
  67463. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67464. * separate meshes. This can be use to improve performances.
  67465. * @see http://doc.babylonjs.com/how_to/multi_materials
  67466. */
  67467. var MultiMaterial = /** @class */ (function (_super) {
  67468. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  67469. /**
  67470. * Instantiates a new Multi Material
  67471. * A multi-material is used to apply different materials to different parts of the same object without the need of
  67472. * separate meshes. This can be use to improve performances.
  67473. * @see http://doc.babylonjs.com/how_to/multi_materials
  67474. * @param name Define the name in the scene
  67475. * @param scene Define the scene the material belongs to
  67476. */
  67477. function MultiMaterial(name, scene) {
  67478. var _this = _super.call(this, name, scene, true) || this;
  67479. scene.multiMaterials.push(_this);
  67480. _this.subMaterials = new Array();
  67481. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  67482. return _this;
  67483. }
  67484. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  67485. /**
  67486. * Gets or Sets the list of Materials used within the multi material.
  67487. * They need to be ordered according to the submeshes order in the associated mesh
  67488. */
  67489. get: function () {
  67490. return this._subMaterials;
  67491. },
  67492. set: function (value) {
  67493. this._subMaterials = value;
  67494. this._hookArray(value);
  67495. },
  67496. enumerable: true,
  67497. configurable: true
  67498. });
  67499. /**
  67500. * Function used to align with Node.getChildren()
  67501. * @returns the list of Materials used within the multi material
  67502. */
  67503. MultiMaterial.prototype.getChildren = function () {
  67504. return this.subMaterials;
  67505. };
  67506. MultiMaterial.prototype._hookArray = function (array) {
  67507. var _this = this;
  67508. var oldPush = array.push;
  67509. array.push = function () {
  67510. var items = [];
  67511. for (var _i = 0; _i < arguments.length; _i++) {
  67512. items[_i] = arguments[_i];
  67513. }
  67514. var result = oldPush.apply(array, items);
  67515. _this._markAllSubMeshesAsTexturesDirty();
  67516. return result;
  67517. };
  67518. var oldSplice = array.splice;
  67519. array.splice = function (index, deleteCount) {
  67520. var deleted = oldSplice.apply(array, [index, deleteCount]);
  67521. _this._markAllSubMeshesAsTexturesDirty();
  67522. return deleted;
  67523. };
  67524. };
  67525. /**
  67526. * Get one of the submaterial by its index in the submaterials array
  67527. * @param index The index to look the sub material at
  67528. * @returns The Material if the index has been defined
  67529. */
  67530. MultiMaterial.prototype.getSubMaterial = function (index) {
  67531. if (index < 0 || index >= this.subMaterials.length) {
  67532. return this.getScene().defaultMaterial;
  67533. }
  67534. return this.subMaterials[index];
  67535. };
  67536. /**
  67537. * Get the list of active textures for the whole sub materials list.
  67538. * @returns All the textures that will be used during the rendering
  67539. */
  67540. MultiMaterial.prototype.getActiveTextures = function () {
  67541. var _a;
  67542. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  67543. if (subMaterial) {
  67544. return subMaterial.getActiveTextures();
  67545. }
  67546. else {
  67547. return [];
  67548. }
  67549. }));
  67550. };
  67551. /**
  67552. * Gets the current class name of the material e.g. "MultiMaterial"
  67553. * Mainly use in serialization.
  67554. * @returns the class name
  67555. */
  67556. MultiMaterial.prototype.getClassName = function () {
  67557. return "MultiMaterial";
  67558. };
  67559. /**
  67560. * Checks if the material is ready to render the requested sub mesh
  67561. * @param mesh Define the mesh the submesh belongs to
  67562. * @param subMesh Define the sub mesh to look readyness for
  67563. * @param useInstances Define whether or not the material is used with instances
  67564. * @returns true if ready, otherwise false
  67565. */
  67566. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  67567. for (var index = 0; index < this.subMaterials.length; index++) {
  67568. var subMaterial = this.subMaterials[index];
  67569. if (subMaterial) {
  67570. if (subMaterial._storeEffectOnSubMeshes) {
  67571. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  67572. return false;
  67573. }
  67574. continue;
  67575. }
  67576. if (!subMaterial.isReady(mesh)) {
  67577. return false;
  67578. }
  67579. }
  67580. }
  67581. return true;
  67582. };
  67583. /**
  67584. * Clones the current material and its related sub materials
  67585. * @param name Define the name of the newly cloned material
  67586. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  67587. * @returns the cloned material
  67588. */
  67589. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  67590. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  67591. for (var index = 0; index < this.subMaterials.length; index++) {
  67592. var subMaterial = null;
  67593. var current = this.subMaterials[index];
  67594. if (cloneChildren && current) {
  67595. subMaterial = current.clone(name + "-" + current.name);
  67596. }
  67597. else {
  67598. subMaterial = this.subMaterials[index];
  67599. }
  67600. newMultiMaterial.subMaterials.push(subMaterial);
  67601. }
  67602. return newMultiMaterial;
  67603. };
  67604. /**
  67605. * Serializes the materials into a JSON representation.
  67606. * @returns the JSON representation
  67607. */
  67608. MultiMaterial.prototype.serialize = function () {
  67609. var serializationObject = {};
  67610. serializationObject.name = this.name;
  67611. serializationObject.id = this.id;
  67612. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  67613. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  67614. }
  67615. serializationObject.materials = [];
  67616. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  67617. var subMat = this.subMaterials[matIndex];
  67618. if (subMat) {
  67619. serializationObject.materials.push(subMat.id);
  67620. }
  67621. else {
  67622. serializationObject.materials.push(null);
  67623. }
  67624. }
  67625. return serializationObject;
  67626. };
  67627. /**
  67628. * Dispose the material and release its associated resources
  67629. * @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)
  67630. * @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)
  67631. * @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)
  67632. */
  67633. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  67634. var scene = this.getScene();
  67635. if (!scene) {
  67636. return;
  67637. }
  67638. if (forceDisposeChildren) {
  67639. for (var index = 0; index < this.subMaterials.length; index++) {
  67640. var subMaterial = this.subMaterials[index];
  67641. if (subMaterial) {
  67642. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  67643. }
  67644. }
  67645. }
  67646. var index = scene.multiMaterials.indexOf(this);
  67647. if (index >= 0) {
  67648. scene.multiMaterials.splice(index, 1);
  67649. }
  67650. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  67651. };
  67652. /**
  67653. * Creates a MultiMaterial from parsed MultiMaterial data.
  67654. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  67655. * @param scene defines the hosting scene
  67656. * @returns a new MultiMaterial
  67657. */
  67658. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  67659. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  67660. multiMaterial.id = parsedMultiMaterial.id;
  67661. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  67662. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  67663. }
  67664. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  67665. var subMatId = parsedMultiMaterial.materials[matIndex];
  67666. if (subMatId) {
  67667. multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
  67668. }
  67669. else {
  67670. multiMaterial.subMaterials.push(null);
  67671. }
  67672. }
  67673. return multiMaterial;
  67674. };
  67675. return MultiMaterial;
  67676. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  67677. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  67678. /***/ }),
  67679. /***/ "./Materials/pushMaterial.ts":
  67680. /*!***********************************!*\
  67681. !*** ./Materials/pushMaterial.ts ***!
  67682. \***********************************/
  67683. /*! exports provided: PushMaterial */
  67684. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67685. "use strict";
  67686. __webpack_require__.r(__webpack_exports__);
  67687. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  67688. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  67689. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  67690. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  67691. /**
  67692. * Base class of materials working in push mode in babylon JS
  67693. * @hidden
  67694. */
  67695. var PushMaterial = /** @class */ (function (_super) {
  67696. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  67697. function PushMaterial(name, scene) {
  67698. var _this = _super.call(this, name, scene) || this;
  67699. _this._normalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  67700. /**
  67701. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  67702. * This means that the material can keep using a previous shader while a new one is being compiled.
  67703. * This is mostly used when shader parallel compilation is supported (true by default)
  67704. */
  67705. _this.allowShaderHotSwapping = true;
  67706. _this._storeEffectOnSubMeshes = true;
  67707. return _this;
  67708. }
  67709. PushMaterial.prototype.getEffect = function () {
  67710. return this._activeEffect;
  67711. };
  67712. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  67713. if (!mesh) {
  67714. return false;
  67715. }
  67716. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  67717. return true;
  67718. }
  67719. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  67720. };
  67721. /**
  67722. * Binds the given world matrix to the active effect
  67723. *
  67724. * @param world the matrix to bind
  67725. */
  67726. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  67727. this._activeEffect.setMatrix("world", world);
  67728. };
  67729. /**
  67730. * Binds the given normal matrix to the active effect
  67731. *
  67732. * @param normalMatrix the matrix to bind
  67733. */
  67734. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  67735. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  67736. };
  67737. PushMaterial.prototype.bind = function (world, mesh) {
  67738. if (!mesh) {
  67739. return;
  67740. }
  67741. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  67742. };
  67743. PushMaterial.prototype._afterBind = function (mesh, effect) {
  67744. if (effect === void 0) { effect = null; }
  67745. _super.prototype._afterBind.call(this, mesh);
  67746. this.getScene()._cachedEffect = effect;
  67747. };
  67748. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  67749. if (visibility === void 0) { visibility = 1; }
  67750. return scene.isCachedMaterialInvalid(this, effect, visibility);
  67751. };
  67752. return PushMaterial;
  67753. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  67754. /***/ }),
  67755. /***/ "./Materials/shaderMaterial.ts":
  67756. /*!*************************************!*\
  67757. !*** ./Materials/shaderMaterial.ts ***!
  67758. \*************************************/
  67759. /*! exports provided: ShaderMaterial */
  67760. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67761. "use strict";
  67762. __webpack_require__.r(__webpack_exports__);
  67763. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  67764. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  67765. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  67766. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  67767. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  67768. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  67769. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  67770. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  67771. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  67772. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  67773. /**
  67774. * 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.
  67775. *
  67776. * This returned material effects how the mesh will look based on the code in the shaders.
  67777. *
  67778. * @see http://doc.babylonjs.com/how_to/shader_material
  67779. */
  67780. var ShaderMaterial = /** @class */ (function (_super) {
  67781. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  67782. /**
  67783. * Instantiate a new shader material.
  67784. * 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.
  67785. * This returned material effects how the mesh will look based on the code in the shaders.
  67786. * @see http://doc.babylonjs.com/how_to/shader_material
  67787. * @param name Define the name of the material in the scene
  67788. * @param scene Define the scene the material belongs to
  67789. * @param shaderPath Defines the route to the shader code in one of three ways:
  67790. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  67791. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  67792. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  67793. * @param options Define the options used to create the shader
  67794. */
  67795. function ShaderMaterial(name, scene, shaderPath, options) {
  67796. if (options === void 0) { options = {}; }
  67797. var _this = _super.call(this, name, scene) || this;
  67798. _this._textures = {};
  67799. _this._textureArrays = {};
  67800. _this._floats = {};
  67801. _this._ints = {};
  67802. _this._floatsArrays = {};
  67803. _this._colors3 = {};
  67804. _this._colors3Arrays = {};
  67805. _this._colors4 = {};
  67806. _this._vectors2 = {};
  67807. _this._vectors3 = {};
  67808. _this._vectors4 = {};
  67809. _this._matrices = {};
  67810. _this._matrices3x3 = {};
  67811. _this._matrices2x2 = {};
  67812. _this._vectors2Arrays = {};
  67813. _this._vectors3Arrays = {};
  67814. _this._cachedWorldViewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  67815. _this._shaderPath = shaderPath;
  67816. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  67817. return _this;
  67818. }
  67819. Object.defineProperty(ShaderMaterial.prototype, "options", {
  67820. /**
  67821. * Gets the options used to compile the shader.
  67822. * They can be modified to trigger a new compilation
  67823. */
  67824. get: function () {
  67825. return this._options;
  67826. },
  67827. enumerable: true,
  67828. configurable: true
  67829. });
  67830. /**
  67831. * Gets the current class name of the material e.g. "ShaderMaterial"
  67832. * Mainly use in serialization.
  67833. * @returns the class name
  67834. */
  67835. ShaderMaterial.prototype.getClassName = function () {
  67836. return "ShaderMaterial";
  67837. };
  67838. /**
  67839. * Specifies if the material will require alpha blending
  67840. * @returns a boolean specifying if alpha blending is needed
  67841. */
  67842. ShaderMaterial.prototype.needAlphaBlending = function () {
  67843. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  67844. };
  67845. /**
  67846. * Specifies if this material should be rendered in alpha test mode
  67847. * @returns a boolean specifying if an alpha test is needed.
  67848. */
  67849. ShaderMaterial.prototype.needAlphaTesting = function () {
  67850. return this._options.needAlphaTesting;
  67851. };
  67852. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  67853. if (this._options.uniforms.indexOf(uniformName) === -1) {
  67854. this._options.uniforms.push(uniformName);
  67855. }
  67856. };
  67857. /**
  67858. * Set a texture in the shader.
  67859. * @param name Define the name of the uniform samplers as defined in the shader
  67860. * @param texture Define the texture to bind to this sampler
  67861. * @return the material itself allowing "fluent" like uniform updates
  67862. */
  67863. ShaderMaterial.prototype.setTexture = function (name, texture) {
  67864. if (this._options.samplers.indexOf(name) === -1) {
  67865. this._options.samplers.push(name);
  67866. }
  67867. this._textures[name] = texture;
  67868. return this;
  67869. };
  67870. /**
  67871. * Set a texture array in the shader.
  67872. * @param name Define the name of the uniform sampler array as defined in the shader
  67873. * @param textures Define the list of textures to bind to this sampler
  67874. * @return the material itself allowing "fluent" like uniform updates
  67875. */
  67876. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  67877. if (this._options.samplers.indexOf(name) === -1) {
  67878. this._options.samplers.push(name);
  67879. }
  67880. this._checkUniform(name);
  67881. this._textureArrays[name] = textures;
  67882. return this;
  67883. };
  67884. /**
  67885. * Set a float in the shader.
  67886. * @param name Define the name of the uniform as defined in the shader
  67887. * @param value Define the value to give to the uniform
  67888. * @return the material itself allowing "fluent" like uniform updates
  67889. */
  67890. ShaderMaterial.prototype.setFloat = function (name, value) {
  67891. this._checkUniform(name);
  67892. this._floats[name] = value;
  67893. return this;
  67894. };
  67895. /**
  67896. * Set a int in the shader.
  67897. * @param name Define the name of the uniform as defined in the shader
  67898. * @param value Define the value to give to the uniform
  67899. * @return the material itself allowing "fluent" like uniform updates
  67900. */
  67901. ShaderMaterial.prototype.setInt = function (name, value) {
  67902. this._checkUniform(name);
  67903. this._ints[name] = value;
  67904. return this;
  67905. };
  67906. /**
  67907. * Set an array of floats in the shader.
  67908. * @param name Define the name of the uniform as defined in the shader
  67909. * @param value Define the value to give to the uniform
  67910. * @return the material itself allowing "fluent" like uniform updates
  67911. */
  67912. ShaderMaterial.prototype.setFloats = function (name, value) {
  67913. this._checkUniform(name);
  67914. this._floatsArrays[name] = value;
  67915. return this;
  67916. };
  67917. /**
  67918. * Set a vec3 in the shader from a Color3.
  67919. * @param name Define the name of the uniform as defined in the shader
  67920. * @param value Define the value to give to the uniform
  67921. * @return the material itself allowing "fluent" like uniform updates
  67922. */
  67923. ShaderMaterial.prototype.setColor3 = function (name, value) {
  67924. this._checkUniform(name);
  67925. this._colors3[name] = value;
  67926. return this;
  67927. };
  67928. /**
  67929. * Set a vec3 array in the shader from a Color3 array.
  67930. * @param name Define the name of the uniform as defined in the shader
  67931. * @param value Define the value to give to the uniform
  67932. * @return the material itself allowing "fluent" like uniform updates
  67933. */
  67934. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  67935. this._checkUniform(name);
  67936. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  67937. color.toArray(arr, arr.length);
  67938. return arr;
  67939. }, []);
  67940. return this;
  67941. };
  67942. /**
  67943. * Set a vec4 in the shader from a Color4.
  67944. * @param name Define the name of the uniform as defined in the shader
  67945. * @param value Define the value to give to the uniform
  67946. * @return the material itself allowing "fluent" like uniform updates
  67947. */
  67948. ShaderMaterial.prototype.setColor4 = function (name, value) {
  67949. this._checkUniform(name);
  67950. this._colors4[name] = value;
  67951. return this;
  67952. };
  67953. /**
  67954. * Set a vec2 in the shader from a Vector2.
  67955. * @param name Define the name of the uniform as defined in the shader
  67956. * @param value Define the value to give to the uniform
  67957. * @return the material itself allowing "fluent" like uniform updates
  67958. */
  67959. ShaderMaterial.prototype.setVector2 = function (name, value) {
  67960. this._checkUniform(name);
  67961. this._vectors2[name] = value;
  67962. return this;
  67963. };
  67964. /**
  67965. * Set a vec3 in the shader from a Vector3.
  67966. * @param name Define the name of the uniform as defined in the shader
  67967. * @param value Define the value to give to the uniform
  67968. * @return the material itself allowing "fluent" like uniform updates
  67969. */
  67970. ShaderMaterial.prototype.setVector3 = function (name, value) {
  67971. this._checkUniform(name);
  67972. this._vectors3[name] = value;
  67973. return this;
  67974. };
  67975. /**
  67976. * Set a vec4 in the shader from a Vector4.
  67977. * @param name Define the name of the uniform as defined in the shader
  67978. * @param value Define the value to give to the uniform
  67979. * @return the material itself allowing "fluent" like uniform updates
  67980. */
  67981. ShaderMaterial.prototype.setVector4 = function (name, value) {
  67982. this._checkUniform(name);
  67983. this._vectors4[name] = value;
  67984. return this;
  67985. };
  67986. /**
  67987. * Set a mat4 in the shader from a Matrix.
  67988. * @param name Define the name of the uniform as defined in the shader
  67989. * @param value Define the value to give to the uniform
  67990. * @return the material itself allowing "fluent" like uniform updates
  67991. */
  67992. ShaderMaterial.prototype.setMatrix = function (name, value) {
  67993. this._checkUniform(name);
  67994. this._matrices[name] = value;
  67995. return this;
  67996. };
  67997. /**
  67998. * Set a mat3 in the shader from a Float32Array.
  67999. * @param name Define the name of the uniform as defined in the shader
  68000. * @param value Define the value to give to the uniform
  68001. * @return the material itself allowing "fluent" like uniform updates
  68002. */
  68003. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  68004. this._checkUniform(name);
  68005. this._matrices3x3[name] = value;
  68006. return this;
  68007. };
  68008. /**
  68009. * Set a mat2 in the shader from a Float32Array.
  68010. * @param name Define the name of the uniform as defined in the shader
  68011. * @param value Define the value to give to the uniform
  68012. * @return the material itself allowing "fluent" like uniform updates
  68013. */
  68014. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  68015. this._checkUniform(name);
  68016. this._matrices2x2[name] = value;
  68017. return this;
  68018. };
  68019. /**
  68020. * Set a vec2 array in the shader from a number array.
  68021. * @param name Define the name of the uniform as defined in the shader
  68022. * @param value Define the value to give to the uniform
  68023. * @return the material itself allowing "fluent" like uniform updates
  68024. */
  68025. ShaderMaterial.prototype.setArray2 = function (name, value) {
  68026. this._checkUniform(name);
  68027. this._vectors2Arrays[name] = value;
  68028. return this;
  68029. };
  68030. /**
  68031. * Set a vec3 array in the shader from a number array.
  68032. * @param name Define the name of the uniform as defined in the shader
  68033. * @param value Define the value to give to the uniform
  68034. * @return the material itself allowing "fluent" like uniform updates
  68035. */
  68036. ShaderMaterial.prototype.setArray3 = function (name, value) {
  68037. this._checkUniform(name);
  68038. this._vectors3Arrays[name] = value;
  68039. return this;
  68040. };
  68041. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  68042. if (!mesh) {
  68043. return true;
  68044. }
  68045. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  68046. return false;
  68047. }
  68048. return false;
  68049. };
  68050. /**
  68051. * Specifies that the submesh is ready to be used
  68052. * @param mesh defines the mesh to check
  68053. * @param subMesh defines which submesh to check
  68054. * @param useInstances specifies that instances should be used
  68055. * @returns a boolean indicating that the submesh is ready or not
  68056. */
  68057. ShaderMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  68058. return this.isReady(mesh, useInstances);
  68059. };
  68060. /**
  68061. * Checks if the material is ready to render the requested mesh
  68062. * @param mesh Define the mesh to render
  68063. * @param useInstances Define whether or not the material is used with instances
  68064. * @returns true if ready, otherwise false
  68065. */
  68066. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  68067. var scene = this.getScene();
  68068. var engine = scene.getEngine();
  68069. if (!this.checkReadyOnEveryCall) {
  68070. if (this._renderId === scene.getRenderId()) {
  68071. if (this._checkCache(mesh, useInstances)) {
  68072. return true;
  68073. }
  68074. }
  68075. }
  68076. // Instances
  68077. var defines = [];
  68078. var attribs = [];
  68079. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  68080. for (var index = 0; index < this._options.defines.length; index++) {
  68081. defines.push(this._options.defines[index]);
  68082. }
  68083. for (var index = 0; index < this._options.attributes.length; index++) {
  68084. attribs.push(this._options.attributes[index]);
  68085. }
  68086. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  68087. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  68088. defines.push("#define VERTEXCOLOR");
  68089. }
  68090. if (useInstances) {
  68091. defines.push("#define INSTANCES");
  68092. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  68093. }
  68094. // Bones
  68095. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  68096. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  68097. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  68098. if (mesh.numBoneInfluencers > 4) {
  68099. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  68100. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  68101. }
  68102. var skeleton = mesh.skeleton;
  68103. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  68104. fallbacks.addCPUSkinningFallback(0, mesh);
  68105. if (skeleton.isUsingTextureForMatrices) {
  68106. defines.push("#define BONETEXTURE");
  68107. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  68108. this._options.uniforms.push("boneTextureWidth");
  68109. }
  68110. if (this._options.samplers.indexOf("boneSampler") === -1) {
  68111. this._options.samplers.push("boneSampler");
  68112. }
  68113. }
  68114. else {
  68115. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  68116. if (this._options.uniforms.indexOf("mBones") === -1) {
  68117. this._options.uniforms.push("mBones");
  68118. }
  68119. }
  68120. }
  68121. else {
  68122. defines.push("#define NUM_BONE_INFLUENCERS 0");
  68123. }
  68124. // Textures
  68125. for (var name in this._textures) {
  68126. if (!this._textures[name].isReady()) {
  68127. return false;
  68128. }
  68129. }
  68130. // Alpha test
  68131. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  68132. defines.push("#define ALPHATEST");
  68133. }
  68134. var previousEffect = this._effect;
  68135. var join = defines.join("\n");
  68136. this._effect = engine.createEffect(this._shaderPath, {
  68137. attributes: attribs,
  68138. uniformsNames: this._options.uniforms,
  68139. uniformBuffersNames: this._options.uniformBuffers,
  68140. samplers: this._options.samplers,
  68141. defines: join,
  68142. fallbacks: fallbacks,
  68143. onCompiled: this.onCompiled,
  68144. onError: this.onError
  68145. }, engine);
  68146. if (!this._effect.isReady()) {
  68147. return false;
  68148. }
  68149. if (previousEffect !== this._effect) {
  68150. scene.resetCachedMaterial();
  68151. }
  68152. this._renderId = scene.getRenderId();
  68153. return true;
  68154. };
  68155. /**
  68156. * Binds the world matrix to the material
  68157. * @param world defines the world transformation matrix
  68158. */
  68159. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  68160. var scene = this.getScene();
  68161. if (!this._effect) {
  68162. return;
  68163. }
  68164. if (this._options.uniforms.indexOf("world") !== -1) {
  68165. this._effect.setMatrix("world", world);
  68166. }
  68167. if (this._options.uniforms.indexOf("worldView") !== -1) {
  68168. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  68169. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  68170. }
  68171. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  68172. this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
  68173. }
  68174. };
  68175. /**
  68176. * Binds the material to the mesh
  68177. * @param world defines the world transformation matrix
  68178. * @param mesh defines the mesh to bind the material to
  68179. */
  68180. ShaderMaterial.prototype.bind = function (world, mesh) {
  68181. // Std values
  68182. this.bindOnlyWorldMatrix(world);
  68183. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  68184. if (this._options.uniforms.indexOf("view") !== -1) {
  68185. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  68186. }
  68187. if (this._options.uniforms.indexOf("projection") !== -1) {
  68188. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  68189. }
  68190. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  68191. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  68192. }
  68193. // Bones
  68194. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  68195. var name;
  68196. // Texture
  68197. for (name in this._textures) {
  68198. this._effect.setTexture(name, this._textures[name]);
  68199. }
  68200. // Texture arrays
  68201. for (name in this._textureArrays) {
  68202. this._effect.setTextureArray(name, this._textureArrays[name]);
  68203. }
  68204. // Int
  68205. for (name in this._ints) {
  68206. this._effect.setInt(name, this._ints[name]);
  68207. }
  68208. // Float
  68209. for (name in this._floats) {
  68210. this._effect.setFloat(name, this._floats[name]);
  68211. }
  68212. // Floats
  68213. for (name in this._floatsArrays) {
  68214. this._effect.setArray(name, this._floatsArrays[name]);
  68215. }
  68216. // Color3
  68217. for (name in this._colors3) {
  68218. this._effect.setColor3(name, this._colors3[name]);
  68219. }
  68220. for (name in this._colors3Arrays) {
  68221. this._effect.setArray3(name, this._colors3Arrays[name]);
  68222. }
  68223. // Color4
  68224. for (name in this._colors4) {
  68225. var color = this._colors4[name];
  68226. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  68227. }
  68228. // Vector2
  68229. for (name in this._vectors2) {
  68230. this._effect.setVector2(name, this._vectors2[name]);
  68231. }
  68232. // Vector3
  68233. for (name in this._vectors3) {
  68234. this._effect.setVector3(name, this._vectors3[name]);
  68235. }
  68236. // Vector4
  68237. for (name in this._vectors4) {
  68238. this._effect.setVector4(name, this._vectors4[name]);
  68239. }
  68240. // Matrix
  68241. for (name in this._matrices) {
  68242. this._effect.setMatrix(name, this._matrices[name]);
  68243. }
  68244. // Matrix 3x3
  68245. for (name in this._matrices3x3) {
  68246. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  68247. }
  68248. // Matrix 2x2
  68249. for (name in this._matrices2x2) {
  68250. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  68251. }
  68252. // Vector2Array
  68253. for (name in this._vectors2Arrays) {
  68254. this._effect.setArray2(name, this._vectors2Arrays[name]);
  68255. }
  68256. // Vector3Array
  68257. for (name in this._vectors3Arrays) {
  68258. this._effect.setArray3(name, this._vectors3Arrays[name]);
  68259. }
  68260. }
  68261. this._afterBind(mesh);
  68262. };
  68263. /**
  68264. * Gets the active textures from the material
  68265. * @returns an array of textures
  68266. */
  68267. ShaderMaterial.prototype.getActiveTextures = function () {
  68268. var activeTextures = _super.prototype.getActiveTextures.call(this);
  68269. for (var name in this._textures) {
  68270. activeTextures.push(this._textures[name]);
  68271. }
  68272. for (var name in this._textureArrays) {
  68273. var array = this._textureArrays[name];
  68274. for (var index = 0; index < array.length; index++) {
  68275. activeTextures.push(array[index]);
  68276. }
  68277. }
  68278. return activeTextures;
  68279. };
  68280. /**
  68281. * Specifies if the material uses a texture
  68282. * @param texture defines the texture to check against the material
  68283. * @returns a boolean specifying if the material uses the texture
  68284. */
  68285. ShaderMaterial.prototype.hasTexture = function (texture) {
  68286. if (_super.prototype.hasTexture.call(this, texture)) {
  68287. return true;
  68288. }
  68289. for (var name in this._textures) {
  68290. if (this._textures[name] === texture) {
  68291. return true;
  68292. }
  68293. }
  68294. for (var name in this._textureArrays) {
  68295. var array = this._textureArrays[name];
  68296. for (var index = 0; index < array.length; index++) {
  68297. if (array[index] === texture) {
  68298. return true;
  68299. }
  68300. }
  68301. }
  68302. return false;
  68303. };
  68304. /**
  68305. * Makes a duplicate of the material, and gives it a new name
  68306. * @param name defines the new name for the duplicated material
  68307. * @returns the cloned material
  68308. */
  68309. ShaderMaterial.prototype.clone = function (name) {
  68310. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  68311. return newShaderMaterial;
  68312. };
  68313. /**
  68314. * Disposes the material
  68315. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  68316. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  68317. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  68318. */
  68319. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  68320. if (forceDisposeTextures) {
  68321. var name;
  68322. for (name in this._textures) {
  68323. this._textures[name].dispose();
  68324. }
  68325. for (name in this._textureArrays) {
  68326. var array = this._textureArrays[name];
  68327. for (var index = 0; index < array.length; index++) {
  68328. array[index].dispose();
  68329. }
  68330. }
  68331. }
  68332. this._textures = {};
  68333. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  68334. };
  68335. /**
  68336. * Serializes this material in a JSON representation
  68337. * @returns the serialized material object
  68338. */
  68339. ShaderMaterial.prototype.serialize = function () {
  68340. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  68341. serializationObject.customType = "ShaderMaterial";
  68342. serializationObject.options = this._options;
  68343. serializationObject.shaderPath = this._shaderPath;
  68344. var name;
  68345. // Texture
  68346. serializationObject.textures = {};
  68347. for (name in this._textures) {
  68348. serializationObject.textures[name] = this._textures[name].serialize();
  68349. }
  68350. // Texture arrays
  68351. serializationObject.textureArrays = {};
  68352. for (name in this._textureArrays) {
  68353. serializationObject.textureArrays[name] = [];
  68354. var array = this._textureArrays[name];
  68355. for (var index = 0; index < array.length; index++) {
  68356. serializationObject.textureArrays[name].push(array[index].serialize());
  68357. }
  68358. }
  68359. // Float
  68360. serializationObject.floats = {};
  68361. for (name in this._floats) {
  68362. serializationObject.floats[name] = this._floats[name];
  68363. }
  68364. // Float s
  68365. serializationObject.FloatArrays = {};
  68366. for (name in this._floatsArrays) {
  68367. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  68368. }
  68369. // Color3
  68370. serializationObject.colors3 = {};
  68371. for (name in this._colors3) {
  68372. serializationObject.colors3[name] = this._colors3[name].asArray();
  68373. }
  68374. // Color3 array
  68375. serializationObject.colors3Arrays = {};
  68376. for (name in this._colors3Arrays) {
  68377. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  68378. }
  68379. // Color4
  68380. serializationObject.colors4 = {};
  68381. for (name in this._colors4) {
  68382. serializationObject.colors4[name] = this._colors4[name].asArray();
  68383. }
  68384. // Vector2
  68385. serializationObject.vectors2 = {};
  68386. for (name in this._vectors2) {
  68387. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  68388. }
  68389. // Vector3
  68390. serializationObject.vectors3 = {};
  68391. for (name in this._vectors3) {
  68392. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  68393. }
  68394. // Vector4
  68395. serializationObject.vectors4 = {};
  68396. for (name in this._vectors4) {
  68397. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  68398. }
  68399. // Matrix
  68400. serializationObject.matrices = {};
  68401. for (name in this._matrices) {
  68402. serializationObject.matrices[name] = this._matrices[name].asArray();
  68403. }
  68404. // Matrix 3x3
  68405. serializationObject.matrices3x3 = {};
  68406. for (name in this._matrices3x3) {
  68407. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  68408. }
  68409. // Matrix 2x2
  68410. serializationObject.matrices2x2 = {};
  68411. for (name in this._matrices2x2) {
  68412. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  68413. }
  68414. // Vector2Array
  68415. serializationObject.vectors2Arrays = {};
  68416. for (name in this._vectors2Arrays) {
  68417. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  68418. }
  68419. // Vector3Array
  68420. serializationObject.vectors3Arrays = {};
  68421. for (name in this._vectors3Arrays) {
  68422. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  68423. }
  68424. return serializationObject;
  68425. };
  68426. /**
  68427. * Creates a shader material from parsed shader material data
  68428. * @param source defines the JSON represnetation of the material
  68429. * @param scene defines the hosting scene
  68430. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68431. * @returns a new material
  68432. */
  68433. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  68434. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  68435. var name;
  68436. // Texture
  68437. for (name in source.textures) {
  68438. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  68439. }
  68440. // Texture arrays
  68441. for (name in source.textureArrays) {
  68442. var array = source.textureArrays[name];
  68443. var textureArray = new Array();
  68444. for (var index = 0; index < array.length; index++) {
  68445. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  68446. }
  68447. material.setTextureArray(name, textureArray);
  68448. }
  68449. // Float
  68450. for (name in source.floats) {
  68451. material.setFloat(name, source.floats[name]);
  68452. }
  68453. // Float s
  68454. for (name in source.floatsArrays) {
  68455. material.setFloats(name, source.floatsArrays[name]);
  68456. }
  68457. // Color3
  68458. for (name in source.colors3) {
  68459. material.setColor3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(source.colors3[name]));
  68460. }
  68461. // Color3 arrays
  68462. for (name in source.colors3Arrays) {
  68463. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  68464. if (i % 3 === 0) {
  68465. arr.push([num]);
  68466. }
  68467. else {
  68468. arr[arr.length - 1].push(num);
  68469. }
  68470. return arr;
  68471. }, []).map(function (color) { return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(color); });
  68472. material.setColor3Array(name, colors);
  68473. }
  68474. // Color4
  68475. for (name in source.colors4) {
  68476. material.setColor4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(source.colors4[name]));
  68477. }
  68478. // Vector2
  68479. for (name in source.vectors2) {
  68480. material.setVector2(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  68481. }
  68482. // Vector3
  68483. for (name in source.vectors3) {
  68484. material.setVector3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  68485. }
  68486. // Vector4
  68487. for (name in source.vectors4) {
  68488. material.setVector4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  68489. }
  68490. // Matrix
  68491. for (name in source.matrices) {
  68492. material.setMatrix(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  68493. }
  68494. // Matrix 3x3
  68495. for (name in source.matrices3x3) {
  68496. material.setMatrix3x3(name, source.matrices3x3[name]);
  68497. }
  68498. // Matrix 2x2
  68499. for (name in source.matrices2x2) {
  68500. material.setMatrix2x2(name, source.matrices2x2[name]);
  68501. }
  68502. // Vector2Array
  68503. for (name in source.vectors2Arrays) {
  68504. material.setArray2(name, source.vectors2Arrays[name]);
  68505. }
  68506. // Vector3Array
  68507. for (name in source.vectors3Arrays) {
  68508. material.setArray3(name, source.vectors3Arrays[name]);
  68509. }
  68510. return material;
  68511. };
  68512. return ShaderMaterial;
  68513. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  68514. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  68515. /***/ }),
  68516. /***/ "./Materials/standardMaterial.ts":
  68517. /*!***************************************!*\
  68518. !*** ./Materials/standardMaterial.ts ***!
  68519. \***************************************/
  68520. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  68521. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  68522. "use strict";
  68523. __webpack_require__.r(__webpack_exports__);
  68524. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  68525. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  68526. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  68527. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  68528. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  68529. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  68530. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  68531. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  68532. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  68533. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  68534. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  68535. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  68536. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  68537. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  68538. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  68539. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  68540. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  68541. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  68542. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  68543. /** @hidden */
  68544. var StandardMaterialDefines = /** @class */ (function (_super) {
  68545. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  68546. function StandardMaterialDefines() {
  68547. var _this = _super.call(this) || this;
  68548. _this.MAINUV1 = false;
  68549. _this.MAINUV2 = false;
  68550. _this.DIFFUSE = false;
  68551. _this.DIFFUSEDIRECTUV = 0;
  68552. _this.AMBIENT = false;
  68553. _this.AMBIENTDIRECTUV = 0;
  68554. _this.OPACITY = false;
  68555. _this.OPACITYDIRECTUV = 0;
  68556. _this.OPACITYRGB = false;
  68557. _this.REFLECTION = false;
  68558. _this.EMISSIVE = false;
  68559. _this.EMISSIVEDIRECTUV = 0;
  68560. _this.SPECULAR = false;
  68561. _this.SPECULARDIRECTUV = 0;
  68562. _this.BUMP = false;
  68563. _this.BUMPDIRECTUV = 0;
  68564. _this.PARALLAX = false;
  68565. _this.PARALLAXOCCLUSION = false;
  68566. _this.SPECULAROVERALPHA = false;
  68567. _this.CLIPPLANE = false;
  68568. _this.CLIPPLANE2 = false;
  68569. _this.CLIPPLANE3 = false;
  68570. _this.CLIPPLANE4 = false;
  68571. _this.ALPHATEST = false;
  68572. _this.DEPTHPREPASS = false;
  68573. _this.ALPHAFROMDIFFUSE = false;
  68574. _this.POINTSIZE = false;
  68575. _this.FOG = false;
  68576. _this.SPECULARTERM = false;
  68577. _this.DIFFUSEFRESNEL = false;
  68578. _this.OPACITYFRESNEL = false;
  68579. _this.REFLECTIONFRESNEL = false;
  68580. _this.REFRACTIONFRESNEL = false;
  68581. _this.EMISSIVEFRESNEL = false;
  68582. _this.FRESNEL = false;
  68583. _this.NORMAL = false;
  68584. _this.UV1 = false;
  68585. _this.UV2 = false;
  68586. _this.VERTEXCOLOR = false;
  68587. _this.VERTEXALPHA = false;
  68588. _this.NUM_BONE_INFLUENCERS = 0;
  68589. _this.BonesPerMesh = 0;
  68590. _this.BONETEXTURE = false;
  68591. _this.INSTANCES = false;
  68592. _this.GLOSSINESS = false;
  68593. _this.ROUGHNESS = false;
  68594. _this.EMISSIVEASILLUMINATION = false;
  68595. _this.LINKEMISSIVEWITHDIFFUSE = false;
  68596. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  68597. _this.LIGHTMAP = false;
  68598. _this.LIGHTMAPDIRECTUV = 0;
  68599. _this.OBJECTSPACE_NORMALMAP = false;
  68600. _this.USELIGHTMAPASSHADOWMAP = false;
  68601. _this.REFLECTIONMAP_3D = false;
  68602. _this.REFLECTIONMAP_SPHERICAL = false;
  68603. _this.REFLECTIONMAP_PLANAR = false;
  68604. _this.REFLECTIONMAP_CUBIC = false;
  68605. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  68606. _this.REFLECTIONMAP_PROJECTION = false;
  68607. _this.REFLECTIONMAP_SKYBOX = false;
  68608. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  68609. _this.REFLECTIONMAP_EXPLICIT = false;
  68610. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  68611. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  68612. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  68613. _this.INVERTCUBICMAP = false;
  68614. _this.LOGARITHMICDEPTH = false;
  68615. _this.REFRACTION = false;
  68616. _this.REFRACTIONMAP_3D = false;
  68617. _this.REFLECTIONOVERALPHA = false;
  68618. _this.TWOSIDEDLIGHTING = false;
  68619. _this.SHADOWFLOAT = false;
  68620. _this.MORPHTARGETS = false;
  68621. _this.MORPHTARGETS_NORMAL = false;
  68622. _this.MORPHTARGETS_TANGENT = false;
  68623. _this.NUM_MORPH_INFLUENCERS = 0;
  68624. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  68625. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  68626. _this.IMAGEPROCESSING = false;
  68627. _this.VIGNETTE = false;
  68628. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  68629. _this.VIGNETTEBLENDMODEOPAQUE = false;
  68630. _this.TONEMAPPING = false;
  68631. _this.TONEMAPPING_ACES = false;
  68632. _this.CONTRAST = false;
  68633. _this.COLORCURVES = false;
  68634. _this.COLORGRADING = false;
  68635. _this.COLORGRADING3D = false;
  68636. _this.SAMPLER3DGREENDEPTH = false;
  68637. _this.SAMPLER3DBGRMAP = false;
  68638. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  68639. _this.MULTIVIEW = false;
  68640. /**
  68641. * If the reflection texture on this material is in linear color space
  68642. * @hidden
  68643. */
  68644. _this.IS_REFLECTION_LINEAR = false;
  68645. /**
  68646. * If the refraction texture on this material is in linear color space
  68647. * @hidden
  68648. */
  68649. _this.IS_REFRACTION_LINEAR = false;
  68650. _this.EXPOSURE = false;
  68651. _this.rebuild();
  68652. return _this;
  68653. }
  68654. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  68655. var modes = [
  68656. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  68657. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  68658. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  68659. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  68660. ];
  68661. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  68662. var mode = modes_1[_i];
  68663. this[mode] = (mode === modeToEnable);
  68664. }
  68665. };
  68666. return StandardMaterialDefines;
  68667. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  68668. /**
  68669. * This is the default material used in Babylon. It is the best trade off between quality
  68670. * and performances.
  68671. * @see http://doc.babylonjs.com/babylon101/materials
  68672. */
  68673. var StandardMaterial = /** @class */ (function (_super) {
  68674. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  68675. /**
  68676. * Instantiates a new standard material.
  68677. * This is the default material used in Babylon. It is the best trade off between quality
  68678. * and performances.
  68679. * @see http://doc.babylonjs.com/babylon101/materials
  68680. * @param name Define the name of the material in the scene
  68681. * @param scene Define the scene the material belong to
  68682. */
  68683. function StandardMaterial(name, scene) {
  68684. var _this = _super.call(this, name, scene) || this;
  68685. /**
  68686. * The color of the material lit by the environmental background lighting.
  68687. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  68688. */
  68689. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  68690. /**
  68691. * The basic color of the material as viewed under a light.
  68692. */
  68693. _this.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  68694. /**
  68695. * Define how the color and intensity of the highlight given by the light in the material.
  68696. */
  68697. _this.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  68698. /**
  68699. * Define the color of the material as if self lit.
  68700. * This will be mixed in the final result even in the absence of light.
  68701. */
  68702. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  68703. /**
  68704. * Defines how sharp are the highlights in the material.
  68705. * The bigger the value the sharper giving a more glossy feeling to the result.
  68706. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  68707. */
  68708. _this.specularPower = 64;
  68709. _this._useAlphaFromDiffuseTexture = false;
  68710. _this._useEmissiveAsIllumination = false;
  68711. _this._linkEmissiveWithDiffuse = false;
  68712. _this._useSpecularOverAlpha = false;
  68713. _this._useReflectionOverAlpha = false;
  68714. _this._disableLighting = false;
  68715. _this._useObjectSpaceNormalMap = false;
  68716. _this._useParallax = false;
  68717. _this._useParallaxOcclusion = false;
  68718. /**
  68719. * 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.
  68720. */
  68721. _this.parallaxScaleBias = 0.05;
  68722. _this._roughness = 0;
  68723. /**
  68724. * In case of refraction, define the value of the indice of refraction.
  68725. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  68726. */
  68727. _this.indexOfRefraction = 0.98;
  68728. /**
  68729. * Invert the refraction texture alongside the y axis.
  68730. * It can be useful with procedural textures or probe for instance.
  68731. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  68732. */
  68733. _this.invertRefractionY = true;
  68734. /**
  68735. * Defines the alpha limits in alpha test mode.
  68736. */
  68737. _this.alphaCutOff = 0.4;
  68738. _this._useLightmapAsShadowmap = false;
  68739. _this._useReflectionFresnelFromSpecular = false;
  68740. _this._useGlossinessFromSpecularMapAlpha = false;
  68741. _this._maxSimultaneousLights = 4;
  68742. _this._invertNormalMapX = false;
  68743. _this._invertNormalMapY = false;
  68744. _this._twoSidedLighting = false;
  68745. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  68746. _this._worldViewProjectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  68747. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  68748. // Setup the default processing configuration to the scene.
  68749. _this._attachImageProcessingConfiguration(null);
  68750. _this.getRenderTargetTextures = function () {
  68751. _this._renderTargets.reset();
  68752. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  68753. _this._renderTargets.push(_this._reflectionTexture);
  68754. }
  68755. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  68756. _this._renderTargets.push(_this._refractionTexture);
  68757. }
  68758. return _this._renderTargets;
  68759. };
  68760. return _this;
  68761. }
  68762. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  68763. /**
  68764. * Gets the image processing configuration used either in this material.
  68765. */
  68766. get: function () {
  68767. return this._imageProcessingConfiguration;
  68768. },
  68769. /**
  68770. * Sets the Default image processing configuration used either in the this material.
  68771. *
  68772. * If sets to null, the scene one is in use.
  68773. */
  68774. set: function (value) {
  68775. this._attachImageProcessingConfiguration(value);
  68776. // Ensure the effect will be rebuilt.
  68777. this._markAllSubMeshesAsTexturesDirty();
  68778. },
  68779. enumerable: true,
  68780. configurable: true
  68781. });
  68782. /**
  68783. * Attaches a new image processing configuration to the Standard Material.
  68784. * @param configuration
  68785. */
  68786. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  68787. var _this = this;
  68788. if (configuration === this._imageProcessingConfiguration) {
  68789. return;
  68790. }
  68791. // Detaches observer.
  68792. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  68793. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  68794. }
  68795. // Pick the scene configuration if needed.
  68796. if (!configuration) {
  68797. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  68798. }
  68799. else {
  68800. this._imageProcessingConfiguration = configuration;
  68801. }
  68802. // Attaches observer.
  68803. if (this._imageProcessingConfiguration) {
  68804. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  68805. _this._markAllSubMeshesAsImageProcessingDirty();
  68806. });
  68807. }
  68808. };
  68809. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  68810. /**
  68811. * Gets wether the color curves effect is enabled.
  68812. */
  68813. get: function () {
  68814. return this.imageProcessingConfiguration.colorCurvesEnabled;
  68815. },
  68816. /**
  68817. * Sets wether the color curves effect is enabled.
  68818. */
  68819. set: function (value) {
  68820. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  68821. },
  68822. enumerable: true,
  68823. configurable: true
  68824. });
  68825. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  68826. /**
  68827. * Gets wether the color grading effect is enabled.
  68828. */
  68829. get: function () {
  68830. return this.imageProcessingConfiguration.colorGradingEnabled;
  68831. },
  68832. /**
  68833. * Gets wether the color grading effect is enabled.
  68834. */
  68835. set: function (value) {
  68836. this.imageProcessingConfiguration.colorGradingEnabled = value;
  68837. },
  68838. enumerable: true,
  68839. configurable: true
  68840. });
  68841. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  68842. /**
  68843. * Gets wether tonemapping is enabled or not.
  68844. */
  68845. get: function () {
  68846. return this._imageProcessingConfiguration.toneMappingEnabled;
  68847. },
  68848. /**
  68849. * Sets wether tonemapping is enabled or not
  68850. */
  68851. set: function (value) {
  68852. this._imageProcessingConfiguration.toneMappingEnabled = value;
  68853. },
  68854. enumerable: true,
  68855. configurable: true
  68856. });
  68857. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  68858. /**
  68859. * The camera exposure used on this material.
  68860. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  68861. * This corresponds to a photographic exposure.
  68862. */
  68863. get: function () {
  68864. return this._imageProcessingConfiguration.exposure;
  68865. },
  68866. /**
  68867. * The camera exposure used on this material.
  68868. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  68869. * This corresponds to a photographic exposure.
  68870. */
  68871. set: function (value) {
  68872. this._imageProcessingConfiguration.exposure = value;
  68873. },
  68874. enumerable: true,
  68875. configurable: true
  68876. });
  68877. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  68878. /**
  68879. * Gets The camera contrast used on this material.
  68880. */
  68881. get: function () {
  68882. return this._imageProcessingConfiguration.contrast;
  68883. },
  68884. /**
  68885. * Sets The camera contrast used on this material.
  68886. */
  68887. set: function (value) {
  68888. this._imageProcessingConfiguration.contrast = value;
  68889. },
  68890. enumerable: true,
  68891. configurable: true
  68892. });
  68893. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  68894. /**
  68895. * Gets the Color Grading 2D Lookup Texture.
  68896. */
  68897. get: function () {
  68898. return this._imageProcessingConfiguration.colorGradingTexture;
  68899. },
  68900. /**
  68901. * Sets the Color Grading 2D Lookup Texture.
  68902. */
  68903. set: function (value) {
  68904. this._imageProcessingConfiguration.colorGradingTexture = value;
  68905. },
  68906. enumerable: true,
  68907. configurable: true
  68908. });
  68909. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  68910. /**
  68911. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  68912. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  68913. * 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;
  68914. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  68915. */
  68916. get: function () {
  68917. return this._imageProcessingConfiguration.colorCurves;
  68918. },
  68919. /**
  68920. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  68921. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  68922. * 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;
  68923. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  68924. */
  68925. set: function (value) {
  68926. this._imageProcessingConfiguration.colorCurves = value;
  68927. },
  68928. enumerable: true,
  68929. configurable: true
  68930. });
  68931. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  68932. /**
  68933. * Gets a boolean indicating that current material needs to register RTT
  68934. */
  68935. get: function () {
  68936. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  68937. return true;
  68938. }
  68939. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  68940. return true;
  68941. }
  68942. return false;
  68943. },
  68944. enumerable: true,
  68945. configurable: true
  68946. });
  68947. /**
  68948. * Gets the current class name of the material e.g. "StandardMaterial"
  68949. * Mainly use in serialization.
  68950. * @returns the class name
  68951. */
  68952. StandardMaterial.prototype.getClassName = function () {
  68953. return "StandardMaterial";
  68954. };
  68955. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  68956. /**
  68957. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  68958. * You can try switching to logarithmic depth.
  68959. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  68960. */
  68961. get: function () {
  68962. return this._useLogarithmicDepth;
  68963. },
  68964. set: function (value) {
  68965. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  68966. this._markAllSubMeshesAsMiscDirty();
  68967. },
  68968. enumerable: true,
  68969. configurable: true
  68970. });
  68971. /**
  68972. * Specifies if the material will require alpha blending
  68973. * @returns a boolean specifying if alpha blending is needed
  68974. */
  68975. StandardMaterial.prototype.needAlphaBlending = function () {
  68976. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  68977. };
  68978. /**
  68979. * Specifies if this material should be rendered in alpha test mode
  68980. * @returns a boolean specifying if an alpha test is needed.
  68981. */
  68982. StandardMaterial.prototype.needAlphaTesting = function () {
  68983. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  68984. };
  68985. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  68986. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  68987. };
  68988. /**
  68989. * Get the texture used for alpha test purpose.
  68990. * @returns the diffuse texture in case of the standard material.
  68991. */
  68992. StandardMaterial.prototype.getAlphaTestTexture = function () {
  68993. return this._diffuseTexture;
  68994. };
  68995. /**
  68996. * Get if the submesh is ready to be used and all its information available.
  68997. * Child classes can use it to update shaders
  68998. * @param mesh defines the mesh to check
  68999. * @param subMesh defines which submesh to check
  69000. * @param useInstances specifies that instances should be used
  69001. * @returns a boolean indicating that the submesh is ready or not
  69002. */
  69003. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  69004. if (useInstances === void 0) { useInstances = false; }
  69005. if (subMesh.effect && this.isFrozen) {
  69006. if (this._wasPreviouslyReady) {
  69007. return true;
  69008. }
  69009. }
  69010. if (!subMesh._materialDefines) {
  69011. subMesh._materialDefines = new StandardMaterialDefines();
  69012. }
  69013. var scene = this.getScene();
  69014. var defines = subMesh._materialDefines;
  69015. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  69016. if (defines._renderId === scene.getRenderId()) {
  69017. return true;
  69018. }
  69019. }
  69020. var engine = scene.getEngine();
  69021. // Lights
  69022. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  69023. // Multiview
  69024. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMultiview(scene, defines);
  69025. // Textures
  69026. if (defines._areTexturesDirty) {
  69027. defines._needUVs = false;
  69028. defines.MAINUV1 = false;
  69029. defines.MAINUV2 = false;
  69030. if (scene.texturesEnabled) {
  69031. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  69032. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  69033. return false;
  69034. }
  69035. else {
  69036. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  69037. }
  69038. }
  69039. else {
  69040. defines.DIFFUSE = false;
  69041. }
  69042. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  69043. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  69044. return false;
  69045. }
  69046. else {
  69047. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  69048. }
  69049. }
  69050. else {
  69051. defines.AMBIENT = false;
  69052. }
  69053. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  69054. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  69055. return false;
  69056. }
  69057. else {
  69058. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  69059. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  69060. }
  69061. }
  69062. else {
  69063. defines.OPACITY = false;
  69064. }
  69065. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  69066. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  69067. return false;
  69068. }
  69069. else {
  69070. defines._needNormals = true;
  69071. defines.REFLECTION = true;
  69072. defines.ROUGHNESS = (this._roughness > 0);
  69073. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  69074. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE);
  69075. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  69076. switch (this._reflectionTexture.coordinatesMode) {
  69077. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  69078. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  69079. break;
  69080. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  69081. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  69082. break;
  69083. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  69084. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  69085. break;
  69086. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  69087. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  69088. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  69089. break;
  69090. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  69091. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  69092. break;
  69093. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  69094. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  69095. break;
  69096. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  69097. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  69098. break;
  69099. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  69100. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  69101. break;
  69102. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  69103. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  69104. default:
  69105. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  69106. break;
  69107. }
  69108. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  69109. }
  69110. }
  69111. else {
  69112. defines.REFLECTION = false;
  69113. }
  69114. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  69115. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  69116. return false;
  69117. }
  69118. else {
  69119. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  69120. }
  69121. }
  69122. else {
  69123. defines.EMISSIVE = false;
  69124. }
  69125. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  69126. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  69127. return false;
  69128. }
  69129. else {
  69130. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  69131. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  69132. }
  69133. }
  69134. else {
  69135. defines.LIGHTMAP = false;
  69136. }
  69137. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  69138. if (!this._specularTexture.isReadyOrNotBlocking()) {
  69139. return false;
  69140. }
  69141. else {
  69142. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  69143. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  69144. }
  69145. }
  69146. else {
  69147. defines.SPECULAR = false;
  69148. }
  69149. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  69150. // Bump texure can not be not blocking.
  69151. if (!this._bumpTexture.isReady()) {
  69152. return false;
  69153. }
  69154. else {
  69155. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  69156. defines.PARALLAX = this._useParallax;
  69157. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  69158. }
  69159. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  69160. }
  69161. else {
  69162. defines.BUMP = false;
  69163. }
  69164. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  69165. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  69166. return false;
  69167. }
  69168. else {
  69169. defines._needUVs = true;
  69170. defines.REFRACTION = true;
  69171. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  69172. }
  69173. }
  69174. else {
  69175. defines.REFRACTION = false;
  69176. }
  69177. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  69178. }
  69179. else {
  69180. defines.DIFFUSE = false;
  69181. defines.AMBIENT = false;
  69182. defines.OPACITY = false;
  69183. defines.REFLECTION = false;
  69184. defines.EMISSIVE = false;
  69185. defines.LIGHTMAP = false;
  69186. defines.BUMP = false;
  69187. defines.REFRACTION = false;
  69188. }
  69189. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  69190. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  69191. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  69192. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  69193. 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);
  69194. }
  69195. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  69196. if (!this._imageProcessingConfiguration.isReady()) {
  69197. return false;
  69198. }
  69199. this._imageProcessingConfiguration.prepareDefines(defines);
  69200. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  69201. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  69202. }
  69203. if (defines._areFresnelDirty) {
  69204. if (StandardMaterial.FresnelEnabled) {
  69205. // Fresnel
  69206. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  69207. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  69208. this._reflectionFresnelParameters) {
  69209. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  69210. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  69211. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  69212. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  69213. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  69214. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  69215. defines._needNormals = true;
  69216. defines.FRESNEL = true;
  69217. }
  69218. }
  69219. else {
  69220. defines.FRESNEL = false;
  69221. }
  69222. }
  69223. // Misc.
  69224. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  69225. // Attribs
  69226. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  69227. // Values that need to be evaluated on every frame
  69228. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  69229. // Get correct effect
  69230. if (defines.isDirty) {
  69231. defines.markAsProcessed();
  69232. // Fallbacks
  69233. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  69234. if (defines.REFLECTION) {
  69235. fallbacks.addFallback(0, "REFLECTION");
  69236. }
  69237. if (defines.SPECULAR) {
  69238. fallbacks.addFallback(0, "SPECULAR");
  69239. }
  69240. if (defines.BUMP) {
  69241. fallbacks.addFallback(0, "BUMP");
  69242. }
  69243. if (defines.PARALLAX) {
  69244. fallbacks.addFallback(1, "PARALLAX");
  69245. }
  69246. if (defines.PARALLAXOCCLUSION) {
  69247. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  69248. }
  69249. if (defines.SPECULAROVERALPHA) {
  69250. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  69251. }
  69252. if (defines.FOG) {
  69253. fallbacks.addFallback(1, "FOG");
  69254. }
  69255. if (defines.POINTSIZE) {
  69256. fallbacks.addFallback(0, "POINTSIZE");
  69257. }
  69258. if (defines.LOGARITHMICDEPTH) {
  69259. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  69260. }
  69261. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  69262. if (defines.SPECULARTERM) {
  69263. fallbacks.addFallback(0, "SPECULARTERM");
  69264. }
  69265. if (defines.DIFFUSEFRESNEL) {
  69266. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  69267. }
  69268. if (defines.OPACITYFRESNEL) {
  69269. fallbacks.addFallback(2, "OPACITYFRESNEL");
  69270. }
  69271. if (defines.REFLECTIONFRESNEL) {
  69272. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  69273. }
  69274. if (defines.EMISSIVEFRESNEL) {
  69275. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  69276. }
  69277. if (defines.FRESNEL) {
  69278. fallbacks.addFallback(4, "FRESNEL");
  69279. }
  69280. if (defines.MULTIVIEW) {
  69281. fallbacks.addFallback(0, "MULTIVIEW");
  69282. }
  69283. //Attributes
  69284. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  69285. if (defines.NORMAL) {
  69286. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  69287. }
  69288. if (defines.UV1) {
  69289. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  69290. }
  69291. if (defines.UV2) {
  69292. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  69293. }
  69294. if (defines.VERTEXCOLOR) {
  69295. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind);
  69296. }
  69297. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  69298. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  69299. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  69300. var shaderName = "default";
  69301. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor", "visibility",
  69302. "vFogInfos", "vFogColor", "pointSize",
  69303. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  69304. "mBones",
  69305. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  69306. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  69307. "vReflectionPosition", "vReflectionSize",
  69308. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  69309. ];
  69310. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  69311. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  69312. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  69313. var uniformBuffers = ["Material", "Scene"];
  69314. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"]) {
  69315. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  69316. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  69317. }
  69318. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareUniformsAndSamplersList({
  69319. uniformsNames: uniforms,
  69320. uniformBuffersNames: uniformBuffers,
  69321. samplers: samplers,
  69322. defines: defines,
  69323. maxSimultaneousLights: this._maxSimultaneousLights
  69324. });
  69325. if (this.customShaderNameResolve) {
  69326. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  69327. }
  69328. var join = defines.toString();
  69329. var previousEffect = subMesh.effect;
  69330. var effect = scene.getEngine().createEffect(shaderName, {
  69331. attributes: attribs,
  69332. uniformsNames: uniforms,
  69333. uniformBuffersNames: uniformBuffers,
  69334. samplers: samplers,
  69335. defines: join,
  69336. fallbacks: fallbacks,
  69337. onCompiled: this.onCompiled,
  69338. onError: this.onError,
  69339. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  69340. }, engine);
  69341. if (effect) {
  69342. // Use previous effect while new one is compiling
  69343. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  69344. effect = previousEffect;
  69345. defines.markAsUnprocessed();
  69346. }
  69347. else {
  69348. scene.resetCachedMaterial();
  69349. subMesh.setEffect(effect, defines);
  69350. this.buildUniformLayout();
  69351. }
  69352. }
  69353. }
  69354. if (!subMesh.effect || !subMesh.effect.isReady()) {
  69355. return false;
  69356. }
  69357. defines._renderId = scene.getRenderId();
  69358. this._wasPreviouslyReady = true;
  69359. return true;
  69360. };
  69361. /**
  69362. * Builds the material UBO layouts.
  69363. * Used internally during the effect preparation.
  69364. */
  69365. StandardMaterial.prototype.buildUniformLayout = function () {
  69366. // Order is important !
  69367. this._uniformBuffer.addUniform("diffuseLeftColor", 4);
  69368. this._uniformBuffer.addUniform("diffuseRightColor", 4);
  69369. this._uniformBuffer.addUniform("opacityParts", 4);
  69370. this._uniformBuffer.addUniform("reflectionLeftColor", 4);
  69371. this._uniformBuffer.addUniform("reflectionRightColor", 4);
  69372. this._uniformBuffer.addUniform("refractionLeftColor", 4);
  69373. this._uniformBuffer.addUniform("refractionRightColor", 4);
  69374. this._uniformBuffer.addUniform("emissiveLeftColor", 4);
  69375. this._uniformBuffer.addUniform("emissiveRightColor", 4);
  69376. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  69377. this._uniformBuffer.addUniform("vAmbientInfos", 2);
  69378. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  69379. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  69380. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  69381. this._uniformBuffer.addUniform("vReflectionSize", 3);
  69382. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  69383. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  69384. this._uniformBuffer.addUniform("vSpecularInfos", 2);
  69385. this._uniformBuffer.addUniform("vBumpInfos", 3);
  69386. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  69387. this._uniformBuffer.addUniform("ambientMatrix", 16);
  69388. this._uniformBuffer.addUniform("opacityMatrix", 16);
  69389. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  69390. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  69391. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  69392. this._uniformBuffer.addUniform("specularMatrix", 16);
  69393. this._uniformBuffer.addUniform("bumpMatrix", 16);
  69394. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  69395. this._uniformBuffer.addUniform("pointSize", 1);
  69396. this._uniformBuffer.addUniform("refractionMatrix", 16);
  69397. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  69398. this._uniformBuffer.addUniform("vSpecularColor", 4);
  69399. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  69400. this._uniformBuffer.addUniform("visibility", 1);
  69401. this._uniformBuffer.addUniform("vDiffuseColor", 4);
  69402. this._uniformBuffer.create();
  69403. };
  69404. /**
  69405. * Unbinds the material from the mesh
  69406. */
  69407. StandardMaterial.prototype.unbind = function () {
  69408. if (this._activeEffect) {
  69409. var needFlag = false;
  69410. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  69411. this._activeEffect.setTexture("reflection2DSampler", null);
  69412. needFlag = true;
  69413. }
  69414. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  69415. this._activeEffect.setTexture("refraction2DSampler", null);
  69416. needFlag = true;
  69417. }
  69418. if (needFlag) {
  69419. this._markAllSubMeshesAsTexturesDirty();
  69420. }
  69421. }
  69422. _super.prototype.unbind.call(this);
  69423. };
  69424. /**
  69425. * Binds the submesh to this material by preparing the effect and shader to draw
  69426. * @param world defines the world transformation matrix
  69427. * @param mesh defines the mesh containing the submesh
  69428. * @param subMesh defines the submesh to bind the material to
  69429. */
  69430. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  69431. var scene = this.getScene();
  69432. var defines = subMesh._materialDefines;
  69433. if (!defines) {
  69434. return;
  69435. }
  69436. var effect = subMesh.effect;
  69437. if (!effect) {
  69438. return;
  69439. }
  69440. this._activeEffect = effect;
  69441. // Matrices
  69442. this.bindOnlyWorldMatrix(world);
  69443. // Normal Matrix
  69444. if (defines.OBJECTSPACE_NORMALMAP) {
  69445. world.toNormalMatrix(this._normalMatrix);
  69446. this.bindOnlyNormalMatrix(this._normalMatrix);
  69447. }
  69448. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  69449. // Bones
  69450. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindBonesParameters(mesh, effect);
  69451. if (mustRebind) {
  69452. this._uniformBuffer.bindToEffect(effect, "Material");
  69453. this.bindViewProjection(effect);
  69454. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  69455. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  69456. // Fresnel
  69457. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  69458. this._uniformBuffer.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  69459. this._uniformBuffer.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  69460. }
  69461. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  69462. 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);
  69463. }
  69464. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  69465. this._uniformBuffer.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  69466. this._uniformBuffer.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  69467. }
  69468. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  69469. this._uniformBuffer.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  69470. this._uniformBuffer.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  69471. }
  69472. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  69473. this._uniformBuffer.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  69474. this._uniformBuffer.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  69475. }
  69476. }
  69477. // Textures
  69478. if (scene.texturesEnabled) {
  69479. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  69480. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  69481. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  69482. if (this._diffuseTexture.hasAlpha) {
  69483. effect.setFloat("alphaCutOff", this.alphaCutOff);
  69484. }
  69485. }
  69486. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  69487. this._uniformBuffer.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  69488. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  69489. }
  69490. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  69491. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  69492. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  69493. }
  69494. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  69495. this._uniformBuffer.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  69496. this._uniformBuffer.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  69497. if (this._reflectionTexture.boundingBoxSize) {
  69498. var cubeTexture = this._reflectionTexture;
  69499. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  69500. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  69501. }
  69502. }
  69503. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  69504. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  69505. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  69506. }
  69507. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  69508. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  69509. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  69510. }
  69511. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  69512. this._uniformBuffer.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  69513. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._specularTexture, this._uniformBuffer, "specular");
  69514. }
  69515. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  69516. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  69517. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  69518. if (scene._mirroredCameraPosition) {
  69519. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  69520. }
  69521. else {
  69522. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  69523. }
  69524. }
  69525. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  69526. var depth = 1.0;
  69527. if (!this._refractionTexture.isCube) {
  69528. this._uniformBuffer.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  69529. if (this._refractionTexture.depth) {
  69530. depth = this._refractionTexture.depth;
  69531. }
  69532. }
  69533. this._uniformBuffer.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  69534. }
  69535. }
  69536. // Point size
  69537. if (this.pointsCloud) {
  69538. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  69539. }
  69540. if (defines.SPECULARTERM) {
  69541. this._uniformBuffer.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  69542. }
  69543. this._uniformBuffer.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].BlackReadOnly);
  69544. // Visibility
  69545. this._uniformBuffer.updateFloat("visibility", mesh.visibility);
  69546. // Diffuse
  69547. this._uniformBuffer.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha);
  69548. }
  69549. // Textures
  69550. if (scene.texturesEnabled) {
  69551. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  69552. effect.setTexture("diffuseSampler", this._diffuseTexture);
  69553. }
  69554. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  69555. effect.setTexture("ambientSampler", this._ambientTexture);
  69556. }
  69557. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  69558. effect.setTexture("opacitySampler", this._opacityTexture);
  69559. }
  69560. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  69561. if (this._reflectionTexture.isCube) {
  69562. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  69563. }
  69564. else {
  69565. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  69566. }
  69567. }
  69568. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  69569. effect.setTexture("emissiveSampler", this._emissiveTexture);
  69570. }
  69571. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  69572. effect.setTexture("lightmapSampler", this._lightmapTexture);
  69573. }
  69574. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  69575. effect.setTexture("specularSampler", this._specularTexture);
  69576. }
  69577. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  69578. effect.setTexture("bumpSampler", this._bumpTexture);
  69579. }
  69580. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  69581. var depth = 1.0;
  69582. if (this._refractionTexture.isCube) {
  69583. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  69584. }
  69585. else {
  69586. effect.setTexture("refraction2DSampler", this._refractionTexture);
  69587. }
  69588. }
  69589. }
  69590. // Clip plane
  69591. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindClipPlane(effect, scene);
  69592. // Colors
  69593. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  69594. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindEyePosition(effect, scene);
  69595. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  69596. }
  69597. if (mustRebind || !this.isFrozen) {
  69598. // Lights
  69599. if (scene.lightsEnabled && !this._disableLighting) {
  69600. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  69601. }
  69602. // View
  69603. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  69604. this.bindView(effect);
  69605. }
  69606. // Fog
  69607. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  69608. // Morph targets
  69609. if (defines.NUM_MORPH_INFLUENCERS) {
  69610. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  69611. }
  69612. // Log. depth
  69613. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  69614. // image processing
  69615. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  69616. this._imageProcessingConfiguration.bind(this._activeEffect);
  69617. }
  69618. }
  69619. this._uniformBuffer.update();
  69620. this._afterBind(mesh, this._activeEffect);
  69621. };
  69622. /**
  69623. * Get the list of animatables in the material.
  69624. * @returns the list of animatables object used in the material
  69625. */
  69626. StandardMaterial.prototype.getAnimatables = function () {
  69627. var results = [];
  69628. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  69629. results.push(this._diffuseTexture);
  69630. }
  69631. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  69632. results.push(this._ambientTexture);
  69633. }
  69634. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  69635. results.push(this._opacityTexture);
  69636. }
  69637. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  69638. results.push(this._reflectionTexture);
  69639. }
  69640. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  69641. results.push(this._emissiveTexture);
  69642. }
  69643. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  69644. results.push(this._specularTexture);
  69645. }
  69646. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  69647. results.push(this._bumpTexture);
  69648. }
  69649. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  69650. results.push(this._lightmapTexture);
  69651. }
  69652. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  69653. results.push(this._refractionTexture);
  69654. }
  69655. return results;
  69656. };
  69657. /**
  69658. * Gets the active textures from the material
  69659. * @returns an array of textures
  69660. */
  69661. StandardMaterial.prototype.getActiveTextures = function () {
  69662. var activeTextures = _super.prototype.getActiveTextures.call(this);
  69663. if (this._diffuseTexture) {
  69664. activeTextures.push(this._diffuseTexture);
  69665. }
  69666. if (this._ambientTexture) {
  69667. activeTextures.push(this._ambientTexture);
  69668. }
  69669. if (this._opacityTexture) {
  69670. activeTextures.push(this._opacityTexture);
  69671. }
  69672. if (this._reflectionTexture) {
  69673. activeTextures.push(this._reflectionTexture);
  69674. }
  69675. if (this._emissiveTexture) {
  69676. activeTextures.push(this._emissiveTexture);
  69677. }
  69678. if (this._specularTexture) {
  69679. activeTextures.push(this._specularTexture);
  69680. }
  69681. if (this._bumpTexture) {
  69682. activeTextures.push(this._bumpTexture);
  69683. }
  69684. if (this._lightmapTexture) {
  69685. activeTextures.push(this._lightmapTexture);
  69686. }
  69687. if (this._refractionTexture) {
  69688. activeTextures.push(this._refractionTexture);
  69689. }
  69690. return activeTextures;
  69691. };
  69692. /**
  69693. * Specifies if the material uses a texture
  69694. * @param texture defines the texture to check against the material
  69695. * @returns a boolean specifying if the material uses the texture
  69696. */
  69697. StandardMaterial.prototype.hasTexture = function (texture) {
  69698. if (_super.prototype.hasTexture.call(this, texture)) {
  69699. return true;
  69700. }
  69701. if (this._diffuseTexture === texture) {
  69702. return true;
  69703. }
  69704. if (this._ambientTexture === texture) {
  69705. return true;
  69706. }
  69707. if (this._opacityTexture === texture) {
  69708. return true;
  69709. }
  69710. if (this._reflectionTexture === texture) {
  69711. return true;
  69712. }
  69713. if (this._emissiveTexture === texture) {
  69714. return true;
  69715. }
  69716. if (this._specularTexture === texture) {
  69717. return true;
  69718. }
  69719. if (this._bumpTexture === texture) {
  69720. return true;
  69721. }
  69722. if (this._lightmapTexture === texture) {
  69723. return true;
  69724. }
  69725. if (this._refractionTexture === texture) {
  69726. return true;
  69727. }
  69728. return false;
  69729. };
  69730. /**
  69731. * Disposes the material
  69732. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  69733. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  69734. */
  69735. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  69736. if (forceDisposeTextures) {
  69737. if (this._diffuseTexture) {
  69738. this._diffuseTexture.dispose();
  69739. }
  69740. if (this._ambientTexture) {
  69741. this._ambientTexture.dispose();
  69742. }
  69743. if (this._opacityTexture) {
  69744. this._opacityTexture.dispose();
  69745. }
  69746. if (this._reflectionTexture) {
  69747. this._reflectionTexture.dispose();
  69748. }
  69749. if (this._emissiveTexture) {
  69750. this._emissiveTexture.dispose();
  69751. }
  69752. if (this._specularTexture) {
  69753. this._specularTexture.dispose();
  69754. }
  69755. if (this._bumpTexture) {
  69756. this._bumpTexture.dispose();
  69757. }
  69758. if (this._lightmapTexture) {
  69759. this._lightmapTexture.dispose();
  69760. }
  69761. if (this._refractionTexture) {
  69762. this._refractionTexture.dispose();
  69763. }
  69764. }
  69765. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  69766. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  69767. }
  69768. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  69769. };
  69770. /**
  69771. * Makes a duplicate of the material, and gives it a new name
  69772. * @param name defines the new name for the duplicated material
  69773. * @returns the cloned material
  69774. */
  69775. StandardMaterial.prototype.clone = function (name) {
  69776. var _this = this;
  69777. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  69778. result.name = name;
  69779. result.id = name;
  69780. return result;
  69781. };
  69782. /**
  69783. * Serializes this material in a JSON representation
  69784. * @returns the serialized material object
  69785. */
  69786. StandardMaterial.prototype.serialize = function () {
  69787. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  69788. };
  69789. /**
  69790. * Creates a standard material from parsed material data
  69791. * @param source defines the JSON representation of the material
  69792. * @param scene defines the hosting scene
  69793. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69794. * @returns a new standard material
  69795. */
  69796. StandardMaterial.Parse = function (source, scene, rootUrl) {
  69797. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  69798. };
  69799. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  69800. // Flags used to enable or disable a type of texture for all Standard Materials
  69801. /**
  69802. * Are diffuse textures enabled in the application.
  69803. */
  69804. get: function () {
  69805. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled;
  69806. },
  69807. set: function (value) {
  69808. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled = value;
  69809. },
  69810. enumerable: true,
  69811. configurable: true
  69812. });
  69813. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  69814. /**
  69815. * Are ambient textures enabled in the application.
  69816. */
  69817. get: function () {
  69818. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled;
  69819. },
  69820. set: function (value) {
  69821. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled = value;
  69822. },
  69823. enumerable: true,
  69824. configurable: true
  69825. });
  69826. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  69827. /**
  69828. * Are opacity textures enabled in the application.
  69829. */
  69830. get: function () {
  69831. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled;
  69832. },
  69833. set: function (value) {
  69834. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled = value;
  69835. },
  69836. enumerable: true,
  69837. configurable: true
  69838. });
  69839. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  69840. /**
  69841. * Are reflection textures enabled in the application.
  69842. */
  69843. get: function () {
  69844. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled;
  69845. },
  69846. set: function (value) {
  69847. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled = value;
  69848. },
  69849. enumerable: true,
  69850. configurable: true
  69851. });
  69852. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  69853. /**
  69854. * Are emissive textures enabled in the application.
  69855. */
  69856. get: function () {
  69857. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled;
  69858. },
  69859. set: function (value) {
  69860. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled = value;
  69861. },
  69862. enumerable: true,
  69863. configurable: true
  69864. });
  69865. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  69866. /**
  69867. * Are specular textures enabled in the application.
  69868. */
  69869. get: function () {
  69870. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled;
  69871. },
  69872. set: function (value) {
  69873. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled = value;
  69874. },
  69875. enumerable: true,
  69876. configurable: true
  69877. });
  69878. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  69879. /**
  69880. * Are bump textures enabled in the application.
  69881. */
  69882. get: function () {
  69883. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled;
  69884. },
  69885. set: function (value) {
  69886. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled = value;
  69887. },
  69888. enumerable: true,
  69889. configurable: true
  69890. });
  69891. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  69892. /**
  69893. * Are lightmap textures enabled in the application.
  69894. */
  69895. get: function () {
  69896. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled;
  69897. },
  69898. set: function (value) {
  69899. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled = value;
  69900. },
  69901. enumerable: true,
  69902. configurable: true
  69903. });
  69904. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  69905. /**
  69906. * Are refraction textures enabled in the application.
  69907. */
  69908. get: function () {
  69909. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled;
  69910. },
  69911. set: function (value) {
  69912. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled = value;
  69913. },
  69914. enumerable: true,
  69915. configurable: true
  69916. });
  69917. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  69918. /**
  69919. * Are color grading textures enabled in the application.
  69920. */
  69921. get: function () {
  69922. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled;
  69923. },
  69924. set: function (value) {
  69925. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled = value;
  69926. },
  69927. enumerable: true,
  69928. configurable: true
  69929. });
  69930. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  69931. /**
  69932. * Are fresnels enabled in the application.
  69933. */
  69934. get: function () {
  69935. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled;
  69936. },
  69937. set: function (value) {
  69938. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled = value;
  69939. },
  69940. enumerable: true,
  69941. configurable: true
  69942. });
  69943. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69944. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  69945. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  69946. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69947. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  69948. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  69949. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69950. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  69951. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  69952. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69953. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69954. ], StandardMaterial.prototype, "ambientTexture", void 0);
  69955. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69956. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  69957. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  69958. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69959. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  69960. ], StandardMaterial.prototype, "opacityTexture", void 0);
  69961. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69962. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  69963. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  69964. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69965. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69966. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  69967. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69968. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  69969. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  69970. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69972. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  69973. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69974. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  69975. ], StandardMaterial.prototype, "_specularTexture", void 0);
  69976. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69977. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69978. ], StandardMaterial.prototype, "specularTexture", void 0);
  69979. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69980. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  69981. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  69982. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69983. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69984. ], StandardMaterial.prototype, "bumpTexture", void 0);
  69985. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69986. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  69987. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  69988. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69989. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69990. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  69991. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69992. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  69993. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  69994. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69995. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  69996. ], StandardMaterial.prototype, "refractionTexture", void 0);
  69997. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  69998. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  69999. ], StandardMaterial.prototype, "ambientColor", void 0);
  70000. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70001. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  70002. ], StandardMaterial.prototype, "diffuseColor", void 0);
  70003. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70004. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  70005. ], StandardMaterial.prototype, "specularColor", void 0);
  70006. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70007. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  70008. ], StandardMaterial.prototype, "emissiveColor", void 0);
  70009. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70010. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  70011. ], StandardMaterial.prototype, "specularPower", void 0);
  70012. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70013. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  70014. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  70015. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70017. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  70018. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70019. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  70020. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  70021. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70022. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70023. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  70024. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70025. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  70026. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  70027. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70028. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70029. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  70030. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70031. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  70032. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  70033. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70034. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70035. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  70036. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70037. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  70038. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  70039. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70040. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70041. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  70042. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70043. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  70044. ], StandardMaterial.prototype, "_disableLighting", void 0);
  70045. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70046. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  70047. ], StandardMaterial.prototype, "disableLighting", void 0);
  70048. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70049. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  70050. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  70051. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70052. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70053. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  70054. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70055. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  70056. ], StandardMaterial.prototype, "_useParallax", void 0);
  70057. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70058. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70059. ], StandardMaterial.prototype, "useParallax", void 0);
  70060. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70061. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  70062. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  70063. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70064. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70065. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  70066. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70067. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  70068. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  70069. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70070. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  70071. ], StandardMaterial.prototype, "_roughness", void 0);
  70072. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70073. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70074. ], StandardMaterial.prototype, "roughness", void 0);
  70075. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70076. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  70077. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  70078. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70079. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  70080. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  70081. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70082. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  70083. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  70084. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70085. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  70086. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  70087. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70088. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70089. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  70090. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70091. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  70092. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  70093. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70094. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  70095. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  70096. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70097. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  70098. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  70099. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70100. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  70101. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  70102. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70103. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  70104. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  70105. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70106. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  70107. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  70108. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70109. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  70110. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  70111. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  70113. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  70114. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70115. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  70116. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  70117. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70118. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  70119. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  70120. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70121. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  70122. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  70123. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70124. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  70125. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  70126. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70127. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  70128. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  70129. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70130. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70131. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  70132. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70133. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  70134. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  70135. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70136. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  70137. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  70138. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70139. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  70140. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  70141. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70142. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70143. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  70144. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70145. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  70146. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  70147. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70148. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70149. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  70150. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70151. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  70152. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  70153. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70154. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  70155. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  70156. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  70157. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  70158. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  70159. return StandardMaterial;
  70160. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  70161. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  70162. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  70163. return new StandardMaterial("default material", scene);
  70164. };
  70165. /***/ }),
  70166. /***/ "./Materials/uniformBuffer.ts":
  70167. /*!************************************!*\
  70168. !*** ./Materials/uniformBuffer.ts ***!
  70169. \************************************/
  70170. /*! exports provided: UniformBuffer */
  70171. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  70172. "use strict";
  70173. __webpack_require__.r(__webpack_exports__);
  70174. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  70175. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  70176. /**
  70177. * Uniform buffer objects.
  70178. *
  70179. * Handles blocks of uniform on the GPU.
  70180. *
  70181. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  70182. *
  70183. * For more information, please refer to :
  70184. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  70185. */
  70186. var UniformBuffer = /** @class */ (function () {
  70187. /**
  70188. * Instantiates a new Uniform buffer objects.
  70189. *
  70190. * Handles blocks of uniform on the GPU.
  70191. *
  70192. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  70193. *
  70194. * For more information, please refer to :
  70195. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  70196. * @param engine Define the engine the buffer is associated with
  70197. * @param data Define the data contained in the buffer
  70198. * @param dynamic Define if the buffer is updatable
  70199. */
  70200. function UniformBuffer(engine, data, dynamic) {
  70201. this._engine = engine;
  70202. this._noUBO = !engine.supportsUniformBuffers;
  70203. this._dynamic = dynamic;
  70204. this._data = data || [];
  70205. this._uniformLocations = {};
  70206. this._uniformSizes = {};
  70207. this._uniformLocationPointer = 0;
  70208. this._needSync = false;
  70209. if (this._noUBO) {
  70210. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  70211. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  70212. this.updateFloat = this._updateFloatForEffect;
  70213. this.updateFloat2 = this._updateFloat2ForEffect;
  70214. this.updateFloat3 = this._updateFloat3ForEffect;
  70215. this.updateFloat4 = this._updateFloat4ForEffect;
  70216. this.updateMatrix = this._updateMatrixForEffect;
  70217. this.updateVector3 = this._updateVector3ForEffect;
  70218. this.updateVector4 = this._updateVector4ForEffect;
  70219. this.updateColor3 = this._updateColor3ForEffect;
  70220. this.updateColor4 = this._updateColor4ForEffect;
  70221. }
  70222. else {
  70223. this._engine._uniformBuffers.push(this);
  70224. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  70225. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  70226. this.updateFloat = this._updateFloatForUniform;
  70227. this.updateFloat2 = this._updateFloat2ForUniform;
  70228. this.updateFloat3 = this._updateFloat3ForUniform;
  70229. this.updateFloat4 = this._updateFloat4ForUniform;
  70230. this.updateMatrix = this._updateMatrixForUniform;
  70231. this.updateVector3 = this._updateVector3ForUniform;
  70232. this.updateVector4 = this._updateVector4ForUniform;
  70233. this.updateColor3 = this._updateColor3ForUniform;
  70234. this.updateColor4 = this._updateColor4ForUniform;
  70235. }
  70236. }
  70237. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  70238. /**
  70239. * Indicates if the buffer is using the WebGL2 UBO implementation,
  70240. * or just falling back on setUniformXXX calls.
  70241. */
  70242. get: function () {
  70243. return !this._noUBO;
  70244. },
  70245. enumerable: true,
  70246. configurable: true
  70247. });
  70248. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  70249. /**
  70250. * Indicates if the WebGL underlying uniform buffer is in sync
  70251. * with the javascript cache data.
  70252. */
  70253. get: function () {
  70254. return !this._needSync;
  70255. },
  70256. enumerable: true,
  70257. configurable: true
  70258. });
  70259. /**
  70260. * Indicates if the WebGL underlying uniform buffer is dynamic.
  70261. * Also, a dynamic UniformBuffer will disable cache verification and always
  70262. * update the underlying WebGL uniform buffer to the GPU.
  70263. * @returns if Dynamic, otherwise false
  70264. */
  70265. UniformBuffer.prototype.isDynamic = function () {
  70266. return this._dynamic !== undefined;
  70267. };
  70268. /**
  70269. * The data cache on JS side.
  70270. * @returns the underlying data as a float array
  70271. */
  70272. UniformBuffer.prototype.getData = function () {
  70273. return this._bufferData;
  70274. };
  70275. /**
  70276. * The underlying WebGL Uniform buffer.
  70277. * @returns the webgl buffer
  70278. */
  70279. UniformBuffer.prototype.getBuffer = function () {
  70280. return this._buffer;
  70281. };
  70282. /**
  70283. * std140 layout specifies how to align data within an UBO structure.
  70284. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  70285. * for specs.
  70286. */
  70287. UniformBuffer.prototype._fillAlignment = function (size) {
  70288. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  70289. // and 4x4 matrices
  70290. // TODO : change if other types are used
  70291. var alignment;
  70292. if (size <= 2) {
  70293. alignment = size;
  70294. }
  70295. else {
  70296. alignment = 4;
  70297. }
  70298. if ((this._uniformLocationPointer % alignment) !== 0) {
  70299. var oldPointer = this._uniformLocationPointer;
  70300. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  70301. var diff = this._uniformLocationPointer - oldPointer;
  70302. for (var i = 0; i < diff; i++) {
  70303. this._data.push(0);
  70304. }
  70305. }
  70306. };
  70307. /**
  70308. * Adds an uniform in the buffer.
  70309. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  70310. * for the layout to be correct !
  70311. * @param name Name of the uniform, as used in the uniform block in the shader.
  70312. * @param size Data size, or data directly.
  70313. */
  70314. UniformBuffer.prototype.addUniform = function (name, size) {
  70315. if (this._noUBO) {
  70316. return;
  70317. }
  70318. if (this._uniformLocations[name] !== undefined) {
  70319. // Already existing uniform
  70320. return;
  70321. }
  70322. // This function must be called in the order of the shader layout !
  70323. // size can be the size of the uniform, or data directly
  70324. var data;
  70325. if (size instanceof Array) {
  70326. data = size;
  70327. size = data.length;
  70328. }
  70329. else {
  70330. size = size;
  70331. data = [];
  70332. // Fill with zeros
  70333. for (var i = 0; i < size; i++) {
  70334. data.push(0);
  70335. }
  70336. }
  70337. this._fillAlignment(size);
  70338. this._uniformSizes[name] = size;
  70339. this._uniformLocations[name] = this._uniformLocationPointer;
  70340. this._uniformLocationPointer += size;
  70341. for (var i = 0; i < size; i++) {
  70342. this._data.push(data[i]);
  70343. }
  70344. this._needSync = true;
  70345. };
  70346. /**
  70347. * Adds a Matrix 4x4 to the uniform buffer.
  70348. * @param name Name of the uniform, as used in the uniform block in the shader.
  70349. * @param mat A 4x4 matrix.
  70350. */
  70351. UniformBuffer.prototype.addMatrix = function (name, mat) {
  70352. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  70353. };
  70354. /**
  70355. * Adds a vec2 to the uniform buffer.
  70356. * @param name Name of the uniform, as used in the uniform block in the shader.
  70357. * @param x Define the x component value of the vec2
  70358. * @param y Define the y component value of the vec2
  70359. */
  70360. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  70361. var temp = [x, y];
  70362. this.addUniform(name, temp);
  70363. };
  70364. /**
  70365. * Adds a vec3 to the uniform buffer.
  70366. * @param name Name of the uniform, as used in the uniform block in the shader.
  70367. * @param x Define the x component value of the vec3
  70368. * @param y Define the y component value of the vec3
  70369. * @param z Define the z component value of the vec3
  70370. */
  70371. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  70372. var temp = [x, y, z];
  70373. this.addUniform(name, temp);
  70374. };
  70375. /**
  70376. * Adds a vec3 to the uniform buffer.
  70377. * @param name Name of the uniform, as used in the uniform block in the shader.
  70378. * @param color Define the vec3 from a Color
  70379. */
  70380. UniformBuffer.prototype.addColor3 = function (name, color) {
  70381. var temp = new Array();
  70382. color.toArray(temp);
  70383. this.addUniform(name, temp);
  70384. };
  70385. /**
  70386. * Adds a vec4 to the uniform buffer.
  70387. * @param name Name of the uniform, as used in the uniform block in the shader.
  70388. * @param color Define the rgb components from a Color
  70389. * @param alpha Define the a component of the vec4
  70390. */
  70391. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  70392. var temp = new Array();
  70393. color.toArray(temp);
  70394. temp.push(alpha);
  70395. this.addUniform(name, temp);
  70396. };
  70397. /**
  70398. * Adds a vec3 to the uniform buffer.
  70399. * @param name Name of the uniform, as used in the uniform block in the shader.
  70400. * @param vector Define the vec3 components from a Vector
  70401. */
  70402. UniformBuffer.prototype.addVector3 = function (name, vector) {
  70403. var temp = new Array();
  70404. vector.toArray(temp);
  70405. this.addUniform(name, temp);
  70406. };
  70407. /**
  70408. * Adds a Matrix 3x3 to the uniform buffer.
  70409. * @param name Name of the uniform, as used in the uniform block in the shader.
  70410. */
  70411. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  70412. this.addUniform(name, 12);
  70413. };
  70414. /**
  70415. * Adds a Matrix 2x2 to the uniform buffer.
  70416. * @param name Name of the uniform, as used in the uniform block in the shader.
  70417. */
  70418. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  70419. this.addUniform(name, 8);
  70420. };
  70421. /**
  70422. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  70423. */
  70424. UniformBuffer.prototype.create = function () {
  70425. if (this._noUBO) {
  70426. return;
  70427. }
  70428. if (this._buffer) {
  70429. return; // nothing to do
  70430. }
  70431. // See spec, alignment must be filled as a vec4
  70432. this._fillAlignment(4);
  70433. this._bufferData = new Float32Array(this._data);
  70434. this._rebuild();
  70435. this._needSync = true;
  70436. };
  70437. /** @hidden */
  70438. UniformBuffer.prototype._rebuild = function () {
  70439. if (this._noUBO) {
  70440. return;
  70441. }
  70442. if (this._dynamic) {
  70443. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  70444. }
  70445. else {
  70446. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  70447. }
  70448. };
  70449. /**
  70450. * Updates the WebGL Uniform Buffer on the GPU.
  70451. * If the `dynamic` flag is set to true, no cache comparison is done.
  70452. * Otherwise, the buffer will be updated only if the cache differs.
  70453. */
  70454. UniformBuffer.prototype.update = function () {
  70455. if (!this._buffer) {
  70456. this.create();
  70457. return;
  70458. }
  70459. if (!this._dynamic && !this._needSync) {
  70460. return;
  70461. }
  70462. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  70463. this._needSync = false;
  70464. };
  70465. /**
  70466. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  70467. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  70468. * @param data Define the flattened data
  70469. * @param size Define the size of the data.
  70470. */
  70471. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  70472. var location = this._uniformLocations[uniformName];
  70473. if (location === undefined) {
  70474. if (this._buffer) {
  70475. // Cannot add an uniform if the buffer is already created
  70476. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  70477. return;
  70478. }
  70479. this.addUniform(uniformName, size);
  70480. location = this._uniformLocations[uniformName];
  70481. }
  70482. if (!this._buffer) {
  70483. this.create();
  70484. }
  70485. if (!this._dynamic) {
  70486. // Cache for static uniform buffers
  70487. var changed = false;
  70488. for (var i = 0; i < size; i++) {
  70489. if (this._bufferData[location + i] !== data[i]) {
  70490. changed = true;
  70491. this._bufferData[location + i] = data[i];
  70492. }
  70493. }
  70494. this._needSync = this._needSync || changed;
  70495. }
  70496. else {
  70497. // No cache for dynamic
  70498. for (var i = 0; i < size; i++) {
  70499. this._bufferData[location + i] = data[i];
  70500. }
  70501. }
  70502. };
  70503. // Update methods
  70504. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  70505. // To match std140, matrix must be realigned
  70506. for (var i = 0; i < 3; i++) {
  70507. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  70508. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  70509. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  70510. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  70511. }
  70512. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  70513. };
  70514. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  70515. this._currentEffect.setMatrix3x3(name, matrix);
  70516. };
  70517. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  70518. this._currentEffect.setMatrix2x2(name, matrix);
  70519. };
  70520. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  70521. // To match std140, matrix must be realigned
  70522. for (var i = 0; i < 2; i++) {
  70523. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  70524. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  70525. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  70526. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  70527. }
  70528. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  70529. };
  70530. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  70531. this._currentEffect.setFloat(name, x);
  70532. };
  70533. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  70534. UniformBuffer._tempBuffer[0] = x;
  70535. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  70536. };
  70537. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  70538. if (suffix === void 0) { suffix = ""; }
  70539. this._currentEffect.setFloat2(name + suffix, x, y);
  70540. };
  70541. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  70542. UniformBuffer._tempBuffer[0] = x;
  70543. UniformBuffer._tempBuffer[1] = y;
  70544. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  70545. };
  70546. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  70547. if (suffix === void 0) { suffix = ""; }
  70548. this._currentEffect.setFloat3(name + suffix, x, y, z);
  70549. };
  70550. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  70551. UniformBuffer._tempBuffer[0] = x;
  70552. UniformBuffer._tempBuffer[1] = y;
  70553. UniformBuffer._tempBuffer[2] = z;
  70554. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  70555. };
  70556. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  70557. if (suffix === void 0) { suffix = ""; }
  70558. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  70559. };
  70560. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  70561. UniformBuffer._tempBuffer[0] = x;
  70562. UniformBuffer._tempBuffer[1] = y;
  70563. UniformBuffer._tempBuffer[2] = z;
  70564. UniformBuffer._tempBuffer[3] = w;
  70565. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  70566. };
  70567. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  70568. this._currentEffect.setMatrix(name, mat);
  70569. };
  70570. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  70571. this.updateUniform(name, mat.toArray(), 16);
  70572. };
  70573. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  70574. this._currentEffect.setVector3(name, vector);
  70575. };
  70576. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  70577. vector.toArray(UniformBuffer._tempBuffer);
  70578. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  70579. };
  70580. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  70581. this._currentEffect.setVector4(name, vector);
  70582. };
  70583. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  70584. vector.toArray(UniformBuffer._tempBuffer);
  70585. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  70586. };
  70587. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  70588. if (suffix === void 0) { suffix = ""; }
  70589. this._currentEffect.setColor3(name + suffix, color);
  70590. };
  70591. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  70592. color.toArray(UniformBuffer._tempBuffer);
  70593. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  70594. };
  70595. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  70596. if (suffix === void 0) { suffix = ""; }
  70597. this._currentEffect.setColor4(name + suffix, color, alpha);
  70598. };
  70599. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  70600. color.toArray(UniformBuffer._tempBuffer);
  70601. UniformBuffer._tempBuffer[3] = alpha;
  70602. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  70603. };
  70604. /**
  70605. * Sets a sampler uniform on the effect.
  70606. * @param name Define the name of the sampler.
  70607. * @param texture Define the texture to set in the sampler
  70608. */
  70609. UniformBuffer.prototype.setTexture = function (name, texture) {
  70610. this._currentEffect.setTexture(name, texture);
  70611. };
  70612. /**
  70613. * Directly updates the value of the uniform in the cache AND on the GPU.
  70614. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  70615. * @param data Define the flattened data
  70616. */
  70617. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  70618. this.updateUniform(uniformName, data, data.length);
  70619. this.update();
  70620. };
  70621. /**
  70622. * Binds this uniform buffer to an effect.
  70623. * @param effect Define the effect to bind the buffer to
  70624. * @param name Name of the uniform block in the shader.
  70625. */
  70626. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  70627. this._currentEffect = effect;
  70628. if (this._noUBO || !this._buffer) {
  70629. return;
  70630. }
  70631. effect.bindUniformBuffer(this._buffer, name);
  70632. };
  70633. /**
  70634. * Disposes the uniform buffer.
  70635. */
  70636. UniformBuffer.prototype.dispose = function () {
  70637. if (this._noUBO) {
  70638. return;
  70639. }
  70640. var uniformBuffers = this._engine._uniformBuffers;
  70641. var index = uniformBuffers.indexOf(this);
  70642. if (index !== -1) {
  70643. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  70644. uniformBuffers.pop();
  70645. }
  70646. if (!this._buffer) {
  70647. return;
  70648. }
  70649. if (this._engine._releaseBuffer(this._buffer)) {
  70650. this._buffer = null;
  70651. }
  70652. };
  70653. // Pool for avoiding memory leaks
  70654. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  70655. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  70656. return UniformBuffer;
  70657. }());
  70658. /***/ }),
  70659. /***/ "./Maths/index.ts":
  70660. /*!************************!*\
  70661. !*** ./Maths/index.ts ***!
  70662. \************************/
  70663. /*! 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 */
  70664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  70665. "use strict";
  70666. __webpack_require__.r(__webpack_exports__);
  70667. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  70668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  70669. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  70670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  70671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  70672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  70673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  70674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  70675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  70676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  70677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  70678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  70679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  70680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  70681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  70682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  70683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  70684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  70685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  70686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  70687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  70688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  70689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  70690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  70691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  70692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  70693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  70694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  70695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Tmp"]; });
  70696. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  70697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  70698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  70699. /***/ }),
  70700. /***/ "./Maths/math.scalar.ts":
  70701. /*!******************************!*\
  70702. !*** ./Maths/math.scalar.ts ***!
  70703. \******************************/
  70704. /*! exports provided: Scalar */
  70705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  70706. "use strict";
  70707. __webpack_require__.r(__webpack_exports__);
  70708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  70709. /**
  70710. * Scalar computation library
  70711. */
  70712. var Scalar = /** @class */ (function () {
  70713. function Scalar() {
  70714. }
  70715. /**
  70716. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70717. * @param a number
  70718. * @param b number
  70719. * @param epsilon (default = 1.401298E-45)
  70720. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  70721. */
  70722. Scalar.WithinEpsilon = function (a, b, epsilon) {
  70723. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  70724. var num = a - b;
  70725. return -epsilon <= num && num <= epsilon;
  70726. };
  70727. /**
  70728. * Returns a string : the upper case translation of the number i to hexadecimal.
  70729. * @param i number
  70730. * @returns the upper case translation of the number i to hexadecimal.
  70731. */
  70732. Scalar.ToHex = function (i) {
  70733. var str = i.toString(16);
  70734. if (i <= 15) {
  70735. return ("0" + str).toUpperCase();
  70736. }
  70737. return str.toUpperCase();
  70738. };
  70739. /**
  70740. * Returns -1 if value is negative and +1 is value is positive.
  70741. * @param value the value
  70742. * @returns the value itself if it's equal to zero.
  70743. */
  70744. Scalar.Sign = function (value) {
  70745. value = +value; // convert to a number
  70746. if (value === 0 || isNaN(value)) {
  70747. return value;
  70748. }
  70749. return value > 0 ? 1 : -1;
  70750. };
  70751. /**
  70752. * Returns the value itself if it's between min and max.
  70753. * Returns min if the value is lower than min.
  70754. * Returns max if the value is greater than max.
  70755. * @param value the value to clmap
  70756. * @param min the min value to clamp to (default: 0)
  70757. * @param max the max value to clamp to (default: 1)
  70758. * @returns the clamped value
  70759. */
  70760. Scalar.Clamp = function (value, min, max) {
  70761. if (min === void 0) { min = 0; }
  70762. if (max === void 0) { max = 1; }
  70763. return Math.min(max, Math.max(min, value));
  70764. };
  70765. /**
  70766. * the log2 of value.
  70767. * @param value the value to compute log2 of
  70768. * @returns the log2 of value.
  70769. */
  70770. Scalar.Log2 = function (value) {
  70771. return Math.log(value) * Math.LOG2E;
  70772. };
  70773. /**
  70774. * Loops the value, so that it is never larger than length and never smaller than 0.
  70775. *
  70776. * This is similar to the modulo operator but it works with floating point numbers.
  70777. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  70778. * With t = 5 and length = 2.5, the result would be 0.0.
  70779. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  70780. * @param value the value
  70781. * @param length the length
  70782. * @returns the looped value
  70783. */
  70784. Scalar.Repeat = function (value, length) {
  70785. return value - Math.floor(value / length) * length;
  70786. };
  70787. /**
  70788. * Normalize the value between 0.0 and 1.0 using min and max values
  70789. * @param value value to normalize
  70790. * @param min max to normalize between
  70791. * @param max min to normalize between
  70792. * @returns the normalized value
  70793. */
  70794. Scalar.Normalize = function (value, min, max) {
  70795. return (value - min) / (max - min);
  70796. };
  70797. /**
  70798. * Denormalize the value from 0.0 and 1.0 using min and max values
  70799. * @param normalized value to denormalize
  70800. * @param min max to denormalize between
  70801. * @param max min to denormalize between
  70802. * @returns the denormalized value
  70803. */
  70804. Scalar.Denormalize = function (normalized, min, max) {
  70805. return (normalized * (max - min) + min);
  70806. };
  70807. /**
  70808. * Calculates the shortest difference between two given angles given in degrees.
  70809. * @param current current angle in degrees
  70810. * @param target target angle in degrees
  70811. * @returns the delta
  70812. */
  70813. Scalar.DeltaAngle = function (current, target) {
  70814. var num = Scalar.Repeat(target - current, 360.0);
  70815. if (num > 180.0) {
  70816. num -= 360.0;
  70817. }
  70818. return num;
  70819. };
  70820. /**
  70821. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  70822. * @param tx value
  70823. * @param length length
  70824. * @returns The returned value will move back and forth between 0 and length
  70825. */
  70826. Scalar.PingPong = function (tx, length) {
  70827. var t = Scalar.Repeat(tx, length * 2.0);
  70828. return length - Math.abs(t - length);
  70829. };
  70830. /**
  70831. * Interpolates between min and max with smoothing at the limits.
  70832. *
  70833. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  70834. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  70835. * @param from from
  70836. * @param to to
  70837. * @param tx value
  70838. * @returns the smooth stepped value
  70839. */
  70840. Scalar.SmoothStep = function (from, to, tx) {
  70841. var t = Scalar.Clamp(tx);
  70842. t = -2.0 * t * t * t + 3.0 * t * t;
  70843. return to * t + from * (1.0 - t);
  70844. };
  70845. /**
  70846. * Moves a value current towards target.
  70847. *
  70848. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  70849. * Negative values of maxDelta pushes the value away from target.
  70850. * @param current current value
  70851. * @param target target value
  70852. * @param maxDelta max distance to move
  70853. * @returns resulting value
  70854. */
  70855. Scalar.MoveTowards = function (current, target, maxDelta) {
  70856. var result = 0;
  70857. if (Math.abs(target - current) <= maxDelta) {
  70858. result = target;
  70859. }
  70860. else {
  70861. result = current + Scalar.Sign(target - current) * maxDelta;
  70862. }
  70863. return result;
  70864. };
  70865. /**
  70866. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70867. *
  70868. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  70869. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  70870. * @param current current value
  70871. * @param target target value
  70872. * @param maxDelta max distance to move
  70873. * @returns resulting angle
  70874. */
  70875. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  70876. var num = Scalar.DeltaAngle(current, target);
  70877. var result = 0;
  70878. if (-maxDelta < num && num < maxDelta) {
  70879. result = target;
  70880. }
  70881. else {
  70882. target = current + num;
  70883. result = Scalar.MoveTowards(current, target, maxDelta);
  70884. }
  70885. return result;
  70886. };
  70887. /**
  70888. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  70889. * @param start start value
  70890. * @param end target value
  70891. * @param amount amount to lerp between
  70892. * @returns the lerped value
  70893. */
  70894. Scalar.Lerp = function (start, end, amount) {
  70895. return start + ((end - start) * amount);
  70896. };
  70897. /**
  70898. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  70899. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  70900. * @param start start value
  70901. * @param end target value
  70902. * @param amount amount to lerp between
  70903. * @returns the lerped value
  70904. */
  70905. Scalar.LerpAngle = function (start, end, amount) {
  70906. var num = Scalar.Repeat(end - start, 360.0);
  70907. if (num > 180.0) {
  70908. num -= 360.0;
  70909. }
  70910. return start + num * Scalar.Clamp(amount);
  70911. };
  70912. /**
  70913. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  70914. * @param a start value
  70915. * @param b target value
  70916. * @param value value between a and b
  70917. * @returns the inverseLerp value
  70918. */
  70919. Scalar.InverseLerp = function (a, b, value) {
  70920. var result = 0;
  70921. if (a != b) {
  70922. result = Scalar.Clamp((value - a) / (b - a));
  70923. }
  70924. else {
  70925. result = 0.0;
  70926. }
  70927. return result;
  70928. };
  70929. /**
  70930. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  70931. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  70932. * @param value1 spline value
  70933. * @param tangent1 spline value
  70934. * @param value2 spline value
  70935. * @param tangent2 spline value
  70936. * @param amount input value
  70937. * @returns hermite result
  70938. */
  70939. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  70940. var squared = amount * amount;
  70941. var cubed = amount * squared;
  70942. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  70943. var part2 = (-2.0 * cubed) + (3.0 * squared);
  70944. var part3 = (cubed - (2.0 * squared)) + amount;
  70945. var part4 = cubed - squared;
  70946. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  70947. };
  70948. /**
  70949. * Returns a random float number between and min and max values
  70950. * @param min min value of random
  70951. * @param max max value of random
  70952. * @returns random value
  70953. */
  70954. Scalar.RandomRange = function (min, max) {
  70955. if (min === max) {
  70956. return min;
  70957. }
  70958. return ((Math.random() * (max - min)) + min);
  70959. };
  70960. /**
  70961. * This function returns percentage of a number in a given range.
  70962. *
  70963. * RangeToPercent(40,20,60) will return 0.5 (50%)
  70964. * RangeToPercent(34,0,100) will return 0.34 (34%)
  70965. * @param number to convert to percentage
  70966. * @param min min range
  70967. * @param max max range
  70968. * @returns the percentage
  70969. */
  70970. Scalar.RangeToPercent = function (number, min, max) {
  70971. return ((number - min) / (max - min));
  70972. };
  70973. /**
  70974. * This function returns number that corresponds to the percentage in a given range.
  70975. *
  70976. * PercentToRange(0.34,0,100) will return 34.
  70977. * @param percent to convert to number
  70978. * @param min min range
  70979. * @param max max range
  70980. * @returns the number
  70981. */
  70982. Scalar.PercentToRange = function (percent, min, max) {
  70983. return ((max - min) * percent + min);
  70984. };
  70985. /**
  70986. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  70987. * @param angle The angle to normalize in radian.
  70988. * @return The converted angle.
  70989. */
  70990. Scalar.NormalizeRadians = function (angle) {
  70991. // More precise but slower version kept for reference.
  70992. // angle = angle % Tools.TwoPi;
  70993. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  70994. //if (angle > Math.PI) {
  70995. // angle -= Tools.TwoPi;
  70996. //}
  70997. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  70998. return angle;
  70999. };
  71000. /**
  71001. * Two pi constants convenient for computation.
  71002. */
  71003. Scalar.TwoPi = Math.PI * 2;
  71004. return Scalar;
  71005. }());
  71006. /***/ }),
  71007. /***/ "./Maths/math.ts":
  71008. /*!***********************!*\
  71009. !*** ./Maths/math.ts ***!
  71010. \***********************/
  71011. /*! 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 */
  71012. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  71013. "use strict";
  71014. __webpack_require__.r(__webpack_exports__);
  71015. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  71016. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  71017. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  71018. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  71019. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  71020. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  71021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  71022. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  71023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  71024. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  71025. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  71026. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  71027. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  71028. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  71029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  71030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  71031. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  71032. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  71033. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  71034. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  71035. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  71036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  71037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  71038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  71039. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  71040. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return Tmp; });
  71041. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  71042. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  71043. /**
  71044. * Constant used to convert a value to gamma space
  71045. * @ignorenaming
  71046. */
  71047. var ToGammaSpace = 1 / 2.2;
  71048. /**
  71049. * Constant used to convert a value to linear space
  71050. * @ignorenaming
  71051. */
  71052. var ToLinearSpace = 2.2;
  71053. /**
  71054. * Constant used to define the minimal number value in Babylon.js
  71055. * @ignorenaming
  71056. */
  71057. var Epsilon = 0.001;
  71058. /**
  71059. * Class used to hold a RBG color
  71060. */
  71061. var Color3 = /** @class */ (function () {
  71062. /**
  71063. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  71064. * @param r defines the red component (between 0 and 1, default is 0)
  71065. * @param g defines the green component (between 0 and 1, default is 0)
  71066. * @param b defines the blue component (between 0 and 1, default is 0)
  71067. */
  71068. function Color3(
  71069. /**
  71070. * Defines the red component (between 0 and 1, default is 0)
  71071. */
  71072. r,
  71073. /**
  71074. * Defines the green component (between 0 and 1, default is 0)
  71075. */
  71076. g,
  71077. /**
  71078. * Defines the blue component (between 0 and 1, default is 0)
  71079. */
  71080. b) {
  71081. if (r === void 0) { r = 0; }
  71082. if (g === void 0) { g = 0; }
  71083. if (b === void 0) { b = 0; }
  71084. this.r = r;
  71085. this.g = g;
  71086. this.b = b;
  71087. }
  71088. /**
  71089. * Creates a string with the Color3 current values
  71090. * @returns the string representation of the Color3 object
  71091. */
  71092. Color3.prototype.toString = function () {
  71093. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  71094. };
  71095. /**
  71096. * Returns the string "Color3"
  71097. * @returns "Color3"
  71098. */
  71099. Color3.prototype.getClassName = function () {
  71100. return "Color3";
  71101. };
  71102. /**
  71103. * Compute the Color3 hash code
  71104. * @returns an unique number that can be used to hash Color3 objects
  71105. */
  71106. Color3.prototype.getHashCode = function () {
  71107. var hash = this.r || 0;
  71108. hash = (hash * 397) ^ (this.g || 0);
  71109. hash = (hash * 397) ^ (this.b || 0);
  71110. return hash;
  71111. };
  71112. // Operators
  71113. /**
  71114. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  71115. * @param array defines the array where to store the r,g,b components
  71116. * @param index defines an optional index in the target array to define where to start storing values
  71117. * @returns the current Color3 object
  71118. */
  71119. Color3.prototype.toArray = function (array, index) {
  71120. if (index === void 0) { index = 0; }
  71121. array[index] = this.r;
  71122. array[index + 1] = this.g;
  71123. array[index + 2] = this.b;
  71124. return this;
  71125. };
  71126. /**
  71127. * Returns a new Color4 object from the current Color3 and the given alpha
  71128. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  71129. * @returns a new Color4 object
  71130. */
  71131. Color3.prototype.toColor4 = function (alpha) {
  71132. if (alpha === void 0) { alpha = 1; }
  71133. return new Color4(this.r, this.g, this.b, alpha);
  71134. };
  71135. /**
  71136. * Returns a new array populated with 3 numeric elements : red, green and blue values
  71137. * @returns the new array
  71138. */
  71139. Color3.prototype.asArray = function () {
  71140. var result = new Array();
  71141. this.toArray(result, 0);
  71142. return result;
  71143. };
  71144. /**
  71145. * Returns the luminance value
  71146. * @returns a float value
  71147. */
  71148. Color3.prototype.toLuminance = function () {
  71149. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  71150. };
  71151. /**
  71152. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  71153. * @param otherColor defines the second operand
  71154. * @returns the new Color3 object
  71155. */
  71156. Color3.prototype.multiply = function (otherColor) {
  71157. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  71158. };
  71159. /**
  71160. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  71161. * @param otherColor defines the second operand
  71162. * @param result defines the Color3 object where to store the result
  71163. * @returns the current Color3
  71164. */
  71165. Color3.prototype.multiplyToRef = function (otherColor, result) {
  71166. result.r = this.r * otherColor.r;
  71167. result.g = this.g * otherColor.g;
  71168. result.b = this.b * otherColor.b;
  71169. return this;
  71170. };
  71171. /**
  71172. * Determines equality between Color3 objects
  71173. * @param otherColor defines the second operand
  71174. * @returns true if the rgb values are equal to the given ones
  71175. */
  71176. Color3.prototype.equals = function (otherColor) {
  71177. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  71178. };
  71179. /**
  71180. * Determines equality between the current Color3 object and a set of r,b,g values
  71181. * @param r defines the red component to check
  71182. * @param g defines the green component to check
  71183. * @param b defines the blue component to check
  71184. * @returns true if the rgb values are equal to the given ones
  71185. */
  71186. Color3.prototype.equalsFloats = function (r, g, b) {
  71187. return this.r === r && this.g === g && this.b === b;
  71188. };
  71189. /**
  71190. * Multiplies in place each rgb value by scale
  71191. * @param scale defines the scaling factor
  71192. * @returns the updated Color3
  71193. */
  71194. Color3.prototype.scale = function (scale) {
  71195. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  71196. };
  71197. /**
  71198. * Multiplies the rgb values by scale and stores the result into "result"
  71199. * @param scale defines the scaling factor
  71200. * @param result defines the Color3 object where to store the result
  71201. * @returns the unmodified current Color3
  71202. */
  71203. Color3.prototype.scaleToRef = function (scale, result) {
  71204. result.r = this.r * scale;
  71205. result.g = this.g * scale;
  71206. result.b = this.b * scale;
  71207. return this;
  71208. };
  71209. /**
  71210. * Scale the current Color3 values by a factor and add the result to a given Color3
  71211. * @param scale defines the scale factor
  71212. * @param result defines color to store the result into
  71213. * @returns the unmodified current Color3
  71214. */
  71215. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  71216. result.r += this.r * scale;
  71217. result.g += this.g * scale;
  71218. result.b += this.b * scale;
  71219. return this;
  71220. };
  71221. /**
  71222. * Clamps the rgb values by the min and max values and stores the result into "result"
  71223. * @param min defines minimum clamping value (default is 0)
  71224. * @param max defines maximum clamping value (default is 1)
  71225. * @param result defines color to store the result into
  71226. * @returns the original Color3
  71227. */
  71228. Color3.prototype.clampToRef = function (min, max, result) {
  71229. if (min === void 0) { min = 0; }
  71230. if (max === void 0) { max = 1; }
  71231. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  71232. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  71233. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  71234. return this;
  71235. };
  71236. /**
  71237. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  71238. * @param otherColor defines the second operand
  71239. * @returns the new Color3
  71240. */
  71241. Color3.prototype.add = function (otherColor) {
  71242. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  71243. };
  71244. /**
  71245. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  71246. * @param otherColor defines the second operand
  71247. * @param result defines Color3 object to store the result into
  71248. * @returns the unmodified current Color3
  71249. */
  71250. Color3.prototype.addToRef = function (otherColor, result) {
  71251. result.r = this.r + otherColor.r;
  71252. result.g = this.g + otherColor.g;
  71253. result.b = this.b + otherColor.b;
  71254. return this;
  71255. };
  71256. /**
  71257. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  71258. * @param otherColor defines the second operand
  71259. * @returns the new Color3
  71260. */
  71261. Color3.prototype.subtract = function (otherColor) {
  71262. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  71263. };
  71264. /**
  71265. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  71266. * @param otherColor defines the second operand
  71267. * @param result defines Color3 object to store the result into
  71268. * @returns the unmodified current Color3
  71269. */
  71270. Color3.prototype.subtractToRef = function (otherColor, result) {
  71271. result.r = this.r - otherColor.r;
  71272. result.g = this.g - otherColor.g;
  71273. result.b = this.b - otherColor.b;
  71274. return this;
  71275. };
  71276. /**
  71277. * Copy the current object
  71278. * @returns a new Color3 copied the current one
  71279. */
  71280. Color3.prototype.clone = function () {
  71281. return new Color3(this.r, this.g, this.b);
  71282. };
  71283. /**
  71284. * Copies the rgb values from the source in the current Color3
  71285. * @param source defines the source Color3 object
  71286. * @returns the updated Color3 object
  71287. */
  71288. Color3.prototype.copyFrom = function (source) {
  71289. this.r = source.r;
  71290. this.g = source.g;
  71291. this.b = source.b;
  71292. return this;
  71293. };
  71294. /**
  71295. * Updates the Color3 rgb values from the given floats
  71296. * @param r defines the red component to read from
  71297. * @param g defines the green component to read from
  71298. * @param b defines the blue component to read from
  71299. * @returns the current Color3 object
  71300. */
  71301. Color3.prototype.copyFromFloats = function (r, g, b) {
  71302. this.r = r;
  71303. this.g = g;
  71304. this.b = b;
  71305. return this;
  71306. };
  71307. /**
  71308. * Updates the Color3 rgb values from the given floats
  71309. * @param r defines the red component to read from
  71310. * @param g defines the green component to read from
  71311. * @param b defines the blue component to read from
  71312. * @returns the current Color3 object
  71313. */
  71314. Color3.prototype.set = function (r, g, b) {
  71315. return this.copyFromFloats(r, g, b);
  71316. };
  71317. /**
  71318. * Compute the Color3 hexadecimal code as a string
  71319. * @returns a string containing the hexadecimal representation of the Color3 object
  71320. */
  71321. Color3.prototype.toHexString = function () {
  71322. var intR = (this.r * 255) | 0;
  71323. var intG = (this.g * 255) | 0;
  71324. var intB = (this.b * 255) | 0;
  71325. 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);
  71326. };
  71327. /**
  71328. * Computes a new Color3 converted from the current one to linear space
  71329. * @returns a new Color3 object
  71330. */
  71331. Color3.prototype.toLinearSpace = function () {
  71332. var convertedColor = new Color3();
  71333. this.toLinearSpaceToRef(convertedColor);
  71334. return convertedColor;
  71335. };
  71336. /**
  71337. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  71338. * @param convertedColor defines the Color3 object where to store the linear space version
  71339. * @returns the unmodified Color3
  71340. */
  71341. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  71342. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  71343. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  71344. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  71345. return this;
  71346. };
  71347. /**
  71348. * Computes a new Color3 converted from the current one to gamma space
  71349. * @returns a new Color3 object
  71350. */
  71351. Color3.prototype.toGammaSpace = function () {
  71352. var convertedColor = new Color3();
  71353. this.toGammaSpaceToRef(convertedColor);
  71354. return convertedColor;
  71355. };
  71356. /**
  71357. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  71358. * @param convertedColor defines the Color3 object where to store the gamma space version
  71359. * @returns the unmodified Color3
  71360. */
  71361. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  71362. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  71363. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  71364. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  71365. return this;
  71366. };
  71367. /**
  71368. * Creates a new Color3 from the string containing valid hexadecimal values
  71369. * @param hex defines a string containing valid hexadecimal values
  71370. * @returns a new Color3 object
  71371. */
  71372. Color3.FromHexString = function (hex) {
  71373. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  71374. return new Color3(0, 0, 0);
  71375. }
  71376. var r = parseInt(hex.substring(1, 3), 16);
  71377. var g = parseInt(hex.substring(3, 5), 16);
  71378. var b = parseInt(hex.substring(5, 7), 16);
  71379. return Color3.FromInts(r, g, b);
  71380. };
  71381. /**
  71382. * Creates a new Vector3 from the starting index of the given array
  71383. * @param array defines the source array
  71384. * @param offset defines an offset in the source array
  71385. * @returns a new Color3 object
  71386. */
  71387. Color3.FromArray = function (array, offset) {
  71388. if (offset === void 0) { offset = 0; }
  71389. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  71390. };
  71391. /**
  71392. * Creates a new Color3 from integer values (< 256)
  71393. * @param r defines the red component to read from (value between 0 and 255)
  71394. * @param g defines the green component to read from (value between 0 and 255)
  71395. * @param b defines the blue component to read from (value between 0 and 255)
  71396. * @returns a new Color3 object
  71397. */
  71398. Color3.FromInts = function (r, g, b) {
  71399. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  71400. };
  71401. /**
  71402. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  71403. * @param start defines the start Color3 value
  71404. * @param end defines the end Color3 value
  71405. * @param amount defines the gradient value between start and end
  71406. * @returns a new Color3 object
  71407. */
  71408. Color3.Lerp = function (start, end, amount) {
  71409. var result = new Color3(0.0, 0.0, 0.0);
  71410. Color3.LerpToRef(start, end, amount, result);
  71411. return result;
  71412. };
  71413. /**
  71414. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  71415. * @param left defines the start value
  71416. * @param right defines the end value
  71417. * @param amount defines the gradient factor
  71418. * @param result defines the Color3 object where to store the result
  71419. */
  71420. Color3.LerpToRef = function (left, right, amount, result) {
  71421. result.r = left.r + ((right.r - left.r) * amount);
  71422. result.g = left.g + ((right.g - left.g) * amount);
  71423. result.b = left.b + ((right.b - left.b) * amount);
  71424. };
  71425. /**
  71426. * Returns a Color3 value containing a red color
  71427. * @returns a new Color3 object
  71428. */
  71429. Color3.Red = function () { return new Color3(1, 0, 0); };
  71430. /**
  71431. * Returns a Color3 value containing a green color
  71432. * @returns a new Color3 object
  71433. */
  71434. Color3.Green = function () { return new Color3(0, 1, 0); };
  71435. /**
  71436. * Returns a Color3 value containing a blue color
  71437. * @returns a new Color3 object
  71438. */
  71439. Color3.Blue = function () { return new Color3(0, 0, 1); };
  71440. /**
  71441. * Returns a Color3 value containing a black color
  71442. * @returns a new Color3 object
  71443. */
  71444. Color3.Black = function () { return new Color3(0, 0, 0); };
  71445. Object.defineProperty(Color3, "BlackReadOnly", {
  71446. /**
  71447. * Gets a Color3 value containing a black color that must not be updated
  71448. */
  71449. get: function () {
  71450. return Color3._BlackReadOnly;
  71451. },
  71452. enumerable: true,
  71453. configurable: true
  71454. });
  71455. /**
  71456. * Returns a Color3 value containing a white color
  71457. * @returns a new Color3 object
  71458. */
  71459. Color3.White = function () { return new Color3(1, 1, 1); };
  71460. /**
  71461. * Returns a Color3 value containing a purple color
  71462. * @returns a new Color3 object
  71463. */
  71464. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  71465. /**
  71466. * Returns a Color3 value containing a magenta color
  71467. * @returns a new Color3 object
  71468. */
  71469. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  71470. /**
  71471. * Returns a Color3 value containing a yellow color
  71472. * @returns a new Color3 object
  71473. */
  71474. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  71475. /**
  71476. * Returns a Color3 value containing a gray color
  71477. * @returns a new Color3 object
  71478. */
  71479. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  71480. /**
  71481. * Returns a Color3 value containing a teal color
  71482. * @returns a new Color3 object
  71483. */
  71484. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  71485. /**
  71486. * Returns a Color3 value containing a random color
  71487. * @returns a new Color3 object
  71488. */
  71489. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  71490. // Statics
  71491. Color3._BlackReadOnly = Color3.Black();
  71492. return Color3;
  71493. }());
  71494. /**
  71495. * Class used to hold a RBGA color
  71496. */
  71497. var Color4 = /** @class */ (function () {
  71498. /**
  71499. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  71500. * @param r defines the red component (between 0 and 1, default is 0)
  71501. * @param g defines the green component (between 0 and 1, default is 0)
  71502. * @param b defines the blue component (between 0 and 1, default is 0)
  71503. * @param a defines the alpha component (between 0 and 1, default is 1)
  71504. */
  71505. function Color4(
  71506. /**
  71507. * Defines the red component (between 0 and 1, default is 0)
  71508. */
  71509. r,
  71510. /**
  71511. * Defines the green component (between 0 and 1, default is 0)
  71512. */
  71513. g,
  71514. /**
  71515. * Defines the blue component (between 0 and 1, default is 0)
  71516. */
  71517. b,
  71518. /**
  71519. * Defines the alpha component (between 0 and 1, default is 1)
  71520. */
  71521. a) {
  71522. if (r === void 0) { r = 0; }
  71523. if (g === void 0) { g = 0; }
  71524. if (b === void 0) { b = 0; }
  71525. if (a === void 0) { a = 1; }
  71526. this.r = r;
  71527. this.g = g;
  71528. this.b = b;
  71529. this.a = a;
  71530. }
  71531. // Operators
  71532. /**
  71533. * Adds in place the given Color4 values to the current Color4 object
  71534. * @param right defines the second operand
  71535. * @returns the current updated Color4 object
  71536. */
  71537. Color4.prototype.addInPlace = function (right) {
  71538. this.r += right.r;
  71539. this.g += right.g;
  71540. this.b += right.b;
  71541. this.a += right.a;
  71542. return this;
  71543. };
  71544. /**
  71545. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  71546. * @returns the new array
  71547. */
  71548. Color4.prototype.asArray = function () {
  71549. var result = new Array();
  71550. this.toArray(result, 0);
  71551. return result;
  71552. };
  71553. /**
  71554. * Stores from the starting index in the given array the Color4 successive values
  71555. * @param array defines the array where to store the r,g,b components
  71556. * @param index defines an optional index in the target array to define where to start storing values
  71557. * @returns the current Color4 object
  71558. */
  71559. Color4.prototype.toArray = function (array, index) {
  71560. if (index === void 0) { index = 0; }
  71561. array[index] = this.r;
  71562. array[index + 1] = this.g;
  71563. array[index + 2] = this.b;
  71564. array[index + 3] = this.a;
  71565. return this;
  71566. };
  71567. /**
  71568. * Determines equality between Color4 objects
  71569. * @param otherColor defines the second operand
  71570. * @returns true if the rgba values are equal to the given ones
  71571. */
  71572. Color4.prototype.equals = function (otherColor) {
  71573. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  71574. };
  71575. /**
  71576. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  71577. * @param right defines the second operand
  71578. * @returns a new Color4 object
  71579. */
  71580. Color4.prototype.add = function (right) {
  71581. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  71582. };
  71583. /**
  71584. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  71585. * @param right defines the second operand
  71586. * @returns a new Color4 object
  71587. */
  71588. Color4.prototype.subtract = function (right) {
  71589. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  71590. };
  71591. /**
  71592. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  71593. * @param right defines the second operand
  71594. * @param result defines the Color4 object where to store the result
  71595. * @returns the current Color4 object
  71596. */
  71597. Color4.prototype.subtractToRef = function (right, result) {
  71598. result.r = this.r - right.r;
  71599. result.g = this.g - right.g;
  71600. result.b = this.b - right.b;
  71601. result.a = this.a - right.a;
  71602. return this;
  71603. };
  71604. /**
  71605. * Creates a new Color4 with the current Color4 values multiplied by scale
  71606. * @param scale defines the scaling factor to apply
  71607. * @returns a new Color4 object
  71608. */
  71609. Color4.prototype.scale = function (scale) {
  71610. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  71611. };
  71612. /**
  71613. * Multiplies the current Color4 values by scale and stores the result in "result"
  71614. * @param scale defines the scaling factor to apply
  71615. * @param result defines the Color4 object where to store the result
  71616. * @returns the current unmodified Color4
  71617. */
  71618. Color4.prototype.scaleToRef = function (scale, result) {
  71619. result.r = this.r * scale;
  71620. result.g = this.g * scale;
  71621. result.b = this.b * scale;
  71622. result.a = this.a * scale;
  71623. return this;
  71624. };
  71625. /**
  71626. * Scale the current Color4 values by a factor and add the result to a given Color4
  71627. * @param scale defines the scale factor
  71628. * @param result defines the Color4 object where to store the result
  71629. * @returns the unmodified current Color4
  71630. */
  71631. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  71632. result.r += this.r * scale;
  71633. result.g += this.g * scale;
  71634. result.b += this.b * scale;
  71635. result.a += this.a * scale;
  71636. return this;
  71637. };
  71638. /**
  71639. * Clamps the rgb values by the min and max values and stores the result into "result"
  71640. * @param min defines minimum clamping value (default is 0)
  71641. * @param max defines maximum clamping value (default is 1)
  71642. * @param result defines color to store the result into.
  71643. * @returns the cuurent Color4
  71644. */
  71645. Color4.prototype.clampToRef = function (min, max, result) {
  71646. if (min === void 0) { min = 0; }
  71647. if (max === void 0) { max = 1; }
  71648. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  71649. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  71650. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  71651. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.a, min, max);
  71652. return this;
  71653. };
  71654. /**
  71655. * Multipy an Color4 value by another and return a new Color4 object
  71656. * @param color defines the Color4 value to multiply by
  71657. * @returns a new Color4 object
  71658. */
  71659. Color4.prototype.multiply = function (color) {
  71660. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  71661. };
  71662. /**
  71663. * Multipy a Color4 value by another and push the result in a reference value
  71664. * @param color defines the Color4 value to multiply by
  71665. * @param result defines the Color4 to fill the result in
  71666. * @returns the result Color4
  71667. */
  71668. Color4.prototype.multiplyToRef = function (color, result) {
  71669. result.r = this.r * color.r;
  71670. result.g = this.g * color.g;
  71671. result.b = this.b * color.b;
  71672. result.a = this.a * color.a;
  71673. return result;
  71674. };
  71675. /**
  71676. * Creates a string with the Color4 current values
  71677. * @returns the string representation of the Color4 object
  71678. */
  71679. Color4.prototype.toString = function () {
  71680. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  71681. };
  71682. /**
  71683. * Returns the string "Color4"
  71684. * @returns "Color4"
  71685. */
  71686. Color4.prototype.getClassName = function () {
  71687. return "Color4";
  71688. };
  71689. /**
  71690. * Compute the Color4 hash code
  71691. * @returns an unique number that can be used to hash Color4 objects
  71692. */
  71693. Color4.prototype.getHashCode = function () {
  71694. var hash = this.r || 0;
  71695. hash = (hash * 397) ^ (this.g || 0);
  71696. hash = (hash * 397) ^ (this.b || 0);
  71697. hash = (hash * 397) ^ (this.a || 0);
  71698. return hash;
  71699. };
  71700. /**
  71701. * Creates a new Color4 copied from the current one
  71702. * @returns a new Color4 object
  71703. */
  71704. Color4.prototype.clone = function () {
  71705. return new Color4(this.r, this.g, this.b, this.a);
  71706. };
  71707. /**
  71708. * Copies the given Color4 values into the current one
  71709. * @param source defines the source Color4 object
  71710. * @returns the current updated Color4 object
  71711. */
  71712. Color4.prototype.copyFrom = function (source) {
  71713. this.r = source.r;
  71714. this.g = source.g;
  71715. this.b = source.b;
  71716. this.a = source.a;
  71717. return this;
  71718. };
  71719. /**
  71720. * Copies the given float values into the current one
  71721. * @param r defines the red component to read from
  71722. * @param g defines the green component to read from
  71723. * @param b defines the blue component to read from
  71724. * @param a defines the alpha component to read from
  71725. * @returns the current updated Color4 object
  71726. */
  71727. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  71728. this.r = r;
  71729. this.g = g;
  71730. this.b = b;
  71731. this.a = a;
  71732. return this;
  71733. };
  71734. /**
  71735. * Copies the given float values into the current one
  71736. * @param r defines the red component to read from
  71737. * @param g defines the green component to read from
  71738. * @param b defines the blue component to read from
  71739. * @param a defines the alpha component to read from
  71740. * @returns the current updated Color4 object
  71741. */
  71742. Color4.prototype.set = function (r, g, b, a) {
  71743. return this.copyFromFloats(r, g, b, a);
  71744. };
  71745. /**
  71746. * Compute the Color4 hexadecimal code as a string
  71747. * @returns a string containing the hexadecimal representation of the Color4 object
  71748. */
  71749. Color4.prototype.toHexString = function () {
  71750. var intR = (this.r * 255) | 0;
  71751. var intG = (this.g * 255) | 0;
  71752. var intB = (this.b * 255) | 0;
  71753. var intA = (this.a * 255) | 0;
  71754. 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);
  71755. };
  71756. /**
  71757. * Computes a new Color4 converted from the current one to linear space
  71758. * @returns a new Color4 object
  71759. */
  71760. Color4.prototype.toLinearSpace = function () {
  71761. var convertedColor = new Color4();
  71762. this.toLinearSpaceToRef(convertedColor);
  71763. return convertedColor;
  71764. };
  71765. /**
  71766. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  71767. * @param convertedColor defines the Color4 object where to store the linear space version
  71768. * @returns the unmodified Color4
  71769. */
  71770. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  71771. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  71772. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  71773. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  71774. convertedColor.a = this.a;
  71775. return this;
  71776. };
  71777. /**
  71778. * Computes a new Color4 converted from the current one to gamma space
  71779. * @returns a new Color4 object
  71780. */
  71781. Color4.prototype.toGammaSpace = function () {
  71782. var convertedColor = new Color4();
  71783. this.toGammaSpaceToRef(convertedColor);
  71784. return convertedColor;
  71785. };
  71786. /**
  71787. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  71788. * @param convertedColor defines the Color4 object where to store the gamma space version
  71789. * @returns the unmodified Color4
  71790. */
  71791. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  71792. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  71793. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  71794. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  71795. convertedColor.a = this.a;
  71796. return this;
  71797. };
  71798. // Statics
  71799. /**
  71800. * Creates a new Color4 from the string containing valid hexadecimal values
  71801. * @param hex defines a string containing valid hexadecimal values
  71802. * @returns a new Color4 object
  71803. */
  71804. Color4.FromHexString = function (hex) {
  71805. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  71806. return new Color4(0.0, 0.0, 0.0, 0.0);
  71807. }
  71808. var r = parseInt(hex.substring(1, 3), 16);
  71809. var g = parseInt(hex.substring(3, 5), 16);
  71810. var b = parseInt(hex.substring(5, 7), 16);
  71811. var a = parseInt(hex.substring(7, 9), 16);
  71812. return Color4.FromInts(r, g, b, a);
  71813. };
  71814. /**
  71815. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71816. * @param left defines the start value
  71817. * @param right defines the end value
  71818. * @param amount defines the gradient factor
  71819. * @returns a new Color4 object
  71820. */
  71821. Color4.Lerp = function (left, right, amount) {
  71822. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  71823. Color4.LerpToRef(left, right, amount, result);
  71824. return result;
  71825. };
  71826. /**
  71827. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71828. * @param left defines the start value
  71829. * @param right defines the end value
  71830. * @param amount defines the gradient factor
  71831. * @param result defines the Color4 object where to store data
  71832. */
  71833. Color4.LerpToRef = function (left, right, amount, result) {
  71834. result.r = left.r + (right.r - left.r) * amount;
  71835. result.g = left.g + (right.g - left.g) * amount;
  71836. result.b = left.b + (right.b - left.b) * amount;
  71837. result.a = left.a + (right.a - left.a) * amount;
  71838. };
  71839. /**
  71840. * Creates a new Color4 from a Color3 and an alpha value
  71841. * @param color3 defines the source Color3 to read from
  71842. * @param alpha defines the alpha component (1.0 by default)
  71843. * @returns a new Color4 object
  71844. */
  71845. Color4.FromColor3 = function (color3, alpha) {
  71846. if (alpha === void 0) { alpha = 1.0; }
  71847. return new Color4(color3.r, color3.g, color3.b, alpha);
  71848. };
  71849. /**
  71850. * Creates a new Color4 from the starting index element of the given array
  71851. * @param array defines the source array to read from
  71852. * @param offset defines the offset in the source array
  71853. * @returns a new Color4 object
  71854. */
  71855. Color4.FromArray = function (array, offset) {
  71856. if (offset === void 0) { offset = 0; }
  71857. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  71858. };
  71859. /**
  71860. * Creates a new Color3 from integer values (< 256)
  71861. * @param r defines the red component to read from (value between 0 and 255)
  71862. * @param g defines the green component to read from (value between 0 and 255)
  71863. * @param b defines the blue component to read from (value between 0 and 255)
  71864. * @param a defines the alpha component to read from (value between 0 and 255)
  71865. * @returns a new Color3 object
  71866. */
  71867. Color4.FromInts = function (r, g, b, a) {
  71868. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  71869. };
  71870. /**
  71871. * Check the content of a given array and convert it to an array containing RGBA data
  71872. * If the original array was already containing count * 4 values then it is returned directly
  71873. * @param colors defines the array to check
  71874. * @param count defines the number of RGBA data to expect
  71875. * @returns an array containing count * 4 values (RGBA)
  71876. */
  71877. Color4.CheckColors4 = function (colors, count) {
  71878. // Check if color3 was used
  71879. if (colors.length === count * 3) {
  71880. var colors4 = [];
  71881. for (var index = 0; index < colors.length; index += 3) {
  71882. var newIndex = (index / 3) * 4;
  71883. colors4[newIndex] = colors[index];
  71884. colors4[newIndex + 1] = colors[index + 1];
  71885. colors4[newIndex + 2] = colors[index + 2];
  71886. colors4[newIndex + 3] = 1.0;
  71887. }
  71888. return colors4;
  71889. }
  71890. return colors;
  71891. };
  71892. return Color4;
  71893. }());
  71894. /**
  71895. * Class representing a vector containing 2 coordinates
  71896. */
  71897. var Vector2 = /** @class */ (function () {
  71898. /**
  71899. * Creates a new Vector2 from the given x and y coordinates
  71900. * @param x defines the first coordinate
  71901. * @param y defines the second coordinate
  71902. */
  71903. function Vector2(
  71904. /** defines the first coordinate */
  71905. x,
  71906. /** defines the second coordinate */
  71907. y) {
  71908. if (x === void 0) { x = 0; }
  71909. if (y === void 0) { y = 0; }
  71910. this.x = x;
  71911. this.y = y;
  71912. }
  71913. /**
  71914. * Gets a string with the Vector2 coordinates
  71915. * @returns a string with the Vector2 coordinates
  71916. */
  71917. Vector2.prototype.toString = function () {
  71918. return "{X: " + this.x + " Y:" + this.y + "}";
  71919. };
  71920. /**
  71921. * Gets class name
  71922. * @returns the string "Vector2"
  71923. */
  71924. Vector2.prototype.getClassName = function () {
  71925. return "Vector2";
  71926. };
  71927. /**
  71928. * Gets current vector hash code
  71929. * @returns the Vector2 hash code as a number
  71930. */
  71931. Vector2.prototype.getHashCode = function () {
  71932. var hash = this.x || 0;
  71933. hash = (hash * 397) ^ (this.y || 0);
  71934. return hash;
  71935. };
  71936. // Operators
  71937. /**
  71938. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  71939. * @param array defines the source array
  71940. * @param index defines the offset in source array
  71941. * @returns the current Vector2
  71942. */
  71943. Vector2.prototype.toArray = function (array, index) {
  71944. if (index === void 0) { index = 0; }
  71945. array[index] = this.x;
  71946. array[index + 1] = this.y;
  71947. return this;
  71948. };
  71949. /**
  71950. * Copy the current vector to an array
  71951. * @returns a new array with 2 elements: the Vector2 coordinates.
  71952. */
  71953. Vector2.prototype.asArray = function () {
  71954. var result = new Array();
  71955. this.toArray(result, 0);
  71956. return result;
  71957. };
  71958. /**
  71959. * Sets the Vector2 coordinates with the given Vector2 coordinates
  71960. * @param source defines the source Vector2
  71961. * @returns the current updated Vector2
  71962. */
  71963. Vector2.prototype.copyFrom = function (source) {
  71964. this.x = source.x;
  71965. this.y = source.y;
  71966. return this;
  71967. };
  71968. /**
  71969. * Sets the Vector2 coordinates with the given floats
  71970. * @param x defines the first coordinate
  71971. * @param y defines the second coordinate
  71972. * @returns the current updated Vector2
  71973. */
  71974. Vector2.prototype.copyFromFloats = function (x, y) {
  71975. this.x = x;
  71976. this.y = y;
  71977. return this;
  71978. };
  71979. /**
  71980. * Sets the Vector2 coordinates with the given floats
  71981. * @param x defines the first coordinate
  71982. * @param y defines the second coordinate
  71983. * @returns the current updated Vector2
  71984. */
  71985. Vector2.prototype.set = function (x, y) {
  71986. return this.copyFromFloats(x, y);
  71987. };
  71988. /**
  71989. * Add another vector with the current one
  71990. * @param otherVector defines the other vector
  71991. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  71992. */
  71993. Vector2.prototype.add = function (otherVector) {
  71994. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  71995. };
  71996. /**
  71997. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  71998. * @param otherVector defines the other vector
  71999. * @param result defines the target vector
  72000. * @returns the unmodified current Vector2
  72001. */
  72002. Vector2.prototype.addToRef = function (otherVector, result) {
  72003. result.x = this.x + otherVector.x;
  72004. result.y = this.y + otherVector.y;
  72005. return this;
  72006. };
  72007. /**
  72008. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  72009. * @param otherVector defines the other vector
  72010. * @returns the current updated Vector2
  72011. */
  72012. Vector2.prototype.addInPlace = function (otherVector) {
  72013. this.x += otherVector.x;
  72014. this.y += otherVector.y;
  72015. return this;
  72016. };
  72017. /**
  72018. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  72019. * @param otherVector defines the other vector
  72020. * @returns a new Vector2
  72021. */
  72022. Vector2.prototype.addVector3 = function (otherVector) {
  72023. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  72024. };
  72025. /**
  72026. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  72027. * @param otherVector defines the other vector
  72028. * @returns a new Vector2
  72029. */
  72030. Vector2.prototype.subtract = function (otherVector) {
  72031. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  72032. };
  72033. /**
  72034. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  72035. * @param otherVector defines the other vector
  72036. * @param result defines the target vector
  72037. * @returns the unmodified current Vector2
  72038. */
  72039. Vector2.prototype.subtractToRef = function (otherVector, result) {
  72040. result.x = this.x - otherVector.x;
  72041. result.y = this.y - otherVector.y;
  72042. return this;
  72043. };
  72044. /**
  72045. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  72046. * @param otherVector defines the other vector
  72047. * @returns the current updated Vector2
  72048. */
  72049. Vector2.prototype.subtractInPlace = function (otherVector) {
  72050. this.x -= otherVector.x;
  72051. this.y -= otherVector.y;
  72052. return this;
  72053. };
  72054. /**
  72055. * Multiplies in place the current Vector2 coordinates by the given ones
  72056. * @param otherVector defines the other vector
  72057. * @returns the current updated Vector2
  72058. */
  72059. Vector2.prototype.multiplyInPlace = function (otherVector) {
  72060. this.x *= otherVector.x;
  72061. this.y *= otherVector.y;
  72062. return this;
  72063. };
  72064. /**
  72065. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  72066. * @param otherVector defines the other vector
  72067. * @returns a new Vector2
  72068. */
  72069. Vector2.prototype.multiply = function (otherVector) {
  72070. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  72071. };
  72072. /**
  72073. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  72074. * @param otherVector defines the other vector
  72075. * @param result defines the target vector
  72076. * @returns the unmodified current Vector2
  72077. */
  72078. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  72079. result.x = this.x * otherVector.x;
  72080. result.y = this.y * otherVector.y;
  72081. return this;
  72082. };
  72083. /**
  72084. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  72085. * @param x defines the first coordinate
  72086. * @param y defines the second coordinate
  72087. * @returns a new Vector2
  72088. */
  72089. Vector2.prototype.multiplyByFloats = function (x, y) {
  72090. return new Vector2(this.x * x, this.y * y);
  72091. };
  72092. /**
  72093. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  72094. * @param otherVector defines the other vector
  72095. * @returns a new Vector2
  72096. */
  72097. Vector2.prototype.divide = function (otherVector) {
  72098. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  72099. };
  72100. /**
  72101. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  72102. * @param otherVector defines the other vector
  72103. * @param result defines the target vector
  72104. * @returns the unmodified current Vector2
  72105. */
  72106. Vector2.prototype.divideToRef = function (otherVector, result) {
  72107. result.x = this.x / otherVector.x;
  72108. result.y = this.y / otherVector.y;
  72109. return this;
  72110. };
  72111. /**
  72112. * Divides the current Vector2 coordinates by the given ones
  72113. * @param otherVector defines the other vector
  72114. * @returns the current updated Vector2
  72115. */
  72116. Vector2.prototype.divideInPlace = function (otherVector) {
  72117. return this.divideToRef(otherVector, this);
  72118. };
  72119. /**
  72120. * Gets a new Vector2 with current Vector2 negated coordinates
  72121. * @returns a new Vector2
  72122. */
  72123. Vector2.prototype.negate = function () {
  72124. return new Vector2(-this.x, -this.y);
  72125. };
  72126. /**
  72127. * Multiply the Vector2 coordinates by scale
  72128. * @param scale defines the scaling factor
  72129. * @returns the current updated Vector2
  72130. */
  72131. Vector2.prototype.scaleInPlace = function (scale) {
  72132. this.x *= scale;
  72133. this.y *= scale;
  72134. return this;
  72135. };
  72136. /**
  72137. * Returns a new Vector2 scaled by "scale" from the current Vector2
  72138. * @param scale defines the scaling factor
  72139. * @returns a new Vector2
  72140. */
  72141. Vector2.prototype.scale = function (scale) {
  72142. var result = new Vector2(0, 0);
  72143. this.scaleToRef(scale, result);
  72144. return result;
  72145. };
  72146. /**
  72147. * Scale the current Vector2 values by a factor to a given Vector2
  72148. * @param scale defines the scale factor
  72149. * @param result defines the Vector2 object where to store the result
  72150. * @returns the unmodified current Vector2
  72151. */
  72152. Vector2.prototype.scaleToRef = function (scale, result) {
  72153. result.x = this.x * scale;
  72154. result.y = this.y * scale;
  72155. return this;
  72156. };
  72157. /**
  72158. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  72159. * @param scale defines the scale factor
  72160. * @param result defines the Vector2 object where to store the result
  72161. * @returns the unmodified current Vector2
  72162. */
  72163. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  72164. result.x += this.x * scale;
  72165. result.y += this.y * scale;
  72166. return this;
  72167. };
  72168. /**
  72169. * Gets a boolean if two vectors are equals
  72170. * @param otherVector defines the other vector
  72171. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  72172. */
  72173. Vector2.prototype.equals = function (otherVector) {
  72174. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  72175. };
  72176. /**
  72177. * Gets a boolean if two vectors are equals (using an epsilon value)
  72178. * @param otherVector defines the other vector
  72179. * @param epsilon defines the minimal distance to consider equality
  72180. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  72181. */
  72182. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  72183. if (epsilon === void 0) { epsilon = Epsilon; }
  72184. 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);
  72185. };
  72186. /**
  72187. * Gets a new Vector2 from current Vector2 floored values
  72188. * @returns a new Vector2
  72189. */
  72190. Vector2.prototype.floor = function () {
  72191. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  72192. };
  72193. /**
  72194. * Gets a new Vector2 from current Vector2 floored values
  72195. * @returns a new Vector2
  72196. */
  72197. Vector2.prototype.fract = function () {
  72198. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  72199. };
  72200. // Properties
  72201. /**
  72202. * Gets the length of the vector
  72203. * @returns the vector length (float)
  72204. */
  72205. Vector2.prototype.length = function () {
  72206. return Math.sqrt(this.x * this.x + this.y * this.y);
  72207. };
  72208. /**
  72209. * Gets the vector squared length
  72210. * @returns the vector squared length (float)
  72211. */
  72212. Vector2.prototype.lengthSquared = function () {
  72213. return (this.x * this.x + this.y * this.y);
  72214. };
  72215. // Methods
  72216. /**
  72217. * Normalize the vector
  72218. * @returns the current updated Vector2
  72219. */
  72220. Vector2.prototype.normalize = function () {
  72221. var len = this.length();
  72222. if (len === 0) {
  72223. return this;
  72224. }
  72225. var num = 1.0 / len;
  72226. this.x *= num;
  72227. this.y *= num;
  72228. return this;
  72229. };
  72230. /**
  72231. * Gets a new Vector2 copied from the Vector2
  72232. * @returns a new Vector2
  72233. */
  72234. Vector2.prototype.clone = function () {
  72235. return new Vector2(this.x, this.y);
  72236. };
  72237. // Statics
  72238. /**
  72239. * Gets a new Vector2(0, 0)
  72240. * @returns a new Vector2
  72241. */
  72242. Vector2.Zero = function () {
  72243. return new Vector2(0, 0);
  72244. };
  72245. /**
  72246. * Gets a new Vector2(1, 1)
  72247. * @returns a new Vector2
  72248. */
  72249. Vector2.One = function () {
  72250. return new Vector2(1, 1);
  72251. };
  72252. /**
  72253. * Gets a new Vector2 set from the given index element of the given array
  72254. * @param array defines the data source
  72255. * @param offset defines the offset in the data source
  72256. * @returns a new Vector2
  72257. */
  72258. Vector2.FromArray = function (array, offset) {
  72259. if (offset === void 0) { offset = 0; }
  72260. return new Vector2(array[offset], array[offset + 1]);
  72261. };
  72262. /**
  72263. * Sets "result" from the given index element of the given array
  72264. * @param array defines the data source
  72265. * @param offset defines the offset in the data source
  72266. * @param result defines the target vector
  72267. */
  72268. Vector2.FromArrayToRef = function (array, offset, result) {
  72269. result.x = array[offset];
  72270. result.y = array[offset + 1];
  72271. };
  72272. /**
  72273. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  72274. * @param value1 defines 1st point of control
  72275. * @param value2 defines 2nd point of control
  72276. * @param value3 defines 3rd point of control
  72277. * @param value4 defines 4th point of control
  72278. * @param amount defines the interpolation factor
  72279. * @returns a new Vector2
  72280. */
  72281. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  72282. var squared = amount * amount;
  72283. var cubed = amount * squared;
  72284. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  72285. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  72286. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  72287. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  72288. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  72289. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  72290. return new Vector2(x, y);
  72291. };
  72292. /**
  72293. * 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".
  72294. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  72295. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  72296. * @param value defines the value to clamp
  72297. * @param min defines the lower limit
  72298. * @param max defines the upper limit
  72299. * @returns a new Vector2
  72300. */
  72301. Vector2.Clamp = function (value, min, max) {
  72302. var x = value.x;
  72303. x = (x > max.x) ? max.x : x;
  72304. x = (x < min.x) ? min.x : x;
  72305. var y = value.y;
  72306. y = (y > max.y) ? max.y : y;
  72307. y = (y < min.y) ? min.y : y;
  72308. return new Vector2(x, y);
  72309. };
  72310. /**
  72311. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  72312. * @param value1 defines the 1st control point
  72313. * @param tangent1 defines the outgoing tangent
  72314. * @param value2 defines the 2nd control point
  72315. * @param tangent2 defines the incoming tangent
  72316. * @param amount defines the interpolation factor
  72317. * @returns a new Vector2
  72318. */
  72319. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  72320. var squared = amount * amount;
  72321. var cubed = amount * squared;
  72322. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  72323. var part2 = (-2.0 * cubed) + (3.0 * squared);
  72324. var part3 = (cubed - (2.0 * squared)) + amount;
  72325. var part4 = cubed - squared;
  72326. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  72327. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  72328. return new Vector2(x, y);
  72329. };
  72330. /**
  72331. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  72332. * @param start defines the start vector
  72333. * @param end defines the end vector
  72334. * @param amount defines the interpolation factor
  72335. * @returns a new Vector2
  72336. */
  72337. Vector2.Lerp = function (start, end, amount) {
  72338. var x = start.x + ((end.x - start.x) * amount);
  72339. var y = start.y + ((end.y - start.y) * amount);
  72340. return new Vector2(x, y);
  72341. };
  72342. /**
  72343. * Gets the dot product of the vector "left" and the vector "right"
  72344. * @param left defines first vector
  72345. * @param right defines second vector
  72346. * @returns the dot product (float)
  72347. */
  72348. Vector2.Dot = function (left, right) {
  72349. return left.x * right.x + left.y * right.y;
  72350. };
  72351. /**
  72352. * Returns a new Vector2 equal to the normalized given vector
  72353. * @param vector defines the vector to normalize
  72354. * @returns a new Vector2
  72355. */
  72356. Vector2.Normalize = function (vector) {
  72357. var newVector = vector.clone();
  72358. newVector.normalize();
  72359. return newVector;
  72360. };
  72361. /**
  72362. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  72363. * @param left defines 1st vector
  72364. * @param right defines 2nd vector
  72365. * @returns a new Vector2
  72366. */
  72367. Vector2.Minimize = function (left, right) {
  72368. var x = (left.x < right.x) ? left.x : right.x;
  72369. var y = (left.y < right.y) ? left.y : right.y;
  72370. return new Vector2(x, y);
  72371. };
  72372. /**
  72373. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  72374. * @param left defines 1st vector
  72375. * @param right defines 2nd vector
  72376. * @returns a new Vector2
  72377. */
  72378. Vector2.Maximize = function (left, right) {
  72379. var x = (left.x > right.x) ? left.x : right.x;
  72380. var y = (left.y > right.y) ? left.y : right.y;
  72381. return new Vector2(x, y);
  72382. };
  72383. /**
  72384. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  72385. * @param vector defines the vector to transform
  72386. * @param transformation defines the matrix to apply
  72387. * @returns a new Vector2
  72388. */
  72389. Vector2.Transform = function (vector, transformation) {
  72390. var r = Vector2.Zero();
  72391. Vector2.TransformToRef(vector, transformation, r);
  72392. return r;
  72393. };
  72394. /**
  72395. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  72396. * @param vector defines the vector to transform
  72397. * @param transformation defines the matrix to apply
  72398. * @param result defines the target vector
  72399. */
  72400. Vector2.TransformToRef = function (vector, transformation, result) {
  72401. var m = transformation.m;
  72402. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  72403. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  72404. result.x = x;
  72405. result.y = y;
  72406. };
  72407. /**
  72408. * Determines if a given vector is included in a triangle
  72409. * @param p defines the vector to test
  72410. * @param p0 defines 1st triangle point
  72411. * @param p1 defines 2nd triangle point
  72412. * @param p2 defines 3rd triangle point
  72413. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  72414. */
  72415. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  72416. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  72417. var sign = a < 0 ? -1 : 1;
  72418. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  72419. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  72420. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  72421. };
  72422. /**
  72423. * Gets the distance between the vectors "value1" and "value2"
  72424. * @param value1 defines first vector
  72425. * @param value2 defines second vector
  72426. * @returns the distance between vectors
  72427. */
  72428. Vector2.Distance = function (value1, value2) {
  72429. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  72430. };
  72431. /**
  72432. * Returns the squared distance between the vectors "value1" and "value2"
  72433. * @param value1 defines first vector
  72434. * @param value2 defines second vector
  72435. * @returns the squared distance between vectors
  72436. */
  72437. Vector2.DistanceSquared = function (value1, value2) {
  72438. var x = value1.x - value2.x;
  72439. var y = value1.y - value2.y;
  72440. return (x * x) + (y * y);
  72441. };
  72442. /**
  72443. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  72444. * @param value1 defines first vector
  72445. * @param value2 defines second vector
  72446. * @returns a new Vector2
  72447. */
  72448. Vector2.Center = function (value1, value2) {
  72449. var center = value1.add(value2);
  72450. center.scaleInPlace(0.5);
  72451. return center;
  72452. };
  72453. /**
  72454. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  72455. * @param p defines the middle point
  72456. * @param segA defines one point of the segment
  72457. * @param segB defines the other point of the segment
  72458. * @returns the shortest distance
  72459. */
  72460. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  72461. var l2 = Vector2.DistanceSquared(segA, segB);
  72462. if (l2 === 0.0) {
  72463. return Vector2.Distance(p, segA);
  72464. }
  72465. var v = segB.subtract(segA);
  72466. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  72467. var proj = segA.add(v.multiplyByFloats(t, t));
  72468. return Vector2.Distance(p, proj);
  72469. };
  72470. return Vector2;
  72471. }());
  72472. /**
  72473. * Classed used to store (x,y,z) vector representation
  72474. * A Vector3 is the main object used in 3D geometry
  72475. * It can represent etiher the coordinates of a point the space, either a direction
  72476. * Reminder: js uses a left handed forward facing system
  72477. */
  72478. var Vector3 = /** @class */ (function () {
  72479. /**
  72480. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  72481. * @param x defines the first coordinates (on X axis)
  72482. * @param y defines the second coordinates (on Y axis)
  72483. * @param z defines the third coordinates (on Z axis)
  72484. */
  72485. function Vector3(
  72486. /**
  72487. * Defines the first coordinates (on X axis)
  72488. */
  72489. x,
  72490. /**
  72491. * Defines the second coordinates (on Y axis)
  72492. */
  72493. y,
  72494. /**
  72495. * Defines the third coordinates (on Z axis)
  72496. */
  72497. z) {
  72498. if (x === void 0) { x = 0; }
  72499. if (y === void 0) { y = 0; }
  72500. if (z === void 0) { z = 0; }
  72501. this.x = x;
  72502. this.y = y;
  72503. this.z = z;
  72504. }
  72505. /**
  72506. * Creates a string representation of the Vector3
  72507. * @returns a string with the Vector3 coordinates.
  72508. */
  72509. Vector3.prototype.toString = function () {
  72510. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  72511. };
  72512. /**
  72513. * Gets the class name
  72514. * @returns the string "Vector3"
  72515. */
  72516. Vector3.prototype.getClassName = function () {
  72517. return "Vector3";
  72518. };
  72519. /**
  72520. * Creates the Vector3 hash code
  72521. * @returns a number which tends to be unique between Vector3 instances
  72522. */
  72523. Vector3.prototype.getHashCode = function () {
  72524. var hash = this.x || 0;
  72525. hash = (hash * 397) ^ (this.y || 0);
  72526. hash = (hash * 397) ^ (this.z || 0);
  72527. return hash;
  72528. };
  72529. // Operators
  72530. /**
  72531. * Creates an array containing three elements : the coordinates of the Vector3
  72532. * @returns a new array of numbers
  72533. */
  72534. Vector3.prototype.asArray = function () {
  72535. var result = [];
  72536. this.toArray(result, 0);
  72537. return result;
  72538. };
  72539. /**
  72540. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  72541. * @param array defines the destination array
  72542. * @param index defines the offset in the destination array
  72543. * @returns the current Vector3
  72544. */
  72545. Vector3.prototype.toArray = function (array, index) {
  72546. if (index === void 0) { index = 0; }
  72547. array[index] = this.x;
  72548. array[index + 1] = this.y;
  72549. array[index + 2] = this.z;
  72550. return this;
  72551. };
  72552. /**
  72553. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  72554. * @returns a new Quaternion object, computed from the Vector3 coordinates
  72555. */
  72556. Vector3.prototype.toQuaternion = function () {
  72557. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  72558. };
  72559. /**
  72560. * Adds the given vector to the current Vector3
  72561. * @param otherVector defines the second operand
  72562. * @returns the current updated Vector3
  72563. */
  72564. Vector3.prototype.addInPlace = function (otherVector) {
  72565. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  72566. };
  72567. /**
  72568. * Adds the given coordinates to the current Vector3
  72569. * @param x defines the x coordinate of the operand
  72570. * @param y defines the y coordinate of the operand
  72571. * @param z defines the z coordinate of the operand
  72572. * @returns the current updated Vector3
  72573. */
  72574. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  72575. this.x += x;
  72576. this.y += y;
  72577. this.z += z;
  72578. return this;
  72579. };
  72580. /**
  72581. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  72582. * @param otherVector defines the second operand
  72583. * @returns the resulting Vector3
  72584. */
  72585. Vector3.prototype.add = function (otherVector) {
  72586. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  72587. };
  72588. /**
  72589. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  72590. * @param otherVector defines the second operand
  72591. * @param result defines the Vector3 object where to store the result
  72592. * @returns the current Vector3
  72593. */
  72594. Vector3.prototype.addToRef = function (otherVector, result) {
  72595. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  72596. };
  72597. /**
  72598. * Subtract the given vector from the current Vector3
  72599. * @param otherVector defines the second operand
  72600. * @returns the current updated Vector3
  72601. */
  72602. Vector3.prototype.subtractInPlace = function (otherVector) {
  72603. this.x -= otherVector.x;
  72604. this.y -= otherVector.y;
  72605. this.z -= otherVector.z;
  72606. return this;
  72607. };
  72608. /**
  72609. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  72610. * @param otherVector defines the second operand
  72611. * @returns the resulting Vector3
  72612. */
  72613. Vector3.prototype.subtract = function (otherVector) {
  72614. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  72615. };
  72616. /**
  72617. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  72618. * @param otherVector defines the second operand
  72619. * @param result defines the Vector3 object where to store the result
  72620. * @returns the current Vector3
  72621. */
  72622. Vector3.prototype.subtractToRef = function (otherVector, result) {
  72623. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  72624. };
  72625. /**
  72626. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  72627. * @param x defines the x coordinate of the operand
  72628. * @param y defines the y coordinate of the operand
  72629. * @param z defines the z coordinate of the operand
  72630. * @returns the resulting Vector3
  72631. */
  72632. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  72633. return new Vector3(this.x - x, this.y - y, this.z - z);
  72634. };
  72635. /**
  72636. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  72637. * @param x defines the x coordinate of the operand
  72638. * @param y defines the y coordinate of the operand
  72639. * @param z defines the z coordinate of the operand
  72640. * @param result defines the Vector3 object where to store the result
  72641. * @returns the current Vector3
  72642. */
  72643. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  72644. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  72645. };
  72646. /**
  72647. * Gets a new Vector3 set with the current Vector3 negated coordinates
  72648. * @returns a new Vector3
  72649. */
  72650. Vector3.prototype.negate = function () {
  72651. return new Vector3(-this.x, -this.y, -this.z);
  72652. };
  72653. /**
  72654. * Multiplies the Vector3 coordinates by the float "scale"
  72655. * @param scale defines the multiplier factor
  72656. * @returns the current updated Vector3
  72657. */
  72658. Vector3.prototype.scaleInPlace = function (scale) {
  72659. this.x *= scale;
  72660. this.y *= scale;
  72661. this.z *= scale;
  72662. return this;
  72663. };
  72664. /**
  72665. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  72666. * @param scale defines the multiplier factor
  72667. * @returns a new Vector3
  72668. */
  72669. Vector3.prototype.scale = function (scale) {
  72670. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  72671. };
  72672. /**
  72673. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  72674. * @param scale defines the multiplier factor
  72675. * @param result defines the Vector3 object where to store the result
  72676. * @returns the current Vector3
  72677. */
  72678. Vector3.prototype.scaleToRef = function (scale, result) {
  72679. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  72680. };
  72681. /**
  72682. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  72683. * @param scale defines the scale factor
  72684. * @param result defines the Vector3 object where to store the result
  72685. * @returns the unmodified current Vector3
  72686. */
  72687. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  72688. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  72689. };
  72690. /**
  72691. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  72692. * @param otherVector defines the second operand
  72693. * @returns true if both vectors are equals
  72694. */
  72695. Vector3.prototype.equals = function (otherVector) {
  72696. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  72697. };
  72698. /**
  72699. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  72700. * @param otherVector defines the second operand
  72701. * @param epsilon defines the minimal distance to define values as equals
  72702. * @returns true if both vectors are distant less than epsilon
  72703. */
  72704. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  72705. if (epsilon === void 0) { epsilon = Epsilon; }
  72706. 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);
  72707. };
  72708. /**
  72709. * Returns true if the current Vector3 coordinates equals the given floats
  72710. * @param x defines the x coordinate of the operand
  72711. * @param y defines the y coordinate of the operand
  72712. * @param z defines the z coordinate of the operand
  72713. * @returns true if both vectors are equals
  72714. */
  72715. Vector3.prototype.equalsToFloats = function (x, y, z) {
  72716. return this.x === x && this.y === y && this.z === z;
  72717. };
  72718. /**
  72719. * Multiplies the current Vector3 coordinates by the given ones
  72720. * @param otherVector defines the second operand
  72721. * @returns the current updated Vector3
  72722. */
  72723. Vector3.prototype.multiplyInPlace = function (otherVector) {
  72724. this.x *= otherVector.x;
  72725. this.y *= otherVector.y;
  72726. this.z *= otherVector.z;
  72727. return this;
  72728. };
  72729. /**
  72730. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  72731. * @param otherVector defines the second operand
  72732. * @returns the new Vector3
  72733. */
  72734. Vector3.prototype.multiply = function (otherVector) {
  72735. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  72736. };
  72737. /**
  72738. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  72739. * @param otherVector defines the second operand
  72740. * @param result defines the Vector3 object where to store the result
  72741. * @returns the current Vector3
  72742. */
  72743. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  72744. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  72745. };
  72746. /**
  72747. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  72748. * @param x defines the x coordinate of the operand
  72749. * @param y defines the y coordinate of the operand
  72750. * @param z defines the z coordinate of the operand
  72751. * @returns the new Vector3
  72752. */
  72753. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  72754. return new Vector3(this.x * x, this.y * y, this.z * z);
  72755. };
  72756. /**
  72757. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  72758. * @param otherVector defines the second operand
  72759. * @returns the new Vector3
  72760. */
  72761. Vector3.prototype.divide = function (otherVector) {
  72762. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  72763. };
  72764. /**
  72765. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  72766. * @param otherVector defines the second operand
  72767. * @param result defines the Vector3 object where to store the result
  72768. * @returns the current Vector3
  72769. */
  72770. Vector3.prototype.divideToRef = function (otherVector, result) {
  72771. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  72772. };
  72773. /**
  72774. * Divides the current Vector3 coordinates by the given ones.
  72775. * @param otherVector defines the second operand
  72776. * @returns the current updated Vector3
  72777. */
  72778. Vector3.prototype.divideInPlace = function (otherVector) {
  72779. return this.divideToRef(otherVector, this);
  72780. };
  72781. /**
  72782. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  72783. * @param other defines the second operand
  72784. * @returns the current updated Vector3
  72785. */
  72786. Vector3.prototype.minimizeInPlace = function (other) {
  72787. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  72788. };
  72789. /**
  72790. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  72791. * @param other defines the second operand
  72792. * @returns the current updated Vector3
  72793. */
  72794. Vector3.prototype.maximizeInPlace = function (other) {
  72795. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  72796. };
  72797. /**
  72798. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  72799. * @param x defines the x coordinate of the operand
  72800. * @param y defines the y coordinate of the operand
  72801. * @param z defines the z coordinate of the operand
  72802. * @returns the current updated Vector3
  72803. */
  72804. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  72805. if (x < this.x) {
  72806. this.x = x;
  72807. }
  72808. if (y < this.y) {
  72809. this.y = y;
  72810. }
  72811. if (z < this.z) {
  72812. this.z = z;
  72813. }
  72814. return this;
  72815. };
  72816. /**
  72817. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  72818. * @param x defines the x coordinate of the operand
  72819. * @param y defines the y coordinate of the operand
  72820. * @param z defines the z coordinate of the operand
  72821. * @returns the current updated Vector3
  72822. */
  72823. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  72824. if (x > this.x) {
  72825. this.x = x;
  72826. }
  72827. if (y > this.y) {
  72828. this.y = y;
  72829. }
  72830. if (z > this.z) {
  72831. this.z = z;
  72832. }
  72833. return this;
  72834. };
  72835. /**
  72836. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  72837. * Check if is non uniform within a certain amount of decimal places to account for this
  72838. * @param epsilon the amount the values can differ
  72839. * @returns if the the vector is non uniform to a certain number of decimal places
  72840. */
  72841. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  72842. var absX = Math.abs(this.x);
  72843. var absY = Math.abs(this.y);
  72844. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  72845. return true;
  72846. }
  72847. var absZ = Math.abs(this.z);
  72848. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  72849. return true;
  72850. }
  72851. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  72852. return true;
  72853. }
  72854. return false;
  72855. };
  72856. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  72857. /**
  72858. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  72859. */
  72860. get: function () {
  72861. var absX = Math.abs(this.x);
  72862. var absY = Math.abs(this.y);
  72863. if (absX !== absY) {
  72864. return true;
  72865. }
  72866. var absZ = Math.abs(this.z);
  72867. if (absX !== absZ) {
  72868. return true;
  72869. }
  72870. if (absY !== absZ) {
  72871. return true;
  72872. }
  72873. return false;
  72874. },
  72875. enumerable: true,
  72876. configurable: true
  72877. });
  72878. /**
  72879. * Gets a new Vector3 from current Vector3 floored values
  72880. * @returns a new Vector3
  72881. */
  72882. Vector3.prototype.floor = function () {
  72883. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  72884. };
  72885. /**
  72886. * Gets a new Vector3 from current Vector3 floored values
  72887. * @returns a new Vector3
  72888. */
  72889. Vector3.prototype.fract = function () {
  72890. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  72891. };
  72892. // Properties
  72893. /**
  72894. * Gets the length of the Vector3
  72895. * @returns the length of the Vecto3
  72896. */
  72897. Vector3.prototype.length = function () {
  72898. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  72899. };
  72900. /**
  72901. * Gets the squared length of the Vector3
  72902. * @returns squared length of the Vector3
  72903. */
  72904. Vector3.prototype.lengthSquared = function () {
  72905. return (this.x * this.x + this.y * this.y + this.z * this.z);
  72906. };
  72907. /**
  72908. * Normalize the current Vector3.
  72909. * Please note that this is an in place operation.
  72910. * @returns the current updated Vector3
  72911. */
  72912. Vector3.prototype.normalize = function () {
  72913. return this.normalizeFromLength(this.length());
  72914. };
  72915. /**
  72916. * Reorders the x y z properties of the vector in place
  72917. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  72918. * @returns the current updated vector
  72919. */
  72920. Vector3.prototype.reorderInPlace = function (order) {
  72921. var _this = this;
  72922. order = order.toLowerCase();
  72923. if (order === "xyz") {
  72924. return this;
  72925. }
  72926. MathTmp.Vector3[0].copyFrom(this);
  72927. ["x", "y", "z"].forEach(function (val, i) {
  72928. _this[val] = MathTmp.Vector3[0][order[i]];
  72929. });
  72930. return this;
  72931. };
  72932. /**
  72933. * Rotates the vector around 0,0,0 by a quaternion
  72934. * @param quaternion the rotation quaternion
  72935. * @param result vector to store the result
  72936. * @returns the resulting vector
  72937. */
  72938. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  72939. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  72940. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  72941. return result;
  72942. };
  72943. /**
  72944. * Rotates a vector around a given point
  72945. * @param quaternion the rotation quaternion
  72946. * @param point the point to rotate around
  72947. * @param result vector to store the result
  72948. * @returns the resulting vector
  72949. */
  72950. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  72951. this.subtractToRef(point, MathTmp.Vector3[0]);
  72952. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  72953. point.addToRef(MathTmp.Vector3[0], result);
  72954. return result;
  72955. };
  72956. /**
  72957. * Normalize the current Vector3 with the given input length.
  72958. * Please note that this is an in place operation.
  72959. * @param len the length of the vector
  72960. * @returns the current updated Vector3
  72961. */
  72962. Vector3.prototype.normalizeFromLength = function (len) {
  72963. if (len === 0 || len === 1.0) {
  72964. return this;
  72965. }
  72966. return this.scaleInPlace(1.0 / len);
  72967. };
  72968. /**
  72969. * Normalize the current Vector3 to a new vector
  72970. * @returns the new Vector3
  72971. */
  72972. Vector3.prototype.normalizeToNew = function () {
  72973. var normalized = new Vector3(0, 0, 0);
  72974. this.normalizeToRef(normalized);
  72975. return normalized;
  72976. };
  72977. /**
  72978. * Normalize the current Vector3 to the reference
  72979. * @param reference define the Vector3 to update
  72980. * @returns the updated Vector3
  72981. */
  72982. Vector3.prototype.normalizeToRef = function (reference) {
  72983. var len = this.length();
  72984. if (len === 0 || len === 1.0) {
  72985. return reference.copyFromFloats(this.x, this.y, this.z);
  72986. }
  72987. return this.scaleToRef(1.0 / len, reference);
  72988. };
  72989. /**
  72990. * Creates a new Vector3 copied from the current Vector3
  72991. * @returns the new Vector3
  72992. */
  72993. Vector3.prototype.clone = function () {
  72994. return new Vector3(this.x, this.y, this.z);
  72995. };
  72996. /**
  72997. * Copies the given vector coordinates to the current Vector3 ones
  72998. * @param source defines the source Vector3
  72999. * @returns the current updated Vector3
  73000. */
  73001. Vector3.prototype.copyFrom = function (source) {
  73002. return this.copyFromFloats(source.x, source.y, source.z);
  73003. };
  73004. /**
  73005. * Copies the given floats to the current Vector3 coordinates
  73006. * @param x defines the x coordinate of the operand
  73007. * @param y defines the y coordinate of the operand
  73008. * @param z defines the z coordinate of the operand
  73009. * @returns the current updated Vector3
  73010. */
  73011. Vector3.prototype.copyFromFloats = function (x, y, z) {
  73012. this.x = x;
  73013. this.y = y;
  73014. this.z = z;
  73015. return this;
  73016. };
  73017. /**
  73018. * Copies the given floats to the current Vector3 coordinates
  73019. * @param x defines the x coordinate of the operand
  73020. * @param y defines the y coordinate of the operand
  73021. * @param z defines the z coordinate of the operand
  73022. * @returns the current updated Vector3
  73023. */
  73024. Vector3.prototype.set = function (x, y, z) {
  73025. return this.copyFromFloats(x, y, z);
  73026. };
  73027. /**
  73028. * Copies the given float to the current Vector3 coordinates
  73029. * @param v defines the x, y and z coordinates of the operand
  73030. * @returns the current updated Vector3
  73031. */
  73032. Vector3.prototype.setAll = function (v) {
  73033. this.x = this.y = this.z = v;
  73034. return this;
  73035. };
  73036. // Statics
  73037. /**
  73038. * Get the clip factor between two vectors
  73039. * @param vector0 defines the first operand
  73040. * @param vector1 defines the second operand
  73041. * @param axis defines the axis to use
  73042. * @param size defines the size along the axis
  73043. * @returns the clip factor
  73044. */
  73045. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  73046. var d0 = Vector3.Dot(vector0, axis) - size;
  73047. var d1 = Vector3.Dot(vector1, axis) - size;
  73048. var s = d0 / (d0 - d1);
  73049. return s;
  73050. };
  73051. /**
  73052. * Get angle between two vectors
  73053. * @param vector0 angle between vector0 and vector1
  73054. * @param vector1 angle between vector0 and vector1
  73055. * @param normal direction of the normal
  73056. * @return the angle between vector0 and vector1
  73057. */
  73058. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  73059. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  73060. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  73061. var dot = Vector3.Dot(v0, v1);
  73062. var n = MathTmp.Vector3[3];
  73063. Vector3.CrossToRef(v0, v1, n);
  73064. if (Vector3.Dot(n, normal) > 0) {
  73065. return Math.acos(dot);
  73066. }
  73067. return -Math.acos(dot);
  73068. };
  73069. /**
  73070. * Returns a new Vector3 set from the index "offset" of the given array
  73071. * @param array defines the source array
  73072. * @param offset defines the offset in the source array
  73073. * @returns the new Vector3
  73074. */
  73075. Vector3.FromArray = function (array, offset) {
  73076. if (offset === void 0) { offset = 0; }
  73077. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  73078. };
  73079. /**
  73080. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  73081. * This function is deprecated. Use FromArray instead
  73082. * @param array defines the source array
  73083. * @param offset defines the offset in the source array
  73084. * @returns the new Vector3
  73085. */
  73086. Vector3.FromFloatArray = function (array, offset) {
  73087. return Vector3.FromArray(array, offset);
  73088. };
  73089. /**
  73090. * Sets the given vector "result" with the element values from the index "offset" of the given array
  73091. * @param array defines the source array
  73092. * @param offset defines the offset in the source array
  73093. * @param result defines the Vector3 where to store the result
  73094. */
  73095. Vector3.FromArrayToRef = function (array, offset, result) {
  73096. result.x = array[offset];
  73097. result.y = array[offset + 1];
  73098. result.z = array[offset + 2];
  73099. };
  73100. /**
  73101. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  73102. * This function is deprecated. Use FromArrayToRef instead.
  73103. * @param array defines the source array
  73104. * @param offset defines the offset in the source array
  73105. * @param result defines the Vector3 where to store the result
  73106. */
  73107. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  73108. return Vector3.FromArrayToRef(array, offset, result);
  73109. };
  73110. /**
  73111. * Sets the given vector "result" with the given floats.
  73112. * @param x defines the x coordinate of the source
  73113. * @param y defines the y coordinate of the source
  73114. * @param z defines the z coordinate of the source
  73115. * @param result defines the Vector3 where to store the result
  73116. */
  73117. Vector3.FromFloatsToRef = function (x, y, z, result) {
  73118. result.copyFromFloats(x, y, z);
  73119. };
  73120. /**
  73121. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  73122. * @returns a new empty Vector3
  73123. */
  73124. Vector3.Zero = function () {
  73125. return new Vector3(0.0, 0.0, 0.0);
  73126. };
  73127. /**
  73128. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  73129. * @returns a new unit Vector3
  73130. */
  73131. Vector3.One = function () {
  73132. return new Vector3(1.0, 1.0, 1.0);
  73133. };
  73134. /**
  73135. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  73136. * @returns a new up Vector3
  73137. */
  73138. Vector3.Up = function () {
  73139. return new Vector3(0.0, 1.0, 0.0);
  73140. };
  73141. Object.defineProperty(Vector3, "UpReadOnly", {
  73142. /**
  73143. * Gets a up Vector3 that must not be updated
  73144. */
  73145. get: function () {
  73146. return Vector3._UpReadOnly;
  73147. },
  73148. enumerable: true,
  73149. configurable: true
  73150. });
  73151. /**
  73152. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  73153. * @returns a new down Vector3
  73154. */
  73155. Vector3.Down = function () {
  73156. return new Vector3(0.0, -1.0, 0.0);
  73157. };
  73158. /**
  73159. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  73160. * @returns a new forward Vector3
  73161. */
  73162. Vector3.Forward = function () {
  73163. return new Vector3(0.0, 0.0, 1.0);
  73164. };
  73165. /**
  73166. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  73167. * @returns a new forward Vector3
  73168. */
  73169. Vector3.Backward = function () {
  73170. return new Vector3(0.0, 0.0, -1.0);
  73171. };
  73172. /**
  73173. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  73174. * @returns a new right Vector3
  73175. */
  73176. Vector3.Right = function () {
  73177. return new Vector3(1.0, 0.0, 0.0);
  73178. };
  73179. /**
  73180. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  73181. * @returns a new left Vector3
  73182. */
  73183. Vector3.Left = function () {
  73184. return new Vector3(-1.0, 0.0, 0.0);
  73185. };
  73186. /**
  73187. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  73188. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73189. * @param vector defines the Vector3 to transform
  73190. * @param transformation defines the transformation matrix
  73191. * @returns the transformed Vector3
  73192. */
  73193. Vector3.TransformCoordinates = function (vector, transformation) {
  73194. var result = Vector3.Zero();
  73195. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  73196. return result;
  73197. };
  73198. /**
  73199. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  73200. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  73201. * @param vector defines the Vector3 to transform
  73202. * @param transformation defines the transformation matrix
  73203. * @param result defines the Vector3 where to store the result
  73204. */
  73205. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  73206. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  73207. };
  73208. /**
  73209. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  73210. * This method computes tranformed coordinates only, not transformed direction vectors
  73211. * @param x define the x coordinate of the source vector
  73212. * @param y define the y coordinate of the source vector
  73213. * @param z define the z coordinate of the source vector
  73214. * @param transformation defines the transformation matrix
  73215. * @param result defines the Vector3 where to store the result
  73216. */
  73217. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  73218. var m = transformation.m;
  73219. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  73220. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  73221. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  73222. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  73223. result.x = rx * rw;
  73224. result.y = ry * rw;
  73225. result.z = rz * rw;
  73226. };
  73227. /**
  73228. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  73229. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73230. * @param vector defines the Vector3 to transform
  73231. * @param transformation defines the transformation matrix
  73232. * @returns the new Vector3
  73233. */
  73234. Vector3.TransformNormal = function (vector, transformation) {
  73235. var result = Vector3.Zero();
  73236. Vector3.TransformNormalToRef(vector, transformation, result);
  73237. return result;
  73238. };
  73239. /**
  73240. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  73241. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73242. * @param vector defines the Vector3 to transform
  73243. * @param transformation defines the transformation matrix
  73244. * @param result defines the Vector3 where to store the result
  73245. */
  73246. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  73247. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  73248. };
  73249. /**
  73250. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  73251. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  73252. * @param x define the x coordinate of the source vector
  73253. * @param y define the y coordinate of the source vector
  73254. * @param z define the z coordinate of the source vector
  73255. * @param transformation defines the transformation matrix
  73256. * @param result defines the Vector3 where to store the result
  73257. */
  73258. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  73259. var m = transformation.m;
  73260. result.x = x * m[0] + y * m[4] + z * m[8];
  73261. result.y = x * m[1] + y * m[5] + z * m[9];
  73262. result.z = x * m[2] + y * m[6] + z * m[10];
  73263. };
  73264. /**
  73265. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  73266. * @param value1 defines the first control point
  73267. * @param value2 defines the second control point
  73268. * @param value3 defines the third control point
  73269. * @param value4 defines the fourth control point
  73270. * @param amount defines the amount on the spline to use
  73271. * @returns the new Vector3
  73272. */
  73273. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  73274. var squared = amount * amount;
  73275. var cubed = amount * squared;
  73276. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  73277. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  73278. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  73279. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  73280. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  73281. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  73282. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  73283. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  73284. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  73285. return new Vector3(x, y, z);
  73286. };
  73287. /**
  73288. * 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"
  73289. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73290. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73291. * @param value defines the current value
  73292. * @param min defines the lower range value
  73293. * @param max defines the upper range value
  73294. * @returns the new Vector3
  73295. */
  73296. Vector3.Clamp = function (value, min, max) {
  73297. var v = new Vector3();
  73298. Vector3.ClampToRef(value, min, max, v);
  73299. return v;
  73300. };
  73301. /**
  73302. * 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"
  73303. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  73304. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  73305. * @param value defines the current value
  73306. * @param min defines the lower range value
  73307. * @param max defines the upper range value
  73308. * @param result defines the Vector3 where to store the result
  73309. */
  73310. Vector3.ClampToRef = function (value, min, max, result) {
  73311. var x = value.x;
  73312. x = (x > max.x) ? max.x : x;
  73313. x = (x < min.x) ? min.x : x;
  73314. var y = value.y;
  73315. y = (y > max.y) ? max.y : y;
  73316. y = (y < min.y) ? min.y : y;
  73317. var z = value.z;
  73318. z = (z > max.z) ? max.z : z;
  73319. z = (z < min.z) ? min.z : z;
  73320. result.copyFromFloats(x, y, z);
  73321. };
  73322. /**
  73323. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  73324. * @param value1 defines the first control point
  73325. * @param tangent1 defines the first tangent vector
  73326. * @param value2 defines the second control point
  73327. * @param tangent2 defines the second tangent vector
  73328. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  73329. * @returns the new Vector3
  73330. */
  73331. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  73332. var squared = amount * amount;
  73333. var cubed = amount * squared;
  73334. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  73335. var part2 = (-2.0 * cubed) + (3.0 * squared);
  73336. var part3 = (cubed - (2.0 * squared)) + amount;
  73337. var part4 = cubed - squared;
  73338. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  73339. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  73340. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  73341. return new Vector3(x, y, z);
  73342. };
  73343. /**
  73344. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  73345. * @param start defines the start value
  73346. * @param end defines the end value
  73347. * @param amount max defines amount between both (between 0 and 1)
  73348. * @returns the new Vector3
  73349. */
  73350. Vector3.Lerp = function (start, end, amount) {
  73351. var result = new Vector3(0, 0, 0);
  73352. Vector3.LerpToRef(start, end, amount, result);
  73353. return result;
  73354. };
  73355. /**
  73356. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  73357. * @param start defines the start value
  73358. * @param end defines the end value
  73359. * @param amount max defines amount between both (between 0 and 1)
  73360. * @param result defines the Vector3 where to store the result
  73361. */
  73362. Vector3.LerpToRef = function (start, end, amount, result) {
  73363. result.x = start.x + ((end.x - start.x) * amount);
  73364. result.y = start.y + ((end.y - start.y) * amount);
  73365. result.z = start.z + ((end.z - start.z) * amount);
  73366. };
  73367. /**
  73368. * Returns the dot product (float) between the vectors "left" and "right"
  73369. * @param left defines the left operand
  73370. * @param right defines the right operand
  73371. * @returns the dot product
  73372. */
  73373. Vector3.Dot = function (left, right) {
  73374. return (left.x * right.x + left.y * right.y + left.z * right.z);
  73375. };
  73376. /**
  73377. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  73378. * The cross product is then orthogonal to both "left" and "right"
  73379. * @param left defines the left operand
  73380. * @param right defines the right operand
  73381. * @returns the cross product
  73382. */
  73383. Vector3.Cross = function (left, right) {
  73384. var result = Vector3.Zero();
  73385. Vector3.CrossToRef(left, right, result);
  73386. return result;
  73387. };
  73388. /**
  73389. * Sets the given vector "result" with the cross product of "left" and "right"
  73390. * The cross product is then orthogonal to both "left" and "right"
  73391. * @param left defines the left operand
  73392. * @param right defines the right operand
  73393. * @param result defines the Vector3 where to store the result
  73394. */
  73395. Vector3.CrossToRef = function (left, right, result) {
  73396. var x = left.y * right.z - left.z * right.y;
  73397. var y = left.z * right.x - left.x * right.z;
  73398. var z = left.x * right.y - left.y * right.x;
  73399. result.copyFromFloats(x, y, z);
  73400. };
  73401. /**
  73402. * Returns a new Vector3 as the normalization of the given vector
  73403. * @param vector defines the Vector3 to normalize
  73404. * @returns the new Vector3
  73405. */
  73406. Vector3.Normalize = function (vector) {
  73407. var result = Vector3.Zero();
  73408. Vector3.NormalizeToRef(vector, result);
  73409. return result;
  73410. };
  73411. /**
  73412. * Sets the given vector "result" with the normalization of the given first vector
  73413. * @param vector defines the Vector3 to normalize
  73414. * @param result defines the Vector3 where to store the result
  73415. */
  73416. Vector3.NormalizeToRef = function (vector, result) {
  73417. vector.normalizeToRef(result);
  73418. };
  73419. /**
  73420. * Project a Vector3 onto screen space
  73421. * @param vector defines the Vector3 to project
  73422. * @param world defines the world matrix to use
  73423. * @param transform defines the transform (view x projection) matrix to use
  73424. * @param viewport defines the screen viewport to use
  73425. * @returns the new Vector3
  73426. */
  73427. Vector3.Project = function (vector, world, transform, viewport) {
  73428. var cw = viewport.width;
  73429. var ch = viewport.height;
  73430. var cx = viewport.x;
  73431. var cy = viewport.y;
  73432. var viewportMatrix = MathTmp.Matrix[1];
  73433. 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);
  73434. var matrix = MathTmp.Matrix[0];
  73435. world.multiplyToRef(transform, matrix);
  73436. matrix.multiplyToRef(viewportMatrix, matrix);
  73437. return Vector3.TransformCoordinates(vector, matrix);
  73438. };
  73439. /** @hidden */
  73440. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  73441. Vector3.TransformCoordinatesToRef(source, matrix, result);
  73442. var m = matrix.m;
  73443. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  73444. if (_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(num, 1.0)) {
  73445. result.scaleInPlace(1.0 / num);
  73446. }
  73447. };
  73448. /**
  73449. * Unproject from screen space to object space
  73450. * @param source defines the screen space Vector3 to use
  73451. * @param viewportWidth defines the current width of the viewport
  73452. * @param viewportHeight defines the current height of the viewport
  73453. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73454. * @param transform defines the transform (view x projection) matrix to use
  73455. * @returns the new Vector3
  73456. */
  73457. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  73458. var matrix = MathTmp.Matrix[0];
  73459. world.multiplyToRef(transform, matrix);
  73460. matrix.invert();
  73461. source.x = source.x / viewportWidth * 2 - 1;
  73462. source.y = -(source.y / viewportHeight * 2 - 1);
  73463. var vector = new Vector3();
  73464. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  73465. return vector;
  73466. };
  73467. /**
  73468. * Unproject from screen space to object space
  73469. * @param source defines the screen space Vector3 to use
  73470. * @param viewportWidth defines the current width of the viewport
  73471. * @param viewportHeight defines the current height of the viewport
  73472. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73473. * @param view defines the view matrix to use
  73474. * @param projection defines the projection matrix to use
  73475. * @returns the new Vector3
  73476. */
  73477. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  73478. var result = Vector3.Zero();
  73479. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  73480. return result;
  73481. };
  73482. /**
  73483. * Unproject from screen space to object space
  73484. * @param source defines the screen space Vector3 to use
  73485. * @param viewportWidth defines the current width of the viewport
  73486. * @param viewportHeight defines the current height of the viewport
  73487. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73488. * @param view defines the view matrix to use
  73489. * @param projection defines the projection matrix to use
  73490. * @param result defines the Vector3 where to store the result
  73491. */
  73492. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  73493. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  73494. };
  73495. /**
  73496. * Unproject from screen space to object space
  73497. * @param sourceX defines the screen space x coordinate to use
  73498. * @param sourceY defines the screen space y coordinate to use
  73499. * @param sourceZ defines the screen space z coordinate to use
  73500. * @param viewportWidth defines the current width of the viewport
  73501. * @param viewportHeight defines the current height of the viewport
  73502. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73503. * @param view defines the view matrix to use
  73504. * @param projection defines the projection matrix to use
  73505. * @param result defines the Vector3 where to store the result
  73506. */
  73507. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  73508. var matrix = MathTmp.Matrix[0];
  73509. world.multiplyToRef(view, matrix);
  73510. matrix.multiplyToRef(projection, matrix);
  73511. matrix.invert();
  73512. var screenSource = MathTmp.Vector3[0];
  73513. screenSource.x = sourceX / viewportWidth * 2 - 1;
  73514. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  73515. screenSource.z = 2 * sourceZ - 1.0;
  73516. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  73517. };
  73518. /**
  73519. * Gets the minimal coordinate values between two Vector3
  73520. * @param left defines the first operand
  73521. * @param right defines the second operand
  73522. * @returns the new Vector3
  73523. */
  73524. Vector3.Minimize = function (left, right) {
  73525. var min = left.clone();
  73526. min.minimizeInPlace(right);
  73527. return min;
  73528. };
  73529. /**
  73530. * Gets the maximal coordinate values between two Vector3
  73531. * @param left defines the first operand
  73532. * @param right defines the second operand
  73533. * @returns the new Vector3
  73534. */
  73535. Vector3.Maximize = function (left, right) {
  73536. var max = left.clone();
  73537. max.maximizeInPlace(right);
  73538. return max;
  73539. };
  73540. /**
  73541. * Returns the distance between the vectors "value1" and "value2"
  73542. * @param value1 defines the first operand
  73543. * @param value2 defines the second operand
  73544. * @returns the distance
  73545. */
  73546. Vector3.Distance = function (value1, value2) {
  73547. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  73548. };
  73549. /**
  73550. * Returns the squared distance between the vectors "value1" and "value2"
  73551. * @param value1 defines the first operand
  73552. * @param value2 defines the second operand
  73553. * @returns the squared distance
  73554. */
  73555. Vector3.DistanceSquared = function (value1, value2) {
  73556. var x = value1.x - value2.x;
  73557. var y = value1.y - value2.y;
  73558. var z = value1.z - value2.z;
  73559. return (x * x) + (y * y) + (z * z);
  73560. };
  73561. /**
  73562. * Returns a new Vector3 located at the center between "value1" and "value2"
  73563. * @param value1 defines the first operand
  73564. * @param value2 defines the second operand
  73565. * @returns the new Vector3
  73566. */
  73567. Vector3.Center = function (value1, value2) {
  73568. var center = value1.add(value2);
  73569. center.scaleInPlace(0.5);
  73570. return center;
  73571. };
  73572. /**
  73573. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  73574. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  73575. * to something in order to rotate it from its local system to the given target system
  73576. * Note: axis1, axis2 and axis3 are normalized during this operation
  73577. * @param axis1 defines the first axis
  73578. * @param axis2 defines the second axis
  73579. * @param axis3 defines the third axis
  73580. * @returns a new Vector3
  73581. */
  73582. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  73583. var rotation = Vector3.Zero();
  73584. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  73585. return rotation;
  73586. };
  73587. /**
  73588. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  73589. * @param axis1 defines the first axis
  73590. * @param axis2 defines the second axis
  73591. * @param axis3 defines the third axis
  73592. * @param ref defines the Vector3 where to store the result
  73593. */
  73594. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  73595. var quat = MathTmp.Quaternion[0];
  73596. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  73597. quat.toEulerAnglesToRef(ref);
  73598. };
  73599. Vector3._UpReadOnly = Vector3.Up();
  73600. return Vector3;
  73601. }());
  73602. /**
  73603. * Vector4 class created for EulerAngle class conversion to Quaternion
  73604. */
  73605. var Vector4 = /** @class */ (function () {
  73606. /**
  73607. * Creates a Vector4 object from the given floats.
  73608. * @param x x value of the vector
  73609. * @param y y value of the vector
  73610. * @param z z value of the vector
  73611. * @param w w value of the vector
  73612. */
  73613. function Vector4(
  73614. /** x value of the vector */
  73615. x,
  73616. /** y value of the vector */
  73617. y,
  73618. /** z value of the vector */
  73619. z,
  73620. /** w value of the vector */
  73621. w) {
  73622. this.x = x;
  73623. this.y = y;
  73624. this.z = z;
  73625. this.w = w;
  73626. }
  73627. /**
  73628. * Returns the string with the Vector4 coordinates.
  73629. * @returns a string containing all the vector values
  73630. */
  73631. Vector4.prototype.toString = function () {
  73632. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  73633. };
  73634. /**
  73635. * Returns the string "Vector4".
  73636. * @returns "Vector4"
  73637. */
  73638. Vector4.prototype.getClassName = function () {
  73639. return "Vector4";
  73640. };
  73641. /**
  73642. * Returns the Vector4 hash code.
  73643. * @returns a unique hash code
  73644. */
  73645. Vector4.prototype.getHashCode = function () {
  73646. var hash = this.x || 0;
  73647. hash = (hash * 397) ^ (this.y || 0);
  73648. hash = (hash * 397) ^ (this.z || 0);
  73649. hash = (hash * 397) ^ (this.w || 0);
  73650. return hash;
  73651. };
  73652. // Operators
  73653. /**
  73654. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  73655. * @returns the resulting array
  73656. */
  73657. Vector4.prototype.asArray = function () {
  73658. var result = new Array();
  73659. this.toArray(result, 0);
  73660. return result;
  73661. };
  73662. /**
  73663. * Populates the given array from the given index with the Vector4 coordinates.
  73664. * @param array array to populate
  73665. * @param index index of the array to start at (default: 0)
  73666. * @returns the Vector4.
  73667. */
  73668. Vector4.prototype.toArray = function (array, index) {
  73669. if (index === undefined) {
  73670. index = 0;
  73671. }
  73672. array[index] = this.x;
  73673. array[index + 1] = this.y;
  73674. array[index + 2] = this.z;
  73675. array[index + 3] = this.w;
  73676. return this;
  73677. };
  73678. /**
  73679. * Adds the given vector to the current Vector4.
  73680. * @param otherVector the vector to add
  73681. * @returns the updated Vector4.
  73682. */
  73683. Vector4.prototype.addInPlace = function (otherVector) {
  73684. this.x += otherVector.x;
  73685. this.y += otherVector.y;
  73686. this.z += otherVector.z;
  73687. this.w += otherVector.w;
  73688. return this;
  73689. };
  73690. /**
  73691. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  73692. * @param otherVector the vector to add
  73693. * @returns the resulting vector
  73694. */
  73695. Vector4.prototype.add = function (otherVector) {
  73696. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  73697. };
  73698. /**
  73699. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  73700. * @param otherVector the vector to add
  73701. * @param result the vector to store the result
  73702. * @returns the current Vector4.
  73703. */
  73704. Vector4.prototype.addToRef = function (otherVector, result) {
  73705. result.x = this.x + otherVector.x;
  73706. result.y = this.y + otherVector.y;
  73707. result.z = this.z + otherVector.z;
  73708. result.w = this.w + otherVector.w;
  73709. return this;
  73710. };
  73711. /**
  73712. * Subtract in place the given vector from the current Vector4.
  73713. * @param otherVector the vector to subtract
  73714. * @returns the updated Vector4.
  73715. */
  73716. Vector4.prototype.subtractInPlace = function (otherVector) {
  73717. this.x -= otherVector.x;
  73718. this.y -= otherVector.y;
  73719. this.z -= otherVector.z;
  73720. this.w -= otherVector.w;
  73721. return this;
  73722. };
  73723. /**
  73724. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  73725. * @param otherVector the vector to add
  73726. * @returns the new vector with the result
  73727. */
  73728. Vector4.prototype.subtract = function (otherVector) {
  73729. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  73730. };
  73731. /**
  73732. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  73733. * @param otherVector the vector to subtract
  73734. * @param result the vector to store the result
  73735. * @returns the current Vector4.
  73736. */
  73737. Vector4.prototype.subtractToRef = function (otherVector, result) {
  73738. result.x = this.x - otherVector.x;
  73739. result.y = this.y - otherVector.y;
  73740. result.z = this.z - otherVector.z;
  73741. result.w = this.w - otherVector.w;
  73742. return this;
  73743. };
  73744. /**
  73745. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73746. */
  73747. /**
  73748. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73749. * @param x value to subtract
  73750. * @param y value to subtract
  73751. * @param z value to subtract
  73752. * @param w value to subtract
  73753. * @returns new vector containing the result
  73754. */
  73755. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  73756. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  73757. };
  73758. /**
  73759. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  73760. * @param x value to subtract
  73761. * @param y value to subtract
  73762. * @param z value to subtract
  73763. * @param w value to subtract
  73764. * @param result the vector to store the result in
  73765. * @returns the current Vector4.
  73766. */
  73767. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  73768. result.x = this.x - x;
  73769. result.y = this.y - y;
  73770. result.z = this.z - z;
  73771. result.w = this.w - w;
  73772. return this;
  73773. };
  73774. /**
  73775. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  73776. * @returns a new vector with the negated values
  73777. */
  73778. Vector4.prototype.negate = function () {
  73779. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  73780. };
  73781. /**
  73782. * Multiplies the current Vector4 coordinates by scale (float).
  73783. * @param scale the number to scale with
  73784. * @returns the updated Vector4.
  73785. */
  73786. Vector4.prototype.scaleInPlace = function (scale) {
  73787. this.x *= scale;
  73788. this.y *= scale;
  73789. this.z *= scale;
  73790. this.w *= scale;
  73791. return this;
  73792. };
  73793. /**
  73794. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  73795. * @param scale the number to scale with
  73796. * @returns a new vector with the result
  73797. */
  73798. Vector4.prototype.scale = function (scale) {
  73799. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  73800. };
  73801. /**
  73802. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  73803. * @param scale the number to scale with
  73804. * @param result a vector to store the result in
  73805. * @returns the current Vector4.
  73806. */
  73807. Vector4.prototype.scaleToRef = function (scale, result) {
  73808. result.x = this.x * scale;
  73809. result.y = this.y * scale;
  73810. result.z = this.z * scale;
  73811. result.w = this.w * scale;
  73812. return this;
  73813. };
  73814. /**
  73815. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  73816. * @param scale defines the scale factor
  73817. * @param result defines the Vector4 object where to store the result
  73818. * @returns the unmodified current Vector4
  73819. */
  73820. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  73821. result.x += this.x * scale;
  73822. result.y += this.y * scale;
  73823. result.z += this.z * scale;
  73824. result.w += this.w * scale;
  73825. return this;
  73826. };
  73827. /**
  73828. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  73829. * @param otherVector the vector to compare against
  73830. * @returns true if they are equal
  73831. */
  73832. Vector4.prototype.equals = function (otherVector) {
  73833. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  73834. };
  73835. /**
  73836. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  73837. * @param otherVector vector to compare against
  73838. * @param epsilon (Default: very small number)
  73839. * @returns true if they are equal
  73840. */
  73841. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  73842. if (epsilon === void 0) { epsilon = Epsilon; }
  73843. return otherVector
  73844. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  73845. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  73846. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  73847. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  73848. };
  73849. /**
  73850. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  73851. * @param x x value to compare against
  73852. * @param y y value to compare against
  73853. * @param z z value to compare against
  73854. * @param w w value to compare against
  73855. * @returns true if equal
  73856. */
  73857. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  73858. return this.x === x && this.y === y && this.z === z && this.w === w;
  73859. };
  73860. /**
  73861. * Multiplies in place the current Vector4 by the given one.
  73862. * @param otherVector vector to multiple with
  73863. * @returns the updated Vector4.
  73864. */
  73865. Vector4.prototype.multiplyInPlace = function (otherVector) {
  73866. this.x *= otherVector.x;
  73867. this.y *= otherVector.y;
  73868. this.z *= otherVector.z;
  73869. this.w *= otherVector.w;
  73870. return this;
  73871. };
  73872. /**
  73873. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  73874. * @param otherVector vector to multiple with
  73875. * @returns resulting new vector
  73876. */
  73877. Vector4.prototype.multiply = function (otherVector) {
  73878. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  73879. };
  73880. /**
  73881. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  73882. * @param otherVector vector to multiple with
  73883. * @param result vector to store the result
  73884. * @returns the current Vector4.
  73885. */
  73886. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  73887. result.x = this.x * otherVector.x;
  73888. result.y = this.y * otherVector.y;
  73889. result.z = this.z * otherVector.z;
  73890. result.w = this.w * otherVector.w;
  73891. return this;
  73892. };
  73893. /**
  73894. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  73895. * @param x x value multiply with
  73896. * @param y y value multiply with
  73897. * @param z z value multiply with
  73898. * @param w w value multiply with
  73899. * @returns resulting new vector
  73900. */
  73901. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  73902. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  73903. };
  73904. /**
  73905. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  73906. * @param otherVector vector to devide with
  73907. * @returns resulting new vector
  73908. */
  73909. Vector4.prototype.divide = function (otherVector) {
  73910. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  73911. };
  73912. /**
  73913. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  73914. * @param otherVector vector to devide with
  73915. * @param result vector to store the result
  73916. * @returns the current Vector4.
  73917. */
  73918. Vector4.prototype.divideToRef = function (otherVector, result) {
  73919. result.x = this.x / otherVector.x;
  73920. result.y = this.y / otherVector.y;
  73921. result.z = this.z / otherVector.z;
  73922. result.w = this.w / otherVector.w;
  73923. return this;
  73924. };
  73925. /**
  73926. * Divides the current Vector3 coordinates by the given ones.
  73927. * @param otherVector vector to devide with
  73928. * @returns the updated Vector3.
  73929. */
  73930. Vector4.prototype.divideInPlace = function (otherVector) {
  73931. return this.divideToRef(otherVector, this);
  73932. };
  73933. /**
  73934. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  73935. * @param other defines the second operand
  73936. * @returns the current updated Vector4
  73937. */
  73938. Vector4.prototype.minimizeInPlace = function (other) {
  73939. if (other.x < this.x) {
  73940. this.x = other.x;
  73941. }
  73942. if (other.y < this.y) {
  73943. this.y = other.y;
  73944. }
  73945. if (other.z < this.z) {
  73946. this.z = other.z;
  73947. }
  73948. if (other.w < this.w) {
  73949. this.w = other.w;
  73950. }
  73951. return this;
  73952. };
  73953. /**
  73954. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  73955. * @param other defines the second operand
  73956. * @returns the current updated Vector4
  73957. */
  73958. Vector4.prototype.maximizeInPlace = function (other) {
  73959. if (other.x > this.x) {
  73960. this.x = other.x;
  73961. }
  73962. if (other.y > this.y) {
  73963. this.y = other.y;
  73964. }
  73965. if (other.z > this.z) {
  73966. this.z = other.z;
  73967. }
  73968. if (other.w > this.w) {
  73969. this.w = other.w;
  73970. }
  73971. return this;
  73972. };
  73973. /**
  73974. * Gets a new Vector4 from current Vector4 floored values
  73975. * @returns a new Vector4
  73976. */
  73977. Vector4.prototype.floor = function () {
  73978. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  73979. };
  73980. /**
  73981. * Gets a new Vector4 from current Vector3 floored values
  73982. * @returns a new Vector4
  73983. */
  73984. Vector4.prototype.fract = function () {
  73985. 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));
  73986. };
  73987. // Properties
  73988. /**
  73989. * Returns the Vector4 length (float).
  73990. * @returns the length
  73991. */
  73992. Vector4.prototype.length = function () {
  73993. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  73994. };
  73995. /**
  73996. * Returns the Vector4 squared length (float).
  73997. * @returns the length squared
  73998. */
  73999. Vector4.prototype.lengthSquared = function () {
  74000. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  74001. };
  74002. // Methods
  74003. /**
  74004. * Normalizes in place the Vector4.
  74005. * @returns the updated Vector4.
  74006. */
  74007. Vector4.prototype.normalize = function () {
  74008. var len = this.length();
  74009. if (len === 0) {
  74010. return this;
  74011. }
  74012. return this.scaleInPlace(1.0 / len);
  74013. };
  74014. /**
  74015. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  74016. * @returns this converted to a new vector3
  74017. */
  74018. Vector4.prototype.toVector3 = function () {
  74019. return new Vector3(this.x, this.y, this.z);
  74020. };
  74021. /**
  74022. * Returns a new Vector4 copied from the current one.
  74023. * @returns the new cloned vector
  74024. */
  74025. Vector4.prototype.clone = function () {
  74026. return new Vector4(this.x, this.y, this.z, this.w);
  74027. };
  74028. /**
  74029. * Updates the current Vector4 with the given one coordinates.
  74030. * @param source the source vector to copy from
  74031. * @returns the updated Vector4.
  74032. */
  74033. Vector4.prototype.copyFrom = function (source) {
  74034. this.x = source.x;
  74035. this.y = source.y;
  74036. this.z = source.z;
  74037. this.w = source.w;
  74038. return this;
  74039. };
  74040. /**
  74041. * Updates the current Vector4 coordinates with the given floats.
  74042. * @param x float to copy from
  74043. * @param y float to copy from
  74044. * @param z float to copy from
  74045. * @param w float to copy from
  74046. * @returns the updated Vector4.
  74047. */
  74048. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  74049. this.x = x;
  74050. this.y = y;
  74051. this.z = z;
  74052. this.w = w;
  74053. return this;
  74054. };
  74055. /**
  74056. * Updates the current Vector4 coordinates with the given floats.
  74057. * @param x float to set from
  74058. * @param y float to set from
  74059. * @param z float to set from
  74060. * @param w float to set from
  74061. * @returns the updated Vector4.
  74062. */
  74063. Vector4.prototype.set = function (x, y, z, w) {
  74064. return this.copyFromFloats(x, y, z, w);
  74065. };
  74066. /**
  74067. * Copies the given float to the current Vector3 coordinates
  74068. * @param v defines the x, y, z and w coordinates of the operand
  74069. * @returns the current updated Vector3
  74070. */
  74071. Vector4.prototype.setAll = function (v) {
  74072. this.x = this.y = this.z = this.w = v;
  74073. return this;
  74074. };
  74075. // Statics
  74076. /**
  74077. * Returns a new Vector4 set from the starting index of the given array.
  74078. * @param array the array to pull values from
  74079. * @param offset the offset into the array to start at
  74080. * @returns the new vector
  74081. */
  74082. Vector4.FromArray = function (array, offset) {
  74083. if (!offset) {
  74084. offset = 0;
  74085. }
  74086. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  74087. };
  74088. /**
  74089. * Updates the given vector "result" from the starting index of the given array.
  74090. * @param array the array to pull values from
  74091. * @param offset the offset into the array to start at
  74092. * @param result the vector to store the result in
  74093. */
  74094. Vector4.FromArrayToRef = function (array, offset, result) {
  74095. result.x = array[offset];
  74096. result.y = array[offset + 1];
  74097. result.z = array[offset + 2];
  74098. result.w = array[offset + 3];
  74099. };
  74100. /**
  74101. * Updates the given vector "result" from the starting index of the given Float32Array.
  74102. * @param array the array to pull values from
  74103. * @param offset the offset into the array to start at
  74104. * @param result the vector to store the result in
  74105. */
  74106. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  74107. Vector4.FromArrayToRef(array, offset, result);
  74108. };
  74109. /**
  74110. * Updates the given vector "result" coordinates from the given floats.
  74111. * @param x float to set from
  74112. * @param y float to set from
  74113. * @param z float to set from
  74114. * @param w float to set from
  74115. * @param result the vector to the floats in
  74116. */
  74117. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  74118. result.x = x;
  74119. result.y = y;
  74120. result.z = z;
  74121. result.w = w;
  74122. };
  74123. /**
  74124. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  74125. * @returns the new vector
  74126. */
  74127. Vector4.Zero = function () {
  74128. return new Vector4(0.0, 0.0, 0.0, 0.0);
  74129. };
  74130. /**
  74131. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  74132. * @returns the new vector
  74133. */
  74134. Vector4.One = function () {
  74135. return new Vector4(1.0, 1.0, 1.0, 1.0);
  74136. };
  74137. /**
  74138. * Returns a new normalized Vector4 from the given one.
  74139. * @param vector the vector to normalize
  74140. * @returns the vector
  74141. */
  74142. Vector4.Normalize = function (vector) {
  74143. var result = Vector4.Zero();
  74144. Vector4.NormalizeToRef(vector, result);
  74145. return result;
  74146. };
  74147. /**
  74148. * Updates the given vector "result" from the normalization of the given one.
  74149. * @param vector the vector to normalize
  74150. * @param result the vector to store the result in
  74151. */
  74152. Vector4.NormalizeToRef = function (vector, result) {
  74153. result.copyFrom(vector);
  74154. result.normalize();
  74155. };
  74156. /**
  74157. * Returns a vector with the minimum values from the left and right vectors
  74158. * @param left left vector to minimize
  74159. * @param right right vector to minimize
  74160. * @returns a new vector with the minimum of the left and right vector values
  74161. */
  74162. Vector4.Minimize = function (left, right) {
  74163. var min = left.clone();
  74164. min.minimizeInPlace(right);
  74165. return min;
  74166. };
  74167. /**
  74168. * Returns a vector with the maximum values from the left and right vectors
  74169. * @param left left vector to maximize
  74170. * @param right right vector to maximize
  74171. * @returns a new vector with the maximum of the left and right vector values
  74172. */
  74173. Vector4.Maximize = function (left, right) {
  74174. var max = left.clone();
  74175. max.maximizeInPlace(right);
  74176. return max;
  74177. };
  74178. /**
  74179. * Returns the distance (float) between the vectors "value1" and "value2".
  74180. * @param value1 value to calulate the distance between
  74181. * @param value2 value to calulate the distance between
  74182. * @return the distance between the two vectors
  74183. */
  74184. Vector4.Distance = function (value1, value2) {
  74185. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  74186. };
  74187. /**
  74188. * Returns the squared distance (float) between the vectors "value1" and "value2".
  74189. * @param value1 value to calulate the distance between
  74190. * @param value2 value to calulate the distance between
  74191. * @return the distance between the two vectors squared
  74192. */
  74193. Vector4.DistanceSquared = function (value1, value2) {
  74194. var x = value1.x - value2.x;
  74195. var y = value1.y - value2.y;
  74196. var z = value1.z - value2.z;
  74197. var w = value1.w - value2.w;
  74198. return (x * x) + (y * y) + (z * z) + (w * w);
  74199. };
  74200. /**
  74201. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  74202. * @param value1 value to calulate the center between
  74203. * @param value2 value to calulate the center between
  74204. * @return the center between the two vectors
  74205. */
  74206. Vector4.Center = function (value1, value2) {
  74207. var center = value1.add(value2);
  74208. center.scaleInPlace(0.5);
  74209. return center;
  74210. };
  74211. /**
  74212. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  74213. * This methods computes transformed normalized direction vectors only.
  74214. * @param vector the vector to transform
  74215. * @param transformation the transformation matrix to apply
  74216. * @returns the new vector
  74217. */
  74218. Vector4.TransformNormal = function (vector, transformation) {
  74219. var result = Vector4.Zero();
  74220. Vector4.TransformNormalToRef(vector, transformation, result);
  74221. return result;
  74222. };
  74223. /**
  74224. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  74225. * This methods computes transformed normalized direction vectors only.
  74226. * @param vector the vector to transform
  74227. * @param transformation the transformation matrix to apply
  74228. * @param result the vector to store the result in
  74229. */
  74230. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  74231. var m = transformation.m;
  74232. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  74233. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  74234. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  74235. result.x = x;
  74236. result.y = y;
  74237. result.z = z;
  74238. result.w = vector.w;
  74239. };
  74240. /**
  74241. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  74242. * This methods computes transformed normalized direction vectors only.
  74243. * @param x value to transform
  74244. * @param y value to transform
  74245. * @param z value to transform
  74246. * @param w value to transform
  74247. * @param transformation the transformation matrix to apply
  74248. * @param result the vector to store the results in
  74249. */
  74250. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  74251. var m = transformation.m;
  74252. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  74253. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  74254. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  74255. result.w = w;
  74256. };
  74257. /**
  74258. * Creates a new Vector4 from a Vector3
  74259. * @param source defines the source data
  74260. * @param w defines the 4th component (default is 0)
  74261. * @returns a new Vector4
  74262. */
  74263. Vector4.FromVector3 = function (source, w) {
  74264. if (w === void 0) { w = 0; }
  74265. return new Vector4(source.x, source.y, source.z, w);
  74266. };
  74267. return Vector4;
  74268. }());
  74269. /**
  74270. * Size containing widht and height
  74271. */
  74272. var Size = /** @class */ (function () {
  74273. /**
  74274. * Creates a Size object from the given width and height (floats).
  74275. * @param width width of the new size
  74276. * @param height height of the new size
  74277. */
  74278. function Size(width, height) {
  74279. this.width = width;
  74280. this.height = height;
  74281. }
  74282. /**
  74283. * Returns a string with the Size width and height
  74284. * @returns a string with the Size width and height
  74285. */
  74286. Size.prototype.toString = function () {
  74287. return "{W: " + this.width + ", H: " + this.height + "}";
  74288. };
  74289. /**
  74290. * "Size"
  74291. * @returns the string "Size"
  74292. */
  74293. Size.prototype.getClassName = function () {
  74294. return "Size";
  74295. };
  74296. /**
  74297. * Returns the Size hash code.
  74298. * @returns a hash code for a unique width and height
  74299. */
  74300. Size.prototype.getHashCode = function () {
  74301. var hash = this.width || 0;
  74302. hash = (hash * 397) ^ (this.height || 0);
  74303. return hash;
  74304. };
  74305. /**
  74306. * Updates the current size from the given one.
  74307. * @param src the given size
  74308. */
  74309. Size.prototype.copyFrom = function (src) {
  74310. this.width = src.width;
  74311. this.height = src.height;
  74312. };
  74313. /**
  74314. * Updates in place the current Size from the given floats.
  74315. * @param width width of the new size
  74316. * @param height height of the new size
  74317. * @returns the updated Size.
  74318. */
  74319. Size.prototype.copyFromFloats = function (width, height) {
  74320. this.width = width;
  74321. this.height = height;
  74322. return this;
  74323. };
  74324. /**
  74325. * Updates in place the current Size from the given floats.
  74326. * @param width width to set
  74327. * @param height height to set
  74328. * @returns the updated Size.
  74329. */
  74330. Size.prototype.set = function (width, height) {
  74331. return this.copyFromFloats(width, height);
  74332. };
  74333. /**
  74334. * Multiplies the width and height by numbers
  74335. * @param w factor to multiple the width by
  74336. * @param h factor to multiple the height by
  74337. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  74338. */
  74339. Size.prototype.multiplyByFloats = function (w, h) {
  74340. return new Size(this.width * w, this.height * h);
  74341. };
  74342. /**
  74343. * Clones the size
  74344. * @returns a new Size copied from the given one.
  74345. */
  74346. Size.prototype.clone = function () {
  74347. return new Size(this.width, this.height);
  74348. };
  74349. /**
  74350. * True if the current Size and the given one width and height are strictly equal.
  74351. * @param other the other size to compare against
  74352. * @returns True if the current Size and the given one width and height are strictly equal.
  74353. */
  74354. Size.prototype.equals = function (other) {
  74355. if (!other) {
  74356. return false;
  74357. }
  74358. return (this.width === other.width) && (this.height === other.height);
  74359. };
  74360. Object.defineProperty(Size.prototype, "surface", {
  74361. /**
  74362. * The surface of the Size : width * height (float).
  74363. */
  74364. get: function () {
  74365. return this.width * this.height;
  74366. },
  74367. enumerable: true,
  74368. configurable: true
  74369. });
  74370. /**
  74371. * Create a new size of zero
  74372. * @returns a new Size set to (0.0, 0.0)
  74373. */
  74374. Size.Zero = function () {
  74375. return new Size(0.0, 0.0);
  74376. };
  74377. /**
  74378. * Sums the width and height of two sizes
  74379. * @param otherSize size to add to this size
  74380. * @returns a new Size set as the addition result of the current Size and the given one.
  74381. */
  74382. Size.prototype.add = function (otherSize) {
  74383. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  74384. return r;
  74385. };
  74386. /**
  74387. * Subtracts the width and height of two
  74388. * @param otherSize size to subtract to this size
  74389. * @returns a new Size set as the subtraction result of the given one from the current Size.
  74390. */
  74391. Size.prototype.subtract = function (otherSize) {
  74392. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  74393. return r;
  74394. };
  74395. /**
  74396. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  74397. * @param start starting size to lerp between
  74398. * @param end end size to lerp between
  74399. * @param amount amount to lerp between the start and end values
  74400. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  74401. */
  74402. Size.Lerp = function (start, end, amount) {
  74403. var w = start.width + ((end.width - start.width) * amount);
  74404. var h = start.height + ((end.height - start.height) * amount);
  74405. return new Size(w, h);
  74406. };
  74407. return Size;
  74408. }());
  74409. /**
  74410. * Class used to store quaternion data
  74411. * @see https://en.wikipedia.org/wiki/Quaternion
  74412. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  74413. */
  74414. var Quaternion = /** @class */ (function () {
  74415. /**
  74416. * Creates a new Quaternion from the given floats
  74417. * @param x defines the first component (0 by default)
  74418. * @param y defines the second component (0 by default)
  74419. * @param z defines the third component (0 by default)
  74420. * @param w defines the fourth component (1.0 by default)
  74421. */
  74422. function Quaternion(
  74423. /** defines the first component (0 by default) */
  74424. x,
  74425. /** defines the second component (0 by default) */
  74426. y,
  74427. /** defines the third component (0 by default) */
  74428. z,
  74429. /** defines the fourth component (1.0 by default) */
  74430. w) {
  74431. if (x === void 0) { x = 0.0; }
  74432. if (y === void 0) { y = 0.0; }
  74433. if (z === void 0) { z = 0.0; }
  74434. if (w === void 0) { w = 1.0; }
  74435. this.x = x;
  74436. this.y = y;
  74437. this.z = z;
  74438. this.w = w;
  74439. }
  74440. /**
  74441. * Gets a string representation for the current quaternion
  74442. * @returns a string with the Quaternion coordinates
  74443. */
  74444. Quaternion.prototype.toString = function () {
  74445. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  74446. };
  74447. /**
  74448. * Gets the class name of the quaternion
  74449. * @returns the string "Quaternion"
  74450. */
  74451. Quaternion.prototype.getClassName = function () {
  74452. return "Quaternion";
  74453. };
  74454. /**
  74455. * Gets a hash code for this quaternion
  74456. * @returns the quaternion hash code
  74457. */
  74458. Quaternion.prototype.getHashCode = function () {
  74459. var hash = this.x || 0;
  74460. hash = (hash * 397) ^ (this.y || 0);
  74461. hash = (hash * 397) ^ (this.z || 0);
  74462. hash = (hash * 397) ^ (this.w || 0);
  74463. return hash;
  74464. };
  74465. /**
  74466. * Copy the quaternion to an array
  74467. * @returns a new array populated with 4 elements from the quaternion coordinates
  74468. */
  74469. Quaternion.prototype.asArray = function () {
  74470. return [this.x, this.y, this.z, this.w];
  74471. };
  74472. /**
  74473. * Check if two quaternions are equals
  74474. * @param otherQuaternion defines the second operand
  74475. * @return true if the current quaternion and the given one coordinates are strictly equals
  74476. */
  74477. Quaternion.prototype.equals = function (otherQuaternion) {
  74478. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  74479. };
  74480. /**
  74481. * Clone the current quaternion
  74482. * @returns a new quaternion copied from the current one
  74483. */
  74484. Quaternion.prototype.clone = function () {
  74485. return new Quaternion(this.x, this.y, this.z, this.w);
  74486. };
  74487. /**
  74488. * Copy a quaternion to the current one
  74489. * @param other defines the other quaternion
  74490. * @returns the updated current quaternion
  74491. */
  74492. Quaternion.prototype.copyFrom = function (other) {
  74493. this.x = other.x;
  74494. this.y = other.y;
  74495. this.z = other.z;
  74496. this.w = other.w;
  74497. return this;
  74498. };
  74499. /**
  74500. * Updates the current quaternion with the given float coordinates
  74501. * @param x defines the x coordinate
  74502. * @param y defines the y coordinate
  74503. * @param z defines the z coordinate
  74504. * @param w defines the w coordinate
  74505. * @returns the updated current quaternion
  74506. */
  74507. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  74508. this.x = x;
  74509. this.y = y;
  74510. this.z = z;
  74511. this.w = w;
  74512. return this;
  74513. };
  74514. /**
  74515. * Updates the current quaternion from the given float coordinates
  74516. * @param x defines the x coordinate
  74517. * @param y defines the y coordinate
  74518. * @param z defines the z coordinate
  74519. * @param w defines the w coordinate
  74520. * @returns the updated current quaternion
  74521. */
  74522. Quaternion.prototype.set = function (x, y, z, w) {
  74523. return this.copyFromFloats(x, y, z, w);
  74524. };
  74525. /**
  74526. * Adds two quaternions
  74527. * @param other defines the second operand
  74528. * @returns a new quaternion as the addition result of the given one and the current quaternion
  74529. */
  74530. Quaternion.prototype.add = function (other) {
  74531. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  74532. };
  74533. /**
  74534. * Add a quaternion to the current one
  74535. * @param other defines the quaternion to add
  74536. * @returns the current quaternion
  74537. */
  74538. Quaternion.prototype.addInPlace = function (other) {
  74539. this.x += other.x;
  74540. this.y += other.y;
  74541. this.z += other.z;
  74542. this.w += other.w;
  74543. return this;
  74544. };
  74545. /**
  74546. * Subtract two quaternions
  74547. * @param other defines the second operand
  74548. * @returns a new quaternion as the subtraction result of the given one from the current one
  74549. */
  74550. Quaternion.prototype.subtract = function (other) {
  74551. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  74552. };
  74553. /**
  74554. * Multiplies the current quaternion by a scale factor
  74555. * @param value defines the scale factor
  74556. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  74557. */
  74558. Quaternion.prototype.scale = function (value) {
  74559. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  74560. };
  74561. /**
  74562. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  74563. * @param scale defines the scale factor
  74564. * @param result defines the Quaternion object where to store the result
  74565. * @returns the unmodified current quaternion
  74566. */
  74567. Quaternion.prototype.scaleToRef = function (scale, result) {
  74568. result.x = this.x * scale;
  74569. result.y = this.y * scale;
  74570. result.z = this.z * scale;
  74571. result.w = this.w * scale;
  74572. return this;
  74573. };
  74574. /**
  74575. * Multiplies in place the current quaternion by a scale factor
  74576. * @param value defines the scale factor
  74577. * @returns the current modified quaternion
  74578. */
  74579. Quaternion.prototype.scaleInPlace = function (value) {
  74580. this.x *= value;
  74581. this.y *= value;
  74582. this.z *= value;
  74583. this.w *= value;
  74584. return this;
  74585. };
  74586. /**
  74587. * Scale the current quaternion values by a factor and add the result to a given quaternion
  74588. * @param scale defines the scale factor
  74589. * @param result defines the Quaternion object where to store the result
  74590. * @returns the unmodified current quaternion
  74591. */
  74592. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  74593. result.x += this.x * scale;
  74594. result.y += this.y * scale;
  74595. result.z += this.z * scale;
  74596. result.w += this.w * scale;
  74597. return this;
  74598. };
  74599. /**
  74600. * Multiplies two quaternions
  74601. * @param q1 defines the second operand
  74602. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  74603. */
  74604. Quaternion.prototype.multiply = function (q1) {
  74605. var result = new Quaternion(0, 0, 0, 1.0);
  74606. this.multiplyToRef(q1, result);
  74607. return result;
  74608. };
  74609. /**
  74610. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  74611. * @param q1 defines the second operand
  74612. * @param result defines the target quaternion
  74613. * @returns the current quaternion
  74614. */
  74615. Quaternion.prototype.multiplyToRef = function (q1, result) {
  74616. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  74617. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  74618. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  74619. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  74620. result.copyFromFloats(x, y, z, w);
  74621. return this;
  74622. };
  74623. /**
  74624. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  74625. * @param q1 defines the second operand
  74626. * @returns the currentupdated quaternion
  74627. */
  74628. Quaternion.prototype.multiplyInPlace = function (q1) {
  74629. this.multiplyToRef(q1, this);
  74630. return this;
  74631. };
  74632. /**
  74633. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  74634. * @param ref defines the target quaternion
  74635. * @returns the current quaternion
  74636. */
  74637. Quaternion.prototype.conjugateToRef = function (ref) {
  74638. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  74639. return this;
  74640. };
  74641. /**
  74642. * Conjugates in place (1-q) the current quaternion
  74643. * @returns the current updated quaternion
  74644. */
  74645. Quaternion.prototype.conjugateInPlace = function () {
  74646. this.x *= -1;
  74647. this.y *= -1;
  74648. this.z *= -1;
  74649. return this;
  74650. };
  74651. /**
  74652. * Conjugates in place (1-q) the current quaternion
  74653. * @returns a new quaternion
  74654. */
  74655. Quaternion.prototype.conjugate = function () {
  74656. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  74657. return result;
  74658. };
  74659. /**
  74660. * Gets length of current quaternion
  74661. * @returns the quaternion length (float)
  74662. */
  74663. Quaternion.prototype.length = function () {
  74664. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  74665. };
  74666. /**
  74667. * Normalize in place the current quaternion
  74668. * @returns the current updated quaternion
  74669. */
  74670. Quaternion.prototype.normalize = function () {
  74671. var len = this.length();
  74672. if (len === 0) {
  74673. return this;
  74674. }
  74675. var inv = 1.0 / len;
  74676. this.x *= inv;
  74677. this.y *= inv;
  74678. this.z *= inv;
  74679. this.w *= inv;
  74680. return this;
  74681. };
  74682. /**
  74683. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  74684. * @param order is a reserved parameter and is ignore for now
  74685. * @returns a new Vector3 containing the Euler angles
  74686. */
  74687. Quaternion.prototype.toEulerAngles = function (order) {
  74688. if (order === void 0) { order = "YZX"; }
  74689. var result = Vector3.Zero();
  74690. this.toEulerAnglesToRef(result);
  74691. return result;
  74692. };
  74693. /**
  74694. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  74695. * @param result defines the vector which will be filled with the Euler angles
  74696. * @param order is a reserved parameter and is ignore for now
  74697. * @returns the current unchanged quaternion
  74698. */
  74699. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  74700. var qz = this.z;
  74701. var qx = this.x;
  74702. var qy = this.y;
  74703. var qw = this.w;
  74704. var sqw = qw * qw;
  74705. var sqz = qz * qz;
  74706. var sqx = qx * qx;
  74707. var sqy = qy * qy;
  74708. var zAxisY = qy * qz - qx * qw;
  74709. var limit = .4999999;
  74710. if (zAxisY < -limit) {
  74711. result.y = 2 * Math.atan2(qy, qw);
  74712. result.x = Math.PI / 2;
  74713. result.z = 0;
  74714. }
  74715. else if (zAxisY > limit) {
  74716. result.y = 2 * Math.atan2(qy, qw);
  74717. result.x = -Math.PI / 2;
  74718. result.z = 0;
  74719. }
  74720. else {
  74721. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  74722. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  74723. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  74724. }
  74725. return this;
  74726. };
  74727. /**
  74728. * Updates the given rotation matrix with the current quaternion values
  74729. * @param result defines the target matrix
  74730. * @returns the current unchanged quaternion
  74731. */
  74732. Quaternion.prototype.toRotationMatrix = function (result) {
  74733. Matrix.FromQuaternionToRef(this, result);
  74734. return this;
  74735. };
  74736. /**
  74737. * Updates the current quaternion from the given rotation matrix values
  74738. * @param matrix defines the source matrix
  74739. * @returns the current updated quaternion
  74740. */
  74741. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  74742. Quaternion.FromRotationMatrixToRef(matrix, this);
  74743. return this;
  74744. };
  74745. // Statics
  74746. /**
  74747. * Creates a new quaternion from a rotation matrix
  74748. * @param matrix defines the source matrix
  74749. * @returns a new quaternion created from the given rotation matrix values
  74750. */
  74751. Quaternion.FromRotationMatrix = function (matrix) {
  74752. var result = new Quaternion();
  74753. Quaternion.FromRotationMatrixToRef(matrix, result);
  74754. return result;
  74755. };
  74756. /**
  74757. * Updates the given quaternion with the given rotation matrix values
  74758. * @param matrix defines the source matrix
  74759. * @param result defines the target quaternion
  74760. */
  74761. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  74762. var data = matrix.m;
  74763. var m11 = data[0], m12 = data[4], m13 = data[8];
  74764. var m21 = data[1], m22 = data[5], m23 = data[9];
  74765. var m31 = data[2], m32 = data[6], m33 = data[10];
  74766. var trace = m11 + m22 + m33;
  74767. var s;
  74768. if (trace > 0) {
  74769. s = 0.5 / Math.sqrt(trace + 1.0);
  74770. result.w = 0.25 / s;
  74771. result.x = (m32 - m23) * s;
  74772. result.y = (m13 - m31) * s;
  74773. result.z = (m21 - m12) * s;
  74774. }
  74775. else if (m11 > m22 && m11 > m33) {
  74776. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  74777. result.w = (m32 - m23) / s;
  74778. result.x = 0.25 * s;
  74779. result.y = (m12 + m21) / s;
  74780. result.z = (m13 + m31) / s;
  74781. }
  74782. else if (m22 > m33) {
  74783. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  74784. result.w = (m13 - m31) / s;
  74785. result.x = (m12 + m21) / s;
  74786. result.y = 0.25 * s;
  74787. result.z = (m23 + m32) / s;
  74788. }
  74789. else {
  74790. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  74791. result.w = (m21 - m12) / s;
  74792. result.x = (m13 + m31) / s;
  74793. result.y = (m23 + m32) / s;
  74794. result.z = 0.25 * s;
  74795. }
  74796. };
  74797. /**
  74798. * Returns the dot product (float) between the quaternions "left" and "right"
  74799. * @param left defines the left operand
  74800. * @param right defines the right operand
  74801. * @returns the dot product
  74802. */
  74803. Quaternion.Dot = function (left, right) {
  74804. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  74805. };
  74806. /**
  74807. * Checks if the two quaternions are close to each other
  74808. * @param quat0 defines the first quaternion to check
  74809. * @param quat1 defines the second quaternion to check
  74810. * @returns true if the two quaternions are close to each other
  74811. */
  74812. Quaternion.AreClose = function (quat0, quat1) {
  74813. var dot = Quaternion.Dot(quat0, quat1);
  74814. return dot >= 0;
  74815. };
  74816. /**
  74817. * Creates an empty quaternion
  74818. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  74819. */
  74820. Quaternion.Zero = function () {
  74821. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  74822. };
  74823. /**
  74824. * Inverse a given quaternion
  74825. * @param q defines the source quaternion
  74826. * @returns a new quaternion as the inverted current quaternion
  74827. */
  74828. Quaternion.Inverse = function (q) {
  74829. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  74830. };
  74831. /**
  74832. * Inverse a given quaternion
  74833. * @param q defines the source quaternion
  74834. * @param result the quaternion the result will be stored in
  74835. * @returns the result quaternion
  74836. */
  74837. Quaternion.InverseToRef = function (q, result) {
  74838. result.set(-q.x, -q.y, -q.z, q.w);
  74839. return result;
  74840. };
  74841. /**
  74842. * Creates an identity quaternion
  74843. * @returns the identity quaternion
  74844. */
  74845. Quaternion.Identity = function () {
  74846. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  74847. };
  74848. /**
  74849. * Gets a boolean indicating if the given quaternion is identity
  74850. * @param quaternion defines the quaternion to check
  74851. * @returns true if the quaternion is identity
  74852. */
  74853. Quaternion.IsIdentity = function (quaternion) {
  74854. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  74855. };
  74856. /**
  74857. * Creates a quaternion from a rotation around an axis
  74858. * @param axis defines the axis to use
  74859. * @param angle defines the angle to use
  74860. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  74861. */
  74862. Quaternion.RotationAxis = function (axis, angle) {
  74863. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  74864. };
  74865. /**
  74866. * Creates a rotation around an axis and stores it into the given quaternion
  74867. * @param axis defines the axis to use
  74868. * @param angle defines the angle to use
  74869. * @param result defines the target quaternion
  74870. * @returns the target quaternion
  74871. */
  74872. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  74873. var sin = Math.sin(angle / 2);
  74874. axis.normalize();
  74875. result.w = Math.cos(angle / 2);
  74876. result.x = axis.x * sin;
  74877. result.y = axis.y * sin;
  74878. result.z = axis.z * sin;
  74879. return result;
  74880. };
  74881. /**
  74882. * Creates a new quaternion from data stored into an array
  74883. * @param array defines the data source
  74884. * @param offset defines the offset in the source array where the data starts
  74885. * @returns a new quaternion
  74886. */
  74887. Quaternion.FromArray = function (array, offset) {
  74888. if (!offset) {
  74889. offset = 0;
  74890. }
  74891. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  74892. };
  74893. /**
  74894. * Create a quaternion from Euler rotation angles
  74895. * @param x Pitch
  74896. * @param y Yaw
  74897. * @param z Roll
  74898. * @returns the new Quaternion
  74899. */
  74900. Quaternion.FromEulerAngles = function (x, y, z) {
  74901. var q = new Quaternion();
  74902. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  74903. return q;
  74904. };
  74905. /**
  74906. * Updates a quaternion from Euler rotation angles
  74907. * @param x Pitch
  74908. * @param y Yaw
  74909. * @param z Roll
  74910. * @param result the quaternion to store the result
  74911. * @returns the updated quaternion
  74912. */
  74913. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  74914. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  74915. return result;
  74916. };
  74917. /**
  74918. * Create a quaternion from Euler rotation vector
  74919. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74920. * @returns the new Quaternion
  74921. */
  74922. Quaternion.FromEulerVector = function (vec) {
  74923. var q = new Quaternion();
  74924. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  74925. return q;
  74926. };
  74927. /**
  74928. * Updates a quaternion from Euler rotation vector
  74929. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  74930. * @param result the quaternion to store the result
  74931. * @returns the updated quaternion
  74932. */
  74933. Quaternion.FromEulerVectorToRef = function (vec, result) {
  74934. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  74935. return result;
  74936. };
  74937. /**
  74938. * Creates a new quaternion from the given Euler float angles (y, x, z)
  74939. * @param yaw defines the rotation around Y axis
  74940. * @param pitch defines the rotation around X axis
  74941. * @param roll defines the rotation around Z axis
  74942. * @returns the new quaternion
  74943. */
  74944. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  74945. var q = new Quaternion();
  74946. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  74947. return q;
  74948. };
  74949. /**
  74950. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  74951. * @param yaw defines the rotation around Y axis
  74952. * @param pitch defines the rotation around X axis
  74953. * @param roll defines the rotation around Z axis
  74954. * @param result defines the target quaternion
  74955. */
  74956. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  74957. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  74958. var halfRoll = roll * 0.5;
  74959. var halfPitch = pitch * 0.5;
  74960. var halfYaw = yaw * 0.5;
  74961. var sinRoll = Math.sin(halfRoll);
  74962. var cosRoll = Math.cos(halfRoll);
  74963. var sinPitch = Math.sin(halfPitch);
  74964. var cosPitch = Math.cos(halfPitch);
  74965. var sinYaw = Math.sin(halfYaw);
  74966. var cosYaw = Math.cos(halfYaw);
  74967. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  74968. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  74969. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  74970. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  74971. };
  74972. /**
  74973. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  74974. * @param alpha defines the rotation around first axis
  74975. * @param beta defines the rotation around second axis
  74976. * @param gamma defines the rotation around third axis
  74977. * @returns the new quaternion
  74978. */
  74979. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  74980. var result = new Quaternion();
  74981. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  74982. return result;
  74983. };
  74984. /**
  74985. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  74986. * @param alpha defines the rotation around first axis
  74987. * @param beta defines the rotation around second axis
  74988. * @param gamma defines the rotation around third axis
  74989. * @param result defines the target quaternion
  74990. */
  74991. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  74992. // Produces a quaternion from Euler angles in the z-x-z orientation
  74993. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  74994. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  74995. var halfBeta = beta * 0.5;
  74996. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  74997. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  74998. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  74999. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  75000. };
  75001. /**
  75002. * 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)
  75003. * @param axis1 defines the first axis
  75004. * @param axis2 defines the second axis
  75005. * @param axis3 defines the third axis
  75006. * @returns the new quaternion
  75007. */
  75008. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  75009. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  75010. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  75011. return quat;
  75012. };
  75013. /**
  75014. * 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
  75015. * @param axis1 defines the first axis
  75016. * @param axis2 defines the second axis
  75017. * @param axis3 defines the third axis
  75018. * @param ref defines the target quaternion
  75019. */
  75020. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  75021. var rotMat = MathTmp.Matrix[0];
  75022. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  75023. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  75024. };
  75025. /**
  75026. * Interpolates between two quaternions
  75027. * @param left defines first quaternion
  75028. * @param right defines second quaternion
  75029. * @param amount defines the gradient to use
  75030. * @returns the new interpolated quaternion
  75031. */
  75032. Quaternion.Slerp = function (left, right, amount) {
  75033. var result = Quaternion.Identity();
  75034. Quaternion.SlerpToRef(left, right, amount, result);
  75035. return result;
  75036. };
  75037. /**
  75038. * Interpolates between two quaternions and stores it into a target quaternion
  75039. * @param left defines first quaternion
  75040. * @param right defines second quaternion
  75041. * @param amount defines the gradient to use
  75042. * @param result defines the target quaternion
  75043. */
  75044. Quaternion.SlerpToRef = function (left, right, amount, result) {
  75045. var num2;
  75046. var num3;
  75047. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  75048. var flag = false;
  75049. if (num4 < 0) {
  75050. flag = true;
  75051. num4 = -num4;
  75052. }
  75053. if (num4 > 0.999999) {
  75054. num3 = 1 - amount;
  75055. num2 = flag ? -amount : amount;
  75056. }
  75057. else {
  75058. var num5 = Math.acos(num4);
  75059. var num6 = (1.0 / Math.sin(num5));
  75060. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  75061. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  75062. }
  75063. result.x = (num3 * left.x) + (num2 * right.x);
  75064. result.y = (num3 * left.y) + (num2 * right.y);
  75065. result.z = (num3 * left.z) + (num2 * right.z);
  75066. result.w = (num3 * left.w) + (num2 * right.w);
  75067. };
  75068. /**
  75069. * Interpolate between two quaternions using Hermite interpolation
  75070. * @param value1 defines first quaternion
  75071. * @param tangent1 defines the incoming tangent
  75072. * @param value2 defines second quaternion
  75073. * @param tangent2 defines the outgoing tangent
  75074. * @param amount defines the target quaternion
  75075. * @returns the new interpolated quaternion
  75076. */
  75077. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  75078. var squared = amount * amount;
  75079. var cubed = amount * squared;
  75080. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  75081. var part2 = (-2.0 * cubed) + (3.0 * squared);
  75082. var part3 = (cubed - (2.0 * squared)) + amount;
  75083. var part4 = cubed - squared;
  75084. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  75085. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  75086. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  75087. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  75088. return new Quaternion(x, y, z, w);
  75089. };
  75090. return Quaternion;
  75091. }());
  75092. /**
  75093. * Class used to store matrix data (4x4)
  75094. */
  75095. var Matrix = /** @class */ (function () {
  75096. /**
  75097. * Creates an empty matrix (filled with zeros)
  75098. */
  75099. function Matrix() {
  75100. this._isIdentity = false;
  75101. this._isIdentityDirty = true;
  75102. this._isIdentity3x2 = true;
  75103. this._isIdentity3x2Dirty = true;
  75104. this._m = new Float32Array(16);
  75105. this._updateIdentityStatus(false);
  75106. }
  75107. Object.defineProperty(Matrix.prototype, "m", {
  75108. /**
  75109. * Gets the internal data of the matrix
  75110. */
  75111. get: function () { return this._m; },
  75112. enumerable: true,
  75113. configurable: true
  75114. });
  75115. /** @hidden */
  75116. Matrix.prototype._markAsUpdated = function () {
  75117. this.updateFlag = Matrix._updateFlagSeed++;
  75118. this._isIdentity = false;
  75119. this._isIdentity3x2 = false;
  75120. this._isIdentityDirty = true;
  75121. this._isIdentity3x2Dirty = true;
  75122. };
  75123. /** @hidden */
  75124. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  75125. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  75126. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  75127. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  75128. this.updateFlag = Matrix._updateFlagSeed++;
  75129. this._isIdentity = isIdentity;
  75130. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  75131. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  75132. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  75133. };
  75134. // Properties
  75135. /**
  75136. * Check if the current matrix is identity
  75137. * @returns true is the matrix is the identity matrix
  75138. */
  75139. Matrix.prototype.isIdentity = function () {
  75140. if (this._isIdentityDirty) {
  75141. this._isIdentityDirty = false;
  75142. var m = this._m;
  75143. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  75144. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  75145. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  75146. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  75147. }
  75148. return this._isIdentity;
  75149. };
  75150. /**
  75151. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  75152. * @returns true is the matrix is the identity matrix
  75153. */
  75154. Matrix.prototype.isIdentityAs3x2 = function () {
  75155. if (this._isIdentity3x2Dirty) {
  75156. this._isIdentity3x2Dirty = false;
  75157. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  75158. this._isIdentity3x2 = false;
  75159. }
  75160. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  75161. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  75162. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  75163. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  75164. this._isIdentity3x2 = false;
  75165. }
  75166. else {
  75167. this._isIdentity3x2 = true;
  75168. }
  75169. }
  75170. return this._isIdentity3x2;
  75171. };
  75172. /**
  75173. * Gets the determinant of the matrix
  75174. * @returns the matrix determinant
  75175. */
  75176. Matrix.prototype.determinant = function () {
  75177. if (this._isIdentity === true) {
  75178. return 1;
  75179. }
  75180. var m = this._m;
  75181. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  75182. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  75183. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  75184. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  75185. // https://en.wikipedia.org/wiki/Laplace_expansion
  75186. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  75187. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  75188. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  75189. // where
  75190. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  75191. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  75192. //
  75193. // Here we do that for the 1st row.
  75194. var det_22_33 = m22 * m33 - m32 * m23;
  75195. var det_21_33 = m21 * m33 - m31 * m23;
  75196. var det_21_32 = m21 * m32 - m31 * m22;
  75197. var det_20_33 = m20 * m33 - m30 * m23;
  75198. var det_20_32 = m20 * m32 - m22 * m30;
  75199. var det_20_31 = m20 * m31 - m30 * m21;
  75200. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  75201. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  75202. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  75203. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  75204. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  75205. };
  75206. // Methods
  75207. /**
  75208. * Returns the matrix as a Float32Array
  75209. * @returns the matrix underlying array
  75210. */
  75211. Matrix.prototype.toArray = function () {
  75212. return this._m;
  75213. };
  75214. /**
  75215. * Returns the matrix as a Float32Array
  75216. * @returns the matrix underlying array.
  75217. */
  75218. Matrix.prototype.asArray = function () {
  75219. return this._m;
  75220. };
  75221. /**
  75222. * Inverts the current matrix in place
  75223. * @returns the current inverted matrix
  75224. */
  75225. Matrix.prototype.invert = function () {
  75226. this.invertToRef(this);
  75227. return this;
  75228. };
  75229. /**
  75230. * Sets all the matrix elements to zero
  75231. * @returns the current matrix
  75232. */
  75233. Matrix.prototype.reset = function () {
  75234. 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);
  75235. this._updateIdentityStatus(false);
  75236. return this;
  75237. };
  75238. /**
  75239. * Adds the current matrix with a second one
  75240. * @param other defines the matrix to add
  75241. * @returns a new matrix as the addition of the current matrix and the given one
  75242. */
  75243. Matrix.prototype.add = function (other) {
  75244. var result = new Matrix();
  75245. this.addToRef(other, result);
  75246. return result;
  75247. };
  75248. /**
  75249. * Sets the given matrix "result" to the addition of the current matrix and the given one
  75250. * @param other defines the matrix to add
  75251. * @param result defines the target matrix
  75252. * @returns the current matrix
  75253. */
  75254. Matrix.prototype.addToRef = function (other, result) {
  75255. var m = this._m;
  75256. var resultM = result._m;
  75257. var otherM = other.m;
  75258. for (var index = 0; index < 16; index++) {
  75259. resultM[index] = m[index] + otherM[index];
  75260. }
  75261. result._markAsUpdated();
  75262. return this;
  75263. };
  75264. /**
  75265. * Adds in place the given matrix to the current matrix
  75266. * @param other defines the second operand
  75267. * @returns the current updated matrix
  75268. */
  75269. Matrix.prototype.addToSelf = function (other) {
  75270. var m = this._m;
  75271. var otherM = other.m;
  75272. for (var index = 0; index < 16; index++) {
  75273. m[index] += otherM[index];
  75274. }
  75275. this._markAsUpdated();
  75276. return this;
  75277. };
  75278. /**
  75279. * Sets the given matrix to the current inverted Matrix
  75280. * @param other defines the target matrix
  75281. * @returns the unmodified current matrix
  75282. */
  75283. Matrix.prototype.invertToRef = function (other) {
  75284. if (this._isIdentity === true) {
  75285. Matrix.IdentityToRef(other);
  75286. return this;
  75287. }
  75288. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  75289. var m = this._m;
  75290. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  75291. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  75292. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  75293. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  75294. var det_22_33 = m22 * m33 - m32 * m23;
  75295. var det_21_33 = m21 * m33 - m31 * m23;
  75296. var det_21_32 = m21 * m32 - m31 * m22;
  75297. var det_20_33 = m20 * m33 - m30 * m23;
  75298. var det_20_32 = m20 * m32 - m22 * m30;
  75299. var det_20_31 = m20 * m31 - m30 * m21;
  75300. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  75301. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  75302. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  75303. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  75304. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  75305. if (det === 0) {
  75306. // not invertible
  75307. other.copyFrom(this);
  75308. return this;
  75309. }
  75310. var detInv = 1 / det;
  75311. var det_12_33 = m12 * m33 - m32 * m13;
  75312. var det_11_33 = m11 * m33 - m31 * m13;
  75313. var det_11_32 = m11 * m32 - m31 * m12;
  75314. var det_10_33 = m10 * m33 - m30 * m13;
  75315. var det_10_32 = m10 * m32 - m30 * m12;
  75316. var det_10_31 = m10 * m31 - m30 * m11;
  75317. var det_12_23 = m12 * m23 - m22 * m13;
  75318. var det_11_23 = m11 * m23 - m21 * m13;
  75319. var det_11_22 = m11 * m22 - m21 * m12;
  75320. var det_10_23 = m10 * m23 - m20 * m13;
  75321. var det_10_22 = m10 * m22 - m20 * m12;
  75322. var det_10_21 = m10 * m21 - m20 * m11;
  75323. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  75324. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  75325. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  75326. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  75327. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  75328. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  75329. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  75330. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  75331. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  75332. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  75333. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  75334. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  75335. 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);
  75336. return this;
  75337. };
  75338. /**
  75339. * add a value at the specified position in the current Matrix
  75340. * @param index the index of the value within the matrix. between 0 and 15.
  75341. * @param value the value to be added
  75342. * @returns the current updated matrix
  75343. */
  75344. Matrix.prototype.addAtIndex = function (index, value) {
  75345. this._m[index] += value;
  75346. this._markAsUpdated();
  75347. return this;
  75348. };
  75349. /**
  75350. * mutiply the specified position in the current Matrix by a value
  75351. * @param index the index of the value within the matrix. between 0 and 15.
  75352. * @param value the value to be added
  75353. * @returns the current updated matrix
  75354. */
  75355. Matrix.prototype.multiplyAtIndex = function (index, value) {
  75356. this._m[index] *= value;
  75357. this._markAsUpdated();
  75358. return this;
  75359. };
  75360. /**
  75361. * Inserts the translation vector (using 3 floats) in the current matrix
  75362. * @param x defines the 1st component of the translation
  75363. * @param y defines the 2nd component of the translation
  75364. * @param z defines the 3rd component of the translation
  75365. * @returns the current updated matrix
  75366. */
  75367. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  75368. this._m[12] = x;
  75369. this._m[13] = y;
  75370. this._m[14] = z;
  75371. this._markAsUpdated();
  75372. return this;
  75373. };
  75374. /**
  75375. * Adds the translation vector (using 3 floats) in the current matrix
  75376. * @param x defines the 1st component of the translation
  75377. * @param y defines the 2nd component of the translation
  75378. * @param z defines the 3rd component of the translation
  75379. * @returns the current updated matrix
  75380. */
  75381. Matrix.prototype.addTranslationFromFloats = function (x, y, z) {
  75382. this._m[12] += x;
  75383. this._m[13] += y;
  75384. this._m[14] += z;
  75385. this._markAsUpdated();
  75386. return this;
  75387. };
  75388. /**
  75389. * Inserts the translation vector in the current matrix
  75390. * @param vector3 defines the translation to insert
  75391. * @returns the current updated matrix
  75392. */
  75393. Matrix.prototype.setTranslation = function (vector3) {
  75394. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  75395. };
  75396. /**
  75397. * Gets the translation value of the current matrix
  75398. * @returns a new Vector3 as the extracted translation from the matrix
  75399. */
  75400. Matrix.prototype.getTranslation = function () {
  75401. return new Vector3(this._m[12], this._m[13], this._m[14]);
  75402. };
  75403. /**
  75404. * Fill a Vector3 with the extracted translation from the matrix
  75405. * @param result defines the Vector3 where to store the translation
  75406. * @returns the current matrix
  75407. */
  75408. Matrix.prototype.getTranslationToRef = function (result) {
  75409. result.x = this._m[12];
  75410. result.y = this._m[13];
  75411. result.z = this._m[14];
  75412. return this;
  75413. };
  75414. /**
  75415. * Remove rotation and scaling part from the matrix
  75416. * @returns the updated matrix
  75417. */
  75418. Matrix.prototype.removeRotationAndScaling = function () {
  75419. var m = this.m;
  75420. 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);
  75421. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  75422. return this;
  75423. };
  75424. /**
  75425. * Multiply two matrices
  75426. * @param other defines the second operand
  75427. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  75428. */
  75429. Matrix.prototype.multiply = function (other) {
  75430. var result = new Matrix();
  75431. this.multiplyToRef(other, result);
  75432. return result;
  75433. };
  75434. /**
  75435. * Copy the current matrix from the given one
  75436. * @param other defines the source matrix
  75437. * @returns the current updated matrix
  75438. */
  75439. Matrix.prototype.copyFrom = function (other) {
  75440. other.copyToArray(this._m);
  75441. var o = other;
  75442. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  75443. return this;
  75444. };
  75445. /**
  75446. * Populates the given array from the starting index with the current matrix values
  75447. * @param array defines the target array
  75448. * @param offset defines the offset in the target array where to start storing values
  75449. * @returns the current matrix
  75450. */
  75451. Matrix.prototype.copyToArray = function (array, offset) {
  75452. if (offset === void 0) { offset = 0; }
  75453. for (var index = 0; index < 16; index++) {
  75454. array[offset + index] = this._m[index];
  75455. }
  75456. return this;
  75457. };
  75458. /**
  75459. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  75460. * @param other defines the second operand
  75461. * @param result defines the matrix where to store the multiplication
  75462. * @returns the current matrix
  75463. */
  75464. Matrix.prototype.multiplyToRef = function (other, result) {
  75465. if (this._isIdentity) {
  75466. result.copyFrom(other);
  75467. return this;
  75468. }
  75469. if (other._isIdentity) {
  75470. result.copyFrom(this);
  75471. return this;
  75472. }
  75473. this.multiplyToArray(other, result._m, 0);
  75474. result._markAsUpdated();
  75475. return this;
  75476. };
  75477. /**
  75478. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  75479. * @param other defines the second operand
  75480. * @param result defines the array where to store the multiplication
  75481. * @param offset defines the offset in the target array where to start storing values
  75482. * @returns the current matrix
  75483. */
  75484. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  75485. var m = this._m;
  75486. var otherM = other.m;
  75487. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  75488. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  75489. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  75490. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  75491. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  75492. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  75493. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  75494. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  75495. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  75496. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  75497. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  75498. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  75499. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  75500. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  75501. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  75502. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  75503. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  75504. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  75505. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  75506. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  75507. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  75508. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  75509. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  75510. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  75511. return this;
  75512. };
  75513. /**
  75514. * Check equality between this matrix and a second one
  75515. * @param value defines the second matrix to compare
  75516. * @returns true is the current matrix and the given one values are strictly equal
  75517. */
  75518. Matrix.prototype.equals = function (value) {
  75519. var other = value;
  75520. if (!other) {
  75521. return false;
  75522. }
  75523. if (this._isIdentity || other._isIdentity) {
  75524. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  75525. return this._isIdentity && other._isIdentity;
  75526. }
  75527. }
  75528. var m = this.m;
  75529. var om = other.m;
  75530. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  75531. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  75532. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  75533. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  75534. };
  75535. /**
  75536. * Clone the current matrix
  75537. * @returns a new matrix from the current matrix
  75538. */
  75539. Matrix.prototype.clone = function () {
  75540. var matrix = new Matrix();
  75541. matrix.copyFrom(this);
  75542. return matrix;
  75543. };
  75544. /**
  75545. * Returns the name of the current matrix class
  75546. * @returns the string "Matrix"
  75547. */
  75548. Matrix.prototype.getClassName = function () {
  75549. return "Matrix";
  75550. };
  75551. /**
  75552. * Gets the hash code of the current matrix
  75553. * @returns the hash code
  75554. */
  75555. Matrix.prototype.getHashCode = function () {
  75556. var hash = this._m[0] || 0;
  75557. for (var i = 1; i < 16; i++) {
  75558. hash = (hash * 397) ^ (this._m[i] || 0);
  75559. }
  75560. return hash;
  75561. };
  75562. /**
  75563. * Decomposes the current Matrix into a translation, rotation and scaling components
  75564. * @param scale defines the scale vector3 given as a reference to update
  75565. * @param rotation defines the rotation quaternion given as a reference to update
  75566. * @param translation defines the translation vector3 given as a reference to update
  75567. * @returns true if operation was successful
  75568. */
  75569. Matrix.prototype.decompose = function (scale, rotation, translation) {
  75570. if (this._isIdentity) {
  75571. if (translation) {
  75572. translation.setAll(0);
  75573. }
  75574. if (scale) {
  75575. scale.setAll(1);
  75576. }
  75577. if (rotation) {
  75578. rotation.copyFromFloats(0, 0, 0, 1);
  75579. }
  75580. return true;
  75581. }
  75582. var m = this._m;
  75583. if (translation) {
  75584. translation.copyFromFloats(m[12], m[13], m[14]);
  75585. }
  75586. scale = scale || MathTmp.Vector3[0];
  75587. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  75588. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  75589. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  75590. if (this.determinant() <= 0) {
  75591. scale.y *= -1;
  75592. }
  75593. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  75594. if (rotation) {
  75595. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  75596. }
  75597. return false;
  75598. }
  75599. if (rotation) {
  75600. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  75601. 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]);
  75602. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  75603. }
  75604. return true;
  75605. };
  75606. /**
  75607. * Gets specific row of the matrix
  75608. * @param index defines the number of the row to get
  75609. * @returns the index-th row of the current matrix as a new Vector4
  75610. */
  75611. Matrix.prototype.getRow = function (index) {
  75612. if (index < 0 || index > 3) {
  75613. return null;
  75614. }
  75615. var i = index * 4;
  75616. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  75617. };
  75618. /**
  75619. * Sets the index-th row of the current matrix to the vector4 values
  75620. * @param index defines the number of the row to set
  75621. * @param row defines the target vector4
  75622. * @returns the updated current matrix
  75623. */
  75624. Matrix.prototype.setRow = function (index, row) {
  75625. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  75626. };
  75627. /**
  75628. * Compute the transpose of the matrix
  75629. * @returns the new transposed matrix
  75630. */
  75631. Matrix.prototype.transpose = function () {
  75632. return Matrix.Transpose(this);
  75633. };
  75634. /**
  75635. * Compute the transpose of the matrix and store it in a given matrix
  75636. * @param result defines the target matrix
  75637. * @returns the current matrix
  75638. */
  75639. Matrix.prototype.transposeToRef = function (result) {
  75640. Matrix.TransposeToRef(this, result);
  75641. return this;
  75642. };
  75643. /**
  75644. * Sets the index-th row of the current matrix with the given 4 x float values
  75645. * @param index defines the row index
  75646. * @param x defines the x component to set
  75647. * @param y defines the y component to set
  75648. * @param z defines the z component to set
  75649. * @param w defines the w component to set
  75650. * @returns the updated current matrix
  75651. */
  75652. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  75653. if (index < 0 || index > 3) {
  75654. return this;
  75655. }
  75656. var i = index * 4;
  75657. this._m[i + 0] = x;
  75658. this._m[i + 1] = y;
  75659. this._m[i + 2] = z;
  75660. this._m[i + 3] = w;
  75661. this._markAsUpdated();
  75662. return this;
  75663. };
  75664. /**
  75665. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  75666. * @param scale defines the scale factor
  75667. * @returns a new matrix
  75668. */
  75669. Matrix.prototype.scale = function (scale) {
  75670. var result = new Matrix();
  75671. this.scaleToRef(scale, result);
  75672. return result;
  75673. };
  75674. /**
  75675. * Scale the current matrix values by a factor to a given result matrix
  75676. * @param scale defines the scale factor
  75677. * @param result defines the matrix to store the result
  75678. * @returns the current matrix
  75679. */
  75680. Matrix.prototype.scaleToRef = function (scale, result) {
  75681. for (var index = 0; index < 16; index++) {
  75682. result._m[index] = this._m[index] * scale;
  75683. }
  75684. result._markAsUpdated();
  75685. return this;
  75686. };
  75687. /**
  75688. * Scale the current matrix values by a factor and add the result to a given matrix
  75689. * @param scale defines the scale factor
  75690. * @param result defines the Matrix to store the result
  75691. * @returns the current matrix
  75692. */
  75693. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  75694. for (var index = 0; index < 16; index++) {
  75695. result._m[index] += this._m[index] * scale;
  75696. }
  75697. result._markAsUpdated();
  75698. return this;
  75699. };
  75700. /**
  75701. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  75702. * @param ref matrix to store the result
  75703. */
  75704. Matrix.prototype.toNormalMatrix = function (ref) {
  75705. var tmp = MathTmp.Matrix[0];
  75706. this.invertToRef(tmp);
  75707. tmp.transposeToRef(ref);
  75708. var m = ref._m;
  75709. 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);
  75710. };
  75711. /**
  75712. * Gets only rotation part of the current matrix
  75713. * @returns a new matrix sets to the extracted rotation matrix from the current one
  75714. */
  75715. Matrix.prototype.getRotationMatrix = function () {
  75716. var result = new Matrix();
  75717. this.getRotationMatrixToRef(result);
  75718. return result;
  75719. };
  75720. /**
  75721. * Extracts the rotation matrix from the current one and sets it as the given "result"
  75722. * @param result defines the target matrix to store data to
  75723. * @returns the current matrix
  75724. */
  75725. Matrix.prototype.getRotationMatrixToRef = function (result) {
  75726. var scale = MathTmp.Vector3[0];
  75727. if (!this.decompose(scale)) {
  75728. Matrix.IdentityToRef(result);
  75729. return this;
  75730. }
  75731. var m = this._m;
  75732. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  75733. 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);
  75734. return this;
  75735. };
  75736. /**
  75737. * Toggles model matrix from being right handed to left handed in place and vice versa
  75738. */
  75739. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  75740. var m = this._m;
  75741. m[2] *= -1;
  75742. m[6] *= -1;
  75743. m[8] *= -1;
  75744. m[9] *= -1;
  75745. m[14] *= -1;
  75746. this._markAsUpdated();
  75747. };
  75748. /**
  75749. * Toggles projection matrix from being right handed to left handed in place and vice versa
  75750. */
  75751. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  75752. var m = this._m;
  75753. m[8] *= -1;
  75754. m[9] *= -1;
  75755. m[10] *= -1;
  75756. m[11] *= -1;
  75757. this._markAsUpdated();
  75758. };
  75759. // Statics
  75760. /**
  75761. * Creates a matrix from an array
  75762. * @param array defines the source array
  75763. * @param offset defines an offset in the source array
  75764. * @returns a new Matrix set from the starting index of the given array
  75765. */
  75766. Matrix.FromArray = function (array, offset) {
  75767. if (offset === void 0) { offset = 0; }
  75768. var result = new Matrix();
  75769. Matrix.FromArrayToRef(array, offset, result);
  75770. return result;
  75771. };
  75772. /**
  75773. * Copy the content of an array into a given matrix
  75774. * @param array defines the source array
  75775. * @param offset defines an offset in the source array
  75776. * @param result defines the target matrix
  75777. */
  75778. Matrix.FromArrayToRef = function (array, offset, result) {
  75779. for (var index = 0; index < 16; index++) {
  75780. result._m[index] = array[index + offset];
  75781. }
  75782. result._markAsUpdated();
  75783. };
  75784. /**
  75785. * Stores an array into a matrix after having multiplied each component by a given factor
  75786. * @param array defines the source array
  75787. * @param offset defines the offset in the source array
  75788. * @param scale defines the scaling factor
  75789. * @param result defines the target matrix
  75790. */
  75791. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  75792. for (var index = 0; index < 16; index++) {
  75793. result._m[index] = array[index + offset] * scale;
  75794. }
  75795. result._markAsUpdated();
  75796. };
  75797. Object.defineProperty(Matrix, "IdentityReadOnly", {
  75798. /**
  75799. * Gets an identity matrix that must not be updated
  75800. */
  75801. get: function () {
  75802. return Matrix._identityReadOnly;
  75803. },
  75804. enumerable: true,
  75805. configurable: true
  75806. });
  75807. /**
  75808. * Stores a list of values (16) inside a given matrix
  75809. * @param initialM11 defines 1st value of 1st row
  75810. * @param initialM12 defines 2nd value of 1st row
  75811. * @param initialM13 defines 3rd value of 1st row
  75812. * @param initialM14 defines 4th value of 1st row
  75813. * @param initialM21 defines 1st value of 2nd row
  75814. * @param initialM22 defines 2nd value of 2nd row
  75815. * @param initialM23 defines 3rd value of 2nd row
  75816. * @param initialM24 defines 4th value of 2nd row
  75817. * @param initialM31 defines 1st value of 3rd row
  75818. * @param initialM32 defines 2nd value of 3rd row
  75819. * @param initialM33 defines 3rd value of 3rd row
  75820. * @param initialM34 defines 4th value of 3rd row
  75821. * @param initialM41 defines 1st value of 4th row
  75822. * @param initialM42 defines 2nd value of 4th row
  75823. * @param initialM43 defines 3rd value of 4th row
  75824. * @param initialM44 defines 4th value of 4th row
  75825. * @param result defines the target matrix
  75826. */
  75827. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  75828. var m = result._m;
  75829. m[0] = initialM11;
  75830. m[1] = initialM12;
  75831. m[2] = initialM13;
  75832. m[3] = initialM14;
  75833. m[4] = initialM21;
  75834. m[5] = initialM22;
  75835. m[6] = initialM23;
  75836. m[7] = initialM24;
  75837. m[8] = initialM31;
  75838. m[9] = initialM32;
  75839. m[10] = initialM33;
  75840. m[11] = initialM34;
  75841. m[12] = initialM41;
  75842. m[13] = initialM42;
  75843. m[14] = initialM43;
  75844. m[15] = initialM44;
  75845. result._markAsUpdated();
  75846. };
  75847. /**
  75848. * Creates new matrix from a list of values (16)
  75849. * @param initialM11 defines 1st value of 1st row
  75850. * @param initialM12 defines 2nd value of 1st row
  75851. * @param initialM13 defines 3rd value of 1st row
  75852. * @param initialM14 defines 4th value of 1st row
  75853. * @param initialM21 defines 1st value of 2nd row
  75854. * @param initialM22 defines 2nd value of 2nd row
  75855. * @param initialM23 defines 3rd value of 2nd row
  75856. * @param initialM24 defines 4th value of 2nd row
  75857. * @param initialM31 defines 1st value of 3rd row
  75858. * @param initialM32 defines 2nd value of 3rd row
  75859. * @param initialM33 defines 3rd value of 3rd row
  75860. * @param initialM34 defines 4th value of 3rd row
  75861. * @param initialM41 defines 1st value of 4th row
  75862. * @param initialM42 defines 2nd value of 4th row
  75863. * @param initialM43 defines 3rd value of 4th row
  75864. * @param initialM44 defines 4th value of 4th row
  75865. * @returns the new matrix
  75866. */
  75867. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  75868. var result = new Matrix();
  75869. var m = result._m;
  75870. m[0] = initialM11;
  75871. m[1] = initialM12;
  75872. m[2] = initialM13;
  75873. m[3] = initialM14;
  75874. m[4] = initialM21;
  75875. m[5] = initialM22;
  75876. m[6] = initialM23;
  75877. m[7] = initialM24;
  75878. m[8] = initialM31;
  75879. m[9] = initialM32;
  75880. m[10] = initialM33;
  75881. m[11] = initialM34;
  75882. m[12] = initialM41;
  75883. m[13] = initialM42;
  75884. m[14] = initialM43;
  75885. m[15] = initialM44;
  75886. result._markAsUpdated();
  75887. return result;
  75888. };
  75889. /**
  75890. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  75891. * @param scale defines the scale vector3
  75892. * @param rotation defines the rotation quaternion
  75893. * @param translation defines the translation vector3
  75894. * @returns a new matrix
  75895. */
  75896. Matrix.Compose = function (scale, rotation, translation) {
  75897. var result = new Matrix();
  75898. Matrix.ComposeToRef(scale, rotation, translation, result);
  75899. return result;
  75900. };
  75901. /**
  75902. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  75903. * @param scale defines the scale vector3
  75904. * @param rotation defines the rotation quaternion
  75905. * @param translation defines the translation vector3
  75906. * @param result defines the target matrix
  75907. */
  75908. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  75909. var m = result._m;
  75910. var x = rotation.x, y = rotation.y, z = rotation.z, w = rotation.w;
  75911. var x2 = x + x, y2 = y + y, z2 = z + z;
  75912. var xx = x * x2, xy = x * y2, xz = x * z2;
  75913. var yy = y * y2, yz = y * z2, zz = z * z2;
  75914. var wx = w * x2, wy = w * y2, wz = w * z2;
  75915. var sx = scale.x, sy = scale.y, sz = scale.z;
  75916. m[0] = (1 - (yy + zz)) * sx;
  75917. m[1] = (xy + wz) * sx;
  75918. m[2] = (xz - wy) * sx;
  75919. m[3] = 0;
  75920. m[4] = (xy - wz) * sy;
  75921. m[5] = (1 - (xx + zz)) * sy;
  75922. m[6] = (yz + wx) * sy;
  75923. m[7] = 0;
  75924. m[8] = (xz + wy) * sz;
  75925. m[9] = (yz - wx) * sz;
  75926. m[10] = (1 - (xx + yy)) * sz;
  75927. m[11] = 0;
  75928. m[12] = translation.x;
  75929. m[13] = translation.y;
  75930. m[14] = translation.z;
  75931. m[15] = 1;
  75932. };
  75933. /**
  75934. * Creates a new identity matrix
  75935. * @returns a new identity matrix
  75936. */
  75937. Matrix.Identity = function () {
  75938. 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);
  75939. identity._updateIdentityStatus(true);
  75940. return identity;
  75941. };
  75942. /**
  75943. * Creates a new identity matrix and stores the result in a given matrix
  75944. * @param result defines the target matrix
  75945. */
  75946. Matrix.IdentityToRef = function (result) {
  75947. 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);
  75948. result._updateIdentityStatus(true);
  75949. };
  75950. /**
  75951. * Creates a new zero matrix
  75952. * @returns a new zero matrix
  75953. */
  75954. Matrix.Zero = function () {
  75955. 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);
  75956. zero._updateIdentityStatus(false);
  75957. return zero;
  75958. };
  75959. /**
  75960. * Creates a new rotation matrix for "angle" radians around the X axis
  75961. * @param angle defines the angle (in radians) to use
  75962. * @return the new matrix
  75963. */
  75964. Matrix.RotationX = function (angle) {
  75965. var result = new Matrix();
  75966. Matrix.RotationXToRef(angle, result);
  75967. return result;
  75968. };
  75969. /**
  75970. * Creates a new matrix as the invert of a given matrix
  75971. * @param source defines the source matrix
  75972. * @returns the new matrix
  75973. */
  75974. Matrix.Invert = function (source) {
  75975. var result = new Matrix();
  75976. source.invertToRef(result);
  75977. return result;
  75978. };
  75979. /**
  75980. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  75981. * @param angle defines the angle (in radians) to use
  75982. * @param result defines the target matrix
  75983. */
  75984. Matrix.RotationXToRef = function (angle, result) {
  75985. var s = Math.sin(angle);
  75986. var c = Math.cos(angle);
  75987. 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);
  75988. result._updateIdentityStatus(c === 1 && s === 0);
  75989. };
  75990. /**
  75991. * Creates a new rotation matrix for "angle" radians around the Y axis
  75992. * @param angle defines the angle (in radians) to use
  75993. * @return the new matrix
  75994. */
  75995. Matrix.RotationY = function (angle) {
  75996. var result = new Matrix();
  75997. Matrix.RotationYToRef(angle, result);
  75998. return result;
  75999. };
  76000. /**
  76001. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  76002. * @param angle defines the angle (in radians) to use
  76003. * @param result defines the target matrix
  76004. */
  76005. Matrix.RotationYToRef = function (angle, result) {
  76006. var s = Math.sin(angle);
  76007. var c = Math.cos(angle);
  76008. 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);
  76009. result._updateIdentityStatus(c === 1 && s === 0);
  76010. };
  76011. /**
  76012. * Creates a new rotation matrix for "angle" radians around the Z axis
  76013. * @param angle defines the angle (in radians) to use
  76014. * @return the new matrix
  76015. */
  76016. Matrix.RotationZ = function (angle) {
  76017. var result = new Matrix();
  76018. Matrix.RotationZToRef(angle, result);
  76019. return result;
  76020. };
  76021. /**
  76022. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  76023. * @param angle defines the angle (in radians) to use
  76024. * @param result defines the target matrix
  76025. */
  76026. Matrix.RotationZToRef = function (angle, result) {
  76027. var s = Math.sin(angle);
  76028. var c = Math.cos(angle);
  76029. 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);
  76030. result._updateIdentityStatus(c === 1 && s === 0);
  76031. };
  76032. /**
  76033. * Creates a new rotation matrix for "angle" radians around the given axis
  76034. * @param axis defines the axis to use
  76035. * @param angle defines the angle (in radians) to use
  76036. * @return the new matrix
  76037. */
  76038. Matrix.RotationAxis = function (axis, angle) {
  76039. var result = new Matrix();
  76040. Matrix.RotationAxisToRef(axis, angle, result);
  76041. return result;
  76042. };
  76043. /**
  76044. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  76045. * @param axis defines the axis to use
  76046. * @param angle defines the angle (in radians) to use
  76047. * @param result defines the target matrix
  76048. */
  76049. Matrix.RotationAxisToRef = function (axis, angle, result) {
  76050. var s = Math.sin(-angle);
  76051. var c = Math.cos(-angle);
  76052. var c1 = 1 - c;
  76053. axis.normalize();
  76054. var m = result._m;
  76055. m[0] = (axis.x * axis.x) * c1 + c;
  76056. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  76057. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  76058. m[3] = 0.0;
  76059. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  76060. m[5] = (axis.y * axis.y) * c1 + c;
  76061. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  76062. m[7] = 0.0;
  76063. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  76064. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  76065. m[10] = (axis.z * axis.z) * c1 + c;
  76066. m[11] = 0.0;
  76067. m[12] = 0.0;
  76068. m[13] = 0.0;
  76069. m[14] = 0.0;
  76070. m[15] = 1.0;
  76071. result._markAsUpdated();
  76072. };
  76073. /**
  76074. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  76075. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  76076. * @param from defines the vector to align
  76077. * @param to defines the vector to align to
  76078. * @param result defines the target matrix
  76079. */
  76080. Matrix.RotationAlignToRef = function (from, to, result) {
  76081. var v = Vector3.Cross(to, from);
  76082. var c = Vector3.Dot(to, from);
  76083. var k = 1 / (1 + c);
  76084. var m = result._m;
  76085. m[0] = v.x * v.x * k + c;
  76086. m[1] = v.y * v.x * k - v.z;
  76087. m[2] = v.z * v.x * k + v.y;
  76088. m[3] = 0;
  76089. m[4] = v.x * v.y * k + v.z;
  76090. m[5] = v.y * v.y * k + c;
  76091. m[6] = v.z * v.y * k - v.x;
  76092. m[7] = 0;
  76093. m[8] = v.x * v.z * k - v.y;
  76094. m[9] = v.y * v.z * k + v.x;
  76095. m[10] = v.z * v.z * k + c;
  76096. m[11] = 0;
  76097. m[12] = 0;
  76098. m[13] = 0;
  76099. m[14] = 0;
  76100. m[15] = 1;
  76101. result._markAsUpdated();
  76102. };
  76103. /**
  76104. * Creates a rotation matrix
  76105. * @param yaw defines the yaw angle in radians (Y axis)
  76106. * @param pitch defines the pitch angle in radians (X axis)
  76107. * @param roll defines the roll angle in radians (X axis)
  76108. * @returns the new rotation matrix
  76109. */
  76110. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  76111. var result = new Matrix();
  76112. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  76113. return result;
  76114. };
  76115. /**
  76116. * Creates a rotation matrix and stores it in a given matrix
  76117. * @param yaw defines the yaw angle in radians (Y axis)
  76118. * @param pitch defines the pitch angle in radians (X axis)
  76119. * @param roll defines the roll angle in radians (X axis)
  76120. * @param result defines the target matrix
  76121. */
  76122. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  76123. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  76124. MathTmp.Quaternion[0].toRotationMatrix(result);
  76125. };
  76126. /**
  76127. * Creates a scaling matrix
  76128. * @param x defines the scale factor on X axis
  76129. * @param y defines the scale factor on Y axis
  76130. * @param z defines the scale factor on Z axis
  76131. * @returns the new matrix
  76132. */
  76133. Matrix.Scaling = function (x, y, z) {
  76134. var result = new Matrix();
  76135. Matrix.ScalingToRef(x, y, z, result);
  76136. return result;
  76137. };
  76138. /**
  76139. * Creates a scaling matrix and stores it in a given matrix
  76140. * @param x defines the scale factor on X axis
  76141. * @param y defines the scale factor on Y axis
  76142. * @param z defines the scale factor on Z axis
  76143. * @param result defines the target matrix
  76144. */
  76145. Matrix.ScalingToRef = function (x, y, z, result) {
  76146. 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);
  76147. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  76148. };
  76149. /**
  76150. * Creates a translation matrix
  76151. * @param x defines the translation on X axis
  76152. * @param y defines the translation on Y axis
  76153. * @param z defines the translationon Z axis
  76154. * @returns the new matrix
  76155. */
  76156. Matrix.Translation = function (x, y, z) {
  76157. var result = new Matrix();
  76158. Matrix.TranslationToRef(x, y, z, result);
  76159. return result;
  76160. };
  76161. /**
  76162. * Creates a translation matrix and stores it in a given matrix
  76163. * @param x defines the translation on X axis
  76164. * @param y defines the translation on Y axis
  76165. * @param z defines the translationon Z axis
  76166. * @param result defines the target matrix
  76167. */
  76168. Matrix.TranslationToRef = function (x, y, z, result) {
  76169. 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);
  76170. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  76171. };
  76172. /**
  76173. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  76174. * @param startValue defines the start value
  76175. * @param endValue defines the end value
  76176. * @param gradient defines the gradient factor
  76177. * @returns the new matrix
  76178. */
  76179. Matrix.Lerp = function (startValue, endValue, gradient) {
  76180. var result = new Matrix();
  76181. Matrix.LerpToRef(startValue, endValue, gradient, result);
  76182. return result;
  76183. };
  76184. /**
  76185. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  76186. * @param startValue defines the start value
  76187. * @param endValue defines the end value
  76188. * @param gradient defines the gradient factor
  76189. * @param result defines the Matrix object where to store data
  76190. */
  76191. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  76192. var resultM = result._m;
  76193. var startM = startValue.m;
  76194. var endM = endValue.m;
  76195. for (var index = 0; index < 16; index++) {
  76196. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  76197. }
  76198. result._markAsUpdated();
  76199. };
  76200. /**
  76201. * Builds a new matrix whose values are computed by:
  76202. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  76203. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  76204. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  76205. * @param startValue defines the first matrix
  76206. * @param endValue defines the second matrix
  76207. * @param gradient defines the gradient between the two matrices
  76208. * @returns the new matrix
  76209. */
  76210. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  76211. var result = new Matrix();
  76212. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  76213. return result;
  76214. };
  76215. /**
  76216. * Update a matrix to values which are computed by:
  76217. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  76218. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  76219. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  76220. * @param startValue defines the first matrix
  76221. * @param endValue defines the second matrix
  76222. * @param gradient defines the gradient between the two matrices
  76223. * @param result defines the target matrix
  76224. */
  76225. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  76226. var startScale = MathTmp.Vector3[0];
  76227. var startRotation = MathTmp.Quaternion[0];
  76228. var startTranslation = MathTmp.Vector3[1];
  76229. startValue.decompose(startScale, startRotation, startTranslation);
  76230. var endScale = MathTmp.Vector3[2];
  76231. var endRotation = MathTmp.Quaternion[1];
  76232. var endTranslation = MathTmp.Vector3[3];
  76233. endValue.decompose(endScale, endRotation, endTranslation);
  76234. var resultScale = MathTmp.Vector3[4];
  76235. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  76236. var resultRotation = MathTmp.Quaternion[2];
  76237. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  76238. var resultTranslation = MathTmp.Vector3[5];
  76239. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  76240. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  76241. };
  76242. /**
  76243. * 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"
  76244. * This function works in left handed mode
  76245. * @param eye defines the final position of the entity
  76246. * @param target defines where the entity should look at
  76247. * @param up defines the up vector for the entity
  76248. * @returns the new matrix
  76249. */
  76250. Matrix.LookAtLH = function (eye, target, up) {
  76251. var result = new Matrix();
  76252. Matrix.LookAtLHToRef(eye, target, up, result);
  76253. return result;
  76254. };
  76255. /**
  76256. * 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".
  76257. * This function works in left handed mode
  76258. * @param eye defines the final position of the entity
  76259. * @param target defines where the entity should look at
  76260. * @param up defines the up vector for the entity
  76261. * @param result defines the target matrix
  76262. */
  76263. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  76264. var xAxis = MathTmp.Vector3[0];
  76265. var yAxis = MathTmp.Vector3[1];
  76266. var zAxis = MathTmp.Vector3[2];
  76267. // Z axis
  76268. target.subtractToRef(eye, zAxis);
  76269. zAxis.normalize();
  76270. // X axis
  76271. Vector3.CrossToRef(up, zAxis, xAxis);
  76272. var xSquareLength = xAxis.lengthSquared();
  76273. if (xSquareLength === 0) {
  76274. xAxis.x = 1.0;
  76275. }
  76276. else {
  76277. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  76278. }
  76279. // Y axis
  76280. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  76281. yAxis.normalize();
  76282. // Eye angles
  76283. var ex = -Vector3.Dot(xAxis, eye);
  76284. var ey = -Vector3.Dot(yAxis, eye);
  76285. var ez = -Vector3.Dot(zAxis, eye);
  76286. 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);
  76287. };
  76288. /**
  76289. * 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"
  76290. * This function works in right handed mode
  76291. * @param eye defines the final position of the entity
  76292. * @param target defines where the entity should look at
  76293. * @param up defines the up vector for the entity
  76294. * @returns the new matrix
  76295. */
  76296. Matrix.LookAtRH = function (eye, target, up) {
  76297. var result = new Matrix();
  76298. Matrix.LookAtRHToRef(eye, target, up, result);
  76299. return result;
  76300. };
  76301. /**
  76302. * 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".
  76303. * This function works in right handed mode
  76304. * @param eye defines the final position of the entity
  76305. * @param target defines where the entity should look at
  76306. * @param up defines the up vector for the entity
  76307. * @param result defines the target matrix
  76308. */
  76309. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  76310. var xAxis = MathTmp.Vector3[0];
  76311. var yAxis = MathTmp.Vector3[1];
  76312. var zAxis = MathTmp.Vector3[2];
  76313. // Z axis
  76314. eye.subtractToRef(target, zAxis);
  76315. zAxis.normalize();
  76316. // X axis
  76317. Vector3.CrossToRef(up, zAxis, xAxis);
  76318. var xSquareLength = xAxis.lengthSquared();
  76319. if (xSquareLength === 0) {
  76320. xAxis.x = 1.0;
  76321. }
  76322. else {
  76323. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  76324. }
  76325. // Y axis
  76326. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  76327. yAxis.normalize();
  76328. // Eye angles
  76329. var ex = -Vector3.Dot(xAxis, eye);
  76330. var ey = -Vector3.Dot(yAxis, eye);
  76331. var ez = -Vector3.Dot(zAxis, eye);
  76332. 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);
  76333. };
  76334. /**
  76335. * Create a left-handed orthographic projection matrix
  76336. * @param width defines the viewport width
  76337. * @param height defines the viewport height
  76338. * @param znear defines the near clip plane
  76339. * @param zfar defines the far clip plane
  76340. * @returns a new matrix as a left-handed orthographic projection matrix
  76341. */
  76342. Matrix.OrthoLH = function (width, height, znear, zfar) {
  76343. var matrix = new Matrix();
  76344. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  76345. return matrix;
  76346. };
  76347. /**
  76348. * Store a left-handed orthographic projection to a given matrix
  76349. * @param width defines the viewport width
  76350. * @param height defines the viewport height
  76351. * @param znear defines the near clip plane
  76352. * @param zfar defines the far clip plane
  76353. * @param result defines the target matrix
  76354. */
  76355. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  76356. var n = znear;
  76357. var f = zfar;
  76358. var a = 2.0 / width;
  76359. var b = 2.0 / height;
  76360. var c = 2.0 / (f - n);
  76361. var d = -(f + n) / (f - n);
  76362. 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);
  76363. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  76364. };
  76365. /**
  76366. * Create a left-handed orthographic projection matrix
  76367. * @param left defines the viewport left coordinate
  76368. * @param right defines the viewport right coordinate
  76369. * @param bottom defines the viewport bottom coordinate
  76370. * @param top defines the viewport top coordinate
  76371. * @param znear defines the near clip plane
  76372. * @param zfar defines the far clip plane
  76373. * @returns a new matrix as a left-handed orthographic projection matrix
  76374. */
  76375. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  76376. var matrix = new Matrix();
  76377. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  76378. return matrix;
  76379. };
  76380. /**
  76381. * Stores a left-handed orthographic projection into a given matrix
  76382. * @param left defines the viewport left coordinate
  76383. * @param right defines the viewport right coordinate
  76384. * @param bottom defines the viewport bottom coordinate
  76385. * @param top defines the viewport top coordinate
  76386. * @param znear defines the near clip plane
  76387. * @param zfar defines the far clip plane
  76388. * @param result defines the target matrix
  76389. */
  76390. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  76391. var n = znear;
  76392. var f = zfar;
  76393. var a = 2.0 / (right - left);
  76394. var b = 2.0 / (top - bottom);
  76395. var c = 2.0 / (f - n);
  76396. var d = -(f + n) / (f - n);
  76397. var i0 = (left + right) / (left - right);
  76398. var i1 = (top + bottom) / (bottom - top);
  76399. 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);
  76400. result._markAsUpdated();
  76401. };
  76402. /**
  76403. * Creates a right-handed orthographic projection matrix
  76404. * @param left defines the viewport left coordinate
  76405. * @param right defines the viewport right coordinate
  76406. * @param bottom defines the viewport bottom coordinate
  76407. * @param top defines the viewport top coordinate
  76408. * @param znear defines the near clip plane
  76409. * @param zfar defines the far clip plane
  76410. * @returns a new matrix as a right-handed orthographic projection matrix
  76411. */
  76412. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  76413. var matrix = new Matrix();
  76414. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  76415. return matrix;
  76416. };
  76417. /**
  76418. * Stores a right-handed orthographic projection into a given matrix
  76419. * @param left defines the viewport left coordinate
  76420. * @param right defines the viewport right coordinate
  76421. * @param bottom defines the viewport bottom coordinate
  76422. * @param top defines the viewport top coordinate
  76423. * @param znear defines the near clip plane
  76424. * @param zfar defines the far clip plane
  76425. * @param result defines the target matrix
  76426. */
  76427. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  76428. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  76429. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  76430. };
  76431. /**
  76432. * Creates a left-handed perspective projection matrix
  76433. * @param width defines the viewport width
  76434. * @param height defines the viewport height
  76435. * @param znear defines the near clip plane
  76436. * @param zfar defines the far clip plane
  76437. * @returns a new matrix as a left-handed perspective projection matrix
  76438. */
  76439. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  76440. var matrix = new Matrix();
  76441. var n = znear;
  76442. var f = zfar;
  76443. var a = 2.0 * n / width;
  76444. var b = 2.0 * n / height;
  76445. var c = (f + n) / (f - n);
  76446. var d = -2.0 * f * n / (f - n);
  76447. 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);
  76448. matrix._updateIdentityStatus(false);
  76449. return matrix;
  76450. };
  76451. /**
  76452. * Creates a left-handed perspective projection matrix
  76453. * @param fov defines the horizontal field of view
  76454. * @param aspect defines the aspect ratio
  76455. * @param znear defines the near clip plane
  76456. * @param zfar defines the far clip plane
  76457. * @returns a new matrix as a left-handed perspective projection matrix
  76458. */
  76459. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  76460. var matrix = new Matrix();
  76461. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  76462. return matrix;
  76463. };
  76464. /**
  76465. * Stores a left-handed perspective projection into a given matrix
  76466. * @param fov defines the horizontal field of view
  76467. * @param aspect defines the aspect ratio
  76468. * @param znear defines the near clip plane
  76469. * @param zfar defines the far clip plane
  76470. * @param result defines the target matrix
  76471. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  76472. */
  76473. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  76474. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  76475. var n = znear;
  76476. var f = zfar;
  76477. var t = 1.0 / (Math.tan(fov * 0.5));
  76478. var a = isVerticalFovFixed ? (t / aspect) : t;
  76479. var b = isVerticalFovFixed ? t : (t * aspect);
  76480. var c = (f + n) / (f - n);
  76481. var d = -2.0 * f * n / (f - n);
  76482. 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);
  76483. result._updateIdentityStatus(false);
  76484. };
  76485. /**
  76486. * Creates a right-handed perspective projection matrix
  76487. * @param fov defines the horizontal field of view
  76488. * @param aspect defines the aspect ratio
  76489. * @param znear defines the near clip plane
  76490. * @param zfar defines the far clip plane
  76491. * @returns a new matrix as a right-handed perspective projection matrix
  76492. */
  76493. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  76494. var matrix = new Matrix();
  76495. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  76496. return matrix;
  76497. };
  76498. /**
  76499. * Stores a right-handed perspective projection into a given matrix
  76500. * @param fov defines the horizontal field of view
  76501. * @param aspect defines the aspect ratio
  76502. * @param znear defines the near clip plane
  76503. * @param zfar defines the far clip plane
  76504. * @param result defines the target matrix
  76505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  76506. */
  76507. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  76508. //alternatively this could be expressed as:
  76509. // m = PerspectiveFovLHToRef
  76510. // m[10] *= -1.0;
  76511. // m[11] *= -1.0;
  76512. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  76513. var n = znear;
  76514. var f = zfar;
  76515. var t = 1.0 / (Math.tan(fov * 0.5));
  76516. var a = isVerticalFovFixed ? (t / aspect) : t;
  76517. var b = isVerticalFovFixed ? t : (t * aspect);
  76518. var c = -(f + n) / (f - n);
  76519. var d = -2 * f * n / (f - n);
  76520. 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);
  76521. result._updateIdentityStatus(false);
  76522. };
  76523. /**
  76524. * Stores a perspective projection for WebVR info a given matrix
  76525. * @param fov defines the field of view
  76526. * @param znear defines the near clip plane
  76527. * @param zfar defines the far clip plane
  76528. * @param result defines the target matrix
  76529. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  76530. */
  76531. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  76532. if (rightHanded === void 0) { rightHanded = false; }
  76533. var rightHandedFactor = rightHanded ? -1 : 1;
  76534. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  76535. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  76536. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  76537. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  76538. var xScale = 2.0 / (leftTan + rightTan);
  76539. var yScale = 2.0 / (upTan + downTan);
  76540. var m = result._m;
  76541. m[0] = xScale;
  76542. m[1] = m[2] = m[3] = m[4] = 0.0;
  76543. m[5] = yScale;
  76544. m[6] = m[7] = 0.0;
  76545. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  76546. m[9] = -((upTan - downTan) * yScale * 0.5);
  76547. m[10] = -zfar / (znear - zfar);
  76548. m[11] = 1.0 * rightHandedFactor;
  76549. m[12] = m[13] = m[15] = 0.0;
  76550. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  76551. result._markAsUpdated();
  76552. };
  76553. /**
  76554. * Computes a complete transformation matrix
  76555. * @param viewport defines the viewport to use
  76556. * @param world defines the world matrix
  76557. * @param view defines the view matrix
  76558. * @param projection defines the projection matrix
  76559. * @param zmin defines the near clip plane
  76560. * @param zmax defines the far clip plane
  76561. * @returns the transformation matrix
  76562. */
  76563. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  76564. var cw = viewport.width;
  76565. var ch = viewport.height;
  76566. var cx = viewport.x;
  76567. var cy = viewport.y;
  76568. 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);
  76569. var matrix = MathTmp.Matrix[0];
  76570. world.multiplyToRef(view, matrix);
  76571. matrix.multiplyToRef(projection, matrix);
  76572. return matrix.multiply(viewportMatrix);
  76573. };
  76574. /**
  76575. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  76576. * @param matrix defines the matrix to use
  76577. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  76578. */
  76579. Matrix.GetAsMatrix2x2 = function (matrix) {
  76580. var m = matrix.m;
  76581. return new Float32Array([m[0], m[1], m[4], m[5]]);
  76582. };
  76583. /**
  76584. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  76585. * @param matrix defines the matrix to use
  76586. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  76587. */
  76588. Matrix.GetAsMatrix3x3 = function (matrix) {
  76589. var m = matrix.m;
  76590. return new Float32Array([
  76591. m[0], m[1], m[2],
  76592. m[4], m[5], m[6],
  76593. m[8], m[9], m[10]
  76594. ]);
  76595. };
  76596. /**
  76597. * Compute the transpose of a given matrix
  76598. * @param matrix defines the matrix to transpose
  76599. * @returns the new matrix
  76600. */
  76601. Matrix.Transpose = function (matrix) {
  76602. var result = new Matrix();
  76603. Matrix.TransposeToRef(matrix, result);
  76604. return result;
  76605. };
  76606. /**
  76607. * Compute the transpose of a matrix and store it in a target matrix
  76608. * @param matrix defines the matrix to transpose
  76609. * @param result defines the target matrix
  76610. */
  76611. Matrix.TransposeToRef = function (matrix, result) {
  76612. var rm = result._m;
  76613. var mm = matrix.m;
  76614. rm[0] = mm[0];
  76615. rm[1] = mm[4];
  76616. rm[2] = mm[8];
  76617. rm[3] = mm[12];
  76618. rm[4] = mm[1];
  76619. rm[5] = mm[5];
  76620. rm[6] = mm[9];
  76621. rm[7] = mm[13];
  76622. rm[8] = mm[2];
  76623. rm[9] = mm[6];
  76624. rm[10] = mm[10];
  76625. rm[11] = mm[14];
  76626. rm[12] = mm[3];
  76627. rm[13] = mm[7];
  76628. rm[14] = mm[11];
  76629. rm[15] = mm[15];
  76630. // identity-ness does not change when transposing
  76631. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  76632. };
  76633. /**
  76634. * Computes a reflection matrix from a plane
  76635. * @param plane defines the reflection plane
  76636. * @returns a new matrix
  76637. */
  76638. Matrix.Reflection = function (plane) {
  76639. var matrix = new Matrix();
  76640. Matrix.ReflectionToRef(plane, matrix);
  76641. return matrix;
  76642. };
  76643. /**
  76644. * Computes a reflection matrix from a plane
  76645. * @param plane defines the reflection plane
  76646. * @param result defines the target matrix
  76647. */
  76648. Matrix.ReflectionToRef = function (plane, result) {
  76649. plane.normalize();
  76650. var x = plane.normal.x;
  76651. var y = plane.normal.y;
  76652. var z = plane.normal.z;
  76653. var temp = -2 * x;
  76654. var temp2 = -2 * y;
  76655. var temp3 = -2 * z;
  76656. 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);
  76657. };
  76658. /**
  76659. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  76660. * @param xaxis defines the value of the 1st axis
  76661. * @param yaxis defines the value of the 2nd axis
  76662. * @param zaxis defines the value of the 3rd axis
  76663. * @param result defines the target matrix
  76664. */
  76665. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  76666. 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);
  76667. };
  76668. /**
  76669. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  76670. * @param quat defines the quaternion to use
  76671. * @param result defines the target matrix
  76672. */
  76673. Matrix.FromQuaternionToRef = function (quat, result) {
  76674. var xx = quat.x * quat.x;
  76675. var yy = quat.y * quat.y;
  76676. var zz = quat.z * quat.z;
  76677. var xy = quat.x * quat.y;
  76678. var zw = quat.z * quat.w;
  76679. var zx = quat.z * quat.x;
  76680. var yw = quat.y * quat.w;
  76681. var yz = quat.y * quat.z;
  76682. var xw = quat.x * quat.w;
  76683. result._m[0] = 1.0 - (2.0 * (yy + zz));
  76684. result._m[1] = 2.0 * (xy + zw);
  76685. result._m[2] = 2.0 * (zx - yw);
  76686. result._m[3] = 0.0;
  76687. result._m[4] = 2.0 * (xy - zw);
  76688. result._m[5] = 1.0 - (2.0 * (zz + xx));
  76689. result._m[6] = 2.0 * (yz + xw);
  76690. result._m[7] = 0.0;
  76691. result._m[8] = 2.0 * (zx + yw);
  76692. result._m[9] = 2.0 * (yz - xw);
  76693. result._m[10] = 1.0 - (2.0 * (yy + xx));
  76694. result._m[11] = 0.0;
  76695. result._m[12] = 0.0;
  76696. result._m[13] = 0.0;
  76697. result._m[14] = 0.0;
  76698. result._m[15] = 1.0;
  76699. result._markAsUpdated();
  76700. };
  76701. Matrix._updateFlagSeed = 0;
  76702. Matrix._identityReadOnly = Matrix.Identity();
  76703. return Matrix;
  76704. }());
  76705. /**
  76706. * Represens a plane by the equation ax + by + cz + d = 0
  76707. */
  76708. var Plane = /** @class */ (function () {
  76709. /**
  76710. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  76711. * @param a a component of the plane
  76712. * @param b b component of the plane
  76713. * @param c c component of the plane
  76714. * @param d d component of the plane
  76715. */
  76716. function Plane(a, b, c, d) {
  76717. this.normal = new Vector3(a, b, c);
  76718. this.d = d;
  76719. }
  76720. /**
  76721. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  76722. */
  76723. Plane.prototype.asArray = function () {
  76724. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  76725. };
  76726. // Methods
  76727. /**
  76728. * @returns a new plane copied from the current Plane.
  76729. */
  76730. Plane.prototype.clone = function () {
  76731. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  76732. };
  76733. /**
  76734. * @returns the string "Plane".
  76735. */
  76736. Plane.prototype.getClassName = function () {
  76737. return "Plane";
  76738. };
  76739. /**
  76740. * @returns the Plane hash code.
  76741. */
  76742. Plane.prototype.getHashCode = function () {
  76743. var hash = this.normal.getHashCode();
  76744. hash = (hash * 397) ^ (this.d || 0);
  76745. return hash;
  76746. };
  76747. /**
  76748. * Normalize the current Plane in place.
  76749. * @returns the updated Plane.
  76750. */
  76751. Plane.prototype.normalize = function () {
  76752. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  76753. var magnitude = 0.0;
  76754. if (norm !== 0) {
  76755. magnitude = 1.0 / norm;
  76756. }
  76757. this.normal.x *= magnitude;
  76758. this.normal.y *= magnitude;
  76759. this.normal.z *= magnitude;
  76760. this.d *= magnitude;
  76761. return this;
  76762. };
  76763. /**
  76764. * Applies a transformation the plane and returns the result
  76765. * @param transformation the transformation matrix to be applied to the plane
  76766. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  76767. */
  76768. Plane.prototype.transform = function (transformation) {
  76769. var transposedMatrix = MathTmp.Matrix[0];
  76770. Matrix.TransposeToRef(transformation, transposedMatrix);
  76771. var m = transposedMatrix.m;
  76772. var x = this.normal.x;
  76773. var y = this.normal.y;
  76774. var z = this.normal.z;
  76775. var d = this.d;
  76776. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  76777. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  76778. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  76779. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  76780. return new Plane(normalX, normalY, normalZ, finalD);
  76781. };
  76782. /**
  76783. * Calcualtte the dot product between the point and the plane normal
  76784. * @param point point to calculate the dot product with
  76785. * @returns the dot product (float) of the point coordinates and the plane normal.
  76786. */
  76787. Plane.prototype.dotCoordinate = function (point) {
  76788. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  76789. };
  76790. /**
  76791. * Updates the current Plane from the plane defined by the three given points.
  76792. * @param point1 one of the points used to contruct the plane
  76793. * @param point2 one of the points used to contruct the plane
  76794. * @param point3 one of the points used to contruct the plane
  76795. * @returns the updated Plane.
  76796. */
  76797. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  76798. var x1 = point2.x - point1.x;
  76799. var y1 = point2.y - point1.y;
  76800. var z1 = point2.z - point1.z;
  76801. var x2 = point3.x - point1.x;
  76802. var y2 = point3.y - point1.y;
  76803. var z2 = point3.z - point1.z;
  76804. var yz = (y1 * z2) - (z1 * y2);
  76805. var xz = (z1 * x2) - (x1 * z2);
  76806. var xy = (x1 * y2) - (y1 * x2);
  76807. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  76808. var invPyth;
  76809. if (pyth !== 0) {
  76810. invPyth = 1.0 / pyth;
  76811. }
  76812. else {
  76813. invPyth = 0.0;
  76814. }
  76815. this.normal.x = yz * invPyth;
  76816. this.normal.y = xz * invPyth;
  76817. this.normal.z = xy * invPyth;
  76818. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  76819. return this;
  76820. };
  76821. /**
  76822. * Checks if the plane is facing a given direction
  76823. * @param direction the direction to check if the plane is facing
  76824. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  76825. * @returns True is the vector "direction" is the same side than the plane normal.
  76826. */
  76827. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  76828. var dot = Vector3.Dot(this.normal, direction);
  76829. return (dot <= epsilon);
  76830. };
  76831. /**
  76832. * Calculates the distance to a point
  76833. * @param point point to calculate distance to
  76834. * @returns the signed distance (float) from the given point to the Plane.
  76835. */
  76836. Plane.prototype.signedDistanceTo = function (point) {
  76837. return Vector3.Dot(point, this.normal) + this.d;
  76838. };
  76839. // Statics
  76840. /**
  76841. * Creates a plane from an array
  76842. * @param array the array to create a plane from
  76843. * @returns a new Plane from the given array.
  76844. */
  76845. Plane.FromArray = function (array) {
  76846. return new Plane(array[0], array[1], array[2], array[3]);
  76847. };
  76848. /**
  76849. * Creates a plane from three points
  76850. * @param point1 point used to create the plane
  76851. * @param point2 point used to create the plane
  76852. * @param point3 point used to create the plane
  76853. * @returns a new Plane defined by the three given points.
  76854. */
  76855. Plane.FromPoints = function (point1, point2, point3) {
  76856. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  76857. result.copyFromPoints(point1, point2, point3);
  76858. return result;
  76859. };
  76860. /**
  76861. * Creates a plane from an origin point and a normal
  76862. * @param origin origin of the plane to be constructed
  76863. * @param normal normal of the plane to be constructed
  76864. * @returns a new Plane the normal vector to this plane at the given origin point.
  76865. * Note : the vector "normal" is updated because normalized.
  76866. */
  76867. Plane.FromPositionAndNormal = function (origin, normal) {
  76868. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  76869. normal.normalize();
  76870. result.normal = normal;
  76871. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  76872. return result;
  76873. };
  76874. /**
  76875. * Calculates the distance from a plane and a point
  76876. * @param origin origin of the plane to be constructed
  76877. * @param normal normal of the plane to be constructed
  76878. * @param point point to calculate distance to
  76879. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  76880. */
  76881. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  76882. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  76883. return Vector3.Dot(point, normal) + d;
  76884. };
  76885. return Plane;
  76886. }());
  76887. /**
  76888. * Class used to represent a viewport on screen
  76889. */
  76890. var Viewport = /** @class */ (function () {
  76891. /**
  76892. * Creates a Viewport object located at (x, y) and sized (width, height)
  76893. * @param x defines viewport left coordinate
  76894. * @param y defines viewport top coordinate
  76895. * @param width defines the viewport width
  76896. * @param height defines the viewport height
  76897. */
  76898. function Viewport(
  76899. /** viewport left coordinate */
  76900. x,
  76901. /** viewport top coordinate */
  76902. y,
  76903. /**viewport width */
  76904. width,
  76905. /** viewport height */
  76906. height) {
  76907. this.x = x;
  76908. this.y = y;
  76909. this.width = width;
  76910. this.height = height;
  76911. }
  76912. /**
  76913. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  76914. * @param renderWidth defines the rendering width
  76915. * @param renderHeight defines the rendering height
  76916. * @returns a new Viewport
  76917. */
  76918. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  76919. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  76920. };
  76921. /**
  76922. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  76923. * @param renderWidth defines the rendering width
  76924. * @param renderHeight defines the rendering height
  76925. * @param ref defines the target viewport
  76926. * @returns the current viewport
  76927. */
  76928. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  76929. ref.x = this.x * renderWidth;
  76930. ref.y = this.y * renderHeight;
  76931. ref.width = this.width * renderWidth;
  76932. ref.height = this.height * renderHeight;
  76933. return this;
  76934. };
  76935. /**
  76936. * Returns a new Viewport copied from the current one
  76937. * @returns a new Viewport
  76938. */
  76939. Viewport.prototype.clone = function () {
  76940. return new Viewport(this.x, this.y, this.width, this.height);
  76941. };
  76942. return Viewport;
  76943. }());
  76944. /**
  76945. * Reprasents a camera frustum
  76946. */
  76947. var Frustum = /** @class */ (function () {
  76948. function Frustum() {
  76949. }
  76950. /**
  76951. * Gets the planes representing the frustum
  76952. * @param transform matrix to be applied to the returned planes
  76953. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  76954. */
  76955. Frustum.GetPlanes = function (transform) {
  76956. var frustumPlanes = [];
  76957. for (var index = 0; index < 6; index++) {
  76958. frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));
  76959. }
  76960. Frustum.GetPlanesToRef(transform, frustumPlanes);
  76961. return frustumPlanes;
  76962. };
  76963. /**
  76964. * Gets the near frustum plane transformed by the transform matrix
  76965. * @param transform transformation matrix to be applied to the resulting frustum plane
  76966. * @param frustumPlane the resuling frustum plane
  76967. */
  76968. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  76969. var m = transform.m;
  76970. frustumPlane.normal.x = m[3] + m[2];
  76971. frustumPlane.normal.y = m[7] + m[6];
  76972. frustumPlane.normal.z = m[11] + m[10];
  76973. frustumPlane.d = m[15] + m[14];
  76974. frustumPlane.normalize();
  76975. };
  76976. /**
  76977. * Gets the far frustum plane transformed by the transform matrix
  76978. * @param transform transformation matrix to be applied to the resulting frustum plane
  76979. * @param frustumPlane the resuling frustum plane
  76980. */
  76981. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  76982. var m = transform.m;
  76983. frustumPlane.normal.x = m[3] - m[2];
  76984. frustumPlane.normal.y = m[7] - m[6];
  76985. frustumPlane.normal.z = m[11] - m[10];
  76986. frustumPlane.d = m[15] - m[14];
  76987. frustumPlane.normalize();
  76988. };
  76989. /**
  76990. * Gets the left frustum plane transformed by the transform matrix
  76991. * @param transform transformation matrix to be applied to the resulting frustum plane
  76992. * @param frustumPlane the resuling frustum plane
  76993. */
  76994. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  76995. var m = transform.m;
  76996. frustumPlane.normal.x = m[3] + m[0];
  76997. frustumPlane.normal.y = m[7] + m[4];
  76998. frustumPlane.normal.z = m[11] + m[8];
  76999. frustumPlane.d = m[15] + m[12];
  77000. frustumPlane.normalize();
  77001. };
  77002. /**
  77003. * Gets the right frustum plane transformed by the transform matrix
  77004. * @param transform transformation matrix to be applied to the resulting frustum plane
  77005. * @param frustumPlane the resuling frustum plane
  77006. */
  77007. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  77008. var m = transform.m;
  77009. frustumPlane.normal.x = m[3] - m[0];
  77010. frustumPlane.normal.y = m[7] - m[4];
  77011. frustumPlane.normal.z = m[11] - m[8];
  77012. frustumPlane.d = m[15] - m[12];
  77013. frustumPlane.normalize();
  77014. };
  77015. /**
  77016. * Gets the top frustum plane transformed by the transform matrix
  77017. * @param transform transformation matrix to be applied to the resulting frustum plane
  77018. * @param frustumPlane the resuling frustum plane
  77019. */
  77020. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  77021. var m = transform.m;
  77022. frustumPlane.normal.x = m[3] - m[1];
  77023. frustumPlane.normal.y = m[7] - m[5];
  77024. frustumPlane.normal.z = m[11] - m[9];
  77025. frustumPlane.d = m[15] - m[13];
  77026. frustumPlane.normalize();
  77027. };
  77028. /**
  77029. * Gets the bottom frustum plane transformed by the transform matrix
  77030. * @param transform transformation matrix to be applied to the resulting frustum plane
  77031. * @param frustumPlane the resuling frustum plane
  77032. */
  77033. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  77034. var m = transform.m;
  77035. frustumPlane.normal.x = m[3] + m[1];
  77036. frustumPlane.normal.y = m[7] + m[5];
  77037. frustumPlane.normal.z = m[11] + m[9];
  77038. frustumPlane.d = m[15] + m[13];
  77039. frustumPlane.normalize();
  77040. };
  77041. /**
  77042. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  77043. * @param transform transformation matrix to be applied to the resulting frustum planes
  77044. * @param frustumPlanes the resuling frustum planes
  77045. */
  77046. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  77047. // Near
  77048. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  77049. // Far
  77050. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  77051. // Left
  77052. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  77053. // Right
  77054. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  77055. // Top
  77056. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  77057. // Bottom
  77058. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  77059. };
  77060. return Frustum;
  77061. }());
  77062. /** Defines supported spaces */
  77063. var Space;
  77064. (function (Space) {
  77065. /** Local (object) space */
  77066. Space[Space["LOCAL"] = 0] = "LOCAL";
  77067. /** World space */
  77068. Space[Space["WORLD"] = 1] = "WORLD";
  77069. /** Bone space */
  77070. Space[Space["BONE"] = 2] = "BONE";
  77071. })(Space || (Space = {}));
  77072. /** Defines the 3 main axes */
  77073. var Axis = /** @class */ (function () {
  77074. function Axis() {
  77075. }
  77076. /** X axis */
  77077. Axis.X = new Vector3(1.0, 0.0, 0.0);
  77078. /** Y axis */
  77079. Axis.Y = new Vector3(0.0, 1.0, 0.0);
  77080. /** Z axis */
  77081. Axis.Z = new Vector3(0.0, 0.0, 1.0);
  77082. return Axis;
  77083. }());
  77084. /** Class used to represent a Bezier curve */
  77085. var BezierCurve = /** @class */ (function () {
  77086. function BezierCurve() {
  77087. }
  77088. /**
  77089. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77090. * @param t defines the time
  77091. * @param x1 defines the left coordinate on X axis
  77092. * @param y1 defines the left coordinate on Y axis
  77093. * @param x2 defines the right coordinate on X axis
  77094. * @param y2 defines the right coordinate on Y axis
  77095. * @returns the interpolated value
  77096. */
  77097. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  77098. // Extract X (which is equal to time here)
  77099. var f0 = 1 - 3 * x2 + 3 * x1;
  77100. var f1 = 3 * x2 - 6 * x1;
  77101. var f2 = 3 * x1;
  77102. var refinedT = t;
  77103. for (var i = 0; i < 5; i++) {
  77104. var refinedT2 = refinedT * refinedT;
  77105. var refinedT3 = refinedT2 * refinedT;
  77106. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  77107. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  77108. refinedT -= (x - t) * slope;
  77109. refinedT = Math.min(1, Math.max(0, refinedT));
  77110. }
  77111. // Resolve cubic bezier for the given x
  77112. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  77113. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  77114. Math.pow(refinedT, 3);
  77115. };
  77116. return BezierCurve;
  77117. }());
  77118. /**
  77119. * Defines potential orientation for back face culling
  77120. */
  77121. var Orientation;
  77122. (function (Orientation) {
  77123. /**
  77124. * Clockwise
  77125. */
  77126. Orientation[Orientation["CW"] = 0] = "CW";
  77127. /** Counter clockwise */
  77128. Orientation[Orientation["CCW"] = 1] = "CCW";
  77129. })(Orientation || (Orientation = {}));
  77130. /**
  77131. * Defines angle representation
  77132. */
  77133. var Angle = /** @class */ (function () {
  77134. /**
  77135. * Creates an Angle object of "radians" radians (float).
  77136. * @param radians the angle in radians
  77137. */
  77138. function Angle(radians) {
  77139. this._radians = radians;
  77140. if (this._radians < 0.0) {
  77141. this._radians += (2.0 * Math.PI);
  77142. }
  77143. }
  77144. /**
  77145. * Get value in degrees
  77146. * @returns the Angle value in degrees (float)
  77147. */
  77148. Angle.prototype.degrees = function () {
  77149. return this._radians * 180.0 / Math.PI;
  77150. };
  77151. /**
  77152. * Get value in radians
  77153. * @returns the Angle value in radians (float)
  77154. */
  77155. Angle.prototype.radians = function () {
  77156. return this._radians;
  77157. };
  77158. /**
  77159. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77160. * @param a defines first vector
  77161. * @param b defines second vector
  77162. * @returns a new Angle
  77163. */
  77164. Angle.BetweenTwoPoints = function (a, b) {
  77165. var delta = b.subtract(a);
  77166. var theta = Math.atan2(delta.y, delta.x);
  77167. return new Angle(theta);
  77168. };
  77169. /**
  77170. * Gets a new Angle object from the given float in radians
  77171. * @param radians defines the angle value in radians
  77172. * @returns a new Angle
  77173. */
  77174. Angle.FromRadians = function (radians) {
  77175. return new Angle(radians);
  77176. };
  77177. /**
  77178. * Gets a new Angle object from the given float in degrees
  77179. * @param degrees defines the angle value in degrees
  77180. * @returns a new Angle
  77181. */
  77182. Angle.FromDegrees = function (degrees) {
  77183. return new Angle(degrees * Math.PI / 180.0);
  77184. };
  77185. return Angle;
  77186. }());
  77187. /**
  77188. * This represents an arc in a 2d space.
  77189. */
  77190. var Arc2 = /** @class */ (function () {
  77191. /**
  77192. * Creates an Arc object from the three given points : start, middle and end.
  77193. * @param startPoint Defines the start point of the arc
  77194. * @param midPoint Defines the midlle point of the arc
  77195. * @param endPoint Defines the end point of the arc
  77196. */
  77197. function Arc2(
  77198. /** Defines the start point of the arc */
  77199. startPoint,
  77200. /** Defines the mid point of the arc */
  77201. midPoint,
  77202. /** Defines the end point of the arc */
  77203. endPoint) {
  77204. this.startPoint = startPoint;
  77205. this.midPoint = midPoint;
  77206. this.endPoint = endPoint;
  77207. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  77208. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  77209. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  77210. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  77211. 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);
  77212. this.radius = this.centerPoint.subtract(this.startPoint).length();
  77213. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  77214. var a1 = this.startAngle.degrees();
  77215. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  77216. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  77217. // angles correction
  77218. if (a2 - a1 > +180.0) {
  77219. a2 -= 360.0;
  77220. }
  77221. if (a2 - a1 < -180.0) {
  77222. a2 += 360.0;
  77223. }
  77224. if (a3 - a2 > +180.0) {
  77225. a3 -= 360.0;
  77226. }
  77227. if (a3 - a2 < -180.0) {
  77228. a3 += 360.0;
  77229. }
  77230. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  77231. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  77232. }
  77233. return Arc2;
  77234. }());
  77235. /**
  77236. * Represents a 2D path made up of multiple 2D points
  77237. */
  77238. var Path2 = /** @class */ (function () {
  77239. /**
  77240. * Creates a Path2 object from the starting 2D coordinates x and y.
  77241. * @param x the starting points x value
  77242. * @param y the starting points y value
  77243. */
  77244. function Path2(x, y) {
  77245. this._points = new Array();
  77246. this._length = 0.0;
  77247. /**
  77248. * If the path start and end point are the same
  77249. */
  77250. this.closed = false;
  77251. this._points.push(new Vector2(x, y));
  77252. }
  77253. /**
  77254. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  77255. * @param x the added points x value
  77256. * @param y the added points y value
  77257. * @returns the updated Path2.
  77258. */
  77259. Path2.prototype.addLineTo = function (x, y) {
  77260. if (this.closed) {
  77261. return this;
  77262. }
  77263. var newPoint = new Vector2(x, y);
  77264. var previousPoint = this._points[this._points.length - 1];
  77265. this._points.push(newPoint);
  77266. this._length += newPoint.subtract(previousPoint).length();
  77267. return this;
  77268. };
  77269. /**
  77270. * 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.
  77271. * @param midX middle point x value
  77272. * @param midY middle point y value
  77273. * @param endX end point x value
  77274. * @param endY end point y value
  77275. * @param numberOfSegments (default: 36)
  77276. * @returns the updated Path2.
  77277. */
  77278. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  77279. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  77280. if (this.closed) {
  77281. return this;
  77282. }
  77283. var startPoint = this._points[this._points.length - 1];
  77284. var midPoint = new Vector2(midX, midY);
  77285. var endPoint = new Vector2(endX, endY);
  77286. var arc = new Arc2(startPoint, midPoint, endPoint);
  77287. var increment = arc.angle.radians() / numberOfSegments;
  77288. if (arc.orientation === Orientation.CW) {
  77289. increment *= -1;
  77290. }
  77291. var currentAngle = arc.startAngle.radians() + increment;
  77292. for (var i = 0; i < numberOfSegments; i++) {
  77293. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  77294. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  77295. this.addLineTo(x, y);
  77296. currentAngle += increment;
  77297. }
  77298. return this;
  77299. };
  77300. /**
  77301. * Closes the Path2.
  77302. * @returns the Path2.
  77303. */
  77304. Path2.prototype.close = function () {
  77305. this.closed = true;
  77306. return this;
  77307. };
  77308. /**
  77309. * Gets the sum of the distance between each sequential point in the path
  77310. * @returns the Path2 total length (float).
  77311. */
  77312. Path2.prototype.length = function () {
  77313. var result = this._length;
  77314. if (!this.closed) {
  77315. var lastPoint = this._points[this._points.length - 1];
  77316. var firstPoint = this._points[0];
  77317. result += (firstPoint.subtract(lastPoint).length());
  77318. }
  77319. return result;
  77320. };
  77321. /**
  77322. * Gets the points which construct the path
  77323. * @returns the Path2 internal array of points.
  77324. */
  77325. Path2.prototype.getPoints = function () {
  77326. return this._points;
  77327. };
  77328. /**
  77329. * Retreives the point at the distance aways from the starting point
  77330. * @param normalizedLengthPosition the length along the path to retreive the point from
  77331. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  77332. */
  77333. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  77334. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  77335. return Vector2.Zero();
  77336. }
  77337. var lengthPosition = normalizedLengthPosition * this.length();
  77338. var previousOffset = 0;
  77339. for (var i = 0; i < this._points.length; i++) {
  77340. var j = (i + 1) % this._points.length;
  77341. var a = this._points[i];
  77342. var b = this._points[j];
  77343. var bToA = b.subtract(a);
  77344. var nextOffset = (bToA.length() + previousOffset);
  77345. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  77346. var dir = bToA.normalize();
  77347. var localOffset = lengthPosition - previousOffset;
  77348. return new Vector2(a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  77349. }
  77350. previousOffset = nextOffset;
  77351. }
  77352. return Vector2.Zero();
  77353. };
  77354. /**
  77355. * Creates a new path starting from an x and y position
  77356. * @param x starting x value
  77357. * @param y starting y value
  77358. * @returns a new Path2 starting at the coordinates (x, y).
  77359. */
  77360. Path2.StartingAt = function (x, y) {
  77361. return new Path2(x, y);
  77362. };
  77363. return Path2;
  77364. }());
  77365. /**
  77366. * Represents a 3D path made up of multiple 3D points
  77367. */
  77368. var Path3D = /** @class */ (function () {
  77369. /**
  77370. * new Path3D(path, normal, raw)
  77371. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  77372. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  77373. * @param path an array of Vector3, the curve axis of the Path3D
  77374. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  77375. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  77376. */
  77377. function Path3D(
  77378. /**
  77379. * an array of Vector3, the curve axis of the Path3D
  77380. */
  77381. path, firstNormal, raw) {
  77382. if (firstNormal === void 0) { firstNormal = null; }
  77383. this.path = path;
  77384. this._curve = new Array();
  77385. this._distances = new Array();
  77386. this._tangents = new Array();
  77387. this._normals = new Array();
  77388. this._binormals = new Array();
  77389. for (var p = 0; p < path.length; p++) {
  77390. this._curve[p] = path[p].clone(); // hard copy
  77391. }
  77392. this._raw = raw || false;
  77393. this._compute(firstNormal);
  77394. }
  77395. /**
  77396. * Returns the Path3D array of successive Vector3 designing its curve.
  77397. * @returns the Path3D array of successive Vector3 designing its curve.
  77398. */
  77399. Path3D.prototype.getCurve = function () {
  77400. return this._curve;
  77401. };
  77402. /**
  77403. * Returns an array populated with tangent vectors on each Path3D curve point.
  77404. * @returns an array populated with tangent vectors on each Path3D curve point.
  77405. */
  77406. Path3D.prototype.getTangents = function () {
  77407. return this._tangents;
  77408. };
  77409. /**
  77410. * Returns an array populated with normal vectors on each Path3D curve point.
  77411. * @returns an array populated with normal vectors on each Path3D curve point.
  77412. */
  77413. Path3D.prototype.getNormals = function () {
  77414. return this._normals;
  77415. };
  77416. /**
  77417. * Returns an array populated with binormal vectors on each Path3D curve point.
  77418. * @returns an array populated with binormal vectors on each Path3D curve point.
  77419. */
  77420. Path3D.prototype.getBinormals = function () {
  77421. return this._binormals;
  77422. };
  77423. /**
  77424. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  77425. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  77426. */
  77427. Path3D.prototype.getDistances = function () {
  77428. return this._distances;
  77429. };
  77430. /**
  77431. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  77432. * @param path path which all values are copied into the curves points
  77433. * @param firstNormal which should be projected onto the curve
  77434. * @returns the same object updated.
  77435. */
  77436. Path3D.prototype.update = function (path, firstNormal) {
  77437. if (firstNormal === void 0) { firstNormal = null; }
  77438. for (var p = 0; p < path.length; p++) {
  77439. this._curve[p].x = path[p].x;
  77440. this._curve[p].y = path[p].y;
  77441. this._curve[p].z = path[p].z;
  77442. }
  77443. this._compute(firstNormal);
  77444. return this;
  77445. };
  77446. // private function compute() : computes tangents, normals and binormals
  77447. Path3D.prototype._compute = function (firstNormal) {
  77448. var l = this._curve.length;
  77449. // first and last tangents
  77450. this._tangents[0] = this._getFirstNonNullVector(0);
  77451. if (!this._raw) {
  77452. this._tangents[0].normalize();
  77453. }
  77454. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  77455. if (!this._raw) {
  77456. this._tangents[l - 1].normalize();
  77457. }
  77458. // normals and binormals at first point : arbitrary vector with _normalVector()
  77459. var tg0 = this._tangents[0];
  77460. var pp0 = this._normalVector(tg0, firstNormal);
  77461. this._normals[0] = pp0;
  77462. if (!this._raw) {
  77463. this._normals[0].normalize();
  77464. }
  77465. this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
  77466. if (!this._raw) {
  77467. this._binormals[0].normalize();
  77468. }
  77469. this._distances[0] = 0.0;
  77470. // normals and binormals : next points
  77471. var prev; // previous vector (segment)
  77472. var cur; // current vector (segment)
  77473. var curTang; // current tangent
  77474. // previous normal
  77475. var prevBinor; // previous binormal
  77476. for (var i = 1; i < l; i++) {
  77477. // tangents
  77478. prev = this._getLastNonNullVector(i);
  77479. if (i < l - 1) {
  77480. cur = this._getFirstNonNullVector(i);
  77481. this._tangents[i] = prev.add(cur);
  77482. this._tangents[i].normalize();
  77483. }
  77484. this._distances[i] = this._distances[i - 1] + prev.length();
  77485. // normals and binormals
  77486. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  77487. curTang = this._tangents[i];
  77488. prevBinor = this._binormals[i - 1];
  77489. this._normals[i] = Vector3.Cross(prevBinor, curTang);
  77490. if (!this._raw) {
  77491. this._normals[i].normalize();
  77492. }
  77493. this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
  77494. if (!this._raw) {
  77495. this._binormals[i].normalize();
  77496. }
  77497. }
  77498. };
  77499. // private function getFirstNonNullVector(index)
  77500. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  77501. Path3D.prototype._getFirstNonNullVector = function (index) {
  77502. var i = 1;
  77503. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  77504. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  77505. i++;
  77506. nNVector = this._curve[index + i].subtract(this._curve[index]);
  77507. }
  77508. return nNVector;
  77509. };
  77510. // private function getLastNonNullVector(index)
  77511. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  77512. Path3D.prototype._getLastNonNullVector = function (index) {
  77513. var i = 1;
  77514. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  77515. while (nLVector.length() === 0 && index > i + 1) {
  77516. i++;
  77517. nLVector = this._curve[index].subtract(this._curve[index - i]);
  77518. }
  77519. return nLVector;
  77520. };
  77521. // private function normalVector(v0, vt, va) :
  77522. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  77523. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  77524. Path3D.prototype._normalVector = function (vt, va) {
  77525. var normal0;
  77526. var tgl = vt.length();
  77527. if (tgl === 0.0) {
  77528. tgl = 1.0;
  77529. }
  77530. if (va === undefined || va === null) {
  77531. var point;
  77532. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, Epsilon)) { // search for a point in the plane
  77533. point = new Vector3(0.0, -1.0, 0.0);
  77534. }
  77535. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, Epsilon)) {
  77536. point = new Vector3(1.0, 0.0, 0.0);
  77537. }
  77538. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, Epsilon)) {
  77539. point = new Vector3(0.0, 0.0, 1.0);
  77540. }
  77541. else {
  77542. point = Vector3.Zero();
  77543. }
  77544. normal0 = Vector3.Cross(vt, point);
  77545. }
  77546. else {
  77547. normal0 = Vector3.Cross(vt, va);
  77548. Vector3.CrossToRef(normal0, vt, normal0);
  77549. }
  77550. normal0.normalize();
  77551. return normal0;
  77552. };
  77553. return Path3D;
  77554. }());
  77555. /**
  77556. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77557. * A Curve3 is designed from a series of successive Vector3.
  77558. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  77559. */
  77560. var Curve3 = /** @class */ (function () {
  77561. /**
  77562. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  77563. * A Curve3 is designed from a series of successive Vector3.
  77564. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  77565. * @param points points which make up the curve
  77566. */
  77567. function Curve3(points) {
  77568. this._length = 0.0;
  77569. this._points = points;
  77570. this._length = this._computeLength(points);
  77571. }
  77572. /**
  77573. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  77574. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  77575. * @param v1 (Vector3) the control point
  77576. * @param v2 (Vector3) the end point of the Quadratic Bezier
  77577. * @param nbPoints (integer) the wanted number of points in the curve
  77578. * @returns the created Curve3
  77579. */
  77580. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  77581. nbPoints = nbPoints > 2 ? nbPoints : 3;
  77582. var bez = new Array();
  77583. var equation = function (t, val0, val1, val2) {
  77584. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  77585. return res;
  77586. };
  77587. for (var i = 0; i <= nbPoints; i++) {
  77588. 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)));
  77589. }
  77590. return new Curve3(bez);
  77591. };
  77592. /**
  77593. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  77594. * @param v0 (Vector3) the origin point of the Cubic Bezier
  77595. * @param v1 (Vector3) the first control point
  77596. * @param v2 (Vector3) the second control point
  77597. * @param v3 (Vector3) the end point of the Cubic Bezier
  77598. * @param nbPoints (integer) the wanted number of points in the curve
  77599. * @returns the created Curve3
  77600. */
  77601. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  77602. nbPoints = nbPoints > 3 ? nbPoints : 4;
  77603. var bez = new Array();
  77604. var equation = function (t, val0, val1, val2, val3) {
  77605. 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;
  77606. return res;
  77607. };
  77608. for (var i = 0; i <= nbPoints; i++) {
  77609. 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)));
  77610. }
  77611. return new Curve3(bez);
  77612. };
  77613. /**
  77614. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  77615. * @param p1 (Vector3) the origin point of the Hermite Spline
  77616. * @param t1 (Vector3) the tangent vector at the origin point
  77617. * @param p2 (Vector3) the end point of the Hermite Spline
  77618. * @param t2 (Vector3) the tangent vector at the end point
  77619. * @param nbPoints (integer) the wanted number of points in the curve
  77620. * @returns the created Curve3
  77621. */
  77622. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  77623. var hermite = new Array();
  77624. var step = 1.0 / nbPoints;
  77625. for (var i = 0; i <= nbPoints; i++) {
  77626. hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
  77627. }
  77628. return new Curve3(hermite);
  77629. };
  77630. /**
  77631. * Returns a Curve3 object along a CatmullRom Spline curve :
  77632. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  77633. * @param nbPoints (integer) the wanted number of points between each curve control points
  77634. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  77635. * @returns the created Curve3
  77636. */
  77637. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  77638. var catmullRom = new Array();
  77639. var step = 1.0 / nbPoints;
  77640. var amount = 0.0;
  77641. if (closed) {
  77642. var pointsCount = points.length;
  77643. for (var i = 0; i < pointsCount; i++) {
  77644. amount = 0;
  77645. for (var c = 0; c < nbPoints; c++) {
  77646. catmullRom.push(Vector3.CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  77647. amount += step;
  77648. }
  77649. }
  77650. catmullRom.push(catmullRom[0]);
  77651. }
  77652. else {
  77653. var totalPoints = new Array();
  77654. totalPoints.push(points[0].clone());
  77655. Array.prototype.push.apply(totalPoints, points);
  77656. totalPoints.push(points[points.length - 1].clone());
  77657. for (var i = 0; i < totalPoints.length - 3; i++) {
  77658. amount = 0;
  77659. for (var c = 0; c < nbPoints; c++) {
  77660. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  77661. amount += step;
  77662. }
  77663. }
  77664. i--;
  77665. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  77666. }
  77667. return new Curve3(catmullRom);
  77668. };
  77669. /**
  77670. * @returns the Curve3 stored array of successive Vector3
  77671. */
  77672. Curve3.prototype.getPoints = function () {
  77673. return this._points;
  77674. };
  77675. /**
  77676. * @returns the computed length (float) of the curve.
  77677. */
  77678. Curve3.prototype.length = function () {
  77679. return this._length;
  77680. };
  77681. /**
  77682. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  77683. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  77684. * curveA and curveB keep unchanged.
  77685. * @param curve the curve to continue from this curve
  77686. * @returns the newly constructed curve
  77687. */
  77688. Curve3.prototype.continue = function (curve) {
  77689. var lastPoint = this._points[this._points.length - 1];
  77690. var continuedPoints = this._points.slice();
  77691. var curvePoints = curve.getPoints();
  77692. for (var i = 1; i < curvePoints.length; i++) {
  77693. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  77694. }
  77695. var continuedCurve = new Curve3(continuedPoints);
  77696. return continuedCurve;
  77697. };
  77698. Curve3.prototype._computeLength = function (path) {
  77699. var l = 0;
  77700. for (var i = 1; i < path.length; i++) {
  77701. l += (path[i].subtract(path[i - 1])).length();
  77702. }
  77703. return l;
  77704. };
  77705. return Curve3;
  77706. }());
  77707. // Vertex formats
  77708. /**
  77709. * Contains position and normal vectors for a vertex
  77710. */
  77711. var PositionNormalVertex = /** @class */ (function () {
  77712. /**
  77713. * Creates a PositionNormalVertex
  77714. * @param position the position of the vertex (defaut: 0,0,0)
  77715. * @param normal the normal of the vertex (defaut: 0,1,0)
  77716. */
  77717. function PositionNormalVertex(
  77718. /** the position of the vertex (defaut: 0,0,0) */
  77719. position,
  77720. /** the normal of the vertex (defaut: 0,1,0) */
  77721. normal) {
  77722. if (position === void 0) { position = Vector3.Zero(); }
  77723. if (normal === void 0) { normal = Vector3.Up(); }
  77724. this.position = position;
  77725. this.normal = normal;
  77726. }
  77727. /**
  77728. * Clones the PositionNormalVertex
  77729. * @returns the cloned PositionNormalVertex
  77730. */
  77731. PositionNormalVertex.prototype.clone = function () {
  77732. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  77733. };
  77734. return PositionNormalVertex;
  77735. }());
  77736. /**
  77737. * Contains position, normal and uv vectors for a vertex
  77738. */
  77739. var PositionNormalTextureVertex = /** @class */ (function () {
  77740. /**
  77741. * Creates a PositionNormalTextureVertex
  77742. * @param position the position of the vertex (defaut: 0,0,0)
  77743. * @param normal the normal of the vertex (defaut: 0,1,0)
  77744. * @param uv the uv of the vertex (default: 0,0)
  77745. */
  77746. function PositionNormalTextureVertex(
  77747. /** the position of the vertex (defaut: 0,0,0) */
  77748. position,
  77749. /** the normal of the vertex (defaut: 0,1,0) */
  77750. normal,
  77751. /** the uv of the vertex (default: 0,0) */
  77752. uv) {
  77753. if (position === void 0) { position = Vector3.Zero(); }
  77754. if (normal === void 0) { normal = Vector3.Up(); }
  77755. if (uv === void 0) { uv = Vector2.Zero(); }
  77756. this.position = position;
  77757. this.normal = normal;
  77758. this.uv = uv;
  77759. }
  77760. /**
  77761. * Clones the PositionNormalTextureVertex
  77762. * @returns the cloned PositionNormalTextureVertex
  77763. */
  77764. PositionNormalTextureVertex.prototype.clone = function () {
  77765. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  77766. };
  77767. return PositionNormalTextureVertex;
  77768. }());
  77769. // Temporary pre-allocated objects for engine internal use
  77770. // usage in any internal function :
  77771. // var tmp = Tmp.Vector3[0]; <= gets access to the first pre-created Vector3
  77772. // There's a Tmp array per object type : int, float, Vector2, Vector3, Vector4, Quaternion, Matrix
  77773. /**
  77774. * @hidden
  77775. */
  77776. var Tmp = /** @class */ (function () {
  77777. function Tmp() {
  77778. }
  77779. Tmp.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Color3.Black);
  77780. Tmp.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  77781. Tmp.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  77782. Tmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  77783. Tmp.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  77784. Tmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  77785. Tmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  77786. return Tmp;
  77787. }());
  77788. /**
  77789. * @hidden
  77790. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  77791. */
  77792. var MathTmp = /** @class */ (function () {
  77793. function MathTmp() {
  77794. }
  77795. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, Vector3.Zero);
  77796. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Matrix.Identity);
  77797. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  77798. return MathTmp;
  77799. }());
  77800. /***/ }),
  77801. /***/ "./Maths/sphericalPolynomial.ts":
  77802. /*!**************************************!*\
  77803. !*** ./Maths/sphericalPolynomial.ts ***!
  77804. \**************************************/
  77805. /*! exports provided: SphericalPolynomial, SphericalHarmonics */
  77806. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77807. "use strict";
  77808. __webpack_require__.r(__webpack_exports__);
  77809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  77810. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  77811. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  77812. /**
  77813. * Class representing spherical polynomial coefficients to the 3rd degree
  77814. */
  77815. var SphericalPolynomial = /** @class */ (function () {
  77816. function SphericalPolynomial() {
  77817. /**
  77818. * The x coefficients of the spherical polynomial
  77819. */
  77820. this.x = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77821. /**
  77822. * The y coefficients of the spherical polynomial
  77823. */
  77824. this.y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77825. /**
  77826. * The z coefficients of the spherical polynomial
  77827. */
  77828. this.z = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77829. /**
  77830. * The xx coefficients of the spherical polynomial
  77831. */
  77832. this.xx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77833. /**
  77834. * The yy coefficients of the spherical polynomial
  77835. */
  77836. this.yy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77837. /**
  77838. * The zz coefficients of the spherical polynomial
  77839. */
  77840. this.zz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77841. /**
  77842. * The xy coefficients of the spherical polynomial
  77843. */
  77844. this.xy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77845. /**
  77846. * The yz coefficients of the spherical polynomial
  77847. */
  77848. this.yz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77849. /**
  77850. * The zx coefficients of the spherical polynomial
  77851. */
  77852. this.zx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77853. }
  77854. /**
  77855. * Adds an ambient color to the spherical polynomial
  77856. * @param color the color to add
  77857. */
  77858. SphericalPolynomial.prototype.addAmbient = function (color) {
  77859. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  77860. this.xx = this.xx.add(colorVector);
  77861. this.yy = this.yy.add(colorVector);
  77862. this.zz = this.zz.add(colorVector);
  77863. };
  77864. /**
  77865. * Scales the spherical polynomial by the given amount
  77866. * @param scale the amount to scale
  77867. */
  77868. SphericalPolynomial.prototype.scale = function (scale) {
  77869. this.x = this.x.scale(scale);
  77870. this.y = this.y.scale(scale);
  77871. this.z = this.z.scale(scale);
  77872. this.xx = this.xx.scale(scale);
  77873. this.yy = this.yy.scale(scale);
  77874. this.zz = this.zz.scale(scale);
  77875. this.yz = this.yz.scale(scale);
  77876. this.zx = this.zx.scale(scale);
  77877. this.xy = this.xy.scale(scale);
  77878. };
  77879. /**
  77880. * Gets the spherical polynomial from harmonics
  77881. * @param harmonics the spherical harmonics
  77882. * @returns the spherical polynomial
  77883. */
  77884. SphericalPolynomial.FromHarmonics = function (harmonics) {
  77885. var result = new SphericalPolynomial();
  77886. result.x = harmonics.l11.scale(1.02333);
  77887. result.y = harmonics.l1_1.scale(1.02333);
  77888. result.z = harmonics.l10.scale(1.02333);
  77889. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.lL22.scale(0.429043));
  77890. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.lL22.scale(0.429043));
  77891. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  77892. result.yz = harmonics.l2_1.scale(0.858086);
  77893. result.zx = harmonics.l21.scale(0.858086);
  77894. result.xy = harmonics.l2_2.scale(0.858086);
  77895. result.scale(1.0 / Math.PI);
  77896. return result;
  77897. };
  77898. /**
  77899. * Constructs a spherical polynomial from an array.
  77900. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  77901. * @returns the spherical polynomial
  77902. */
  77903. SphericalPolynomial.FromArray = function (data) {
  77904. var sp = new SphericalPolynomial();
  77905. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  77906. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  77907. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  77908. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  77909. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  77910. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  77911. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  77912. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  77913. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  77914. return sp;
  77915. };
  77916. return SphericalPolynomial;
  77917. }());
  77918. /**
  77919. * Class representing spherical harmonics coefficients to the 3rd degree
  77920. */
  77921. var SphericalHarmonics = /** @class */ (function () {
  77922. function SphericalHarmonics() {
  77923. /**
  77924. * The l0,0 coefficients of the spherical harmonics
  77925. */
  77926. this.l00 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77927. /**
  77928. * The l1,-1 coefficients of the spherical harmonics
  77929. */
  77930. this.l1_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77931. /**
  77932. * The l1,0 coefficients of the spherical harmonics
  77933. */
  77934. this.l10 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77935. /**
  77936. * The l1,1 coefficients of the spherical harmonics
  77937. */
  77938. this.l11 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77939. /**
  77940. * The l2,-2 coefficients of the spherical harmonics
  77941. */
  77942. this.l2_2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77943. /**
  77944. * The l2,-1 coefficients of the spherical harmonics
  77945. */
  77946. this.l2_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77947. /**
  77948. * The l2,0 coefficients of the spherical harmonics
  77949. */
  77950. this.l20 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77951. /**
  77952. * The l2,1 coefficients of the spherical harmonics
  77953. */
  77954. this.l21 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77955. /**
  77956. * The l2,2 coefficients of the spherical harmonics
  77957. */
  77958. this.lL22 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77959. }
  77960. /**
  77961. * Adds a light to the spherical harmonics
  77962. * @param direction the direction of the light
  77963. * @param color the color of the light
  77964. * @param deltaSolidAngle the delta solid angle of the light
  77965. */
  77966. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  77967. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  77968. var c = colorVector.scale(deltaSolidAngle);
  77969. this.l00 = this.l00.add(c.scale(0.282095));
  77970. this.l1_1 = this.l1_1.add(c.scale(0.488603 * direction.y));
  77971. this.l10 = this.l10.add(c.scale(0.488603 * direction.z));
  77972. this.l11 = this.l11.add(c.scale(0.488603 * direction.x));
  77973. this.l2_2 = this.l2_2.add(c.scale(1.092548 * direction.x * direction.y));
  77974. this.l2_1 = this.l2_1.add(c.scale(1.092548 * direction.y * direction.z));
  77975. this.l21 = this.l21.add(c.scale(1.092548 * direction.x * direction.z));
  77976. this.l20 = this.l20.add(c.scale(0.315392 * (3.0 * direction.z * direction.z - 1.0)));
  77977. this.lL22 = this.lL22.add(c.scale(0.546274 * (direction.x * direction.x - direction.y * direction.y)));
  77978. };
  77979. /**
  77980. * Scales the spherical harmonics by the given amount
  77981. * @param scale the amount to scale
  77982. */
  77983. SphericalHarmonics.prototype.scale = function (scale) {
  77984. this.l00 = this.l00.scale(scale);
  77985. this.l1_1 = this.l1_1.scale(scale);
  77986. this.l10 = this.l10.scale(scale);
  77987. this.l11 = this.l11.scale(scale);
  77988. this.l2_2 = this.l2_2.scale(scale);
  77989. this.l2_1 = this.l2_1.scale(scale);
  77990. this.l20 = this.l20.scale(scale);
  77991. this.l21 = this.l21.scale(scale);
  77992. this.lL22 = this.lL22.scale(scale);
  77993. };
  77994. /**
  77995. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  77996. *
  77997. * ```
  77998. * E_lm = A_l * L_lm
  77999. * ```
  78000. *
  78001. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  78002. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  78003. * the scaling factors are given in equation 9.
  78004. */
  78005. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  78006. // Constant (Band 0)
  78007. this.l00 = this.l00.scale(3.141593);
  78008. // Linear (Band 1)
  78009. this.l1_1 = this.l1_1.scale(2.094395);
  78010. this.l10 = this.l10.scale(2.094395);
  78011. this.l11 = this.l11.scale(2.094395);
  78012. // Quadratic (Band 2)
  78013. this.l2_2 = this.l2_2.scale(0.785398);
  78014. this.l2_1 = this.l2_1.scale(0.785398);
  78015. this.l20 = this.l20.scale(0.785398);
  78016. this.l21 = this.l21.scale(0.785398);
  78017. this.lL22 = this.lL22.scale(0.785398);
  78018. };
  78019. /**
  78020. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  78021. *
  78022. * ```
  78023. * L = (1/pi) * E * rho
  78024. * ```
  78025. *
  78026. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  78027. */
  78028. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  78029. this.scale(1.0 / Math.PI);
  78030. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  78031. // (The pixel shader must apply albedo after texture fetches, etc).
  78032. };
  78033. /**
  78034. * Gets the spherical harmonics from polynomial
  78035. * @param polynomial the spherical polynomial
  78036. * @returns the spherical harmonics
  78037. */
  78038. SphericalHarmonics.FromPolynomial = function (polynomial) {
  78039. var result = new SphericalHarmonics();
  78040. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  78041. result.l1_1 = polynomial.y.scale(0.977204);
  78042. result.l10 = polynomial.z.scale(0.977204);
  78043. result.l11 = polynomial.x.scale(0.977204);
  78044. result.l2_2 = polynomial.xy.scale(1.16538);
  78045. result.l2_1 = polynomial.yz.scale(1.16538);
  78046. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  78047. result.l21 = polynomial.zx.scale(1.16538);
  78048. result.lL22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  78049. result.scale(Math.PI);
  78050. return result;
  78051. };
  78052. /**
  78053. * Constructs a spherical harmonics from an array.
  78054. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  78055. * @returns the spherical harmonics
  78056. */
  78057. SphericalHarmonics.FromArray = function (data) {
  78058. var sh = new SphericalHarmonics();
  78059. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  78060. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  78061. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  78062. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  78063. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  78064. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  78065. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  78066. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  78067. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.lL22);
  78068. return sh;
  78069. };
  78070. return SphericalHarmonics;
  78071. }());
  78072. /***/ }),
  78073. /***/ "./Meshes/Builders/boxBuilder.ts":
  78074. /*!***************************************!*\
  78075. !*** ./Meshes/Builders/boxBuilder.ts ***!
  78076. \***************************************/
  78077. /*! exports provided: BoxBuilder */
  78078. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78079. "use strict";
  78080. __webpack_require__.r(__webpack_exports__);
  78081. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return BoxBuilder; });
  78082. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78083. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78084. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78085. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox = function (options) {
  78086. var normalsSource = [
  78087. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1),
  78088. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1),
  78089. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0),
  78090. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0),
  78091. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0),
  78092. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)
  78093. ];
  78094. var indices = [];
  78095. var positions = [];
  78096. var normals = [];
  78097. var uvs = [];
  78098. var width = options.width || options.size || 1;
  78099. var height = options.height || options.size || 1;
  78100. var depth = options.depth || options.size || 1;
  78101. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  78102. var faceUV = options.faceUV || new Array(6);
  78103. var faceColors = options.faceColors;
  78104. var colors = [];
  78105. // default face colors and UV if undefined
  78106. for (var f = 0; f < 6; f++) {
  78107. if (faceUV[f] === undefined) {
  78108. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  78109. }
  78110. if (faceColors && faceColors[f] === undefined) {
  78111. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  78112. }
  78113. }
  78114. var scaleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](width / 2, height / 2, depth / 2);
  78115. // Create each face in turn.
  78116. for (var index = 0; index < normalsSource.length; index++) {
  78117. var normal = normalsSource[index];
  78118. // Get two vectors perpendicular to the face normal and to each other.
  78119. var side1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal.y, normal.z, normal.x);
  78120. var side2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(normal, side1);
  78121. // Six indices (two triangles) per face.
  78122. var verticesLength = positions.length / 3;
  78123. indices.push(verticesLength);
  78124. indices.push(verticesLength + 1);
  78125. indices.push(verticesLength + 2);
  78126. indices.push(verticesLength);
  78127. indices.push(verticesLength + 2);
  78128. indices.push(verticesLength + 3);
  78129. // Four vertices per face.
  78130. var vertex = normal.subtract(side1).subtract(side2).multiply(scaleVector);
  78131. positions.push(vertex.x, vertex.y, vertex.z);
  78132. normals.push(normal.x, normal.y, normal.z);
  78133. uvs.push(faceUV[index].z, faceUV[index].w);
  78134. if (faceColors) {
  78135. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  78136. }
  78137. vertex = normal.subtract(side1).add(side2).multiply(scaleVector);
  78138. positions.push(vertex.x, vertex.y, vertex.z);
  78139. normals.push(normal.x, normal.y, normal.z);
  78140. uvs.push(faceUV[index].x, faceUV[index].w);
  78141. if (faceColors) {
  78142. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  78143. }
  78144. vertex = normal.add(side1).add(side2).multiply(scaleVector);
  78145. positions.push(vertex.x, vertex.y, vertex.z);
  78146. normals.push(normal.x, normal.y, normal.z);
  78147. uvs.push(faceUV[index].x, faceUV[index].y);
  78148. if (faceColors) {
  78149. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  78150. }
  78151. vertex = normal.add(side1).subtract(side2).multiply(scaleVector);
  78152. positions.push(vertex.x, vertex.y, vertex.z);
  78153. normals.push(normal.x, normal.y, normal.z);
  78154. uvs.push(faceUV[index].z, faceUV[index].y);
  78155. if (faceColors) {
  78156. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  78157. }
  78158. }
  78159. // sides
  78160. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78161. // Result
  78162. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78163. vertexData.indices = indices;
  78164. vertexData.positions = positions;
  78165. vertexData.normals = normals;
  78166. vertexData.uvs = uvs;
  78167. if (faceColors) {
  78168. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  78169. vertexData.colors = totalColors;
  78170. }
  78171. return vertexData;
  78172. };
  78173. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  78174. if (scene === void 0) { scene = null; }
  78175. var options = {
  78176. size: size,
  78177. sideOrientation: sideOrientation,
  78178. updatable: updatable
  78179. };
  78180. return BoxBuilder.CreateBox(name, options, scene);
  78181. };
  78182. /**
  78183. * Class containing static functions to help procedurally build meshes
  78184. */
  78185. var BoxBuilder = /** @class */ (function () {
  78186. function BoxBuilder() {
  78187. }
  78188. /**
  78189. * Creates a box mesh
  78190. * * The parameter `size` sets the size (float) of each box side (default 1)
  78191. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  78192. * * 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)
  78193. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  78194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78195. * * 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
  78196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78197. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  78198. * @param name defines the name of the mesh
  78199. * @param options defines the options used to create the mesh
  78200. * @param scene defines the hosting scene
  78201. * @returns the box mesh
  78202. */
  78203. BoxBuilder.CreateBox = function (name, options, scene) {
  78204. if (scene === void 0) { scene = null; }
  78205. var box = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  78206. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78207. box._originalBuilderSideOrientation = options.sideOrientation;
  78208. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox(options);
  78209. vertexData.applyToMesh(box, options.updatable);
  78210. return box;
  78211. };
  78212. return BoxBuilder;
  78213. }());
  78214. /***/ }),
  78215. /***/ "./Meshes/Builders/cylinderBuilder.ts":
  78216. /*!********************************************!*\
  78217. !*** ./Meshes/Builders/cylinderBuilder.ts ***!
  78218. \********************************************/
  78219. /*! exports provided: CylinderBuilder */
  78220. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78221. "use strict";
  78222. __webpack_require__.r(__webpack_exports__);
  78223. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return CylinderBuilder; });
  78224. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78225. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78226. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78227. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  78228. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder = function (options) {
  78229. var height = options.height || 2;
  78230. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  78231. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  78232. var tessellation = options.tessellation || 24;
  78233. var subdivisions = options.subdivisions || 1;
  78234. var hasRings = options.hasRings ? true : false;
  78235. var enclose = options.enclose ? true : false;
  78236. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  78237. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  78238. var faceUV = options.faceUV || new Array(3);
  78239. var faceColors = options.faceColors;
  78240. // default face colors and UV if undefined
  78241. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  78242. var ringNb = (hasRings) ? subdivisions : 1;
  78243. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  78244. var f;
  78245. for (f = 0; f < surfaceNb; f++) {
  78246. if (faceColors && faceColors[f] === undefined) {
  78247. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  78248. }
  78249. }
  78250. for (f = 0; f < surfaceNb; f++) {
  78251. if (faceUV && faceUV[f] === undefined) {
  78252. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  78253. }
  78254. }
  78255. var indices = new Array();
  78256. var positions = new Array();
  78257. var normals = new Array();
  78258. var uvs = new Array();
  78259. var colors = new Array();
  78260. var angle_step = Math.PI * 2 * arc / tessellation;
  78261. var angle;
  78262. var h;
  78263. var radius;
  78264. var tan = (diameterBottom - diameterTop) / 2 / height;
  78265. var ringVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78266. var ringNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78267. var ringFirstVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78268. var ringFirstNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78269. var quadNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78270. var Y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Y;
  78271. // positions, normals, uvs
  78272. var i;
  78273. var j;
  78274. var r;
  78275. var ringIdx = 1;
  78276. var s = 1; // surface index
  78277. var cs = 0;
  78278. var v = 0;
  78279. for (i = 0; i <= subdivisions; i++) {
  78280. h = i / subdivisions;
  78281. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  78282. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  78283. for (r = 0; r < ringIdx; r++) {
  78284. if (hasRings) {
  78285. s += r;
  78286. }
  78287. if (enclose) {
  78288. s += 2 * r;
  78289. }
  78290. for (j = 0; j <= tessellation; j++) {
  78291. angle = j * angle_step;
  78292. // position
  78293. ringVertex.x = Math.cos(-angle) * radius;
  78294. ringVertex.y = -height / 2 + h * height;
  78295. ringVertex.z = Math.sin(-angle) * radius;
  78296. // normal
  78297. if (diameterTop === 0 && i === subdivisions) {
  78298. // if no top cap, reuse former normals
  78299. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  78300. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  78301. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  78302. }
  78303. else {
  78304. ringNormal.x = ringVertex.x;
  78305. ringNormal.z = ringVertex.z;
  78306. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  78307. ringNormal.normalize();
  78308. }
  78309. // keep first ring vertex values for enclose
  78310. if (j === 0) {
  78311. ringFirstVertex.copyFrom(ringVertex);
  78312. ringFirstNormal.copyFrom(ringNormal);
  78313. }
  78314. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  78315. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  78316. if (hasRings) {
  78317. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  78318. }
  78319. else {
  78320. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  78321. }
  78322. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  78323. if (faceColors) {
  78324. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  78325. }
  78326. }
  78327. // if enclose, add four vertices and their dedicated normals
  78328. if (arc !== 1 && enclose) {
  78329. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  78330. positions.push(0, ringVertex.y, 0);
  78331. positions.push(0, ringVertex.y, 0);
  78332. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  78333. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  78334. quadNormal.normalize();
  78335. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  78336. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  78337. quadNormal.normalize();
  78338. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  78339. if (hasRings) {
  78340. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  78341. }
  78342. else {
  78343. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  78344. }
  78345. uvs.push(faceUV[s + 1].x, v);
  78346. uvs.push(faceUV[s + 1].z, v);
  78347. if (hasRings) {
  78348. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  78349. }
  78350. else {
  78351. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  78352. }
  78353. uvs.push(faceUV[s + 2].x, v);
  78354. uvs.push(faceUV[s + 2].z, v);
  78355. if (faceColors) {
  78356. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  78357. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  78358. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  78359. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  78360. }
  78361. }
  78362. if (cs !== s) {
  78363. cs = s;
  78364. }
  78365. }
  78366. }
  78367. // indices
  78368. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  78369. var s;
  78370. i = 0;
  78371. for (s = 0; s < subdivisions; s++) {
  78372. var i0 = 0;
  78373. var i1 = 0;
  78374. var i2 = 0;
  78375. var i3 = 0;
  78376. for (j = 0; j < tessellation; j++) {
  78377. i0 = i * (e + 1) + j;
  78378. i1 = (i + 1) * (e + 1) + j;
  78379. i2 = i * (e + 1) + (j + 1);
  78380. i3 = (i + 1) * (e + 1) + (j + 1);
  78381. indices.push(i0, i1, i2);
  78382. indices.push(i3, i2, i1);
  78383. }
  78384. if (arc !== 1 && enclose) { // if enclose, add two quads
  78385. indices.push(i0 + 2, i1 + 2, i2 + 2);
  78386. indices.push(i3 + 2, i2 + 2, i1 + 2);
  78387. indices.push(i0 + 4, i1 + 4, i2 + 4);
  78388. indices.push(i3 + 4, i2 + 4, i1 + 4);
  78389. }
  78390. i = (hasRings) ? (i + 2) : (i + 1);
  78391. }
  78392. // Caps
  78393. var createCylinderCap = function (isTop) {
  78394. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  78395. if (radius === 0) {
  78396. return;
  78397. }
  78398. // Cap positions, normals & uvs
  78399. var angle;
  78400. var circleVector;
  78401. var i;
  78402. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  78403. var c = null;
  78404. if (faceColors) {
  78405. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  78406. }
  78407. // cap center
  78408. var vbase = positions.length / 3;
  78409. var offset = isTop ? height / 2 : -height / 2;
  78410. var center = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  78411. positions.push(center.x, center.y, center.z);
  78412. normals.push(0, isTop ? 1 : -1, 0);
  78413. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  78414. if (c) {
  78415. colors.push(c.r, c.g, c.b, c.a);
  78416. }
  78417. var textureScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  78418. for (i = 0; i <= tessellation; i++) {
  78419. angle = Math.PI * 2 * i * arc / tessellation;
  78420. var cos = Math.cos(-angle);
  78421. var sin = Math.sin(-angle);
  78422. circleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  78423. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  78424. positions.push(circleVector.x, circleVector.y, circleVector.z);
  78425. normals.push(0, isTop ? 1 : -1, 0);
  78426. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  78427. if (c) {
  78428. colors.push(c.r, c.g, c.b, c.a);
  78429. }
  78430. }
  78431. // Cap indices
  78432. for (i = 0; i < tessellation; i++) {
  78433. if (!isTop) {
  78434. indices.push(vbase);
  78435. indices.push(vbase + (i + 1));
  78436. indices.push(vbase + (i + 2));
  78437. }
  78438. else {
  78439. indices.push(vbase);
  78440. indices.push(vbase + (i + 2));
  78441. indices.push(vbase + (i + 1));
  78442. }
  78443. }
  78444. };
  78445. // add caps to geometry
  78446. createCylinderCap(false);
  78447. createCylinderCap(true);
  78448. // Sides
  78449. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78450. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78451. vertexData.indices = indices;
  78452. vertexData.positions = positions;
  78453. vertexData.normals = normals;
  78454. vertexData.uvs = uvs;
  78455. if (faceColors) {
  78456. vertexData.colors = colors;
  78457. }
  78458. return vertexData;
  78459. };
  78460. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  78461. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"])) {
  78462. if (scene !== undefined) {
  78463. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DEFAULTSIDE;
  78464. updatable = scene;
  78465. }
  78466. scene = subdivisions;
  78467. subdivisions = 1;
  78468. }
  78469. var options = {
  78470. height: height,
  78471. diameterTop: diameterTop,
  78472. diameterBottom: diameterBottom,
  78473. tessellation: tessellation,
  78474. subdivisions: subdivisions,
  78475. sideOrientation: sideOrientation,
  78476. updatable: updatable
  78477. };
  78478. return CylinderBuilder.CreateCylinder(name, options, scene);
  78479. };
  78480. /**
  78481. * Class containing static functions to help procedurally build meshes
  78482. */
  78483. var CylinderBuilder = /** @class */ (function () {
  78484. function CylinderBuilder() {
  78485. }
  78486. /**
  78487. * Creates a cylinder or a cone mesh
  78488. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  78489. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  78490. * * 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.
  78491. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  78492. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  78493. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  78494. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  78495. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  78496. * * 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).
  78497. * * 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
  78498. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  78499. * * 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
  78500. * * 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.
  78501. * * If `enclose` is false, a ring surface is one element.
  78502. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  78503. * * 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
  78504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78505. * * 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
  78506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78507. * @param name defines the name of the mesh
  78508. * @param options defines the options used to create the mesh
  78509. * @param scene defines the hosting scene
  78510. * @returns the cylinder mesh
  78511. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  78512. */
  78513. CylinderBuilder.CreateCylinder = function (name, options, scene) {
  78514. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  78515. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78516. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  78517. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder(options);
  78518. vertexData.applyToMesh(cylinder, options.updatable);
  78519. return cylinder;
  78520. };
  78521. return CylinderBuilder;
  78522. }());
  78523. /***/ }),
  78524. /***/ "./Meshes/Builders/decalBuilder.ts":
  78525. /*!*****************************************!*\
  78526. !*** ./Meshes/Builders/decalBuilder.ts ***!
  78527. \*****************************************/
  78528. /*! exports provided: DecalBuilder */
  78529. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78530. "use strict";
  78531. __webpack_require__.r(__webpack_exports__);
  78532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return DecalBuilder; });
  78533. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78534. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78535. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  78536. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78537. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  78538. var options = {
  78539. position: position,
  78540. normal: normal,
  78541. size: size,
  78542. angle: angle
  78543. };
  78544. return DecalBuilder.CreateDecal(name, sourceMesh, options);
  78545. };
  78546. /**
  78547. * Class containing static functions to help procedurally build meshes
  78548. */
  78549. var DecalBuilder = /** @class */ (function () {
  78550. function DecalBuilder() {
  78551. }
  78552. /**
  78553. * Creates a decal mesh.
  78554. * 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
  78555. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  78556. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  78557. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  78558. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  78559. * @param name defines the name of the mesh
  78560. * @param sourceMesh defines the mesh where the decal must be applied
  78561. * @param options defines the options used to create the mesh
  78562. * @param scene defines the hosting scene
  78563. * @returns the decal mesh
  78564. * @see https://doc.babylonjs.com/how_to/decals
  78565. */
  78566. DecalBuilder.CreateDecal = function (name, sourceMesh, options) {
  78567. var indices = sourceMesh.getIndices();
  78568. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  78569. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  78570. var position = options.position || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78571. var normal = options.normal || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up();
  78572. var size = options.size || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  78573. var angle = options.angle || 0;
  78574. // Getting correct rotation
  78575. if (!normal) {
  78576. var target = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1);
  78577. var camera = sourceMesh.getScene().activeCamera;
  78578. var cameraWorldTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  78579. normal = camera.globalPosition.subtract(cameraWorldTarget);
  78580. }
  78581. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  78582. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  78583. var pitch = Math.atan2(normal.y, len);
  78584. // Matrix
  78585. 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));
  78586. var inverseDecalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Invert(decalWorldMatrix);
  78587. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  78588. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  78589. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  78590. vertexData.indices = [];
  78591. vertexData.positions = [];
  78592. vertexData.normals = [];
  78593. vertexData.uvs = [];
  78594. var currentVertexDataIndex = 0;
  78595. var extractDecalVector3 = function (indexId) {
  78596. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]();
  78597. if (!indices || !positions || !normals) {
  78598. return result;
  78599. }
  78600. var vertexId = indices[indexId];
  78601. result.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  78602. // Send vector to decal local world
  78603. result.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  78604. // Get normal
  78605. result.normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  78606. result.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result.normal, transformMatrix);
  78607. return result;
  78608. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  78609. var clip = function (vertices, axis) {
  78610. if (vertices.length === 0) {
  78611. return vertices;
  78612. }
  78613. var clipSize = 0.5 * Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(size, axis));
  78614. var clipVertices = function (v0, v1) {
  78615. var clipFactor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  78616. 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));
  78617. };
  78618. var result = new Array();
  78619. for (var index = 0; index < vertices.length; index += 3) {
  78620. var v1Out;
  78621. var v2Out;
  78622. var v3Out;
  78623. var total = 0;
  78624. var nV1 = null;
  78625. var nV2 = null;
  78626. var nV3 = null;
  78627. var nV4 = null;
  78628. var d1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  78629. var d2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  78630. var d3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  78631. v1Out = d1 > 0;
  78632. v2Out = d2 > 0;
  78633. v3Out = d3 > 0;
  78634. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  78635. switch (total) {
  78636. case 0:
  78637. result.push(vertices[index]);
  78638. result.push(vertices[index + 1]);
  78639. result.push(vertices[index + 2]);
  78640. break;
  78641. case 1:
  78642. if (v1Out) {
  78643. nV1 = vertices[index + 1];
  78644. nV2 = vertices[index + 2];
  78645. nV3 = clipVertices(vertices[index], nV1);
  78646. nV4 = clipVertices(vertices[index], nV2);
  78647. }
  78648. if (v2Out) {
  78649. nV1 = vertices[index];
  78650. nV2 = vertices[index + 2];
  78651. nV3 = clipVertices(vertices[index + 1], nV1);
  78652. nV4 = clipVertices(vertices[index + 1], nV2);
  78653. result.push(nV3);
  78654. result.push(nV2.clone());
  78655. result.push(nV1.clone());
  78656. result.push(nV2.clone());
  78657. result.push(nV3.clone());
  78658. result.push(nV4);
  78659. break;
  78660. }
  78661. if (v3Out) {
  78662. nV1 = vertices[index];
  78663. nV2 = vertices[index + 1];
  78664. nV3 = clipVertices(vertices[index + 2], nV1);
  78665. nV4 = clipVertices(vertices[index + 2], nV2);
  78666. }
  78667. if (nV1 && nV2 && nV3 && nV4) {
  78668. result.push(nV1.clone());
  78669. result.push(nV2.clone());
  78670. result.push(nV3);
  78671. result.push(nV4);
  78672. result.push(nV3.clone());
  78673. result.push(nV2.clone());
  78674. }
  78675. break;
  78676. case 2:
  78677. if (!v1Out) {
  78678. nV1 = vertices[index].clone();
  78679. nV2 = clipVertices(nV1, vertices[index + 1]);
  78680. nV3 = clipVertices(nV1, vertices[index + 2]);
  78681. result.push(nV1);
  78682. result.push(nV2);
  78683. result.push(nV3);
  78684. }
  78685. if (!v2Out) {
  78686. nV1 = vertices[index + 1].clone();
  78687. nV2 = clipVertices(nV1, vertices[index + 2]);
  78688. nV3 = clipVertices(nV1, vertices[index]);
  78689. result.push(nV1);
  78690. result.push(nV2);
  78691. result.push(nV3);
  78692. }
  78693. if (!v3Out) {
  78694. nV1 = vertices[index + 2].clone();
  78695. nV2 = clipVertices(nV1, vertices[index]);
  78696. nV3 = clipVertices(nV1, vertices[index + 1]);
  78697. result.push(nV1);
  78698. result.push(nV2);
  78699. result.push(nV3);
  78700. }
  78701. break;
  78702. case 3:
  78703. break;
  78704. }
  78705. }
  78706. return result;
  78707. };
  78708. for (var index = 0; index < indices.length; index += 3) {
  78709. var faceVertices = new Array();
  78710. faceVertices.push(extractDecalVector3(index));
  78711. faceVertices.push(extractDecalVector3(index + 1));
  78712. faceVertices.push(extractDecalVector3(index + 2));
  78713. // Clip
  78714. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0));
  78715. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0));
  78716. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0));
  78717. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0));
  78718. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1));
  78719. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1));
  78720. if (faceVertices.length === 0) {
  78721. continue;
  78722. }
  78723. // Add UVs and get back to world
  78724. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  78725. var vertex = faceVertices[vIndex];
  78726. //TODO check for Int32Array | Uint32Array | Uint16Array
  78727. vertexData.indices.push(currentVertexDataIndex);
  78728. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  78729. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  78730. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  78731. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  78732. currentVertexDataIndex++;
  78733. }
  78734. }
  78735. // Return mesh
  78736. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, sourceMesh.getScene());
  78737. vertexData.applyToMesh(decal);
  78738. decal.position = position.clone();
  78739. decal.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pitch, yaw, angle);
  78740. return decal;
  78741. };
  78742. return DecalBuilder;
  78743. }());
  78744. /***/ }),
  78745. /***/ "./Meshes/Builders/discBuilder.ts":
  78746. /*!****************************************!*\
  78747. !*** ./Meshes/Builders/discBuilder.ts ***!
  78748. \****************************************/
  78749. /*! exports provided: DiscBuilder */
  78750. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78751. "use strict";
  78752. __webpack_require__.r(__webpack_exports__);
  78753. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return DiscBuilder; });
  78754. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78755. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78756. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc = function (options) {
  78757. var positions = new Array();
  78758. var indices = new Array();
  78759. var normals = new Array();
  78760. var uvs = new Array();
  78761. var radius = options.radius || 0.5;
  78762. var tessellation = options.tessellation || 64;
  78763. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  78764. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  78765. // positions and uvs
  78766. positions.push(0, 0, 0); // disc center first
  78767. uvs.push(0.5, 0.5);
  78768. var theta = Math.PI * 2 * arc;
  78769. var step = theta / tessellation;
  78770. for (var a = 0; a < theta; a += step) {
  78771. var x = Math.cos(a);
  78772. var y = Math.sin(a);
  78773. var u = (x + 1) / 2;
  78774. var v = (1 - y) / 2;
  78775. positions.push(radius * x, radius * y, 0);
  78776. uvs.push(u, v);
  78777. }
  78778. if (arc === 1) {
  78779. positions.push(positions[3], positions[4], positions[5]); // close the circle
  78780. uvs.push(uvs[2], uvs[3]);
  78781. }
  78782. //indices
  78783. var vertexNb = positions.length / 3;
  78784. for (var i = 1; i < vertexNb - 1; i++) {
  78785. indices.push(i + 1, 0, i);
  78786. }
  78787. // result
  78788. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ComputeNormals(positions, indices, normals);
  78789. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78790. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  78791. vertexData.indices = indices;
  78792. vertexData.positions = positions;
  78793. vertexData.normals = normals;
  78794. vertexData.uvs = uvs;
  78795. return vertexData;
  78796. };
  78797. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  78798. if (scene === void 0) { scene = null; }
  78799. var options = {
  78800. radius: radius,
  78801. tessellation: tessellation,
  78802. sideOrientation: sideOrientation,
  78803. updatable: updatable
  78804. };
  78805. return DiscBuilder.CreateDisc(name, options, scene);
  78806. };
  78807. /**
  78808. * Class containing static functions to help procedurally build meshes
  78809. */
  78810. var DiscBuilder = /** @class */ (function () {
  78811. function DiscBuilder() {
  78812. }
  78813. /**
  78814. * Creates a plane polygonal mesh. By default, this is a disc
  78815. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  78816. * * 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
  78817. * * 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
  78818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78819. * * 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
  78820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78821. * @param name defines the name of the mesh
  78822. * @param options defines the options used to create the mesh
  78823. * @param scene defines the hosting scene
  78824. * @returns the plane polygonal mesh
  78825. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  78826. */
  78827. DiscBuilder.CreateDisc = function (name, options, scene) {
  78828. if (scene === void 0) { scene = null; }
  78829. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  78830. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78831. disc._originalBuilderSideOrientation = options.sideOrientation;
  78832. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc(options);
  78833. vertexData.applyToMesh(disc, options.updatable);
  78834. return disc;
  78835. };
  78836. return DiscBuilder;
  78837. }());
  78838. /***/ }),
  78839. /***/ "./Meshes/Builders/groundBuilder.ts":
  78840. /*!******************************************!*\
  78841. !*** ./Meshes/Builders/groundBuilder.ts ***!
  78842. \******************************************/
  78843. /*! exports provided: GroundBuilder */
  78844. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78845. "use strict";
  78846. __webpack_require__.r(__webpack_exports__);
  78847. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return GroundBuilder; });
  78848. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78849. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78850. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78851. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../groundMesh */ "./Meshes/groundMesh.ts");
  78852. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  78853. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  78854. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround = function (options) {
  78855. var indices = [];
  78856. var positions = [];
  78857. var normals = [];
  78858. var uvs = [];
  78859. var row, col;
  78860. var width = options.width || 1;
  78861. var height = options.height || 1;
  78862. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  78863. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  78864. for (row = 0; row <= subdivisionsY; row++) {
  78865. for (col = 0; col <= subdivisionsX; col++) {
  78866. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  78867. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  78868. positions.push(position.x, position.y, position.z);
  78869. normals.push(normal.x, normal.y, normal.z);
  78870. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  78871. }
  78872. }
  78873. for (row = 0; row < subdivisionsY; row++) {
  78874. for (col = 0; col < subdivisionsX; col++) {
  78875. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  78876. indices.push(col + 1 + row * (subdivisionsX + 1));
  78877. indices.push(col + row * (subdivisionsX + 1));
  78878. indices.push(col + (row + 1) * (subdivisionsX + 1));
  78879. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  78880. indices.push(col + row * (subdivisionsX + 1));
  78881. }
  78882. }
  78883. // Result
  78884. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78885. vertexData.indices = indices;
  78886. vertexData.positions = positions;
  78887. vertexData.normals = normals;
  78888. vertexData.uvs = uvs;
  78889. return vertexData;
  78890. };
  78891. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround = function (options) {
  78892. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  78893. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  78894. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  78895. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  78896. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  78897. var precision = options.precision || { w: 1, h: 1 };
  78898. var indices = new Array();
  78899. var positions = new Array();
  78900. var normals = new Array();
  78901. var uvs = new Array();
  78902. var row, col, tileRow, tileCol;
  78903. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  78904. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  78905. precision.w = (precision.w < 1) ? 1 : precision.w;
  78906. precision.h = (precision.h < 1) ? 1 : precision.h;
  78907. var tileSize = {
  78908. 'w': (xmax - xmin) / subdivisions.w,
  78909. 'h': (zmax - zmin) / subdivisions.h
  78910. };
  78911. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  78912. // Indices
  78913. var base = positions.length / 3;
  78914. var rowLength = precision.w + 1;
  78915. for (row = 0; row < precision.h; row++) {
  78916. for (col = 0; col < precision.w; col++) {
  78917. var square = [
  78918. base + col + row * rowLength,
  78919. base + (col + 1) + row * rowLength,
  78920. base + (col + 1) + (row + 1) * rowLength,
  78921. base + col + (row + 1) * rowLength
  78922. ];
  78923. indices.push(square[1]);
  78924. indices.push(square[2]);
  78925. indices.push(square[3]);
  78926. indices.push(square[0]);
  78927. indices.push(square[1]);
  78928. indices.push(square[3]);
  78929. }
  78930. }
  78931. // Position, normals and uvs
  78932. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78933. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  78934. for (row = 0; row <= precision.h; row++) {
  78935. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  78936. for (col = 0; col <= precision.w; col++) {
  78937. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  78938. position.y = 0;
  78939. positions.push(position.x, position.y, position.z);
  78940. normals.push(normal.x, normal.y, normal.z);
  78941. uvs.push(col / precision.w, row / precision.h);
  78942. }
  78943. }
  78944. }
  78945. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  78946. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  78947. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  78948. }
  78949. }
  78950. // Result
  78951. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78952. vertexData.indices = indices;
  78953. vertexData.positions = positions;
  78954. vertexData.normals = normals;
  78955. vertexData.uvs = uvs;
  78956. return vertexData;
  78957. };
  78958. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap = function (options) {
  78959. var indices = [];
  78960. var positions = [];
  78961. var normals = [];
  78962. var uvs = [];
  78963. var row, col;
  78964. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  78965. var alphaFilter = options.alphaFilter || 0.0;
  78966. var invert = false;
  78967. if (options.minHeight > options.maxHeight) {
  78968. invert = true;
  78969. var temp = options.maxHeight;
  78970. options.maxHeight = options.minHeight;
  78971. options.minHeight = temp;
  78972. }
  78973. // Vertices
  78974. for (row = 0; row <= options.subdivisions; row++) {
  78975. for (col = 0; col <= options.subdivisions; col++) {
  78976. 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));
  78977. // Compute height
  78978. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  78979. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  78980. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  78981. var r = options.buffer[pos] / 255.0;
  78982. var g = options.buffer[pos + 1] / 255.0;
  78983. var b = options.buffer[pos + 2] / 255.0;
  78984. var a = options.buffer[pos + 3] / 255.0;
  78985. if (invert) {
  78986. r = 1.0 - r;
  78987. g = 1.0 - g;
  78988. b = 1.0 - b;
  78989. }
  78990. var gradient = r * filter.r + g * filter.g + b * filter.b;
  78991. // If our alpha channel is not within our filter then we will assign a 'special' height
  78992. // Then when building the indices, we will ignore any vertex that is using the special height
  78993. if (a >= alphaFilter) {
  78994. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  78995. }
  78996. else {
  78997. position.y = options.minHeight - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; // We can't have a height below minHeight, normally.
  78998. }
  78999. // Add vertex
  79000. positions.push(position.x, position.y, position.z);
  79001. normals.push(0, 0, 0);
  79002. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  79003. }
  79004. }
  79005. // Indices
  79006. for (row = 0; row < options.subdivisions; row++) {
  79007. for (col = 0; col < options.subdivisions; col++) {
  79008. // Calculate Indices
  79009. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  79010. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  79011. var idx3 = (col + row * (options.subdivisions + 1));
  79012. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  79013. // Check that all indices are visible (based on our special height)
  79014. // Only display the vertex if all Indices are visible
  79015. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  79016. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  79017. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  79018. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  79019. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  79020. indices.push(idx1);
  79021. indices.push(idx2);
  79022. indices.push(idx3);
  79023. }
  79024. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  79025. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  79026. indices.push(idx4);
  79027. indices.push(idx1);
  79028. indices.push(idx3);
  79029. }
  79030. }
  79031. }
  79032. // Normals
  79033. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  79034. // Result
  79035. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79036. vertexData.indices = indices;
  79037. vertexData.positions = positions;
  79038. vertexData.normals = normals;
  79039. vertexData.uvs = uvs;
  79040. return vertexData;
  79041. };
  79042. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  79043. var options = {
  79044. width: width,
  79045. height: height,
  79046. subdivisions: subdivisions,
  79047. updatable: updatable
  79048. };
  79049. return GroundBuilder.CreateGround(name, options, scene);
  79050. };
  79051. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  79052. var options = {
  79053. xmin: xmin,
  79054. zmin: zmin,
  79055. xmax: xmax,
  79056. zmax: zmax,
  79057. subdivisions: subdivisions,
  79058. precision: precision,
  79059. updatable: updatable
  79060. };
  79061. return GroundBuilder.CreateTiledGround(name, options, scene);
  79062. };
  79063. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  79064. var options = {
  79065. width: width,
  79066. height: height,
  79067. subdivisions: subdivisions,
  79068. minHeight: minHeight,
  79069. maxHeight: maxHeight,
  79070. updatable: updatable,
  79071. onReady: onReady,
  79072. alphaFilter: alphaFilter
  79073. };
  79074. return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  79075. };
  79076. /**
  79077. * Class containing static functions to help procedurally build meshes
  79078. */
  79079. var GroundBuilder = /** @class */ (function () {
  79080. function GroundBuilder() {
  79081. }
  79082. /**
  79083. * Creates a ground mesh
  79084. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  79085. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  79086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79087. * @param name defines the name of the mesh
  79088. * @param options defines the options used to create the mesh
  79089. * @param scene defines the hosting scene
  79090. * @returns the ground mesh
  79091. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  79092. */
  79093. GroundBuilder.CreateGround = function (name, options, scene) {
  79094. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  79095. ground._setReady(false);
  79096. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  79097. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  79098. ground._width = options.width || 1;
  79099. ground._height = options.height || 1;
  79100. ground._maxX = ground._width / 2;
  79101. ground._maxZ = ground._height / 2;
  79102. ground._minX = -ground._maxX;
  79103. ground._minZ = -ground._maxZ;
  79104. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround(options);
  79105. vertexData.applyToMesh(ground, options.updatable);
  79106. ground._setReady(true);
  79107. return ground;
  79108. };
  79109. /**
  79110. * Creates a tiled ground mesh
  79111. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  79112. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  79113. * * 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
  79114. * * 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
  79115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79116. * @param name defines the name of the mesh
  79117. * @param options defines the options used to create the mesh
  79118. * @param scene defines the hosting scene
  79119. * @returns the tiled ground mesh
  79120. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  79121. */
  79122. GroundBuilder.CreateTiledGround = function (name, options, scene) {
  79123. if (scene === void 0) { scene = null; }
  79124. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79125. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround(options);
  79126. vertexData.applyToMesh(tiledGround, options.updatable);
  79127. return tiledGround;
  79128. };
  79129. /**
  79130. * Creates a ground mesh from a height map
  79131. * * The parameter `url` sets the URL of the height map image resource.
  79132. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  79133. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  79134. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  79135. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  79136. * * 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.
  79137. * * 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).
  79138. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  79139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  79140. * @param name defines the name of the mesh
  79141. * @param url defines the url to the height map
  79142. * @param options defines the options used to create the mesh
  79143. * @param scene defines the hosting scene
  79144. * @returns the ground mesh
  79145. * @see https://doc.babylonjs.com/babylon101/height_map
  79146. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  79147. */
  79148. GroundBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  79149. if (scene === void 0) { scene = null; }
  79150. var width = options.width || 10.0;
  79151. var height = options.height || 10.0;
  79152. var subdivisions = options.subdivisions || 1 | 0;
  79153. var minHeight = options.minHeight || 0.0;
  79154. var maxHeight = options.maxHeight || 1.0;
  79155. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  79156. var alphaFilter = options.alphaFilter || 0.0;
  79157. var updatable = options.updatable;
  79158. var onReady = options.onReady;
  79159. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  79160. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  79161. ground._subdivisionsX = subdivisions;
  79162. ground._subdivisionsY = subdivisions;
  79163. ground._width = width;
  79164. ground._height = height;
  79165. ground._maxX = ground._width / 2.0;
  79166. ground._maxZ = ground._height / 2.0;
  79167. ground._minX = -ground._maxX;
  79168. ground._minZ = -ground._maxZ;
  79169. ground._setReady(false);
  79170. var onload = function (img) {
  79171. // Getting height map data
  79172. var canvas = document.createElement("canvas");
  79173. var context = canvas.getContext("2d");
  79174. if (!context) {
  79175. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  79176. }
  79177. if (scene.isDisposed) {
  79178. return;
  79179. }
  79180. var bufferWidth = img.width;
  79181. var bufferHeight = img.height;
  79182. canvas.width = bufferWidth;
  79183. canvas.height = bufferHeight;
  79184. context.drawImage(img, 0, 0);
  79185. // Create VertexData from map data
  79186. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  79187. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  79188. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap({
  79189. width: width, height: height,
  79190. subdivisions: subdivisions,
  79191. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  79192. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  79193. alphaFilter: alphaFilter
  79194. });
  79195. vertexData.applyToMesh(ground, updatable);
  79196. //execute ready callback, if set
  79197. if (onReady) {
  79198. onReady(ground);
  79199. }
  79200. ground._setReady(true);
  79201. };
  79202. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  79203. return ground;
  79204. };
  79205. return GroundBuilder;
  79206. }());
  79207. /***/ }),
  79208. /***/ "./Meshes/Builders/hemisphereBuilder.ts":
  79209. /*!**********************************************!*\
  79210. !*** ./Meshes/Builders/hemisphereBuilder.ts ***!
  79211. \**********************************************/
  79212. /*! exports provided: HemisphereBuilder */
  79213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79214. "use strict";
  79215. __webpack_require__.r(__webpack_exports__);
  79216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return HemisphereBuilder; });
  79217. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79218. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  79219. /**
  79220. * Creates a hemispheric light
  79221. */
  79222. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateHemisphere = function (name, segments, diameter, scene) {
  79223. var options = {
  79224. segments: segments,
  79225. diameter: diameter
  79226. };
  79227. return HemisphereBuilder.CreateHemisphere(name, options, scene);
  79228. };
  79229. /**
  79230. * Class containing static functions to help procedurally build meshes
  79231. */
  79232. var HemisphereBuilder = /** @class */ (function () {
  79233. function HemisphereBuilder() {
  79234. }
  79235. /**
  79236. * Creates a hemisphere mesh
  79237. * @param name defines the name of the mesh
  79238. * @param options defines the options used to create the mesh
  79239. * @param scene defines the hosting scene
  79240. * @returns the hemisphere mesh
  79241. */
  79242. HemisphereBuilder.CreateHemisphere = function (name, options, scene) {
  79243. if (!options.diameter) {
  79244. options.diameter = 1;
  79245. }
  79246. if (!options.segments) {
  79247. options.segments = 16;
  79248. }
  79249. var halfSphere = _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("", { slice: 0.5, diameter: options.diameter, segments: options.segments }, scene);
  79250. var disc = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc("", options.diameter / 2, (options.segments * 3) + (4 - options.segments), scene);
  79251. disc.rotation.x = -Math.PI / 2;
  79252. disc.parent = halfSphere;
  79253. var merged = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].MergeMeshes([disc, halfSphere], true);
  79254. merged.name = name;
  79255. return merged;
  79256. };
  79257. return HemisphereBuilder;
  79258. }());
  79259. /***/ }),
  79260. /***/ "./Meshes/Builders/icoSphereBuilder.ts":
  79261. /*!*********************************************!*\
  79262. !*** ./Meshes/Builders/icoSphereBuilder.ts ***!
  79263. \*********************************************/
  79264. /*! exports provided: IcoSphereBuilder */
  79265. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79266. "use strict";
  79267. __webpack_require__.r(__webpack_exports__);
  79268. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return IcoSphereBuilder; });
  79269. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79270. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79271. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79272. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere = function (options) {
  79273. var sideOrientation = options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  79274. var radius = options.radius || 1;
  79275. var flat = (options.flat === undefined) ? true : options.flat;
  79276. var subdivisions = options.subdivisions || 4;
  79277. var radiusX = options.radiusX || radius;
  79278. var radiusY = options.radiusY || radius;
  79279. var radiusZ = options.radiusZ || radius;
  79280. var t = (1 + Math.sqrt(5)) / 2;
  79281. // 12 vertex x,y,z
  79282. var ico_vertices = [
  79283. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  79284. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  79285. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  79286. ];
  79287. // index of 3 vertex makes a face of icopshere
  79288. var ico_indices = [
  79289. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  79290. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  79291. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  79292. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  79293. ];
  79294. // vertex for uv have aliased position, not for UV
  79295. var vertices_unalias_id = [
  79296. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  79297. // vertex alias
  79298. 0,
  79299. 2,
  79300. 3,
  79301. 3,
  79302. 3,
  79303. 4,
  79304. 7,
  79305. 8,
  79306. 9,
  79307. 9,
  79308. 10,
  79309. 11 // 23: B + 12
  79310. ];
  79311. // uv as integer step (not pixels !)
  79312. var ico_vertexuv = [
  79313. 5, 1, 3, 1, 6, 4, 0, 0,
  79314. 5, 3, 4, 2, 2, 2, 4, 0,
  79315. 2, 0, 1, 1, 6, 0, 6, 2,
  79316. // vertex alias (for same vertex on different faces)
  79317. 0, 4,
  79318. 3, 3,
  79319. 4, 4,
  79320. 3, 1,
  79321. 4, 2,
  79322. 4, 4,
  79323. 0, 2,
  79324. 1, 1,
  79325. 2, 2,
  79326. 3, 3,
  79327. 1, 3,
  79328. 2, 4 // 23: B + 12
  79329. ];
  79330. // Vertices[0, 1, ...9, A, B] : position on UV plane
  79331. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  79332. // First island of uv mapping
  79333. // v = 4h 3+ 2
  79334. // v = 3h 9+ 4
  79335. // v = 2h 9+ 5 B
  79336. // v = 1h 9 1 0
  79337. // v = 0h 3 8 7 A
  79338. // u = 0 1 2 3 4 5 6 *a
  79339. // Second island of uv mapping
  79340. // v = 4h 0+ B+ 4+
  79341. // v = 3h A+ 2+
  79342. // v = 2h 7+ 6 3+
  79343. // v = 1h 8+ 3+
  79344. // v = 0h
  79345. // u = 0 1 2 3 4 5 6 *a
  79346. // Face layout on texture UV mapping
  79347. // ============
  79348. // \ 4 /\ 16 / ======
  79349. // \ / \ / /\ 11 /
  79350. // \/ 7 \/ / \ /
  79351. // ======= / 10 \/
  79352. // /\ 17 /\ =======
  79353. // / \ / \ \ 15 /\
  79354. // / 8 \/ 12 \ \ / \
  79355. // ============ \/ 6 \
  79356. // \ 18 /\ ============
  79357. // \ / \ \ 5 /\ 0 /
  79358. // \/ 13 \ \ / \ /
  79359. // ======= \/ 1 \/
  79360. // =============
  79361. // /\ 19 /\ 2 /\
  79362. // / \ / \ / \
  79363. // / 14 \/ 9 \/ 3 \
  79364. // ===================
  79365. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  79366. var ustep = 138 / 1024;
  79367. var vstep = 239 / 1024;
  79368. var uoffset = 60 / 1024;
  79369. var voffset = 26 / 1024;
  79370. // Second island should have margin, not to touch the first island
  79371. // avoid any borderline artefact in pixel rounding
  79372. var island_u_offset = -40 / 1024;
  79373. var island_v_offset = +20 / 1024;
  79374. // face is either island 0 or 1 :
  79375. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  79376. var island = [
  79377. 0, 0, 0, 0, 1,
  79378. 0, 0, 1, 1, 0,
  79379. 0, 0, 1, 1, 0,
  79380. 0, 1, 1, 1, 0 // 15 - 19
  79381. ];
  79382. var indices = new Array();
  79383. var positions = new Array();
  79384. var normals = new Array();
  79385. var uvs = new Array();
  79386. var current_indice = 0;
  79387. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  79388. var face_vertex_pos = new Array(3);
  79389. var face_vertex_uv = new Array(3);
  79390. var v012;
  79391. for (v012 = 0; v012 < 3; v012++) {
  79392. face_vertex_pos[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79393. face_vertex_uv[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  79394. }
  79395. // create all with normals
  79396. for (var face = 0; face < 20; face++) {
  79397. // 3 vertex per face
  79398. for (v012 = 0; v012 < 3; v012++) {
  79399. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  79400. var v_id = ico_indices[3 * face + v012];
  79401. // vertex have 3D position (x,y,z)
  79402. 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]);
  79403. // Normalize to get normal, then scale to radius
  79404. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  79405. // uv Coordinates from vertex ID
  79406. 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);
  79407. }
  79408. // Subdivide the face (interpolate pos, norm, uv)
  79409. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  79410. // - norm is linear interpolation of vertex corner normal
  79411. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  79412. // - uv is linear interpolation
  79413. //
  79414. // Topology is as below for sub-divide by 2
  79415. // vertex shown as v0,v1,v2
  79416. // interp index is i1 to progress in range [v0,v1[
  79417. // interp index is i2 to progress in range [v0,v2[
  79418. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  79419. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  79420. //
  79421. //
  79422. // i2 v2
  79423. // ^ ^
  79424. // / / \
  79425. // / / \
  79426. // / / \
  79427. // / / (0,1) \
  79428. // / #---------\
  79429. // / / \ (0,0)'/ \
  79430. // / / \ / \
  79431. // / / \ / \
  79432. // / / (0,0) \ / (1,0) \
  79433. // / #---------#---------\
  79434. // v0 v1
  79435. //
  79436. // --------------------> i1
  79437. //
  79438. // interp of (i1,i2):
  79439. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  79440. // along i1 : lerp(x0,x1, i1/(S-i2))
  79441. //
  79442. // centroid of triangle is needed to get help normal computation
  79443. // (c1,c2) are used for centroid location
  79444. var interp_vertex = function (i1, i2, c1, c2) {
  79445. // vertex is interpolated from
  79446. // - face_vertex_pos[0..2]
  79447. // - face_vertex_uv[0..2]
  79448. var pos_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  79449. var pos_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  79450. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  79451. pos_interp.normalize();
  79452. var vertex_normal;
  79453. if (flat) {
  79454. // in flat mode, recalculate normal as face centroid normal
  79455. var centroid_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  79456. var centroid_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  79457. vertex_normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  79458. }
  79459. else {
  79460. // in smooth mode, recalculate normal from each single vertex position
  79461. vertex_normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  79462. }
  79463. // Vertex normal need correction due to X,Y,Z radius scaling
  79464. vertex_normal.x /= radiusX;
  79465. vertex_normal.y /= radiusY;
  79466. vertex_normal.z /= radiusZ;
  79467. vertex_normal.normalize();
  79468. var uv_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  79469. var uv_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  79470. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  79471. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  79472. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  79473. uvs.push(uv_interp.x, uv_interp.y);
  79474. // push each vertex has member of a face
  79475. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  79476. indices.push(current_indice);
  79477. current_indice++;
  79478. };
  79479. for (var i2 = 0; i2 < subdivisions; i2++) {
  79480. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  79481. // face : (i1,i2) for /\ :
  79482. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  79483. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  79484. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  79485. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  79486. if (i1 + i2 + 1 < subdivisions) {
  79487. // face : (i1,i2)' for \/ :
  79488. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  79489. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  79490. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  79491. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  79492. }
  79493. }
  79494. }
  79495. }
  79496. // Sides
  79497. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79498. // Result
  79499. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79500. vertexData.indices = indices;
  79501. vertexData.positions = positions;
  79502. vertexData.normals = normals;
  79503. vertexData.uvs = uvs;
  79504. return vertexData;
  79505. };
  79506. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateIcoSphere = function (name, options, scene) {
  79507. return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
  79508. };
  79509. /**
  79510. * Class containing static functions to help procedurally build meshes
  79511. */
  79512. var IcoSphereBuilder = /** @class */ (function () {
  79513. function IcoSphereBuilder() {
  79514. }
  79515. /**
  79516. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  79517. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  79518. * * 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`)
  79519. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  79520. * * 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
  79521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79522. * * 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
  79523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79524. * @param name defines the name of the mesh
  79525. * @param options defines the options used to create the mesh
  79526. * @param scene defines the hosting scene
  79527. * @returns the icosahedron mesh
  79528. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  79529. */
  79530. IcoSphereBuilder.CreateIcoSphere = function (name, options, scene) {
  79531. if (scene === void 0) { scene = null; }
  79532. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  79533. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79534. sphere._originalBuilderSideOrientation = options.sideOrientation;
  79535. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere(options);
  79536. vertexData.applyToMesh(sphere, options.updatable);
  79537. return sphere;
  79538. };
  79539. return IcoSphereBuilder;
  79540. }());
  79541. /***/ }),
  79542. /***/ "./Meshes/Builders/index.ts":
  79543. /*!**********************************!*\
  79544. !*** ./Meshes/Builders/index.ts ***!
  79545. \**********************************/
  79546. /*! exports provided: BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  79547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79548. "use strict";
  79549. __webpack_require__.r(__webpack_exports__);
  79550. /* harmony import */ var _boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  79551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  79552. /* harmony import */ var _discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./discBuilder */ "./Meshes/Builders/discBuilder.ts");
  79553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"]; });
  79554. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  79555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"]; });
  79556. /* harmony import */ var _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  79557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"]; });
  79558. /* harmony import */ var _hemisphereBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphereBuilder */ "./Meshes/Builders/hemisphereBuilder.ts");
  79559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _hemisphereBuilder__WEBPACK_IMPORTED_MODULE_4__["HemisphereBuilder"]; });
  79560. /* harmony import */ var _cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  79561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _cylinderBuilder__WEBPACK_IMPORTED_MODULE_5__["CylinderBuilder"]; });
  79562. /* harmony import */ var _torusBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  79563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _torusBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusBuilder"]; });
  79564. /* harmony import */ var _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  79565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_7__["TorusKnotBuilder"]; });
  79566. /* harmony import */ var _linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  79567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _linesBuilder__WEBPACK_IMPORTED_MODULE_8__["LinesBuilder"]; });
  79568. /* harmony import */ var _polygonBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  79569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _polygonBuilder__WEBPACK_IMPORTED_MODULE_9__["PolygonBuilder"]; });
  79570. /* harmony import */ var _shapeBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  79571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _shapeBuilder__WEBPACK_IMPORTED_MODULE_10__["ShapeBuilder"]; });
  79572. /* harmony import */ var _latheBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  79573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _latheBuilder__WEBPACK_IMPORTED_MODULE_11__["LatheBuilder"]; });
  79574. /* harmony import */ var _planeBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  79575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _planeBuilder__WEBPACK_IMPORTED_MODULE_12__["PlaneBuilder"]; });
  79576. /* harmony import */ var _groundBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  79577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _groundBuilder__WEBPACK_IMPORTED_MODULE_13__["GroundBuilder"]; });
  79578. /* harmony import */ var _tubeBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  79579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _tubeBuilder__WEBPACK_IMPORTED_MODULE_14__["TubeBuilder"]; });
  79580. /* harmony import */ var _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  79581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_15__["PolyhedronBuilder"]; });
  79582. /* harmony import */ var _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  79583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_16__["IcoSphereBuilder"]; });
  79584. /* harmony import */ var _decalBuilder__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  79585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _decalBuilder__WEBPACK_IMPORTED_MODULE_17__["DecalBuilder"]; });
  79586. /***/ }),
  79587. /***/ "./Meshes/Builders/latheBuilder.ts":
  79588. /*!*****************************************!*\
  79589. !*** ./Meshes/Builders/latheBuilder.ts ***!
  79590. \*****************************************/
  79591. /*! exports provided: LatheBuilder */
  79592. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79593. "use strict";
  79594. __webpack_require__.r(__webpack_exports__);
  79595. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return LatheBuilder; });
  79596. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79597. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79598. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  79599. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  79600. var options = {
  79601. shape: shape,
  79602. radius: radius,
  79603. tessellation: tessellation,
  79604. sideOrientation: sideOrientation,
  79605. updatable: updatable
  79606. };
  79607. return LatheBuilder.CreateLathe(name, options, scene);
  79608. };
  79609. /**
  79610. * Class containing static functions to help procedurally build meshes
  79611. */
  79612. var LatheBuilder = /** @class */ (function () {
  79613. function LatheBuilder() {
  79614. }
  79615. /**
  79616. * Creates lathe mesh.
  79617. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  79618. * * 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
  79619. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  79620. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  79621. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  79622. * * 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
  79623. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  79624. * * 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
  79625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  79626. * * 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
  79627. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  79628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79629. * @param name defines the name of the mesh
  79630. * @param options defines the options used to create the mesh
  79631. * @param scene defines the hosting scene
  79632. * @returns the lathe mesh
  79633. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  79634. */
  79635. LatheBuilder.CreateLathe = function (name, options, scene) {
  79636. if (scene === void 0) { scene = null; }
  79637. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  79638. var closed = (options.closed === undefined) ? true : options.closed;
  79639. var shape = options.shape;
  79640. var radius = options.radius || 1;
  79641. var tessellation = options.tessellation || 64;
  79642. var clip = options.clip || 0;
  79643. var updatable = options.updatable;
  79644. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  79645. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  79646. var pi2 = Math.PI * 2;
  79647. var paths = new Array();
  79648. var invertUV = options.invertUV || false;
  79649. var i = 0;
  79650. var p = 0;
  79651. var step = pi2 / tessellation * arc;
  79652. var rotated;
  79653. var path = new Array();
  79654. for (i = 0; i <= tessellation - clip; i++) {
  79655. var path = [];
  79656. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  79657. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[0].y, 0));
  79658. 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));
  79659. }
  79660. for (p = 0; p < shape.length; p++) {
  79661. 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);
  79662. path.push(rotated);
  79663. }
  79664. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  79665. 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));
  79666. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[shape.length - 1].y, 0));
  79667. }
  79668. paths.push(path);
  79669. }
  79670. // lathe ribbon
  79671. 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);
  79672. return lathe;
  79673. };
  79674. return LatheBuilder;
  79675. }());
  79676. /***/ }),
  79677. /***/ "./Meshes/Builders/linesBuilder.ts":
  79678. /*!*****************************************!*\
  79679. !*** ./Meshes/Builders/linesBuilder.ts ***!
  79680. \*****************************************/
  79681. /*! exports provided: LinesBuilder */
  79682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79683. "use strict";
  79684. __webpack_require__.r(__webpack_exports__);
  79685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return LinesBuilder; });
  79686. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  79687. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79688. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79689. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  79690. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  79691. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem = function (options) {
  79692. var indices = [];
  79693. var positions = [];
  79694. var lines = options.lines;
  79695. var colors = options.colors;
  79696. var vertexColors = [];
  79697. var idx = 0;
  79698. for (var l = 0; l < lines.length; l++) {
  79699. var points = lines[l];
  79700. for (var index = 0; index < points.length; index++) {
  79701. positions.push(points[index].x, points[index].y, points[index].z);
  79702. if (colors) {
  79703. var color = colors[l];
  79704. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  79705. }
  79706. if (index > 0) {
  79707. indices.push(idx - 1);
  79708. indices.push(idx);
  79709. }
  79710. idx++;
  79711. }
  79712. }
  79713. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79714. vertexData.indices = indices;
  79715. vertexData.positions = positions;
  79716. if (colors) {
  79717. vertexData.colors = vertexColors;
  79718. }
  79719. return vertexData;
  79720. };
  79721. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines = function (options) {
  79722. var dashSize = options.dashSize || 3;
  79723. var gapSize = options.gapSize || 1;
  79724. var dashNb = options.dashNb || 200;
  79725. var points = options.points;
  79726. var positions = new Array();
  79727. var indices = new Array();
  79728. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79729. var lg = 0;
  79730. var nb = 0;
  79731. var shft = 0;
  79732. var dashshft = 0;
  79733. var curshft = 0;
  79734. var idx = 0;
  79735. var i = 0;
  79736. for (i = 0; i < points.length - 1; i++) {
  79737. points[i + 1].subtractToRef(points[i], curvect);
  79738. lg += curvect.length();
  79739. }
  79740. shft = lg / dashNb;
  79741. dashshft = dashSize * shft / (dashSize + gapSize);
  79742. for (i = 0; i < points.length - 1; i++) {
  79743. points[i + 1].subtractToRef(points[i], curvect);
  79744. nb = Math.floor(curvect.length() / shft);
  79745. curvect.normalize();
  79746. for (var j = 0; j < nb; j++) {
  79747. curshft = shft * j;
  79748. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  79749. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  79750. indices.push(idx, idx + 1);
  79751. idx += 2;
  79752. }
  79753. }
  79754. // Result
  79755. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  79756. vertexData.positions = positions;
  79757. vertexData.indices = indices;
  79758. return vertexData;
  79759. };
  79760. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  79761. if (scene === void 0) { scene = null; }
  79762. if (updatable === void 0) { updatable = false; }
  79763. if (instance === void 0) { instance = null; }
  79764. var options = {
  79765. points: points,
  79766. updatable: updatable,
  79767. instance: instance
  79768. };
  79769. return LinesBuilder.CreateLines(name, options, scene);
  79770. };
  79771. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  79772. if (scene === void 0) { scene = null; }
  79773. var options = {
  79774. points: points,
  79775. dashSize: dashSize,
  79776. gapSize: gapSize,
  79777. dashNb: dashNb,
  79778. updatable: updatable,
  79779. instance: instance
  79780. };
  79781. return LinesBuilder.CreateDashedLines(name, options, scene);
  79782. };
  79783. /**
  79784. * Class containing static functions to help procedurally build meshes
  79785. */
  79786. var LinesBuilder = /** @class */ (function () {
  79787. function LinesBuilder() {
  79788. }
  79789. /**
  79790. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  79791. * * 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
  79792. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  79793. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  79794. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  79795. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  79796. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  79797. * * 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
  79798. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  79799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79800. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  79801. * @param name defines the name of the new line system
  79802. * @param options defines the options used to create the line system
  79803. * @param scene defines the hosting scene
  79804. * @returns a new line system mesh
  79805. */
  79806. LinesBuilder.CreateLineSystem = function (name, options, scene) {
  79807. var instance = options.instance;
  79808. var lines = options.lines;
  79809. var colors = options.colors;
  79810. if (instance) { // lines update
  79811. var positions = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  79812. var vertexColor;
  79813. var lineColors;
  79814. if (colors) {
  79815. vertexColor = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  79816. }
  79817. var i = 0;
  79818. var c = 0;
  79819. for (var l = 0; l < lines.length; l++) {
  79820. var points = lines[l];
  79821. for (var p = 0; p < points.length; p++) {
  79822. positions[i] = points[p].x;
  79823. positions[i + 1] = points[p].y;
  79824. positions[i + 2] = points[p].z;
  79825. if (colors && vertexColor) {
  79826. lineColors = colors[l];
  79827. vertexColor[c] = lineColors[p].r;
  79828. vertexColor[c + 1] = lineColors[p].g;
  79829. vertexColor[c + 2] = lineColors[p].b;
  79830. vertexColor[c + 3] = lineColors[p].a;
  79831. c += 4;
  79832. }
  79833. i += 3;
  79834. }
  79835. }
  79836. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  79837. if (colors && vertexColor) {
  79838. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  79839. }
  79840. return instance;
  79841. }
  79842. // line system creation
  79843. var useVertexColor = (colors) ? true : false;
  79844. var lineSystem = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  79845. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem(options);
  79846. vertexData.applyToMesh(lineSystem, options.updatable);
  79847. return lineSystem;
  79848. };
  79849. /**
  79850. * Creates a line mesh
  79851. * 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
  79852. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  79853. * * The parameter `points` is an array successive Vector3
  79854. * * 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
  79855. * * The optional parameter `colors` is an array of successive Color4, one per line point
  79856. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  79857. * * When updating an instance, remember that only point positions can change, not the number of points
  79858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  79860. * @param name defines the name of the new line system
  79861. * @param options defines the options used to create the line system
  79862. * @param scene defines the hosting scene
  79863. * @returns a new line mesh
  79864. */
  79865. LinesBuilder.CreateLines = function (name, options, scene) {
  79866. if (scene === void 0) { scene = null; }
  79867. var colors = (options.colors) ? [options.colors] : null;
  79868. var lines = LinesBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  79869. return lines;
  79870. };
  79871. /**
  79872. * Creates a dashed line mesh
  79873. * * 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
  79874. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  79875. * * The parameter `points` is an array successive Vector3
  79876. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  79877. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  79878. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  79879. * * 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
  79880. * * When updating an instance, remember that only point positions can change, not the number of points
  79881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  79882. * @param name defines the name of the mesh
  79883. * @param options defines the options used to create the mesh
  79884. * @param scene defines the hosting scene
  79885. * @returns the dashed line mesh
  79886. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  79887. */
  79888. LinesBuilder.CreateDashedLines = function (name, options, scene) {
  79889. if (scene === void 0) { scene = null; }
  79890. var points = options.points;
  79891. var instance = options.instance;
  79892. var gapSize = options.gapSize || 1;
  79893. var dashSize = options.dashSize || 3;
  79894. if (instance) { // dashed lines update
  79895. var positionFunction = function (positions) {
  79896. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  79897. var nbSeg = positions.length / 6;
  79898. var lg = 0;
  79899. var nb = 0;
  79900. var shft = 0;
  79901. var dashshft = 0;
  79902. var curshft = 0;
  79903. var p = 0;
  79904. var i = 0;
  79905. var j = 0;
  79906. for (i = 0; i < points.length - 1; i++) {
  79907. points[i + 1].subtractToRef(points[i], curvect);
  79908. lg += curvect.length();
  79909. }
  79910. shft = lg / nbSeg;
  79911. var dashSize = instance._creationDataStorage.dashSize;
  79912. var gapSize = instance._creationDataStorage.gapSize;
  79913. dashshft = dashSize * shft / (dashSize + gapSize);
  79914. for (i = 0; i < points.length - 1; i++) {
  79915. points[i + 1].subtractToRef(points[i], curvect);
  79916. nb = Math.floor(curvect.length() / shft);
  79917. curvect.normalize();
  79918. j = 0;
  79919. while (j < nb && p < positions.length) {
  79920. curshft = shft * j;
  79921. positions[p] = points[i].x + curshft * curvect.x;
  79922. positions[p + 1] = points[i].y + curshft * curvect.y;
  79923. positions[p + 2] = points[i].z + curshft * curvect.z;
  79924. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  79925. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  79926. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  79927. p += 6;
  79928. j++;
  79929. }
  79930. }
  79931. while (p < positions.length) {
  79932. positions[p] = points[i].x;
  79933. positions[p + 1] = points[i].y;
  79934. positions[p + 2] = points[i].z;
  79935. p += 3;
  79936. }
  79937. };
  79938. instance.updateMeshPositions(positionFunction, false);
  79939. return instance;
  79940. }
  79941. // dashed lines creation
  79942. var dashedLines = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene);
  79943. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines(options);
  79944. vertexData.applyToMesh(dashedLines, options.updatable);
  79945. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  79946. dashedLines._creationDataStorage.dashSize = dashSize;
  79947. dashedLines._creationDataStorage.gapSize = gapSize;
  79948. return dashedLines;
  79949. };
  79950. return LinesBuilder;
  79951. }());
  79952. /***/ }),
  79953. /***/ "./Meshes/Builders/planeBuilder.ts":
  79954. /*!*****************************************!*\
  79955. !*** ./Meshes/Builders/planeBuilder.ts ***!
  79956. \*****************************************/
  79957. /*! exports provided: PlaneBuilder */
  79958. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  79959. "use strict";
  79960. __webpack_require__.r(__webpack_exports__);
  79961. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return PlaneBuilder; });
  79962. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  79963. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  79964. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane = function (options) {
  79965. var indices = [];
  79966. var positions = [];
  79967. var normals = [];
  79968. var uvs = [];
  79969. var width = options.width || options.size || 1;
  79970. var height = options.height || options.size || 1;
  79971. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  79972. // Vertices
  79973. var halfWidth = width / 2.0;
  79974. var halfHeight = height / 2.0;
  79975. positions.push(-halfWidth, -halfHeight, 0);
  79976. normals.push(0, 0, -1.0);
  79977. uvs.push(0.0, 0.0);
  79978. positions.push(halfWidth, -halfHeight, 0);
  79979. normals.push(0, 0, -1.0);
  79980. uvs.push(1.0, 0.0);
  79981. positions.push(halfWidth, halfHeight, 0);
  79982. normals.push(0, 0, -1.0);
  79983. uvs.push(1.0, 1.0);
  79984. positions.push(-halfWidth, halfHeight, 0);
  79985. normals.push(0, 0, -1.0);
  79986. uvs.push(0.0, 1.0);
  79987. // Indices
  79988. indices.push(0);
  79989. indices.push(1);
  79990. indices.push(2);
  79991. indices.push(0);
  79992. indices.push(2);
  79993. indices.push(3);
  79994. // Sides
  79995. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  79996. // Result
  79997. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  79998. vertexData.indices = indices;
  79999. vertexData.positions = positions;
  80000. vertexData.normals = normals;
  80001. vertexData.uvs = uvs;
  80002. return vertexData;
  80003. };
  80004. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  80005. var options = {
  80006. size: size,
  80007. width: size,
  80008. height: size,
  80009. sideOrientation: sideOrientation,
  80010. updatable: updatable
  80011. };
  80012. return PlaneBuilder.CreatePlane(name, options, scene);
  80013. };
  80014. /**
  80015. * Class containing static functions to help procedurally build meshes
  80016. */
  80017. var PlaneBuilder = /** @class */ (function () {
  80018. function PlaneBuilder() {
  80019. }
  80020. /**
  80021. * Creates a plane mesh
  80022. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  80023. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  80024. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  80025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80026. * * 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
  80027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80028. * @param name defines the name of the mesh
  80029. * @param options defines the options used to create the mesh
  80030. * @param scene defines the hosting scene
  80031. * @returns the plane mesh
  80032. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  80033. */
  80034. PlaneBuilder.CreatePlane = function (name, options, scene) {
  80035. if (scene === void 0) { scene = null; }
  80036. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  80037. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80038. plane._originalBuilderSideOrientation = options.sideOrientation;
  80039. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane(options);
  80040. vertexData.applyToMesh(plane, options.updatable);
  80041. if (options.sourcePlane) {
  80042. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  80043. plane.setDirection(options.sourcePlane.normal.scale(-1));
  80044. }
  80045. return plane;
  80046. };
  80047. return PlaneBuilder;
  80048. }());
  80049. /***/ }),
  80050. /***/ "./Meshes/Builders/polygonBuilder.ts":
  80051. /*!*******************************************!*\
  80052. !*** ./Meshes/Builders/polygonBuilder.ts ***!
  80053. \*******************************************/
  80054. /*! exports provided: PolygonBuilder */
  80055. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80056. "use strict";
  80057. __webpack_require__.r(__webpack_exports__);
  80058. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return PolygonBuilder; });
  80059. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80060. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80061. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80062. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../polygonMesh */ "./Meshes/polygonMesh.ts");
  80063. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  80064. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  80065. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  80066. var faceUV = fUV || new Array(3);
  80067. var faceColors = fColors;
  80068. var colors = [];
  80069. // default face colors and UV if undefined
  80070. for (var f = 0; f < 3; f++) {
  80071. if (faceUV[f] === undefined) {
  80072. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  80073. }
  80074. if (faceColors && faceColors[f] === undefined) {
  80075. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  80076. }
  80077. }
  80078. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  80079. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  80080. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  80081. var indices = polygon.getIndices();
  80082. // set face colours and textures
  80083. var idx = 0;
  80084. var face = 0;
  80085. for (var index = 0; index < normals.length; index += 3) {
  80086. //Edge Face no. 1
  80087. if (Math.abs(normals[index + 1]) < 0.001) {
  80088. face = 1;
  80089. }
  80090. //Top Face no. 0
  80091. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  80092. face = 0;
  80093. }
  80094. //Bottom Face no. 2
  80095. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  80096. face = 2;
  80097. }
  80098. idx = index / 3;
  80099. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  80100. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  80101. if (faceColors) {
  80102. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  80103. }
  80104. }
  80105. // sides
  80106. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  80107. // Result
  80108. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  80109. vertexData.indices = indices;
  80110. vertexData.positions = positions;
  80111. vertexData.normals = normals;
  80112. vertexData.uvs = uvs;
  80113. if (faceColors) {
  80114. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  80115. vertexData.colors = totalColors;
  80116. }
  80117. return vertexData;
  80118. };
  80119. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  80120. if (earcutInjection === void 0) { earcutInjection = earcut; }
  80121. var options = {
  80122. shape: shape,
  80123. holes: holes,
  80124. updatable: updatable,
  80125. sideOrientation: sideOrientation
  80126. };
  80127. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  80128. };
  80129. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  80130. if (earcutInjection === void 0) { earcutInjection = earcut; }
  80131. var options = {
  80132. shape: shape,
  80133. holes: holes,
  80134. depth: depth,
  80135. updatable: updatable,
  80136. sideOrientation: sideOrientation
  80137. };
  80138. return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
  80139. };
  80140. /**
  80141. * Class containing static functions to help procedurally build meshes
  80142. */
  80143. var PolygonBuilder = /** @class */ (function () {
  80144. function PolygonBuilder() {
  80145. }
  80146. /**
  80147. * Creates a polygon mesh
  80148. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  80149. * * 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
  80150. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80152. * * 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)
  80153. * * Remember you can only change the shape positions, not their number when updating a polygon
  80154. * @param name defines the name of the mesh
  80155. * @param options defines the options used to create the mesh
  80156. * @param scene defines the hosting scene
  80157. * @param earcutInjection can be used to inject your own earcut reference
  80158. * @returns the polygon mesh
  80159. */
  80160. PolygonBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  80161. if (scene === void 0) { scene = null; }
  80162. if (earcutInjection === void 0) { earcutInjection = earcut; }
  80163. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80164. var shape = options.shape;
  80165. var holes = options.holes || [];
  80166. var depth = options.depth || 0;
  80167. var contours = [];
  80168. var hole = [];
  80169. for (var i = 0; i < shape.length; i++) {
  80170. contours[i] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](shape[i].x, shape[i].z);
  80171. }
  80172. var epsilon = 0.00000001;
  80173. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  80174. contours.pop();
  80175. }
  80176. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_3__["PolygonMeshBuilder"](name, contours, scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene, earcutInjection);
  80177. for (var hNb = 0; hNb < holes.length; hNb++) {
  80178. hole = [];
  80179. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  80180. hole.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  80181. }
  80182. polygonTriangulation.addHole(hole);
  80183. }
  80184. var polygon = polygonTriangulation.build(options.updatable, depth);
  80185. polygon._originalBuilderSideOrientation = options.sideOrientation;
  80186. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  80187. vertexData.applyToMesh(polygon, options.updatable);
  80188. return polygon;
  80189. };
  80190. /**
  80191. * Creates an extruded polygon mesh, with depth in the Y direction.
  80192. * * 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)
  80193. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  80194. * @param name defines the name of the mesh
  80195. * @param options defines the options used to create the mesh
  80196. * @param scene defines the hosting scene
  80197. * @param earcutInjection can be used to inject your own earcut reference
  80198. * @returns the polygon mesh
  80199. */
  80200. PolygonBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  80201. if (scene === void 0) { scene = null; }
  80202. if (earcutInjection === void 0) { earcutInjection = earcut; }
  80203. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  80204. };
  80205. return PolygonBuilder;
  80206. }());
  80207. /***/ }),
  80208. /***/ "./Meshes/Builders/polyhedronBuilder.ts":
  80209. /*!**********************************************!*\
  80210. !*** ./Meshes/Builders/polyhedronBuilder.ts ***!
  80211. \**********************************************/
  80212. /*! exports provided: PolyhedronBuilder */
  80213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80214. "use strict";
  80215. __webpack_require__.r(__webpack_exports__);
  80216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return PolyhedronBuilder; });
  80217. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80218. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80219. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80220. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron = function (options) {
  80221. // provided polyhedron types :
  80222. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  80223. // 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)
  80224. var polyhedra = [];
  80225. 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]] };
  80226. 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]] };
  80227. polyhedra[2] = {
  80228. 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]],
  80229. 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]]
  80230. };
  80231. polyhedra[3] = {
  80232. 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]],
  80233. 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]]
  80234. };
  80235. polyhedra[4] = {
  80236. 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]],
  80237. 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]]
  80238. };
  80239. 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]] };
  80240. 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]] };
  80241. 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]] };
  80242. 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]] };
  80243. 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]] };
  80244. 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]] };
  80245. 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]] };
  80246. 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]] };
  80247. 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]] };
  80248. polyhedra[14] = {
  80249. 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]],
  80250. 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]]
  80251. };
  80252. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  80253. var size = options.size;
  80254. var sizeX = options.sizeX || size || 1;
  80255. var sizeY = options.sizeY || size || 1;
  80256. var sizeZ = options.sizeZ || size || 1;
  80257. var data = options.custom || polyhedra[type];
  80258. var nbfaces = data.face.length;
  80259. var faceUV = options.faceUV || new Array(nbfaces);
  80260. var faceColors = options.faceColors;
  80261. var flat = (options.flat === undefined) ? true : options.flat;
  80262. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  80263. var positions = new Array();
  80264. var indices = new Array();
  80265. var normals = new Array();
  80266. var uvs = new Array();
  80267. var colors = new Array();
  80268. var index = 0;
  80269. var faceIdx = 0; // face cursor in the array "indexes"
  80270. var indexes = new Array();
  80271. var i = 0;
  80272. var f = 0;
  80273. var u, v, ang, x, y, tmp;
  80274. // default face colors and UV if undefined
  80275. if (flat) {
  80276. for (f = 0; f < nbfaces; f++) {
  80277. if (faceColors && faceColors[f] === undefined) {
  80278. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  80279. }
  80280. if (faceUV && faceUV[f] === undefined) {
  80281. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  80282. }
  80283. }
  80284. }
  80285. if (!flat) {
  80286. for (i = 0; i < data.vertex.length; i++) {
  80287. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  80288. uvs.push(0, 0);
  80289. }
  80290. for (f = 0; f < nbfaces; f++) {
  80291. for (i = 0; i < data.face[f].length - 2; i++) {
  80292. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  80293. }
  80294. }
  80295. }
  80296. else {
  80297. for (f = 0; f < nbfaces; f++) {
  80298. var fl = data.face[f].length; // number of vertices of the current face
  80299. ang = 2 * Math.PI / fl;
  80300. x = 0.5 * Math.tan(ang / 2);
  80301. y = 0.5;
  80302. // positions, uvs, colors
  80303. for (i = 0; i < fl; i++) {
  80304. // positions
  80305. 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);
  80306. indexes.push(index);
  80307. index++;
  80308. // uvs
  80309. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  80310. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  80311. uvs.push(u, v);
  80312. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  80313. y = x * Math.sin(ang) + y * Math.cos(ang);
  80314. x = tmp;
  80315. // colors
  80316. if (faceColors) {
  80317. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  80318. }
  80319. }
  80320. // indices from indexes
  80321. for (i = 0; i < fl - 2; i++) {
  80322. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  80323. }
  80324. faceIdx += fl;
  80325. }
  80326. }
  80327. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  80328. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  80329. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  80330. vertexData.positions = positions;
  80331. vertexData.indices = indices;
  80332. vertexData.normals = normals;
  80333. vertexData.uvs = uvs;
  80334. if (faceColors && flat) {
  80335. vertexData.colors = colors;
  80336. }
  80337. return vertexData;
  80338. };
  80339. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  80340. return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
  80341. };
  80342. /**
  80343. * Class containing static functions to help procedurally build meshes
  80344. */
  80345. var PolyhedronBuilder = /** @class */ (function () {
  80346. function PolyhedronBuilder() {
  80347. }
  80348. /**
  80349. * Creates a polyhedron mesh
  80350. * * 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
  80351. * * The parameter `size` (positive float, default 1) sets the polygon size
  80352. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  80353. * * 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`
  80354. * * 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
  80355. * * 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)`)
  80356. * * 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
  80357. * * 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
  80358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80359. * * 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
  80360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80361. * @param name defines the name of the mesh
  80362. * @param options defines the options used to create the mesh
  80363. * @param scene defines the hosting scene
  80364. * @returns the polyhedron mesh
  80365. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  80366. */
  80367. PolyhedronBuilder.CreatePolyhedron = function (name, options, scene) {
  80368. if (scene === void 0) { scene = null; }
  80369. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  80370. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80371. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  80372. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron(options);
  80373. vertexData.applyToMesh(polyhedron, options.updatable);
  80374. return polyhedron;
  80375. };
  80376. return PolyhedronBuilder;
  80377. }());
  80378. /***/ }),
  80379. /***/ "./Meshes/Builders/ribbonBuilder.ts":
  80380. /*!******************************************!*\
  80381. !*** ./Meshes/Builders/ribbonBuilder.ts ***!
  80382. \******************************************/
  80383. /*! exports provided: RibbonBuilder */
  80384. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80385. "use strict";
  80386. __webpack_require__.r(__webpack_exports__);
  80387. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return RibbonBuilder; });
  80388. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80389. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80390. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  80391. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80392. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  80393. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon = function (options) {
  80394. var pathArray = options.pathArray;
  80395. var closeArray = options.closeArray || false;
  80396. var closePath = options.closePath || false;
  80397. var invertUV = options.invertUV || false;
  80398. var defaultOffset = Math.floor(pathArray[0].length / 2);
  80399. var offset = options.offset || defaultOffset;
  80400. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  80401. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  80402. var customUV = options.uvs;
  80403. var customColors = options.colors;
  80404. var positions = [];
  80405. var indices = [];
  80406. var normals = [];
  80407. var uvs = [];
  80408. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  80409. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  80410. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  80411. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  80412. var minlg; // minimal length among all paths from pathArray
  80413. var lg = []; // array of path lengths : nb of vertex per path
  80414. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  80415. var p; // path iterator
  80416. var i; // point iterator
  80417. var j; // point iterator
  80418. // if single path in pathArray
  80419. if (pathArray.length < 2) {
  80420. var ar1 = [];
  80421. var ar2 = [];
  80422. for (i = 0; i < pathArray[0].length - offset; i++) {
  80423. ar1.push(pathArray[0][i]);
  80424. ar2.push(pathArray[0][i + offset]);
  80425. }
  80426. pathArray = [ar1, ar2];
  80427. }
  80428. // positions and horizontal distances (u)
  80429. var idc = 0;
  80430. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  80431. var path;
  80432. var l;
  80433. minlg = pathArray[0].length;
  80434. var vectlg;
  80435. var dist;
  80436. for (p = 0; p < pathArray.length; p++) {
  80437. uTotalDistance[p] = 0;
  80438. us[p] = [0];
  80439. path = pathArray[p];
  80440. l = path.length;
  80441. minlg = (minlg < l) ? minlg : l;
  80442. j = 0;
  80443. while (j < l) {
  80444. positions.push(path[j].x, path[j].y, path[j].z);
  80445. if (j > 0) {
  80446. vectlg = path[j].subtract(path[j - 1]).length();
  80447. dist = vectlg + uTotalDistance[p];
  80448. us[p].push(dist);
  80449. uTotalDistance[p] = dist;
  80450. }
  80451. j++;
  80452. }
  80453. if (closePath) { // an extra hidden vertex is added in the "positions" array
  80454. j--;
  80455. positions.push(path[0].x, path[0].y, path[0].z);
  80456. vectlg = path[j].subtract(path[0]).length();
  80457. dist = vectlg + uTotalDistance[p];
  80458. us[p].push(dist);
  80459. uTotalDistance[p] = dist;
  80460. }
  80461. lg[p] = l + closePathCorr;
  80462. idx[p] = idc;
  80463. idc += (l + closePathCorr);
  80464. }
  80465. // vertical distances (v)
  80466. var path1;
  80467. var path2;
  80468. var vertex1 = null;
  80469. var vertex2 = null;
  80470. for (i = 0; i < minlg + closePathCorr; i++) {
  80471. vTotalDistance[i] = 0;
  80472. vs[i] = [0];
  80473. for (p = 0; p < pathArray.length - 1; p++) {
  80474. path1 = pathArray[p];
  80475. path2 = pathArray[p + 1];
  80476. if (i === minlg) { // closePath
  80477. vertex1 = path1[0];
  80478. vertex2 = path2[0];
  80479. }
  80480. else {
  80481. vertex1 = path1[i];
  80482. vertex2 = path2[i];
  80483. }
  80484. vectlg = vertex2.subtract(vertex1).length();
  80485. dist = vectlg + vTotalDistance[i];
  80486. vs[i].push(dist);
  80487. vTotalDistance[i] = dist;
  80488. }
  80489. if (closeArray && vertex2 && vertex1) {
  80490. path1 = pathArray[p];
  80491. path2 = pathArray[0];
  80492. if (i === minlg) { // closePath
  80493. vertex2 = path2[0];
  80494. }
  80495. vectlg = vertex2.subtract(vertex1).length();
  80496. dist = vectlg + vTotalDistance[i];
  80497. vTotalDistance[i] = dist;
  80498. }
  80499. }
  80500. // uvs
  80501. var u;
  80502. var v;
  80503. if (customUV) {
  80504. for (p = 0; p < customUV.length; p++) {
  80505. uvs.push(customUV[p].x, customUV[p].y);
  80506. }
  80507. }
  80508. else {
  80509. for (p = 0; p < pathArray.length; p++) {
  80510. for (i = 0; i < minlg + closePathCorr; i++) {
  80511. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  80512. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  80513. if (invertUV) {
  80514. uvs.push(v, u);
  80515. }
  80516. else {
  80517. uvs.push(u, v);
  80518. }
  80519. }
  80520. }
  80521. }
  80522. // indices
  80523. p = 0; // path index
  80524. var pi = 0; // positions array index
  80525. var l1 = lg[p] - 1; // path1 length
  80526. var l2 = lg[p + 1] - 1; // path2 length
  80527. var min = (l1 < l2) ? l1 : l2; // current path stop index
  80528. var shft = idx[1] - idx[0]; // shift
  80529. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  80530. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  80531. // 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
  80532. indices.push(pi, pi + shft, pi + 1);
  80533. indices.push(pi + shft + 1, pi + 1, pi + shft);
  80534. pi += 1;
  80535. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  80536. p++;
  80537. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  80538. shft = idx[0] - idx[p];
  80539. l1 = lg[p] - 1;
  80540. l2 = lg[0] - 1;
  80541. }
  80542. else {
  80543. shft = idx[p + 1] - idx[p];
  80544. l1 = lg[p] - 1;
  80545. l2 = lg[p + 1] - 1;
  80546. }
  80547. pi = idx[p];
  80548. min = (l1 < l2) ? l1 + pi : l2 + pi;
  80549. }
  80550. }
  80551. // normals
  80552. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals);
  80553. if (closePath) { // update both the first and last vertex normals to their average value
  80554. var indexFirst = 0;
  80555. var indexLast = 0;
  80556. for (p = 0; p < pathArray.length; p++) {
  80557. indexFirst = idx[p] * 3;
  80558. if (p + 1 < pathArray.length) {
  80559. indexLast = (idx[p + 1] - 1) * 3;
  80560. }
  80561. else {
  80562. indexLast = normals.length - 3;
  80563. }
  80564. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  80565. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  80566. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  80567. normals[indexLast] = normals[indexFirst];
  80568. normals[indexLast + 1] = normals[indexFirst + 1];
  80569. normals[indexLast + 2] = normals[indexFirst + 2];
  80570. }
  80571. }
  80572. // sides
  80573. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  80574. // Colors
  80575. var colors = null;
  80576. if (customColors) {
  80577. colors = new Float32Array(customColors.length * 4);
  80578. for (var c = 0; c < customColors.length; c++) {
  80579. colors[c * 4] = customColors[c].r;
  80580. colors[c * 4 + 1] = customColors[c].g;
  80581. colors[c * 4 + 2] = customColors[c].b;
  80582. colors[c * 4 + 3] = customColors[c].a;
  80583. }
  80584. }
  80585. // Result
  80586. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  80587. var positions32 = new Float32Array(positions);
  80588. var normals32 = new Float32Array(normals);
  80589. var uvs32 = new Float32Array(uvs);
  80590. vertexData.indices = indices;
  80591. vertexData.positions = positions32;
  80592. vertexData.normals = normals32;
  80593. vertexData.uvs = uvs32;
  80594. if (colors) {
  80595. vertexData.set(colors, _buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  80596. }
  80597. if (closePath) {
  80598. vertexData._idx = idx;
  80599. }
  80600. return vertexData;
  80601. };
  80602. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  80603. if (closeArray === void 0) { closeArray = false; }
  80604. if (updatable === void 0) { updatable = false; }
  80605. return RibbonBuilder.CreateRibbon(name, {
  80606. pathArray: pathArray,
  80607. closeArray: closeArray,
  80608. closePath: closePath,
  80609. offset: offset,
  80610. updatable: updatable,
  80611. sideOrientation: sideOrientation,
  80612. instance: instance
  80613. }, scene);
  80614. };
  80615. /**
  80616. * Class containing static functions to help procedurally build meshes
  80617. */
  80618. var RibbonBuilder = /** @class */ (function () {
  80619. function RibbonBuilder() {
  80620. }
  80621. /**
  80622. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  80623. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  80624. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  80625. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  80626. * * 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
  80627. * * 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
  80628. * * 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
  80629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80630. * * 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
  80631. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  80632. * * 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
  80633. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  80634. * * 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
  80635. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  80636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80637. * @param name defines the name of the mesh
  80638. * @param options defines the options used to create the mesh
  80639. * @param scene defines the hosting scene
  80640. * @returns the ribbon mesh
  80641. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  80642. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  80643. */
  80644. RibbonBuilder.CreateRibbon = function (name, options, scene) {
  80645. if (scene === void 0) { scene = null; }
  80646. var pathArray = options.pathArray;
  80647. var closeArray = options.closeArray;
  80648. var closePath = options.closePath;
  80649. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80650. var instance = options.instance;
  80651. var updatable = options.updatable;
  80652. if (instance) { // existing ribbon instance update
  80653. // positionFunction : ribbon case
  80654. // only pathArray and sideOrientation parameters are taken into account for positions update
  80655. var minimum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0].setAll(Number.MAX_VALUE);
  80656. var maximum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1].setAll(-Number.MAX_VALUE);
  80657. var positionFunction = function (positions) {
  80658. var minlg = pathArray[0].length;
  80659. var mesh = instance;
  80660. var i = 0;
  80661. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DOUBLESIDE) ? 2 : 1;
  80662. for (var si = 1; si <= ns; ++si) {
  80663. for (var p = 0; p < pathArray.length; ++p) {
  80664. var path = pathArray[p];
  80665. var l = path.length;
  80666. minlg = (minlg < l) ? minlg : l;
  80667. for (var j = 0; j < minlg; ++j) {
  80668. var pathPoint = path[j];
  80669. positions[i] = pathPoint.x;
  80670. positions[i + 1] = pathPoint.y;
  80671. positions[i + 2] = pathPoint.z;
  80672. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  80673. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  80674. i += 3;
  80675. }
  80676. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  80677. var pathPoint = path[0];
  80678. positions[i] = pathPoint.x;
  80679. positions[i + 1] = pathPoint.y;
  80680. positions[i + 2] = pathPoint.z;
  80681. i += 3;
  80682. }
  80683. }
  80684. }
  80685. };
  80686. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  80687. positionFunction(positions);
  80688. if (instance._boundingInfo) {
  80689. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  80690. }
  80691. else {
  80692. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  80693. }
  80694. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positions, false, false);
  80695. if (options.colors) {
  80696. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  80697. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  80698. var color = options.colors[c];
  80699. colors[colorIndex] = color.r;
  80700. colors[colorIndex + 1] = color.g;
  80701. colors[colorIndex + 2] = color.b;
  80702. colors[colorIndex + 3] = color.a;
  80703. }
  80704. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colors, false, false);
  80705. }
  80706. if (options.uvs) {
  80707. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  80708. for (var i = 0; i < options.uvs.length; i++) {
  80709. uvs[i * 2] = options.uvs[i].x;
  80710. uvs[i * 2 + 1] = options.uvs[i].y;
  80711. }
  80712. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvs, false, false);
  80713. }
  80714. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  80715. var indices = instance.getIndices();
  80716. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  80717. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  80718. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals, params);
  80719. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  80720. var indexFirst = 0;
  80721. var indexLast = 0;
  80722. for (var p = 0; p < pathArray.length; p++) {
  80723. indexFirst = instance._creationDataStorage.idx[p] * 3;
  80724. if (p + 1 < pathArray.length) {
  80725. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  80726. }
  80727. else {
  80728. indexLast = normals.length - 3;
  80729. }
  80730. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  80731. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  80732. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  80733. normals[indexLast] = normals[indexFirst];
  80734. normals[indexLast + 1] = normals[indexFirst + 1];
  80735. normals[indexLast + 2] = normals[indexFirst + 2];
  80736. }
  80737. }
  80738. if (!(instance.areNormalsFrozen)) {
  80739. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normals, false, false);
  80740. }
  80741. }
  80742. return instance;
  80743. }
  80744. else { // new ribbon creation
  80745. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  80746. ribbon._originalBuilderSideOrientation = sideOrientation;
  80747. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  80748. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon(options);
  80749. if (closePath) {
  80750. ribbon._creationDataStorage.idx = vertexData._idx;
  80751. }
  80752. ribbon._creationDataStorage.closePath = closePath;
  80753. ribbon._creationDataStorage.closeArray = closeArray;
  80754. vertexData.applyToMesh(ribbon, updatable);
  80755. return ribbon;
  80756. }
  80757. };
  80758. return RibbonBuilder;
  80759. }());
  80760. /***/ }),
  80761. /***/ "./Meshes/Builders/shapeBuilder.ts":
  80762. /*!*****************************************!*\
  80763. !*** ./Meshes/Builders/shapeBuilder.ts ***!
  80764. \*****************************************/
  80765. /*! exports provided: ShapeBuilder */
  80766. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80767. "use strict";
  80768. __webpack_require__.r(__webpack_exports__);
  80769. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return ShapeBuilder; });
  80770. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80771. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80772. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  80773. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  80774. if (scene === void 0) { scene = null; }
  80775. var options = {
  80776. shape: shape,
  80777. path: path,
  80778. scale: scale,
  80779. rotation: rotation,
  80780. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  80781. sideOrientation: sideOrientation,
  80782. instance: instance,
  80783. updatable: updatable
  80784. };
  80785. return ShapeBuilder.ExtrudeShape(name, options, scene);
  80786. };
  80787. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  80788. var options = {
  80789. shape: shape,
  80790. path: path,
  80791. scaleFunction: scaleFunction,
  80792. rotationFunction: rotationFunction,
  80793. ribbonCloseArray: ribbonCloseArray,
  80794. ribbonClosePath: ribbonClosePath,
  80795. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  80796. sideOrientation: sideOrientation,
  80797. instance: instance,
  80798. updatable: updatable
  80799. };
  80800. return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
  80801. };
  80802. /**
  80803. * Class containing static functions to help procedurally build meshes
  80804. */
  80805. var ShapeBuilder = /** @class */ (function () {
  80806. function ShapeBuilder() {
  80807. }
  80808. /**
  80809. * 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.
  80810. * * 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.
  80811. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  80812. * * 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.
  80813. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  80814. * * 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
  80815. * * 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
  80816. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  80817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80818. * * 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
  80819. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  80820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80821. * @param name defines the name of the mesh
  80822. * @param options defines the options used to create the mesh
  80823. * @param scene defines the hosting scene
  80824. * @returns the extruded shape mesh
  80825. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  80826. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80827. */
  80828. ShapeBuilder.ExtrudeShape = function (name, options, scene) {
  80829. if (scene === void 0) { scene = null; }
  80830. var path = options.path;
  80831. var shape = options.shape;
  80832. var scale = options.scale || 1;
  80833. var rotation = options.rotation || 0;
  80834. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  80835. var updatable = options.updatable;
  80836. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80837. var instance = options.instance || null;
  80838. var invertUV = options.invertUV || false;
  80839. 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);
  80840. };
  80841. /**
  80842. * Creates an custom extruded shape mesh.
  80843. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  80844. * * 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.
  80845. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  80846. * * 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
  80847. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  80848. * * 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
  80849. * * It must returns a float value that will be the scale value applied to the shape on each path point
  80850. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  80851. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  80852. * * 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
  80853. * * 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
  80854. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  80855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  80856. * * 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
  80857. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  80858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80859. * @param name defines the name of the mesh
  80860. * @param options defines the options used to create the mesh
  80861. * @param scene defines the hosting scene
  80862. * @returns the custom extruded shape mesh
  80863. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  80864. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  80865. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80866. */
  80867. ShapeBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  80868. if (scene === void 0) { scene = null; }
  80869. var path = options.path;
  80870. var shape = options.shape;
  80871. var scaleFunction = options.scaleFunction || (function () { return 1; });
  80872. var rotationFunction = options.rotationFunction || (function () { return 0; });
  80873. var ribbonCloseArray = options.ribbonCloseArray || false;
  80874. var ribbonClosePath = options.ribbonClosePath || false;
  80875. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  80876. var updatable = options.updatable;
  80877. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  80878. var instance = options.instance;
  80879. var invertUV = options.invertUV || false;
  80880. 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);
  80881. };
  80882. ShapeBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  80883. // extrusion geometry
  80884. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  80885. var tangents = path3D.getTangents();
  80886. var normals = path3D.getNormals();
  80887. var binormals = path3D.getBinormals();
  80888. var distances = path3D.getDistances();
  80889. var angle = 0;
  80890. var returnScale = function () { return scale !== null ? scale : 1; };
  80891. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  80892. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  80893. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  80894. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  80895. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  80896. for (var i = 0; i < curve.length; i++) {
  80897. var shapePath = new Array();
  80898. var angleStep = rotate(i, distances[i]);
  80899. var scaleRatio = scl(i, distances[i]);
  80900. for (var p = 0; p < shape.length; p++) {
  80901. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  80902. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  80903. var rotated = shapePath[p] ? shapePath[p] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  80904. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  80905. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  80906. shapePath[p] = rotated;
  80907. }
  80908. shapePaths[index] = shapePath;
  80909. angle += angleStep;
  80910. index++;
  80911. }
  80912. // cap
  80913. var capPath = function (shapePath) {
  80914. var pointCap = Array();
  80915. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  80916. var i;
  80917. for (i = 0; i < shapePath.length; i++) {
  80918. barycenter.addInPlace(shapePath[i]);
  80919. }
  80920. barycenter.scaleInPlace(1.0 / shapePath.length);
  80921. for (i = 0; i < shapePath.length; i++) {
  80922. pointCap.push(barycenter);
  80923. }
  80924. return pointCap;
  80925. };
  80926. switch (cap) {
  80927. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  80928. break;
  80929. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  80930. shapePaths[0] = capPath(shapePaths[2]);
  80931. shapePaths[1] = shapePaths[2];
  80932. break;
  80933. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  80934. shapePaths[index] = shapePaths[index - 1];
  80935. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  80936. break;
  80937. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  80938. shapePaths[0] = capPath(shapePaths[2]);
  80939. shapePaths[1] = shapePaths[2];
  80940. shapePaths[index] = shapePaths[index - 1];
  80941. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  80942. break;
  80943. default:
  80944. break;
  80945. }
  80946. return shapePaths;
  80947. };
  80948. var path3D;
  80949. var pathArray;
  80950. if (instance) { // instance update
  80951. var storage = instance._creationDataStorage;
  80952. path3D = storage.path3D.update(curve);
  80953. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  80954. instance = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  80955. return instance;
  80956. }
  80957. // extruded shape creation
  80958. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](curve);
  80959. var newShapePaths = new Array();
  80960. cap = (cap < 0 || cap > 3) ? 0 : cap;
  80961. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  80962. 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);
  80963. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  80964. extrudedGeneric._creationDataStorage.path3D = path3D;
  80965. extrudedGeneric._creationDataStorage.cap = cap;
  80966. return extrudedGeneric;
  80967. };
  80968. return ShapeBuilder;
  80969. }());
  80970. /***/ }),
  80971. /***/ "./Meshes/Builders/sphereBuilder.ts":
  80972. /*!******************************************!*\
  80973. !*** ./Meshes/Builders/sphereBuilder.ts ***!
  80974. \******************************************/
  80975. /*! exports provided: SphereBuilder */
  80976. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80977. "use strict";
  80978. __webpack_require__.r(__webpack_exports__);
  80979. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return SphereBuilder; });
  80980. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  80981. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  80982. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  80983. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere = function (options) {
  80984. var segments = options.segments || 32;
  80985. var diameterX = options.diameterX || options.diameter || 1;
  80986. var diameterY = options.diameterY || options.diameter || 1;
  80987. var diameterZ = options.diameterZ || options.diameter || 1;
  80988. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  80989. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  80990. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  80991. var radius = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  80992. var totalZRotationSteps = 2 + segments;
  80993. var totalYRotationSteps = 2 * totalZRotationSteps;
  80994. var indices = [];
  80995. var positions = [];
  80996. var normals = [];
  80997. var uvs = [];
  80998. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  80999. var normalizedZ = zRotationStep / totalZRotationSteps;
  81000. var angleZ = normalizedZ * Math.PI * slice;
  81001. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  81002. var normalizedY = yRotationStep / totalYRotationSteps;
  81003. var angleY = normalizedY * Math.PI * 2 * arc;
  81004. var rotationZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  81005. var rotationY = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  81006. var afterRotZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  81007. var complete = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  81008. var vertex = complete.multiply(radius);
  81009. var normal = complete.divide(radius).normalize();
  81010. positions.push(vertex.x, vertex.y, vertex.z);
  81011. normals.push(normal.x, normal.y, normal.z);
  81012. uvs.push(normalizedY, normalizedZ);
  81013. }
  81014. if (zRotationStep > 0) {
  81015. var verticesCount = positions.length / 3;
  81016. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  81017. indices.push((firstIndex));
  81018. indices.push((firstIndex + 1));
  81019. indices.push(firstIndex + totalYRotationSteps + 1);
  81020. indices.push((firstIndex + totalYRotationSteps + 1));
  81021. indices.push((firstIndex + 1));
  81022. indices.push((firstIndex + totalYRotationSteps + 2));
  81023. }
  81024. }
  81025. }
  81026. // Sides
  81027. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  81028. // Result
  81029. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  81030. vertexData.indices = indices;
  81031. vertexData.positions = positions;
  81032. vertexData.normals = normals;
  81033. vertexData.uvs = uvs;
  81034. return vertexData;
  81035. };
  81036. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  81037. var options = {
  81038. segments: segments,
  81039. diameterX: diameter,
  81040. diameterY: diameter,
  81041. diameterZ: diameter,
  81042. sideOrientation: sideOrientation,
  81043. updatable: updatable
  81044. };
  81045. return SphereBuilder.CreateSphere(name, options, scene);
  81046. };
  81047. /**
  81048. * Class containing static functions to help procedurally build meshes
  81049. */
  81050. var SphereBuilder = /** @class */ (function () {
  81051. function SphereBuilder() {
  81052. }
  81053. /**
  81054. * Creates a sphere mesh
  81055. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  81056. * * 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`)
  81057. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  81058. * * 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
  81059. * * 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)
  81060. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81061. * * 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
  81062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81063. * @param name defines the name of the mesh
  81064. * @param options defines the options used to create the mesh
  81065. * @param scene defines the hosting scene
  81066. * @returns the sphere mesh
  81067. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  81068. */
  81069. SphereBuilder.CreateSphere = function (name, options, scene) {
  81070. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  81071. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  81072. sphere._originalBuilderSideOrientation = options.sideOrientation;
  81073. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere(options);
  81074. vertexData.applyToMesh(sphere, options.updatable);
  81075. return sphere;
  81076. };
  81077. return SphereBuilder;
  81078. }());
  81079. /***/ }),
  81080. /***/ "./Meshes/Builders/torusBuilder.ts":
  81081. /*!*****************************************!*\
  81082. !*** ./Meshes/Builders/torusBuilder.ts ***!
  81083. \*****************************************/
  81084. /*! exports provided: TorusBuilder */
  81085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81086. "use strict";
  81087. __webpack_require__.r(__webpack_exports__);
  81088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return TorusBuilder; });
  81089. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  81090. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  81091. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81092. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus = function (options) {
  81093. var indices = [];
  81094. var positions = [];
  81095. var normals = [];
  81096. var uvs = [];
  81097. var diameter = options.diameter || 1;
  81098. var thickness = options.thickness || 0.5;
  81099. var tessellation = options.tessellation || 16;
  81100. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  81101. var stride = tessellation + 1;
  81102. for (var i = 0; i <= tessellation; i++) {
  81103. var u = i / tessellation;
  81104. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  81105. 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));
  81106. for (var j = 0; j <= tessellation; j++) {
  81107. var v = 1 - j / tessellation;
  81108. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  81109. var dx = Math.cos(innerAngle);
  81110. var dy = Math.sin(innerAngle);
  81111. // Create a vertex.
  81112. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  81113. var position = normal.scale(thickness / 2);
  81114. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  81115. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  81116. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  81117. positions.push(position.x, position.y, position.z);
  81118. normals.push(normal.x, normal.y, normal.z);
  81119. uvs.push(textureCoordinate.x, textureCoordinate.y);
  81120. // And create indices for two triangles.
  81121. var nextI = (i + 1) % stride;
  81122. var nextJ = (j + 1) % stride;
  81123. indices.push(i * stride + j);
  81124. indices.push(i * stride + nextJ);
  81125. indices.push(nextI * stride + j);
  81126. indices.push(i * stride + nextJ);
  81127. indices.push(nextI * stride + nextJ);
  81128. indices.push(nextI * stride + j);
  81129. }
  81130. }
  81131. // Sides
  81132. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  81133. // Result
  81134. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  81135. vertexData.indices = indices;
  81136. vertexData.positions = positions;
  81137. vertexData.normals = normals;
  81138. vertexData.uvs = uvs;
  81139. return vertexData;
  81140. };
  81141. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  81142. var options = {
  81143. diameter: diameter,
  81144. thickness: thickness,
  81145. tessellation: tessellation,
  81146. sideOrientation: sideOrientation,
  81147. updatable: updatable
  81148. };
  81149. return TorusBuilder.CreateTorus(name, options, scene);
  81150. };
  81151. /**
  81152. * Class containing static functions to help procedurally build meshes
  81153. */
  81154. var TorusBuilder = /** @class */ (function () {
  81155. function TorusBuilder() {
  81156. }
  81157. /**
  81158. * Creates a torus mesh
  81159. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  81160. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  81161. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  81162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81163. * * 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
  81164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81165. * @param name defines the name of the mesh
  81166. * @param options defines the options used to create the mesh
  81167. * @param scene defines the hosting scene
  81168. * @returns the torus mesh
  81169. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  81170. */
  81171. TorusBuilder.CreateTorus = function (name, options, scene) {
  81172. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  81173. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  81174. torus._originalBuilderSideOrientation = options.sideOrientation;
  81175. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus(options);
  81176. vertexData.applyToMesh(torus, options.updatable);
  81177. return torus;
  81178. };
  81179. return TorusBuilder;
  81180. }());
  81181. /***/ }),
  81182. /***/ "./Meshes/Builders/torusKnotBuilder.ts":
  81183. /*!*********************************************!*\
  81184. !*** ./Meshes/Builders/torusKnotBuilder.ts ***!
  81185. \*********************************************/
  81186. /*! exports provided: TorusKnotBuilder */
  81187. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81188. "use strict";
  81189. __webpack_require__.r(__webpack_exports__);
  81190. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return TorusKnotBuilder; });
  81191. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  81192. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  81193. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81194. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot = function (options) {
  81195. var indices = new Array();
  81196. var positions = new Array();
  81197. var normals = new Array();
  81198. var uvs = new Array();
  81199. var radius = options.radius || 2;
  81200. var tube = options.tube || 0.5;
  81201. var radialSegments = options.radialSegments || 32;
  81202. var tubularSegments = options.tubularSegments || 32;
  81203. var p = options.p || 2;
  81204. var q = options.q || 3;
  81205. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  81206. // Helper
  81207. var getPos = function (angle) {
  81208. var cu = Math.cos(angle);
  81209. var su = Math.sin(angle);
  81210. var quOverP = q / p * angle;
  81211. var cs = Math.cos(quOverP);
  81212. var tx = radius * (2 + cs) * 0.5 * cu;
  81213. var ty = radius * (2 + cs) * su * 0.5;
  81214. var tz = radius * Math.sin(quOverP) * 0.5;
  81215. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  81216. };
  81217. // Vertices
  81218. var i;
  81219. var j;
  81220. for (i = 0; i <= radialSegments; i++) {
  81221. var modI = i % radialSegments;
  81222. var u = modI / radialSegments * 2 * p * Math.PI;
  81223. var p1 = getPos(u);
  81224. var p2 = getPos(u + 0.01);
  81225. var tang = p2.subtract(p1);
  81226. var n = p2.add(p1);
  81227. var bitan = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  81228. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  81229. bitan.normalize();
  81230. n.normalize();
  81231. for (j = 0; j < tubularSegments; j++) {
  81232. var modJ = j % tubularSegments;
  81233. var v = modJ / tubularSegments * 2 * Math.PI;
  81234. var cx = -tube * Math.cos(v);
  81235. var cy = tube * Math.sin(v);
  81236. positions.push(p1.x + cx * n.x + cy * bitan.x);
  81237. positions.push(p1.y + cx * n.y + cy * bitan.y);
  81238. positions.push(p1.z + cx * n.z + cy * bitan.z);
  81239. uvs.push(i / radialSegments);
  81240. uvs.push(j / tubularSegments);
  81241. }
  81242. }
  81243. for (i = 0; i < radialSegments; i++) {
  81244. for (j = 0; j < tubularSegments; j++) {
  81245. var jNext = (j + 1) % tubularSegments;
  81246. var a = i * tubularSegments + j;
  81247. var b = (i + 1) * tubularSegments + j;
  81248. var c = (i + 1) * tubularSegments + jNext;
  81249. var d = i * tubularSegments + jNext;
  81250. indices.push(d);
  81251. indices.push(b);
  81252. indices.push(a);
  81253. indices.push(d);
  81254. indices.push(c);
  81255. indices.push(b);
  81256. }
  81257. }
  81258. // Normals
  81259. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  81260. // Sides
  81261. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  81262. // Result
  81263. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  81264. vertexData.indices = indices;
  81265. vertexData.positions = positions;
  81266. vertexData.normals = normals;
  81267. vertexData.uvs = uvs;
  81268. return vertexData;
  81269. };
  81270. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  81271. var options = {
  81272. radius: radius,
  81273. tube: tube,
  81274. radialSegments: radialSegments,
  81275. tubularSegments: tubularSegments,
  81276. p: p,
  81277. q: q,
  81278. sideOrientation: sideOrientation,
  81279. updatable: updatable
  81280. };
  81281. return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
  81282. };
  81283. /**
  81284. * Class containing static functions to help procedurally build meshes
  81285. */
  81286. var TorusKnotBuilder = /** @class */ (function () {
  81287. function TorusKnotBuilder() {
  81288. }
  81289. /**
  81290. * Creates a torus knot mesh
  81291. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  81292. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  81293. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  81294. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  81295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81296. * * 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
  81297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  81298. * @param name defines the name of the mesh
  81299. * @param options defines the options used to create the mesh
  81300. * @param scene defines the hosting scene
  81301. * @returns the torus knot mesh
  81302. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  81303. */
  81304. TorusKnotBuilder.CreateTorusKnot = function (name, options, scene) {
  81305. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  81306. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  81307. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  81308. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot(options);
  81309. vertexData.applyToMesh(torusKnot, options.updatable);
  81310. return torusKnot;
  81311. };
  81312. return TorusKnotBuilder;
  81313. }());
  81314. /***/ }),
  81315. /***/ "./Meshes/Builders/tubeBuilder.ts":
  81316. /*!****************************************!*\
  81317. !*** ./Meshes/Builders/tubeBuilder.ts ***!
  81318. \****************************************/
  81319. /*! exports provided: TubeBuilder */
  81320. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81321. "use strict";
  81322. __webpack_require__.r(__webpack_exports__);
  81323. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return TubeBuilder; });
  81324. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  81325. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  81326. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  81327. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  81328. var options = {
  81329. path: path,
  81330. radius: radius,
  81331. tessellation: tessellation,
  81332. radiusFunction: radiusFunction,
  81333. arc: 1,
  81334. cap: cap,
  81335. updatable: updatable,
  81336. sideOrientation: sideOrientation,
  81337. instance: instance
  81338. };
  81339. return TubeBuilder.CreateTube(name, options, scene);
  81340. };
  81341. /**
  81342. * Class containing static functions to help procedurally build meshes
  81343. */
  81344. var TubeBuilder = /** @class */ (function () {
  81345. function TubeBuilder() {
  81346. }
  81347. /**
  81348. * Creates a tube mesh.
  81349. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  81350. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  81351. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  81352. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  81353. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  81354. * * 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)
  81355. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  81356. * * 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
  81357. * * 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
  81358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  81359. * * 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
  81360. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  81361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81362. * @param name defines the name of the mesh
  81363. * @param options defines the options used to create the mesh
  81364. * @param scene defines the hosting scene
  81365. * @returns the tube mesh
  81366. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  81367. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  81368. */
  81369. TubeBuilder.CreateTube = function (name, options, scene) {
  81370. if (scene === void 0) { scene = null; }
  81371. var path = options.path;
  81372. var instance = options.instance;
  81373. var radius = 1.0;
  81374. if (options.radius !== undefined) {
  81375. radius = options.radius;
  81376. }
  81377. else if (instance) {
  81378. radius = instance._creationDataStorage.radius;
  81379. }
  81380. var tessellation = options.tessellation || 64 | 0;
  81381. var radiusFunction = options.radiusFunction || null;
  81382. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  81383. var invertUV = options.invertUV || false;
  81384. var updatable = options.updatable;
  81385. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  81386. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  81387. // tube geometry
  81388. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  81389. var tangents = path3D.getTangents();
  81390. var normals = path3D.getNormals();
  81391. var distances = path3D.getDistances();
  81392. var pi2 = Math.PI * 2;
  81393. var step = pi2 / tessellation * arc;
  81394. var returnRadius = function () { return radius; };
  81395. var radiusFunctionFinal = radiusFunction || returnRadius;
  81396. var circlePath;
  81397. var rad;
  81398. var normal;
  81399. var rotated;
  81400. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  81401. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  81402. for (var i = 0; i < path.length; i++) {
  81403. rad = radiusFunctionFinal(i, distances[i]); // current radius
  81404. circlePath = Array(); // current circle array
  81405. normal = normals[i]; // current normal
  81406. for (var t = 0; t < tessellation; t++) {
  81407. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  81408. rotated = circlePath[t] ? circlePath[t] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  81409. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  81410. rotated.scaleInPlace(rad).addInPlace(path[i]);
  81411. circlePath[t] = rotated;
  81412. }
  81413. circlePaths[index] = circlePath;
  81414. index++;
  81415. }
  81416. // cap
  81417. var capPath = function (nbPoints, pathIndex) {
  81418. var pointCap = Array();
  81419. for (var i = 0; i < nbPoints; i++) {
  81420. pointCap.push(path[pathIndex]);
  81421. }
  81422. return pointCap;
  81423. };
  81424. switch (cap) {
  81425. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  81426. break;
  81427. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  81428. circlePaths[0] = capPath(tessellation, 0);
  81429. circlePaths[1] = circlePaths[2].slice(0);
  81430. break;
  81431. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  81432. circlePaths[index] = circlePaths[index - 1].slice(0);
  81433. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  81434. break;
  81435. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  81436. circlePaths[0] = capPath(tessellation, 0);
  81437. circlePaths[1] = circlePaths[2].slice(0);
  81438. circlePaths[index] = circlePaths[index - 1].slice(0);
  81439. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  81440. break;
  81441. default:
  81442. break;
  81443. }
  81444. return circlePaths;
  81445. };
  81446. var path3D;
  81447. var pathArray;
  81448. if (instance) { // tube update
  81449. var storage = instance._creationDataStorage;
  81450. var arc = options.arc || storage.arc;
  81451. path3D = storage.path3D.update(path);
  81452. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  81453. instance = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon("", { pathArray: pathArray, instance: instance });
  81454. // Update mode, no need to recreate the storage.
  81455. storage.path3D = path3D;
  81456. storage.pathArray = pathArray;
  81457. storage.arc = arc;
  81458. storage.radius = radius;
  81459. return instance;
  81460. }
  81461. // tube creation
  81462. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](path);
  81463. var newPathArray = new Array();
  81464. cap = (cap < 0 || cap > 3) ? 0 : cap;
  81465. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  81466. 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);
  81467. tube._creationDataStorage.pathArray = pathArray;
  81468. tube._creationDataStorage.path3D = path3D;
  81469. tube._creationDataStorage.tessellation = tessellation;
  81470. tube._creationDataStorage.cap = cap;
  81471. tube._creationDataStorage.arc = options.arc;
  81472. tube._creationDataStorage.radius = radius;
  81473. return tube;
  81474. };
  81475. return TubeBuilder;
  81476. }());
  81477. /***/ }),
  81478. /***/ "./Meshes/Compression/dracoCompression.ts":
  81479. /*!************************************************!*\
  81480. !*** ./Meshes/Compression/dracoCompression.ts ***!
  81481. \************************************************/
  81482. /*! exports provided: DracoCompression */
  81483. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81484. "use strict";
  81485. __webpack_require__.r(__webpack_exports__);
  81486. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  81487. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  81488. /* harmony import */ var _Misc_workerPool__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/workerPool */ "./Misc/workerPool.ts");
  81489. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81490. /**
  81491. * Draco compression (https://google.github.io/draco/)
  81492. *
  81493. * This class wraps the Draco module.
  81494. *
  81495. * **Encoder**
  81496. *
  81497. * The encoder is not currently implemented.
  81498. *
  81499. * **Decoder**
  81500. *
  81501. * 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.
  81502. *
  81503. * To update the configuration, use the following code:
  81504. * ```javascript
  81505. * DracoCompression.Configuration = {
  81506. * decoder: {
  81507. * wasmUrl: "<url to the WebAssembly library>",
  81508. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  81509. * fallbackUrl: "<url to the fallback JavaScript library>",
  81510. * }
  81511. * };
  81512. * ```
  81513. *
  81514. * 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.
  81515. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  81516. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  81517. *
  81518. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  81519. * ```javascript
  81520. * var dracoCompression = new DracoCompression();
  81521. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  81522. * [VertexBuffer.PositionKind]: 0
  81523. * });
  81524. * ```
  81525. *
  81526. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  81527. */
  81528. var DracoCompression = /** @class */ (function () {
  81529. /**
  81530. * Constructor
  81531. * @param numWorkers The number of workers for async operations
  81532. */
  81533. function DracoCompression(numWorkers) {
  81534. if (numWorkers === void 0) { numWorkers = DracoCompression.DefaultNumWorkers; }
  81535. if (!URL || !URL.createObjectURL) {
  81536. throw new Error("Object URLs are not available");
  81537. }
  81538. if (!Worker) {
  81539. throw new Error("Workers are not available");
  81540. }
  81541. this._workerPoolPromise = this._loadDecoderWasmBinaryAsync().then(function (decoderWasmBinary) {
  81542. var workerBlobUrl = URL.createObjectURL(new Blob(["(" + DracoCompression._Worker.toString() + ")()"], { type: "application/javascript" }));
  81543. var workerPromises = new Array(numWorkers);
  81544. for (var i = 0; i < workerPromises.length; i++) {
  81545. workerPromises[i] = new Promise(function (resolve, reject) {
  81546. var decoder = DracoCompression.Configuration.decoder;
  81547. if (decoder) {
  81548. var worker_1 = new Worker(workerBlobUrl);
  81549. var onError_1 = function (error) {
  81550. worker_1.removeEventListener("error", onError_1);
  81551. worker_1.removeEventListener("message", onMessage_1);
  81552. reject(error);
  81553. };
  81554. var onMessage_1 = function (message) {
  81555. if (message.data === "done") {
  81556. worker_1.removeEventListener("error", onError_1);
  81557. worker_1.removeEventListener("message", onMessage_1);
  81558. resolve(worker_1);
  81559. }
  81560. };
  81561. worker_1.addEventListener("error", onError_1);
  81562. worker_1.addEventListener("message", onMessage_1);
  81563. worker_1.postMessage({
  81564. id: "initDecoder",
  81565. decoderWasmUrl: decoder.wasmUrl ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetAbsoluteUrl(decoder.wasmUrl) : null,
  81566. decoderWasmBinary: decoderWasmBinary,
  81567. fallbackUrl: decoder.fallbackUrl ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetAbsoluteUrl(decoder.fallbackUrl) : null
  81568. });
  81569. }
  81570. });
  81571. }
  81572. return Promise.all(workerPromises).then(function (workers) {
  81573. return new _Misc_workerPool__WEBPACK_IMPORTED_MODULE_1__["WorkerPool"](workers);
  81574. });
  81575. });
  81576. }
  81577. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  81578. /**
  81579. * Returns true if the decoder is available.
  81580. */
  81581. get: function () {
  81582. if (typeof DracoDecoderModule !== "undefined") {
  81583. return true;
  81584. }
  81585. var decoder = DracoCompression.Configuration.decoder;
  81586. if (decoder) {
  81587. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  81588. return true;
  81589. }
  81590. if (decoder.fallbackUrl) {
  81591. return true;
  81592. }
  81593. }
  81594. return false;
  81595. },
  81596. enumerable: true,
  81597. configurable: true
  81598. });
  81599. DracoCompression.GetDefaultNumWorkers = function () {
  81600. var hardwareConcurrency = navigator && navigator.hardwareConcurrency;
  81601. if (!hardwareConcurrency) {
  81602. return 1;
  81603. }
  81604. // Use 50% of the available logical processors but capped at 4.
  81605. return Math.min(Math.floor(hardwareConcurrency * 0.5), 4);
  81606. };
  81607. /**
  81608. * Stop all async operations and release resources.
  81609. */
  81610. DracoCompression.prototype.dispose = function () {
  81611. this._workerPoolPromise.then(function (workerPool) {
  81612. workerPool.dispose();
  81613. });
  81614. delete this._workerPoolPromise;
  81615. };
  81616. /**
  81617. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  81618. * @returns a promise that resolves when ready
  81619. */
  81620. DracoCompression.prototype.whenReadyAsync = function () {
  81621. return this._workerPoolPromise.then(function () { });
  81622. };
  81623. /**
  81624. * Decode Draco compressed mesh data to vertex data.
  81625. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  81626. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  81627. * @returns A promise that resolves with the decoded vertex data
  81628. */
  81629. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  81630. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  81631. return this._workerPoolPromise.then(function (workerPool) {
  81632. return new Promise(function (resolve, reject) {
  81633. workerPool.push(function (worker, onComplete) {
  81634. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  81635. var onError = function (error) {
  81636. worker.removeEventListener("error", onError);
  81637. worker.removeEventListener("message", onMessage);
  81638. reject(error);
  81639. onComplete();
  81640. };
  81641. var onMessage = function (message) {
  81642. if (message.data === "done") {
  81643. worker.removeEventListener("error", onError);
  81644. worker.removeEventListener("message", onMessage);
  81645. resolve(vertexData);
  81646. onComplete();
  81647. }
  81648. else if (message.data.id === "indices") {
  81649. vertexData.indices = message.data.value;
  81650. }
  81651. else {
  81652. vertexData.set(message.data.value, message.data.id);
  81653. }
  81654. };
  81655. worker.addEventListener("error", onError);
  81656. worker.addEventListener("message", onMessage);
  81657. var dataViewCopy = new Uint8Array(dataView.byteLength);
  81658. dataViewCopy.set(new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength));
  81659. worker.postMessage({ id: "decodeMesh", dataView: dataViewCopy, attributes: attributes }, [dataViewCopy.buffer]);
  81660. });
  81661. });
  81662. });
  81663. };
  81664. /**
  81665. * The worker function that gets converted to a blob url to pass into a worker.
  81666. */
  81667. DracoCompression._Worker = function () {
  81668. // self is actually a DedicatedWorkerGlobalScope
  81669. var _self = self;
  81670. var decoderModulePromise;
  81671. function initDecoder(decoderWasmUrl, decoderWasmBinary, fallbackUrl) {
  81672. if (decoderWasmUrl && decoderWasmBinary && typeof WebAssembly === "object") {
  81673. importScripts(decoderWasmUrl);
  81674. decoderModulePromise = DracoDecoderModule({
  81675. wasmBinary: decoderWasmBinary
  81676. });
  81677. }
  81678. else if (fallbackUrl) {
  81679. importScripts(fallbackUrl);
  81680. decoderModulePromise = DracoDecoderModule();
  81681. }
  81682. else {
  81683. throw Error("Failed to initialize Draco decoder");
  81684. }
  81685. _self.postMessage("done");
  81686. }
  81687. function decodeMesh(dataView, attributes) {
  81688. decoderModulePromise.then(function (decoderModule) {
  81689. var buffer = new decoderModule.DecoderBuffer();
  81690. buffer.Init(dataView, dataView.byteLength);
  81691. var decoder = new decoderModule.Decoder();
  81692. var geometry;
  81693. var status;
  81694. try {
  81695. var type = decoder.GetEncodedGeometryType(buffer);
  81696. switch (type) {
  81697. case decoderModule.TRIANGULAR_MESH:
  81698. geometry = new decoderModule.Mesh();
  81699. status = decoder.DecodeBufferToMesh(buffer, geometry);
  81700. break;
  81701. case decoderModule.POINT_CLOUD:
  81702. geometry = new decoderModule.PointCloud();
  81703. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  81704. break;
  81705. default:
  81706. throw new Error("Invalid geometry type " + type);
  81707. }
  81708. if (!status.ok() || !geometry.ptr) {
  81709. throw new Error(status.error_msg());
  81710. }
  81711. var numPoints = geometry.num_points();
  81712. if (type === decoderModule.TRIANGULAR_MESH) {
  81713. var numFaces = geometry.num_faces();
  81714. var faceIndices = new decoderModule.DracoInt32Array();
  81715. try {
  81716. var indices = new Uint32Array(numFaces * 3);
  81717. for (var i = 0; i < numFaces; i++) {
  81718. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  81719. var offset = i * 3;
  81720. indices[offset + 0] = faceIndices.GetValue(0);
  81721. indices[offset + 1] = faceIndices.GetValue(1);
  81722. indices[offset + 2] = faceIndices.GetValue(2);
  81723. }
  81724. _self.postMessage({ id: "indices", value: indices }, [indices.buffer]);
  81725. }
  81726. finally {
  81727. decoderModule.destroy(faceIndices);
  81728. }
  81729. }
  81730. for (var kind in attributes) {
  81731. var uniqueId = attributes[kind];
  81732. var attribute = decoder.GetAttributeByUniqueId(geometry, uniqueId);
  81733. var dracoData = new decoderModule.DracoFloat32Array();
  81734. try {
  81735. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  81736. var babylonData = new Float32Array(numPoints * attribute.num_components());
  81737. for (var i = 0; i < babylonData.length; i++) {
  81738. babylonData[i] = dracoData.GetValue(i);
  81739. }
  81740. _self.postMessage({ id: kind, value: babylonData }, [babylonData.buffer]);
  81741. }
  81742. finally {
  81743. decoderModule.destroy(dracoData);
  81744. }
  81745. }
  81746. }
  81747. finally {
  81748. if (geometry) {
  81749. decoderModule.destroy(geometry);
  81750. }
  81751. decoderModule.destroy(decoder);
  81752. decoderModule.destroy(buffer);
  81753. }
  81754. _self.postMessage("done");
  81755. });
  81756. }
  81757. _self.onmessage = function (event) {
  81758. var data = event.data;
  81759. switch (data.id) {
  81760. case "initDecoder": {
  81761. initDecoder(data.decoderWasmUrl, data.decoderWasmBinary, data.fallbackUrl);
  81762. break;
  81763. }
  81764. case "decodeMesh": {
  81765. decodeMesh(data.dataView, data.attributes);
  81766. break;
  81767. }
  81768. }
  81769. };
  81770. };
  81771. DracoCompression.prototype._loadDecoderWasmBinaryAsync = function () {
  81772. var decoder = DracoCompression.Configuration.decoder;
  81773. if (decoder && decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  81774. var wasmBinaryUrl_1 = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetAbsoluteUrl(decoder.wasmBinaryUrl);
  81775. return new Promise(function (resolve, reject) {
  81776. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(wasmBinaryUrl_1, function (data) {
  81777. resolve(data);
  81778. }, undefined, undefined, true, function (request, exception) {
  81779. reject(exception);
  81780. });
  81781. });
  81782. }
  81783. else {
  81784. return Promise.resolve(null);
  81785. }
  81786. };
  81787. /**
  81788. * The configuration. Defaults to the following urls:
  81789. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  81790. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  81791. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  81792. */
  81793. DracoCompression.Configuration = {
  81794. decoder: {
  81795. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  81796. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  81797. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  81798. }
  81799. };
  81800. /**
  81801. * Default number of workers to create when creating the draco compression object.
  81802. */
  81803. DracoCompression.DefaultNumWorkers = DracoCompression.GetDefaultNumWorkers();
  81804. return DracoCompression;
  81805. }());
  81806. /***/ }),
  81807. /***/ "./Meshes/Compression/index.ts":
  81808. /*!*************************************!*\
  81809. !*** ./Meshes/Compression/index.ts ***!
  81810. \*************************************/
  81811. /*! exports provided: DracoCompression */
  81812. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81813. "use strict";
  81814. __webpack_require__.r(__webpack_exports__);
  81815. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  81816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  81817. /***/ }),
  81818. /***/ "./Meshes/abstractMesh.ts":
  81819. /*!********************************!*\
  81820. !*** ./Meshes/abstractMesh.ts ***!
  81821. \********************************/
  81822. /*! exports provided: AbstractMesh */
  81823. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81824. "use strict";
  81825. __webpack_require__.r(__webpack_exports__);
  81826. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  81827. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  81828. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  81829. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  81830. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  81831. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  81832. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  81833. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81834. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  81835. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  81836. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  81837. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  81838. /** @hidden */
  81839. var _FacetDataStorage = /** @class */ (function () {
  81840. function _FacetDataStorage() {
  81841. this.facetNb = 0; // facet number
  81842. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  81843. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  81844. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  81845. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  81846. this.bbSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  81847. this.subDiv = {
  81848. max: 1,
  81849. X: 1,
  81850. Y: 1,
  81851. Z: 1
  81852. };
  81853. this.facetDepthSort = false; // is the facet depth sort to be computed
  81854. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  81855. }
  81856. return _FacetDataStorage;
  81857. }());
  81858. /**
  81859. * Class used to store all common mesh properties
  81860. */
  81861. var AbstractMesh = /** @class */ (function (_super) {
  81862. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  81863. // Constructor
  81864. /**
  81865. * Creates a new AbstractMesh
  81866. * @param name defines the name of the mesh
  81867. * @param scene defines the hosting scene
  81868. */
  81869. function AbstractMesh(name, scene) {
  81870. if (scene === void 0) { scene = null; }
  81871. var _this = _super.call(this, name, scene, false) || this;
  81872. _this._facetData = new _FacetDataStorage();
  81873. /**
  81874. * The culling strategy to use to check whether the mesh must be rendered or not.
  81875. * This value can be changed at any time and will be used on the next render mesh selection.
  81876. * The possible values are :
  81877. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  81878. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  81879. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  81880. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  81881. * Please read each static variable documentation to get details about the culling process.
  81882. * */
  81883. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  81884. // Events
  81885. /**
  81886. * An event triggered when this mesh collides with another one
  81887. */
  81888. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  81889. /**
  81890. * An event triggered when the collision's position changes
  81891. */
  81892. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  81893. /**
  81894. * An event triggered when material is changed
  81895. */
  81896. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  81897. // Properties
  81898. /**
  81899. * Gets or sets the orientation for POV movement & rotation
  81900. */
  81901. _this.definedFacingForward = true;
  81902. _this._visibility = 1.0;
  81903. /** Gets or sets the alpha index used to sort transparent meshes
  81904. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  81905. */
  81906. _this.alphaIndex = Number.MAX_VALUE;
  81907. /**
  81908. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  81909. */
  81910. _this.isVisible = true;
  81911. /**
  81912. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  81913. */
  81914. _this.isPickable = true;
  81915. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  81916. _this.showSubMeshesBoundingBox = false;
  81917. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  81918. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  81919. */
  81920. _this.isBlocker = false;
  81921. /**
  81922. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  81923. */
  81924. _this.enablePointerMoveEvents = false;
  81925. /**
  81926. * Specifies the rendering group id for this mesh (0 by default)
  81927. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  81928. */
  81929. _this.renderingGroupId = 0;
  81930. _this._receiveShadows = false;
  81931. /** Defines color to use when rendering outline */
  81932. _this.outlineColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  81933. /** Define width to use when rendering outline */
  81934. _this.outlineWidth = 0.02;
  81935. /** Defines color to use when rendering overlay */
  81936. _this.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  81937. /** Defines alpha to use when rendering overlay */
  81938. _this.overlayAlpha = 0.5;
  81939. _this._hasVertexAlpha = false;
  81940. _this._useVertexColors = true;
  81941. _this._computeBonesUsingShaders = true;
  81942. _this._numBoneInfluencers = 4;
  81943. _this._applyFog = true;
  81944. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  81945. _this.useOctreeForRenderingSelection = true;
  81946. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  81947. _this.useOctreeForPicking = true;
  81948. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  81949. _this.useOctreeForCollisions = true;
  81950. _this._layerMask = 0x0FFFFFFF;
  81951. /**
  81952. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  81953. */
  81954. _this.alwaysSelectAsActiveMesh = false;
  81955. /**
  81956. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  81957. */
  81958. _this.doNotSyncBoundingInfo = false;
  81959. /**
  81960. * Gets or sets the current action manager
  81961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  81962. */
  81963. _this.actionManager = null;
  81964. // Collisions
  81965. _this._checkCollisions = false;
  81966. _this._collisionMask = -1;
  81967. _this._collisionGroup = -1;
  81968. /**
  81969. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  81970. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81971. */
  81972. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  81973. /**
  81974. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  81975. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  81976. */
  81977. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  81978. _this._oldPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  81979. _this._diffPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  81980. // Edges
  81981. /**
  81982. * Defines edge width used when edgesRenderer is enabled
  81983. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81984. */
  81985. _this.edgesWidth = 1;
  81986. /**
  81987. * Defines edge color used when edgesRenderer is enabled
  81988. * @see https://www.babylonjs-playground.com/#10OJSG#13
  81989. */
  81990. _this.edgesColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](1, 0, 0, 1);
  81991. /** @hidden */
  81992. _this._renderId = 0;
  81993. /** @hidden */
  81994. _this._intersectionsInProgress = new Array();
  81995. /** @hidden */
  81996. _this._unIndexed = false;
  81997. /** @hidden */
  81998. _this._lightSources = new Array();
  81999. /**
  82000. * An event triggered when the mesh is rebuilt.
  82001. */
  82002. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  82003. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  82004. if (collidedMesh === void 0) { collidedMesh = null; }
  82005. newPosition.subtractToRef(_this._oldPositionForCollisions, _this._diffPositionForCollisions);
  82006. if (_this._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  82007. _this.position.addInPlace(_this._diffPositionForCollisions);
  82008. }
  82009. if (collidedMesh) {
  82010. _this.onCollideObservable.notifyObservers(collidedMesh);
  82011. }
  82012. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  82013. };
  82014. _this.getScene().addMesh(_this);
  82015. _this._resyncLightSources();
  82016. return _this;
  82017. }
  82018. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  82019. /**
  82020. * No billboard
  82021. */
  82022. get: function () {
  82023. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  82024. },
  82025. enumerable: true,
  82026. configurable: true
  82027. });
  82028. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  82029. /** Billboard on X axis */
  82030. get: function () {
  82031. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  82032. },
  82033. enumerable: true,
  82034. configurable: true
  82035. });
  82036. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  82037. /** Billboard on Y axis */
  82038. get: function () {
  82039. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  82040. },
  82041. enumerable: true,
  82042. configurable: true
  82043. });
  82044. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  82045. /** Billboard on Z axis */
  82046. get: function () {
  82047. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  82048. },
  82049. enumerable: true,
  82050. configurable: true
  82051. });
  82052. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  82053. /** Billboard on all axes */
  82054. get: function () {
  82055. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  82056. },
  82057. enumerable: true,
  82058. configurable: true
  82059. });
  82060. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  82061. /**
  82062. * Gets the number of facets in the mesh
  82063. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82064. */
  82065. get: function () {
  82066. return this._facetData.facetNb;
  82067. },
  82068. enumerable: true,
  82069. configurable: true
  82070. });
  82071. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  82072. /**
  82073. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  82074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82075. */
  82076. get: function () {
  82077. return this._facetData.partitioningSubdivisions;
  82078. },
  82079. set: function (nb) {
  82080. this._facetData.partitioningSubdivisions = nb;
  82081. },
  82082. enumerable: true,
  82083. configurable: true
  82084. });
  82085. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  82086. /**
  82087. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  82088. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  82089. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  82090. */
  82091. get: function () {
  82092. return this._facetData.partitioningBBoxRatio;
  82093. },
  82094. set: function (ratio) {
  82095. this._facetData.partitioningBBoxRatio = ratio;
  82096. },
  82097. enumerable: true,
  82098. configurable: true
  82099. });
  82100. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  82101. /**
  82102. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  82103. * Works only for updatable meshes.
  82104. * Doesn't work with multi-materials
  82105. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82106. */
  82107. get: function () {
  82108. return this._facetData.facetDepthSort;
  82109. },
  82110. set: function (sort) {
  82111. this._facetData.facetDepthSort = sort;
  82112. },
  82113. enumerable: true,
  82114. configurable: true
  82115. });
  82116. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  82117. /**
  82118. * The location (Vector3) where the facet depth sort must be computed from.
  82119. * By default, the active camera position.
  82120. * Used only when facet depth sort is enabled
  82121. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  82122. */
  82123. get: function () {
  82124. return this._facetData.facetDepthSortFrom;
  82125. },
  82126. set: function (location) {
  82127. this._facetData.facetDepthSortFrom = location;
  82128. },
  82129. enumerable: true,
  82130. configurable: true
  82131. });
  82132. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  82133. /**
  82134. * gets a boolean indicating if facetData is enabled
  82135. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  82136. */
  82137. get: function () {
  82138. return this._facetData.facetDataEnabled;
  82139. },
  82140. enumerable: true,
  82141. configurable: true
  82142. });
  82143. /** @hidden */
  82144. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  82145. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  82146. return false;
  82147. }
  82148. this._markSubMeshesAsMiscDirty();
  82149. return true;
  82150. };
  82151. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  82152. /** Set a function to call when this mesh collides with another one */
  82153. set: function (callback) {
  82154. if (this._onCollideObserver) {
  82155. this.onCollideObservable.remove(this._onCollideObserver);
  82156. }
  82157. this._onCollideObserver = this.onCollideObservable.add(callback);
  82158. },
  82159. enumerable: true,
  82160. configurable: true
  82161. });
  82162. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  82163. /** Set a function to call when the collision's position changes */
  82164. set: function (callback) {
  82165. if (this._onCollisionPositionChangeObserver) {
  82166. this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver);
  82167. }
  82168. this._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  82169. },
  82170. enumerable: true,
  82171. configurable: true
  82172. });
  82173. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  82174. /**
  82175. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82176. */
  82177. get: function () {
  82178. return this._visibility;
  82179. },
  82180. /**
  82181. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  82182. */
  82183. set: function (value) {
  82184. if (this._visibility === value) {
  82185. return;
  82186. }
  82187. this._visibility = value;
  82188. this._markSubMeshesAsMiscDirty();
  82189. },
  82190. enumerable: true,
  82191. configurable: true
  82192. });
  82193. Object.defineProperty(AbstractMesh.prototype, "material", {
  82194. /** Gets or sets current material */
  82195. get: function () {
  82196. return this._material;
  82197. },
  82198. set: function (value) {
  82199. if (this._material === value) {
  82200. return;
  82201. }
  82202. // remove from material mesh map id needed
  82203. if (this._material && this._material.meshMap) {
  82204. this._material.meshMap[this.uniqueId] = undefined;
  82205. }
  82206. this._material = value;
  82207. if (value && value.meshMap) {
  82208. value.meshMap[this.uniqueId] = this;
  82209. }
  82210. if (this.onMaterialChangedObservable.hasObservers) {
  82211. this.onMaterialChangedObservable.notifyObservers(this);
  82212. }
  82213. if (!this.subMeshes) {
  82214. return;
  82215. }
  82216. this._unBindEffect();
  82217. },
  82218. enumerable: true,
  82219. configurable: true
  82220. });
  82221. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  82222. /**
  82223. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  82224. * @see http://doc.babylonjs.com/babylon101/shadows
  82225. */
  82226. get: function () {
  82227. return this._receiveShadows;
  82228. },
  82229. set: function (value) {
  82230. if (this._receiveShadows === value) {
  82231. return;
  82232. }
  82233. this._receiveShadows = value;
  82234. this._markSubMeshesAsLightDirty();
  82235. },
  82236. enumerable: true,
  82237. configurable: true
  82238. });
  82239. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  82240. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  82241. get: function () {
  82242. return this._hasVertexAlpha;
  82243. },
  82244. set: function (value) {
  82245. if (this._hasVertexAlpha === value) {
  82246. return;
  82247. }
  82248. this._hasVertexAlpha = value;
  82249. this._markSubMeshesAsAttributesDirty();
  82250. this._markSubMeshesAsMiscDirty();
  82251. },
  82252. enumerable: true,
  82253. configurable: true
  82254. });
  82255. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  82256. /** 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) */
  82257. get: function () {
  82258. return this._useVertexColors;
  82259. },
  82260. set: function (value) {
  82261. if (this._useVertexColors === value) {
  82262. return;
  82263. }
  82264. this._useVertexColors = value;
  82265. this._markSubMeshesAsAttributesDirty();
  82266. },
  82267. enumerable: true,
  82268. configurable: true
  82269. });
  82270. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  82271. /**
  82272. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  82273. */
  82274. get: function () {
  82275. return this._computeBonesUsingShaders;
  82276. },
  82277. set: function (value) {
  82278. if (this._computeBonesUsingShaders === value) {
  82279. return;
  82280. }
  82281. this._computeBonesUsingShaders = value;
  82282. this._markSubMeshesAsAttributesDirty();
  82283. },
  82284. enumerable: true,
  82285. configurable: true
  82286. });
  82287. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  82288. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  82289. get: function () {
  82290. return this._numBoneInfluencers;
  82291. },
  82292. set: function (value) {
  82293. if (this._numBoneInfluencers === value) {
  82294. return;
  82295. }
  82296. this._numBoneInfluencers = value;
  82297. this._markSubMeshesAsAttributesDirty();
  82298. },
  82299. enumerable: true,
  82300. configurable: true
  82301. });
  82302. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  82303. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  82304. get: function () {
  82305. return this._applyFog;
  82306. },
  82307. set: function (value) {
  82308. if (this._applyFog === value) {
  82309. return;
  82310. }
  82311. this._applyFog = value;
  82312. this._markSubMeshesAsMiscDirty();
  82313. },
  82314. enumerable: true,
  82315. configurable: true
  82316. });
  82317. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  82318. /**
  82319. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  82320. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  82321. */
  82322. get: function () {
  82323. return this._layerMask;
  82324. },
  82325. set: function (value) {
  82326. if (value === this._layerMask) {
  82327. return;
  82328. }
  82329. this._layerMask = value;
  82330. this._resyncLightSources();
  82331. },
  82332. enumerable: true,
  82333. configurable: true
  82334. });
  82335. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  82336. /**
  82337. * Gets or sets a collision mask used to mask collisions (default is -1).
  82338. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82339. */
  82340. get: function () {
  82341. return this._collisionMask;
  82342. },
  82343. set: function (mask) {
  82344. this._collisionMask = !isNaN(mask) ? mask : -1;
  82345. },
  82346. enumerable: true,
  82347. configurable: true
  82348. });
  82349. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  82350. /**
  82351. * Gets or sets the current collision group mask (-1 by default).
  82352. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  82353. */
  82354. get: function () {
  82355. return this._collisionGroup;
  82356. },
  82357. set: function (mask) {
  82358. this._collisionGroup = !isNaN(mask) ? mask : -1;
  82359. },
  82360. enumerable: true,
  82361. configurable: true
  82362. });
  82363. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  82364. /** @hidden */
  82365. get: function () {
  82366. return null;
  82367. },
  82368. enumerable: true,
  82369. configurable: true
  82370. });
  82371. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  82372. get: function () {
  82373. return this._skeleton;
  82374. },
  82375. /**
  82376. * Gets or sets a skeleton to apply skining transformations
  82377. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  82378. */
  82379. set: function (value) {
  82380. if (this._skeleton && this._skeleton.needInitialSkinMatrix) {
  82381. this._skeleton._unregisterMeshWithPoseMatrix(this);
  82382. }
  82383. if (value && value.needInitialSkinMatrix) {
  82384. value._registerMeshWithPoseMatrix(this);
  82385. }
  82386. this._skeleton = value;
  82387. if (!this._skeleton) {
  82388. this._bonesTransformMatrices = null;
  82389. }
  82390. this._markSubMeshesAsAttributesDirty();
  82391. },
  82392. enumerable: true,
  82393. configurable: true
  82394. });
  82395. /**
  82396. * Returns the string "AbstractMesh"
  82397. * @returns "AbstractMesh"
  82398. */
  82399. AbstractMesh.prototype.getClassName = function () {
  82400. return "AbstractMesh";
  82401. };
  82402. /**
  82403. * Gets a string representation of the current mesh
  82404. * @param fullDetails defines a boolean indicating if full details must be included
  82405. * @returns a string representation of the current mesh
  82406. */
  82407. AbstractMesh.prototype.toString = function (fullDetails) {
  82408. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  82409. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  82410. if (this._skeleton) {
  82411. ret += ", skeleton: " + this._skeleton.name;
  82412. }
  82413. if (fullDetails) {
  82414. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  82415. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingFreezeWorldMatrix ? "YES" : "NO");
  82416. }
  82417. return ret;
  82418. };
  82419. /**
  82420. * @hidden
  82421. */
  82422. AbstractMesh.prototype._getEffectiveParent = function () {
  82423. if (this._masterMesh && this.billboardMode !== _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE) {
  82424. return this._masterMesh;
  82425. }
  82426. return _super.prototype._getEffectiveParent.call(this);
  82427. };
  82428. /** @hidden */
  82429. AbstractMesh.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  82430. if (initialCall === void 0) { initialCall = true; }
  82431. if (this.actionManager && (initialCall || this.actionManager.isRecursive)) {
  82432. if (trigger) {
  82433. if (this.actionManager.hasSpecificTrigger(trigger)) {
  82434. return this.actionManager;
  82435. }
  82436. }
  82437. else {
  82438. return this.actionManager;
  82439. }
  82440. }
  82441. if (!this.parent) {
  82442. return null;
  82443. }
  82444. return this.parent._getActionManagerForTrigger(trigger, false);
  82445. };
  82446. /** @hidden */
  82447. AbstractMesh.prototype._rebuild = function () {
  82448. this.onRebuildObservable.notifyObservers(this);
  82449. if (this._occlusionQuery) {
  82450. this._occlusionQuery = null;
  82451. }
  82452. if (!this.subMeshes) {
  82453. return;
  82454. }
  82455. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  82456. var subMesh = _a[_i];
  82457. subMesh._rebuild();
  82458. }
  82459. };
  82460. /** @hidden */
  82461. AbstractMesh.prototype._resyncLightSources = function () {
  82462. this._lightSources.length = 0;
  82463. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  82464. var light = _a[_i];
  82465. if (!light.isEnabled()) {
  82466. continue;
  82467. }
  82468. if (light.canAffectMesh(this)) {
  82469. this._lightSources.push(light);
  82470. }
  82471. }
  82472. this._markSubMeshesAsLightDirty();
  82473. };
  82474. /** @hidden */
  82475. AbstractMesh.prototype._resyncLighSource = function (light) {
  82476. var isIn = light.isEnabled() && light.canAffectMesh(this);
  82477. var index = this._lightSources.indexOf(light);
  82478. if (index === -1) {
  82479. if (!isIn) {
  82480. return;
  82481. }
  82482. this._lightSources.push(light);
  82483. }
  82484. else {
  82485. if (isIn) {
  82486. return;
  82487. }
  82488. this._lightSources.splice(index, 1);
  82489. }
  82490. this._markSubMeshesAsLightDirty();
  82491. };
  82492. /** @hidden */
  82493. AbstractMesh.prototype._unBindEffect = function () {
  82494. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  82495. var subMesh = _a[_i];
  82496. subMesh.setEffect(null);
  82497. }
  82498. };
  82499. /** @hidden */
  82500. AbstractMesh.prototype._removeLightSource = function (light) {
  82501. var index = this._lightSources.indexOf(light);
  82502. if (index === -1) {
  82503. return;
  82504. }
  82505. this._lightSources.splice(index, 1);
  82506. this._markSubMeshesAsLightDirty();
  82507. };
  82508. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  82509. if (!this.subMeshes) {
  82510. return;
  82511. }
  82512. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  82513. var subMesh = _a[_i];
  82514. if (subMesh._materialDefines) {
  82515. func(subMesh._materialDefines);
  82516. }
  82517. }
  82518. };
  82519. /** @hidden */
  82520. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  82521. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  82522. };
  82523. /** @hidden */
  82524. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  82525. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  82526. };
  82527. /** @hidden */
  82528. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  82529. if (!this.subMeshes) {
  82530. return;
  82531. }
  82532. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  82533. var subMesh = _a[_i];
  82534. var material = subMesh.getMaterial();
  82535. if (material) {
  82536. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MATERIAL_MiscDirtyFlag);
  82537. }
  82538. }
  82539. };
  82540. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  82541. /**
  82542. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  82543. */
  82544. get: function () {
  82545. return this._scaling;
  82546. },
  82547. set: function (newScaling) {
  82548. this._scaling = newScaling;
  82549. if (this.physicsImpostor) {
  82550. this.physicsImpostor.forceUpdate();
  82551. }
  82552. },
  82553. enumerable: true,
  82554. configurable: true
  82555. });
  82556. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  82557. // Methods
  82558. /**
  82559. * Returns true if the mesh is blocked. Implemented by child classes
  82560. */
  82561. get: function () {
  82562. return false;
  82563. },
  82564. enumerable: true,
  82565. configurable: true
  82566. });
  82567. /**
  82568. * Returns the mesh itself by default. Implemented by child classes
  82569. * @param camera defines the camera to use to pick the right LOD level
  82570. * @returns the currentAbstractMesh
  82571. */
  82572. AbstractMesh.prototype.getLOD = function (camera) {
  82573. return this;
  82574. };
  82575. /**
  82576. * Returns 0 by default. Implemented by child classes
  82577. * @returns an integer
  82578. */
  82579. AbstractMesh.prototype.getTotalVertices = function () {
  82580. return 0;
  82581. };
  82582. /**
  82583. * Returns a positive integer : the total number of indices in this mesh geometry.
  82584. * @returns the numner of indices or zero if the mesh has no geometry.
  82585. */
  82586. AbstractMesh.prototype.getTotalIndices = function () {
  82587. return 0;
  82588. };
  82589. /**
  82590. * Returns null by default. Implemented by child classes
  82591. * @returns null
  82592. */
  82593. AbstractMesh.prototype.getIndices = function () {
  82594. return null;
  82595. };
  82596. /**
  82597. * Returns the array of the requested vertex data kind. Implemented by child classes
  82598. * @param kind defines the vertex data kind to use
  82599. * @returns null
  82600. */
  82601. AbstractMesh.prototype.getVerticesData = function (kind) {
  82602. return null;
  82603. };
  82604. /**
  82605. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82606. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82607. * Note that a new underlying VertexBuffer object is created each call.
  82608. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82609. * @param kind defines vertex data kind:
  82610. * * VertexBuffer.PositionKind
  82611. * * VertexBuffer.UVKind
  82612. * * VertexBuffer.UV2Kind
  82613. * * VertexBuffer.UV3Kind
  82614. * * VertexBuffer.UV4Kind
  82615. * * VertexBuffer.UV5Kind
  82616. * * VertexBuffer.UV6Kind
  82617. * * VertexBuffer.ColorKind
  82618. * * VertexBuffer.MatricesIndicesKind
  82619. * * VertexBuffer.MatricesIndicesExtraKind
  82620. * * VertexBuffer.MatricesWeightsKind
  82621. * * VertexBuffer.MatricesWeightsExtraKind
  82622. * @param data defines the data source
  82623. * @param updatable defines if the data must be flagged as updatable (or static)
  82624. * @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
  82625. * @returns the current mesh
  82626. */
  82627. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  82628. return this;
  82629. };
  82630. /**
  82631. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82632. * If the mesh has no geometry, it is simply returned as it is.
  82633. * @param kind defines vertex data kind:
  82634. * * VertexBuffer.PositionKind
  82635. * * VertexBuffer.UVKind
  82636. * * VertexBuffer.UV2Kind
  82637. * * VertexBuffer.UV3Kind
  82638. * * VertexBuffer.UV4Kind
  82639. * * VertexBuffer.UV5Kind
  82640. * * VertexBuffer.UV6Kind
  82641. * * VertexBuffer.ColorKind
  82642. * * VertexBuffer.MatricesIndicesKind
  82643. * * VertexBuffer.MatricesIndicesExtraKind
  82644. * * VertexBuffer.MatricesWeightsKind
  82645. * * VertexBuffer.MatricesWeightsExtraKind
  82646. * @param data defines the data source
  82647. * @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
  82648. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  82649. * @returns the current mesh
  82650. */
  82651. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  82652. return this;
  82653. };
  82654. /**
  82655. * Sets the mesh indices,
  82656. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  82657. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  82658. * @param totalVertices Defines the total number of vertices
  82659. * @returns the current mesh
  82660. */
  82661. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  82662. return this;
  82663. };
  82664. /**
  82665. * Gets a boolean indicating if specific vertex data is present
  82666. * @param kind defines the vertex data kind to use
  82667. * @returns true is data kind is present
  82668. */
  82669. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  82670. return false;
  82671. };
  82672. /**
  82673. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  82674. * @returns a BoundingInfo
  82675. */
  82676. AbstractMesh.prototype.getBoundingInfo = function () {
  82677. if (this._masterMesh) {
  82678. return this._masterMesh.getBoundingInfo();
  82679. }
  82680. if (!this._boundingInfo) {
  82681. // this._boundingInfo is being created here
  82682. this._updateBoundingInfo();
  82683. }
  82684. // cannot be null.
  82685. return this._boundingInfo;
  82686. };
  82687. /**
  82688. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  82689. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  82690. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  82691. * @returns the current mesh
  82692. */
  82693. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants, ignoreRotation) {
  82694. if (includeDescendants === void 0) { includeDescendants = true; }
  82695. if (ignoreRotation === void 0) { ignoreRotation = false; }
  82696. var storedRotation = null;
  82697. var storedRotationQuaternion = null;
  82698. if (ignoreRotation) {
  82699. if (this.rotationQuaternion) {
  82700. storedRotationQuaternion = this.rotationQuaternion.clone();
  82701. this.rotationQuaternion.copyFromFloats(0, 0, 0, 1);
  82702. }
  82703. else if (this.rotation) {
  82704. storedRotation = this.rotation.clone();
  82705. this.rotation.copyFromFloats(0, 0, 0);
  82706. }
  82707. }
  82708. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
  82709. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  82710. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  82711. if (maxDimension === 0) {
  82712. return this;
  82713. }
  82714. var scale = 1 / maxDimension;
  82715. this.scaling.scaleInPlace(scale);
  82716. if (ignoreRotation) {
  82717. if (this.rotationQuaternion && storedRotationQuaternion) {
  82718. this.rotationQuaternion.copyFrom(storedRotationQuaternion);
  82719. }
  82720. else if (this.rotation && storedRotation) {
  82721. this.rotation.copyFrom(storedRotation);
  82722. }
  82723. }
  82724. return this;
  82725. };
  82726. /**
  82727. * Overwrite the current bounding info
  82728. * @param boundingInfo defines the new bounding info
  82729. * @returns the current mesh
  82730. */
  82731. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  82732. this._boundingInfo = boundingInfo;
  82733. return this;
  82734. };
  82735. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  82736. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  82737. get: function () {
  82738. 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));
  82739. },
  82740. enumerable: true,
  82741. configurable: true
  82742. });
  82743. /** @hidden */
  82744. AbstractMesh.prototype._preActivate = function () {
  82745. };
  82746. /** @hidden */
  82747. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  82748. };
  82749. /** @hidden */
  82750. AbstractMesh.prototype._activate = function (renderId) {
  82751. this._renderId = renderId;
  82752. };
  82753. /**
  82754. * Gets the current world matrix
  82755. * @returns a Matrix
  82756. */
  82757. AbstractMesh.prototype.getWorldMatrix = function () {
  82758. if (this._masterMesh && this.billboardMode === _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE) {
  82759. return this._masterMesh.getWorldMatrix();
  82760. }
  82761. return _super.prototype.getWorldMatrix.call(this);
  82762. };
  82763. /** @hidden */
  82764. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  82765. if (this._masterMesh) {
  82766. return this._masterMesh._getWorldMatrixDeterminant();
  82767. }
  82768. return _super.prototype._getWorldMatrixDeterminant.call(this);
  82769. };
  82770. // ================================== Point of View Movement =================================
  82771. /**
  82772. * Perform relative position change from the point of view of behind the front of the mesh.
  82773. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82774. * Supports definition of mesh facing forward or backward
  82775. * @param amountRight defines the distance on the right axis
  82776. * @param amountUp defines the distance on the up axis
  82777. * @param amountForward defines the distance on the forward axis
  82778. * @returns the current mesh
  82779. */
  82780. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  82781. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  82782. return this;
  82783. };
  82784. /**
  82785. * Calculate relative position change from the point of view of behind the front of the mesh.
  82786. * This is performed taking into account the meshes current rotation, so you do not have to care.
  82787. * Supports definition of mesh facing forward or backward
  82788. * @param amountRight defines the distance on the right axis
  82789. * @param amountUp defines the distance on the up axis
  82790. * @param amountForward defines the distance on the forward axis
  82791. * @returns the new displacement vector
  82792. */
  82793. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  82794. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  82795. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  82796. rotQuaternion.toRotationMatrix(rotMatrix);
  82797. var translationDelta = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  82798. var defForwardMult = this.definedFacingForward ? -1 : 1;
  82799. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  82800. return translationDelta;
  82801. };
  82802. // ================================== Point of View Rotation =================================
  82803. /**
  82804. * Perform relative rotation change from the point of view of behind the front of the mesh.
  82805. * Supports definition of mesh facing forward or backward
  82806. * @param flipBack defines the flip
  82807. * @param twirlClockwise defines the twirl
  82808. * @param tiltRight defines the tilt
  82809. * @returns the current mesh
  82810. */
  82811. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  82812. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  82813. return this;
  82814. };
  82815. /**
  82816. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  82817. * Supports definition of mesh facing forward or backward.
  82818. * @param flipBack defines the flip
  82819. * @param twirlClockwise defines the twirl
  82820. * @param tiltRight defines the tilt
  82821. * @returns the new rotation vector
  82822. */
  82823. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  82824. var defForwardMult = this.definedFacingForward ? 1 : -1;
  82825. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  82826. };
  82827. /**
  82828. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  82829. * @param includeDescendants Include bounding info from descendants as well (true by default)
  82830. * @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
  82831. * @returns the new bounding vectors
  82832. */
  82833. AbstractMesh.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  82834. if (includeDescendants === void 0) { includeDescendants = true; }
  82835. if (predicate === void 0) { predicate = null; }
  82836. // Ensures that all world matrix will be recomputed.
  82837. this.getScene().incrementRenderId();
  82838. this.computeWorldMatrix(true);
  82839. var min;
  82840. var max;
  82841. var boundingInfo = this.getBoundingInfo();
  82842. if (!this.subMeshes) {
  82843. min = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  82844. max = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  82845. }
  82846. else {
  82847. min = boundingInfo.boundingBox.minimumWorld;
  82848. max = boundingInfo.boundingBox.maximumWorld;
  82849. }
  82850. if (includeDescendants) {
  82851. var descendants = this.getDescendants(false);
  82852. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  82853. var descendant = descendants_1[_i];
  82854. var childMesh = descendant;
  82855. childMesh.computeWorldMatrix(true);
  82856. // Filters meshes based on custom predicate function.
  82857. if (predicate && !predicate(childMesh)) {
  82858. continue;
  82859. }
  82860. //make sure we have the needed params to get mix and max
  82861. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  82862. continue;
  82863. }
  82864. var childBoundingInfo = childMesh.getBoundingInfo();
  82865. var boundingBox = childBoundingInfo.boundingBox;
  82866. var minBox = boundingBox.minimumWorld;
  82867. var maxBox = boundingBox.maximumWorld;
  82868. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  82869. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  82870. }
  82871. }
  82872. return {
  82873. min: min,
  82874. max: max
  82875. };
  82876. };
  82877. /**
  82878. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82879. * This means the mesh underlying bounding box and sphere are recomputed.
  82880. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82881. * @returns the current mesh
  82882. */
  82883. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  82884. if (applySkeleton === void 0) { applySkeleton = false; }
  82885. if (this._boundingInfo && this._boundingInfo.isLocked) {
  82886. return this;
  82887. }
  82888. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  82889. return this;
  82890. };
  82891. /** @hidden */
  82892. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  82893. if (data) {
  82894. var extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMax(data, 0, this.getTotalVertices(), bias);
  82895. if (this._boundingInfo) {
  82896. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  82897. }
  82898. else {
  82899. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](extend.minimum, extend.maximum);
  82900. }
  82901. }
  82902. if (this.subMeshes) {
  82903. for (var index = 0; index < this.subMeshes.length; index++) {
  82904. this.subMeshes[index].refreshBoundingInfo();
  82905. }
  82906. }
  82907. this._updateBoundingInfo();
  82908. };
  82909. /** @hidden */
  82910. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  82911. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  82912. if (data && applySkeleton && this.skeleton) {
  82913. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  82914. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  82915. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  82916. if (matricesWeightsData && matricesIndicesData) {
  82917. var needExtras = this.numBoneInfluencers > 4;
  82918. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  82919. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  82920. this.skeleton.prepare();
  82921. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  82922. var tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  82923. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  82924. var tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  82925. var matWeightIdx = 0;
  82926. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  82927. finalMatrix.reset();
  82928. var inf;
  82929. var weight;
  82930. for (inf = 0; inf < 4; inf++) {
  82931. weight = matricesWeightsData[matWeightIdx + inf];
  82932. if (weight > 0) {
  82933. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  82934. finalMatrix.addToSelf(tempMatrix);
  82935. }
  82936. }
  82937. if (needExtras) {
  82938. for (inf = 0; inf < 4; inf++) {
  82939. weight = matricesWeightsExtraData[matWeightIdx + inf];
  82940. if (weight > 0) {
  82941. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  82942. finalMatrix.addToSelf(tempMatrix);
  82943. }
  82944. }
  82945. }
  82946. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  82947. tempVector.toArray(data, index);
  82948. }
  82949. }
  82950. }
  82951. return data;
  82952. };
  82953. /** @hidden */
  82954. AbstractMesh.prototype._updateBoundingInfo = function () {
  82955. var effectiveMesh = this._effectiveMesh;
  82956. if (this._boundingInfo) {
  82957. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  82958. }
  82959. else {
  82960. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  82961. }
  82962. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  82963. return this;
  82964. };
  82965. /** @hidden */
  82966. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  82967. if (!this.subMeshes) {
  82968. return this;
  82969. }
  82970. var count = this.subMeshes.length;
  82971. for (var subIndex = 0; subIndex < count; subIndex++) {
  82972. var subMesh = this.subMeshes[subIndex];
  82973. if (count > 1 || !subMesh.IsGlobal) {
  82974. subMesh.updateBoundingInfo(matrix);
  82975. }
  82976. }
  82977. return this;
  82978. };
  82979. /** @hidden */
  82980. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  82981. if (this.doNotSyncBoundingInfo) {
  82982. return;
  82983. }
  82984. // Bounding info
  82985. this._updateBoundingInfo();
  82986. };
  82987. Object.defineProperty(AbstractMesh.prototype, "_effectiveMesh", {
  82988. /** @hidden */
  82989. get: function () {
  82990. return (this.skeleton && this.skeleton.overrideMesh) || this;
  82991. },
  82992. enumerable: true,
  82993. configurable: true
  82994. });
  82995. /**
  82996. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  82997. * A mesh is in the frustum if its bounding box intersects the frustum
  82998. * @param frustumPlanes defines the frustum to test
  82999. * @returns true if the mesh is in the frustum planes
  83000. */
  83001. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  83002. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  83003. };
  83004. /**
  83005. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  83006. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  83007. * @param frustumPlanes defines the frustum to test
  83008. * @returns true if the mesh is completely in the frustum planes
  83009. */
  83010. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  83011. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  83012. };
  83013. /**
  83014. * True if the mesh intersects another mesh or a SolidParticle object
  83015. * @param mesh defines a target mesh or SolidParticle to test
  83016. * @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)
  83017. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  83018. * @returns true if there is an intersection
  83019. */
  83020. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  83021. if (precise === void 0) { precise = false; }
  83022. if (!this._boundingInfo || !mesh._boundingInfo) {
  83023. return false;
  83024. }
  83025. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  83026. return true;
  83027. }
  83028. if (includeDescendants) {
  83029. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  83030. var child = _a[_i];
  83031. if (child.intersectsMesh(mesh, precise, true)) {
  83032. return true;
  83033. }
  83034. }
  83035. }
  83036. return false;
  83037. };
  83038. /**
  83039. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  83040. * @param point defines the point to test
  83041. * @returns true if there is an intersection
  83042. */
  83043. AbstractMesh.prototype.intersectsPoint = function (point) {
  83044. if (!this._boundingInfo) {
  83045. return false;
  83046. }
  83047. return this._boundingInfo.intersectsPoint(point);
  83048. };
  83049. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  83050. // Collisions
  83051. /**
  83052. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  83053. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83054. */
  83055. get: function () {
  83056. return this._checkCollisions;
  83057. },
  83058. set: function (collisionEnabled) {
  83059. this._checkCollisions = collisionEnabled;
  83060. },
  83061. enumerable: true,
  83062. configurable: true
  83063. });
  83064. Object.defineProperty(AbstractMesh.prototype, "collider", {
  83065. /**
  83066. * Gets Collider object used to compute collisions (not physics)
  83067. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83068. */
  83069. get: function () {
  83070. return this._collider;
  83071. },
  83072. enumerable: true,
  83073. configurable: true
  83074. });
  83075. /**
  83076. * Move the mesh using collision engine
  83077. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83078. * @param displacement defines the requested displacement vector
  83079. * @returns the current mesh
  83080. */
  83081. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  83082. var globalPosition = this.getAbsolutePosition();
  83083. globalPosition.addToRef(this.ellipsoidOffset, this._oldPositionForCollisions);
  83084. var coordinator = this.getScene().collisionCoordinator;
  83085. if (!this._collider) {
  83086. this._collider = coordinator.createCollider();
  83087. }
  83088. this._collider._radius = this.ellipsoid;
  83089. coordinator.getNewPosition(this._oldPositionForCollisions, displacement, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  83090. return this;
  83091. };
  83092. // Collisions
  83093. /** @hidden */
  83094. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  83095. this._generatePointsArray();
  83096. if (!this._positions) {
  83097. return this;
  83098. }
  83099. // Transformation
  83100. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  83101. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  83102. subMesh._lastColliderWorldVertices = [];
  83103. subMesh._trianglePlanes = [];
  83104. var start = subMesh.verticesStart;
  83105. var end = (subMesh.verticesStart + subMesh.verticesCount);
  83106. for (var i = start; i < end; i++) {
  83107. subMesh._lastColliderWorldVertices.push(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  83108. }
  83109. }
  83110. // Collide
  83111. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial());
  83112. if (collider.collisionFound) {
  83113. collider.collidedMesh = this;
  83114. }
  83115. return this;
  83116. };
  83117. /** @hidden */
  83118. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  83119. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  83120. var len = subMeshes.length;
  83121. for (var index = 0; index < len; index++) {
  83122. var subMesh = subMeshes.data[index];
  83123. // Bounding test
  83124. if (len > 1 && !subMesh._checkCollision(collider)) {
  83125. continue;
  83126. }
  83127. this._collideForSubMesh(subMesh, transformMatrix, collider);
  83128. }
  83129. return this;
  83130. };
  83131. /** @hidden */
  83132. AbstractMesh.prototype._checkCollision = function (collider) {
  83133. // Bounding box test
  83134. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  83135. return this;
  83136. }
  83137. // Transformation matrix
  83138. var collisionsScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  83139. var collisionsTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  83140. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  83141. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  83142. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  83143. return this;
  83144. };
  83145. // Picking
  83146. /** @hidden */
  83147. AbstractMesh.prototype._generatePointsArray = function () {
  83148. return false;
  83149. };
  83150. /**
  83151. * Checks if the passed Ray intersects with the mesh
  83152. * @param ray defines the ray to use
  83153. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  83154. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  83155. * @returns the picking info
  83156. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83157. */
  83158. AbstractMesh.prototype.intersects = function (ray, fastCheck, trianglePredicate) {
  83159. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  83160. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  83161. var boundingInfo = this._boundingInfo;
  83162. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  83163. return pickingInfo;
  83164. }
  83165. if (!this._generatePointsArray()) {
  83166. return pickingInfo;
  83167. }
  83168. var intersectInfo = null;
  83169. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  83170. var len = subMeshes.length;
  83171. for (var index = 0; index < len; index++) {
  83172. var subMesh = subMeshes.data[index];
  83173. // Bounding test
  83174. if (len > 1 && !subMesh.canIntersects(ray)) {
  83175. continue;
  83176. }
  83177. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck, trianglePredicate);
  83178. if (currentIntersectInfo) {
  83179. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  83180. intersectInfo = currentIntersectInfo;
  83181. intersectInfo.subMeshId = index;
  83182. if (fastCheck) {
  83183. break;
  83184. }
  83185. }
  83186. }
  83187. }
  83188. if (intersectInfo) {
  83189. // Get picked point
  83190. var world = this.getWorldMatrix();
  83191. var worldOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  83192. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  83193. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  83194. ray.direction.scaleToRef(intersectInfo.distance, direction);
  83195. var worldDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  83196. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  83197. // Return result
  83198. pickingInfo.hit = true;
  83199. pickingInfo.distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  83200. pickingInfo.pickedPoint = pickedPoint;
  83201. pickingInfo.pickedMesh = this;
  83202. pickingInfo.bu = intersectInfo.bu || 0;
  83203. pickingInfo.bv = intersectInfo.bv || 0;
  83204. pickingInfo.faceId = intersectInfo.faceId;
  83205. pickingInfo.subMeshId = intersectInfo.subMeshId;
  83206. return pickingInfo;
  83207. }
  83208. return pickingInfo;
  83209. };
  83210. /**
  83211. * Clones the current mesh
  83212. * @param name defines the mesh name
  83213. * @param newParent defines the new mesh parent
  83214. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  83215. * @returns the new mesh
  83216. */
  83217. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  83218. return null;
  83219. };
  83220. /**
  83221. * Disposes all the submeshes of the current meshnp
  83222. * @returns the current mesh
  83223. */
  83224. AbstractMesh.prototype.releaseSubMeshes = function () {
  83225. if (this.subMeshes) {
  83226. while (this.subMeshes.length) {
  83227. this.subMeshes[0].dispose();
  83228. }
  83229. }
  83230. else {
  83231. this.subMeshes = new Array();
  83232. }
  83233. return this;
  83234. };
  83235. /**
  83236. * Releases resources associated with this abstract mesh.
  83237. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83238. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83239. */
  83240. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  83241. var _this = this;
  83242. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  83243. var index;
  83244. // Smart Array Retainers.
  83245. this.getScene().freeActiveMeshes();
  83246. this.getScene().freeRenderingGroups();
  83247. // Action manager
  83248. if (this.actionManager !== undefined && this.actionManager !== null) {
  83249. this.actionManager.dispose();
  83250. this.actionManager = null;
  83251. }
  83252. // Skeleton
  83253. this._skeleton = null;
  83254. // Intersections in progress
  83255. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  83256. var other = this._intersectionsInProgress[index];
  83257. var pos = other._intersectionsInProgress.indexOf(this);
  83258. other._intersectionsInProgress.splice(pos, 1);
  83259. }
  83260. this._intersectionsInProgress = [];
  83261. // Lights
  83262. var lights = this.getScene().lights;
  83263. lights.forEach(function (light) {
  83264. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  83265. if (meshIndex !== -1) {
  83266. light.includedOnlyMeshes.splice(meshIndex, 1);
  83267. }
  83268. meshIndex = light.excludedMeshes.indexOf(_this);
  83269. if (meshIndex !== -1) {
  83270. light.excludedMeshes.splice(meshIndex, 1);
  83271. }
  83272. // Shadow generators
  83273. var generator = light.getShadowGenerator();
  83274. if (generator) {
  83275. var shadowMap = generator.getShadowMap();
  83276. if (shadowMap && shadowMap.renderList) {
  83277. meshIndex = shadowMap.renderList.indexOf(_this);
  83278. if (meshIndex !== -1) {
  83279. shadowMap.renderList.splice(meshIndex, 1);
  83280. }
  83281. }
  83282. }
  83283. });
  83284. // SubMeshes
  83285. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  83286. this.releaseSubMeshes();
  83287. }
  83288. // Query
  83289. var engine = this.getScene().getEngine();
  83290. if (this._occlusionQuery) {
  83291. this.isOcclusionQueryInProgress = false;
  83292. engine.deleteQuery(this._occlusionQuery);
  83293. this._occlusionQuery = null;
  83294. }
  83295. // Engine
  83296. engine.wipeCaches();
  83297. // Remove from scene
  83298. this.getScene().removeMesh(this);
  83299. if (disposeMaterialAndTextures) {
  83300. if (this.material) {
  83301. if (this.material.getClassName() === "MultiMaterial") {
  83302. this.material.dispose(false, true, true);
  83303. }
  83304. else {
  83305. this.material.dispose(false, true);
  83306. }
  83307. }
  83308. }
  83309. if (!doNotRecurse) {
  83310. // Particles
  83311. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  83312. if (this.getScene().particleSystems[index].emitter === this) {
  83313. this.getScene().particleSystems[index].dispose();
  83314. index--;
  83315. }
  83316. }
  83317. }
  83318. // facet data
  83319. if (this._facetData.facetDataEnabled) {
  83320. this.disableFacetData();
  83321. }
  83322. this.onAfterWorldMatrixUpdateObservable.clear();
  83323. this.onCollideObservable.clear();
  83324. this.onCollisionPositionChangeObservable.clear();
  83325. this.onRebuildObservable.clear();
  83326. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  83327. };
  83328. /**
  83329. * Adds the passed mesh as a child to the current mesh
  83330. * @param mesh defines the child mesh
  83331. * @returns the current mesh
  83332. */
  83333. AbstractMesh.prototype.addChild = function (mesh) {
  83334. mesh.setParent(this);
  83335. return this;
  83336. };
  83337. /**
  83338. * Removes the passed mesh from the current mesh children list
  83339. * @param mesh defines the child mesh
  83340. * @returns the current mesh
  83341. */
  83342. AbstractMesh.prototype.removeChild = function (mesh) {
  83343. mesh.setParent(null);
  83344. return this;
  83345. };
  83346. // Facet data
  83347. /** @hidden */
  83348. AbstractMesh.prototype._initFacetData = function () {
  83349. var data = this._facetData;
  83350. if (!data.facetNormals) {
  83351. data.facetNormals = new Array();
  83352. }
  83353. if (!data.facetPositions) {
  83354. data.facetPositions = new Array();
  83355. }
  83356. if (!data.facetPartitioning) {
  83357. data.facetPartitioning = new Array();
  83358. }
  83359. data.facetNb = (this.getIndices().length / 3) | 0;
  83360. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  83361. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  83362. for (var f = 0; f < data.facetNb; f++) {
  83363. data.facetNormals[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83364. data.facetPositions[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83365. }
  83366. data.facetDataEnabled = true;
  83367. return this;
  83368. };
  83369. /**
  83370. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  83371. * This method can be called within the render loop.
  83372. * 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
  83373. * @returns the current mesh
  83374. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83375. */
  83376. AbstractMesh.prototype.updateFacetData = function () {
  83377. var data = this._facetData;
  83378. if (!data.facetDataEnabled) {
  83379. this._initFacetData();
  83380. }
  83381. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  83382. var indices = this.getIndices();
  83383. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  83384. var bInfo = this.getBoundingInfo();
  83385. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  83386. // init arrays, matrix and sort function on first call
  83387. data.facetDepthSortEnabled = true;
  83388. if (indices instanceof Uint16Array) {
  83389. data.depthSortedIndices = new Uint16Array(indices);
  83390. }
  83391. else if (indices instanceof Uint32Array) {
  83392. data.depthSortedIndices = new Uint32Array(indices);
  83393. }
  83394. else {
  83395. var needs32bits = false;
  83396. for (var i = 0; i < indices.length; i++) {
  83397. if (indices[i] > 65535) {
  83398. needs32bits = true;
  83399. break;
  83400. }
  83401. }
  83402. if (needs32bits) {
  83403. data.depthSortedIndices = new Uint32Array(indices);
  83404. }
  83405. else {
  83406. data.depthSortedIndices = new Uint16Array(indices);
  83407. }
  83408. }
  83409. data.facetDepthSortFunction = function (f1, f2) {
  83410. return (f2.sqDistance - f1.sqDistance);
  83411. };
  83412. if (!data.facetDepthSortFrom) {
  83413. var camera = this.getScene().activeCamera;
  83414. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83415. }
  83416. data.depthSortedFacets = [];
  83417. for (var f = 0; f < data.facetNb; f++) {
  83418. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  83419. data.depthSortedFacets.push(depthSortedFacet);
  83420. }
  83421. data.invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  83422. data.facetDepthSortOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83423. }
  83424. 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"];
  83425. 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"];
  83426. 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"];
  83427. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  83428. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  83429. data.subDiv.max = data.partitioningSubdivisions;
  83430. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  83431. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  83432. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  83433. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  83434. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  83435. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  83436. // set the parameters for ComputeNormals()
  83437. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  83438. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  83439. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  83440. data.facetParameters.bInfo = bInfo;
  83441. data.facetParameters.bbSize = data.bbSize;
  83442. data.facetParameters.subDiv = data.subDiv;
  83443. data.facetParameters.ratio = this.partitioningBBoxRatio;
  83444. data.facetParameters.depthSort = data.facetDepthSort;
  83445. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  83446. this.computeWorldMatrix(true);
  83447. this._worldMatrix.invertToRef(data.invertedMatrix);
  83448. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  83449. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  83450. }
  83451. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  83452. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  83453. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  83454. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  83455. var l = (data.depthSortedIndices.length / 3) | 0;
  83456. for (var f = 0; f < l; f++) {
  83457. var sind = data.depthSortedFacets[f].ind;
  83458. data.depthSortedIndices[f * 3] = indices[sind];
  83459. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  83460. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  83461. }
  83462. this.updateIndices(data.depthSortedIndices, undefined, true);
  83463. }
  83464. return this;
  83465. };
  83466. /**
  83467. * Returns the facetLocalNormals array.
  83468. * The normals are expressed in the mesh local spac
  83469. * @returns an array of Vector3
  83470. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83471. */
  83472. AbstractMesh.prototype.getFacetLocalNormals = function () {
  83473. if (!this._facetData.facetNormals) {
  83474. this.updateFacetData();
  83475. }
  83476. return this._facetData.facetNormals;
  83477. };
  83478. /**
  83479. * Returns the facetLocalPositions array.
  83480. * The facet positions are expressed in the mesh local space
  83481. * @returns an array of Vector3
  83482. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83483. */
  83484. AbstractMesh.prototype.getFacetLocalPositions = function () {
  83485. if (!this._facetData.facetPositions) {
  83486. this.updateFacetData();
  83487. }
  83488. return this._facetData.facetPositions;
  83489. };
  83490. /**
  83491. * Returns the facetLocalPartioning array
  83492. * @returns an array of array of numbers
  83493. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83494. */
  83495. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  83496. if (!this._facetData.facetPartitioning) {
  83497. this.updateFacetData();
  83498. }
  83499. return this._facetData.facetPartitioning;
  83500. };
  83501. /**
  83502. * Returns the i-th facet position in the world system.
  83503. * This method allocates a new Vector3 per call
  83504. * @param i defines the facet index
  83505. * @returns a new Vector3
  83506. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83507. */
  83508. AbstractMesh.prototype.getFacetPosition = function (i) {
  83509. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83510. this.getFacetPositionToRef(i, pos);
  83511. return pos;
  83512. };
  83513. /**
  83514. * Sets the reference Vector3 with the i-th facet position in the world system
  83515. * @param i defines the facet index
  83516. * @param ref defines the target vector
  83517. * @returns the current mesh
  83518. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83519. */
  83520. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  83521. var localPos = (this.getFacetLocalPositions())[i];
  83522. var world = this.getWorldMatrix();
  83523. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  83524. return this;
  83525. };
  83526. /**
  83527. * Returns the i-th facet normal in the world system.
  83528. * This method allocates a new Vector3 per call
  83529. * @param i defines the facet index
  83530. * @returns a new Vector3
  83531. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83532. */
  83533. AbstractMesh.prototype.getFacetNormal = function (i) {
  83534. var norm = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  83535. this.getFacetNormalToRef(i, norm);
  83536. return norm;
  83537. };
  83538. /**
  83539. * Sets the reference Vector3 with the i-th facet normal in the world system
  83540. * @param i defines the facet index
  83541. * @param ref defines the target vector
  83542. * @returns the current mesh
  83543. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83544. */
  83545. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  83546. var localNorm = (this.getFacetLocalNormals())[i];
  83547. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  83548. return this;
  83549. };
  83550. /**
  83551. * 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)
  83552. * @param x defines x coordinate
  83553. * @param y defines y coordinate
  83554. * @param z defines z coordinate
  83555. * @returns the array of facet indexes
  83556. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83557. */
  83558. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  83559. var bInfo = this.getBoundingInfo();
  83560. var data = this._facetData;
  83561. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  83562. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  83563. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  83564. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  83565. return null;
  83566. }
  83567. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  83568. };
  83569. /**
  83570. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  83571. * @param projected sets as the (x,y,z) world projection on the facet
  83572. * @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
  83573. * @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
  83574. * @param x defines x coordinate
  83575. * @param y defines y coordinate
  83576. * @param z defines z coordinate
  83577. * @returns the face index if found (or null instead)
  83578. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83579. */
  83580. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  83581. if (checkFace === void 0) { checkFace = false; }
  83582. if (facing === void 0) { facing = true; }
  83583. var world = this.getWorldMatrix();
  83584. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5];
  83585. world.invertToRef(invMat);
  83586. var invVect = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[8];
  83587. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  83588. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  83589. if (projected) {
  83590. // tranform the local computed projected vector to world coordinates
  83591. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  83592. }
  83593. return closest;
  83594. };
  83595. /**
  83596. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  83597. * @param projected sets as the (x,y,z) local projection on the facet
  83598. * @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
  83599. * @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
  83600. * @param x defines x coordinate
  83601. * @param y defines y coordinate
  83602. * @param z defines z coordinate
  83603. * @returns the face index if found (or null instead)
  83604. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83605. */
  83606. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  83607. if (checkFace === void 0) { checkFace = false; }
  83608. if (facing === void 0) { facing = true; }
  83609. var closest = null;
  83610. var tmpx = 0.0;
  83611. var tmpy = 0.0;
  83612. var tmpz = 0.0;
  83613. var d = 0.0; // tmp dot facet normal * facet position
  83614. var t0 = 0.0;
  83615. var projx = 0.0;
  83616. var projy = 0.0;
  83617. var projz = 0.0;
  83618. // Get all the facets in the same partitioning block than (x, y, z)
  83619. var facetPositions = this.getFacetLocalPositions();
  83620. var facetNormals = this.getFacetLocalNormals();
  83621. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  83622. if (!facetsInBlock) {
  83623. return null;
  83624. }
  83625. // Get the closest facet to (x, y, z)
  83626. var shortest = Number.MAX_VALUE; // init distance vars
  83627. var tmpDistance = shortest;
  83628. var fib; // current facet in the block
  83629. var norm; // current facet normal
  83630. var p0; // current facet barycenter position
  83631. // loop on all the facets in the current partitioning block
  83632. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  83633. fib = facetsInBlock[idx];
  83634. norm = facetNormals[fib];
  83635. p0 = facetPositions[fib];
  83636. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  83637. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  83638. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  83639. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  83640. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  83641. projx = x + norm.x * t0;
  83642. projy = y + norm.y * t0;
  83643. projz = z + norm.z * t0;
  83644. tmpx = projx - x;
  83645. tmpy = projy - y;
  83646. tmpz = projz - z;
  83647. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  83648. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  83649. shortest = tmpDistance;
  83650. closest = fib;
  83651. if (projected) {
  83652. projected.x = projx;
  83653. projected.y = projy;
  83654. projected.z = projz;
  83655. }
  83656. }
  83657. }
  83658. }
  83659. return closest;
  83660. };
  83661. /**
  83662. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  83663. * @returns the parameters
  83664. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83665. */
  83666. AbstractMesh.prototype.getFacetDataParameters = function () {
  83667. return this._facetData.facetParameters;
  83668. };
  83669. /**
  83670. * Disables the feature FacetData and frees the related memory
  83671. * @returns the current mesh
  83672. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83673. */
  83674. AbstractMesh.prototype.disableFacetData = function () {
  83675. if (this._facetData.facetDataEnabled) {
  83676. this._facetData.facetDataEnabled = false;
  83677. this._facetData.facetPositions = new Array();
  83678. this._facetData.facetNormals = new Array();
  83679. this._facetData.facetPartitioning = new Array();
  83680. this._facetData.facetParameters = null;
  83681. this._facetData.depthSortedIndices = new Uint32Array(0);
  83682. }
  83683. return this;
  83684. };
  83685. /**
  83686. * Updates the AbstractMesh indices array
  83687. * @param indices defines the data source
  83688. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83689. * @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)
  83690. * @returns the current mesh
  83691. */
  83692. AbstractMesh.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  83693. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  83694. return this;
  83695. };
  83696. /**
  83697. * Creates new normals data for the mesh
  83698. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  83699. * @returns the current mesh
  83700. */
  83701. AbstractMesh.prototype.createNormals = function (updatable) {
  83702. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  83703. var indices = this.getIndices();
  83704. var normals;
  83705. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  83706. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  83707. }
  83708. else {
  83709. normals = [];
  83710. }
  83711. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  83712. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  83713. return this;
  83714. };
  83715. /**
  83716. * Align the mesh with a normal
  83717. * @param normal defines the normal to use
  83718. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  83719. * @returns the current mesh
  83720. */
  83721. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  83722. if (!upDirection) {
  83723. upDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y;
  83724. }
  83725. var axisX = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  83726. var axisZ = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  83727. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  83728. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  83729. if (this.rotationQuaternion) {
  83730. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  83731. }
  83732. else {
  83733. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  83734. }
  83735. return this;
  83736. };
  83737. /** @hidden */
  83738. AbstractMesh.prototype._checkOcclusionQuery = function () {
  83739. return false;
  83740. };
  83741. /** No occlusion */
  83742. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  83743. /** Occlusion set to optimisitic */
  83744. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  83745. /** Occlusion set to strict */
  83746. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  83747. /** Use an accurante occlusion algorithm */
  83748. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  83749. /** Use a conservative occlusion algorithm */
  83750. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  83751. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  83752. * Test order :
  83753. * Is the bounding sphere outside the frustum ?
  83754. * If not, are the bounding box vertices outside the frustum ?
  83755. * It not, then the cullable object is in the frustum.
  83756. */
  83757. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  83758. /** Culling strategy : Bounding Sphere Only.
  83759. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  83760. * It's also less accurate than the standard because some not visible objects can still be selected.
  83761. * Test : is the bounding sphere outside the frustum ?
  83762. * If not, then the cullable object is in the frustum.
  83763. */
  83764. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  83765. /** Culling strategy : Optimistic Inclusion.
  83766. * This in an inclusion test first, then the standard exclusion test.
  83767. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  83768. * 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.
  83769. * Anyway, it's as accurate as the standard strategy.
  83770. * Test :
  83771. * Is the cullable object bounding sphere center in the frustum ?
  83772. * If not, apply the default culling strategy.
  83773. */
  83774. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  83775. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  83776. * This in an inclusion test first, then the bounding sphere only exclusion test.
  83777. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  83778. * 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.
  83779. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  83780. * Test :
  83781. * Is the cullable object bounding sphere center in the frustum ?
  83782. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  83783. */
  83784. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  83785. return AbstractMesh;
  83786. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  83787. /***/ }),
  83788. /***/ "./Meshes/buffer.ts":
  83789. /*!**************************!*\
  83790. !*** ./Meshes/buffer.ts ***!
  83791. \**************************/
  83792. /*! exports provided: Buffer, VertexBuffer */
  83793. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83794. "use strict";
  83795. __webpack_require__.r(__webpack_exports__);
  83796. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  83797. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  83798. /**
  83799. * Class used to store data that will be store in GPU memory
  83800. */
  83801. var Buffer = /** @class */ (function () {
  83802. /**
  83803. * Constructor
  83804. * @param engine the engine
  83805. * @param data the data to use for this buffer
  83806. * @param updatable whether the data is updatable
  83807. * @param stride the stride (optional)
  83808. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  83809. * @param instanced whether the buffer is instanced (optional)
  83810. * @param useBytes set to true if the stride in in bytes (optional)
  83811. */
  83812. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  83813. if (stride === void 0) { stride = 0; }
  83814. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  83815. if (instanced === void 0) { instanced = false; }
  83816. if (useBytes === void 0) { useBytes = false; }
  83817. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  83818. this._engine = engine.getScene().getEngine();
  83819. }
  83820. else {
  83821. this._engine = engine;
  83822. }
  83823. this._updatable = updatable;
  83824. this._instanced = instanced;
  83825. this._data = data;
  83826. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  83827. if (!postponeInternalCreation) { // by default
  83828. this.create();
  83829. }
  83830. }
  83831. /**
  83832. * Create a new VertexBuffer based on the current buffer
  83833. * @param kind defines the vertex buffer kind (position, normal, etc.)
  83834. * @param offset defines offset in the buffer (0 by default)
  83835. * @param size defines the size in floats of attributes (position is 3 for instance)
  83836. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  83837. * @param instanced defines if the vertex buffer contains indexed data
  83838. * @param useBytes defines if the offset and stride are in bytes
  83839. * @returns the new vertex buffer
  83840. */
  83841. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  83842. if (useBytes === void 0) { useBytes = false; }
  83843. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  83844. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  83845. // a lot of these parameters are ignored as they are overriden by the buffer
  83846. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  83847. };
  83848. // Properties
  83849. /**
  83850. * Gets a boolean indicating if the Buffer is updatable?
  83851. * @returns true if the buffer is updatable
  83852. */
  83853. Buffer.prototype.isUpdatable = function () {
  83854. return this._updatable;
  83855. };
  83856. /**
  83857. * Gets current buffer's data
  83858. * @returns a DataArray or null
  83859. */
  83860. Buffer.prototype.getData = function () {
  83861. return this._data;
  83862. };
  83863. /**
  83864. * Gets underlying native buffer
  83865. * @returns underlying native buffer
  83866. */
  83867. Buffer.prototype.getBuffer = function () {
  83868. return this._buffer;
  83869. };
  83870. /**
  83871. * Gets the stride in float32 units (i.e. byte stride / 4).
  83872. * May not be an integer if the byte stride is not divisible by 4.
  83873. * DEPRECATED. Use byteStride instead.
  83874. * @returns the stride in float32 units
  83875. */
  83876. Buffer.prototype.getStrideSize = function () {
  83877. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  83878. };
  83879. // Methods
  83880. /**
  83881. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  83882. * @param data defines the data to store
  83883. */
  83884. Buffer.prototype.create = function (data) {
  83885. if (data === void 0) { data = null; }
  83886. if (!data && this._buffer) {
  83887. return; // nothing to do
  83888. }
  83889. data = data || this._data;
  83890. if (!data) {
  83891. return;
  83892. }
  83893. if (!this._buffer) { // create buffer
  83894. if (this._updatable) {
  83895. this._buffer = this._engine.createDynamicVertexBuffer(data);
  83896. this._data = data;
  83897. }
  83898. else {
  83899. this._buffer = this._engine.createVertexBuffer(data);
  83900. }
  83901. }
  83902. else if (this._updatable) { // update buffer
  83903. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  83904. this._data = data;
  83905. }
  83906. };
  83907. /** @hidden */
  83908. Buffer.prototype._rebuild = function () {
  83909. this._buffer = null;
  83910. this.create(this._data);
  83911. };
  83912. /**
  83913. * Update current buffer data
  83914. * @param data defines the data to store
  83915. */
  83916. Buffer.prototype.update = function (data) {
  83917. this.create(data);
  83918. };
  83919. /**
  83920. * Updates the data directly.
  83921. * @param data the new data
  83922. * @param offset the new offset
  83923. * @param vertexCount the vertex count (optional)
  83924. * @param useBytes set to true if the offset is in bytes
  83925. */
  83926. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  83927. if (useBytes === void 0) { useBytes = false; }
  83928. if (!this._buffer) {
  83929. return;
  83930. }
  83931. if (this._updatable) { // update buffer
  83932. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  83933. this._data = null;
  83934. }
  83935. };
  83936. /**
  83937. * Release all resources
  83938. */
  83939. Buffer.prototype.dispose = function () {
  83940. if (!this._buffer) {
  83941. return;
  83942. }
  83943. if (this._engine._releaseBuffer(this._buffer)) {
  83944. this._buffer = null;
  83945. }
  83946. };
  83947. return Buffer;
  83948. }());
  83949. /**
  83950. * Specialized buffer used to store vertex data
  83951. */
  83952. var VertexBuffer = /** @class */ (function () {
  83953. /**
  83954. * Constructor
  83955. * @param engine the engine
  83956. * @param data the data to use for this vertex buffer
  83957. * @param kind the vertex buffer kind
  83958. * @param updatable whether the data is updatable
  83959. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  83960. * @param stride the stride (optional)
  83961. * @param instanced whether the buffer is instanced (optional)
  83962. * @param offset the offset of the data (optional)
  83963. * @param size the number of components (optional)
  83964. * @param type the type of the component (optional)
  83965. * @param normalized whether the data contains normalized data (optional)
  83966. * @param useBytes set to true if stride and offset are in bytes (optional)
  83967. */
  83968. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  83969. if (normalized === void 0) { normalized = false; }
  83970. if (useBytes === void 0) { useBytes = false; }
  83971. if (data instanceof Buffer) {
  83972. this._buffer = data;
  83973. this._ownsBuffer = false;
  83974. }
  83975. else {
  83976. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  83977. this._ownsBuffer = true;
  83978. }
  83979. this._kind = kind;
  83980. if (type == undefined) {
  83981. var data_1 = this.getData();
  83982. this.type = VertexBuffer.FLOAT;
  83983. if (data_1 instanceof Int8Array) {
  83984. this.type = VertexBuffer.BYTE;
  83985. }
  83986. else if (data_1 instanceof Uint8Array) {
  83987. this.type = VertexBuffer.UNSIGNED_BYTE;
  83988. }
  83989. else if (data_1 instanceof Int16Array) {
  83990. this.type = VertexBuffer.SHORT;
  83991. }
  83992. else if (data_1 instanceof Uint16Array) {
  83993. this.type = VertexBuffer.UNSIGNED_SHORT;
  83994. }
  83995. else if (data_1 instanceof Int32Array) {
  83996. this.type = VertexBuffer.INT;
  83997. }
  83998. else if (data_1 instanceof Uint32Array) {
  83999. this.type = VertexBuffer.UNSIGNED_INT;
  84000. }
  84001. }
  84002. else {
  84003. this.type = type;
  84004. }
  84005. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  84006. if (useBytes) {
  84007. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  84008. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  84009. this.byteOffset = offset || 0;
  84010. }
  84011. else {
  84012. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  84013. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  84014. this.byteOffset = (offset || 0) * typeByteLength;
  84015. }
  84016. this.normalized = normalized;
  84017. this._instanced = instanced !== undefined ? instanced : false;
  84018. this._instanceDivisor = instanced ? 1 : 0;
  84019. }
  84020. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  84021. /**
  84022. * Gets or sets the instance divisor when in instanced mode
  84023. */
  84024. get: function () {
  84025. return this._instanceDivisor;
  84026. },
  84027. set: function (value) {
  84028. this._instanceDivisor = value;
  84029. if (value == 0) {
  84030. this._instanced = false;
  84031. }
  84032. else {
  84033. this._instanced = true;
  84034. }
  84035. },
  84036. enumerable: true,
  84037. configurable: true
  84038. });
  84039. /** @hidden */
  84040. VertexBuffer.prototype._rebuild = function () {
  84041. if (!this._buffer) {
  84042. return;
  84043. }
  84044. this._buffer._rebuild();
  84045. };
  84046. /**
  84047. * Returns the kind of the VertexBuffer (string)
  84048. * @returns a string
  84049. */
  84050. VertexBuffer.prototype.getKind = function () {
  84051. return this._kind;
  84052. };
  84053. // Properties
  84054. /**
  84055. * Gets a boolean indicating if the VertexBuffer is updatable?
  84056. * @returns true if the buffer is updatable
  84057. */
  84058. VertexBuffer.prototype.isUpdatable = function () {
  84059. return this._buffer.isUpdatable();
  84060. };
  84061. /**
  84062. * Gets current buffer's data
  84063. * @returns a DataArray or null
  84064. */
  84065. VertexBuffer.prototype.getData = function () {
  84066. return this._buffer.getData();
  84067. };
  84068. /**
  84069. * Gets underlying native buffer
  84070. * @returns underlying native buffer
  84071. */
  84072. VertexBuffer.prototype.getBuffer = function () {
  84073. return this._buffer.getBuffer();
  84074. };
  84075. /**
  84076. * Gets the stride in float32 units (i.e. byte stride / 4).
  84077. * May not be an integer if the byte stride is not divisible by 4.
  84078. * DEPRECATED. Use byteStride instead.
  84079. * @returns the stride in float32 units
  84080. */
  84081. VertexBuffer.prototype.getStrideSize = function () {
  84082. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  84083. };
  84084. /**
  84085. * Returns the offset as a multiple of the type byte length.
  84086. * DEPRECATED. Use byteOffset instead.
  84087. * @returns the offset in bytes
  84088. */
  84089. VertexBuffer.prototype.getOffset = function () {
  84090. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  84091. };
  84092. /**
  84093. * Returns the number of components per vertex attribute (integer)
  84094. * @returns the size in float
  84095. */
  84096. VertexBuffer.prototype.getSize = function () {
  84097. return this._size;
  84098. };
  84099. /**
  84100. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  84101. * @returns true if this buffer is instanced
  84102. */
  84103. VertexBuffer.prototype.getIsInstanced = function () {
  84104. return this._instanced;
  84105. };
  84106. /**
  84107. * Returns the instancing divisor, zero for non-instanced (integer).
  84108. * @returns a number
  84109. */
  84110. VertexBuffer.prototype.getInstanceDivisor = function () {
  84111. return this._instanceDivisor;
  84112. };
  84113. // Methods
  84114. /**
  84115. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84116. * @param data defines the data to store
  84117. */
  84118. VertexBuffer.prototype.create = function (data) {
  84119. this._buffer.create(data);
  84120. };
  84121. /**
  84122. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  84123. * This function will create a new buffer if the current one is not updatable
  84124. * @param data defines the data to store
  84125. */
  84126. VertexBuffer.prototype.update = function (data) {
  84127. this._buffer.update(data);
  84128. };
  84129. /**
  84130. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  84131. * Returns the directly updated WebGLBuffer.
  84132. * @param data the new data
  84133. * @param offset the new offset
  84134. * @param useBytes set to true if the offset is in bytes
  84135. */
  84136. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  84137. if (useBytes === void 0) { useBytes = false; }
  84138. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  84139. };
  84140. /**
  84141. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  84142. */
  84143. VertexBuffer.prototype.dispose = function () {
  84144. if (this._ownsBuffer) {
  84145. this._buffer.dispose();
  84146. }
  84147. };
  84148. /**
  84149. * Enumerates each value of this vertex buffer as numbers.
  84150. * @param count the number of values to enumerate
  84151. * @param callback the callback function called for each value
  84152. */
  84153. VertexBuffer.prototype.forEach = function (count, callback) {
  84154. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  84155. };
  84156. /**
  84157. * Deduces the stride given a kind.
  84158. * @param kind The kind string to deduce
  84159. * @returns The deduced stride
  84160. */
  84161. VertexBuffer.DeduceStride = function (kind) {
  84162. switch (kind) {
  84163. case VertexBuffer.UVKind:
  84164. case VertexBuffer.UV2Kind:
  84165. case VertexBuffer.UV3Kind:
  84166. case VertexBuffer.UV4Kind:
  84167. case VertexBuffer.UV5Kind:
  84168. case VertexBuffer.UV6Kind:
  84169. return 2;
  84170. case VertexBuffer.NormalKind:
  84171. case VertexBuffer.PositionKind:
  84172. return 3;
  84173. case VertexBuffer.ColorKind:
  84174. case VertexBuffer.MatricesIndicesKind:
  84175. case VertexBuffer.MatricesIndicesExtraKind:
  84176. case VertexBuffer.MatricesWeightsKind:
  84177. case VertexBuffer.MatricesWeightsExtraKind:
  84178. case VertexBuffer.TangentKind:
  84179. return 4;
  84180. default:
  84181. throw new Error("Invalid kind '" + kind + "'");
  84182. }
  84183. };
  84184. /**
  84185. * Gets the byte length of the given type.
  84186. * @param type the type
  84187. * @returns the number of bytes
  84188. */
  84189. VertexBuffer.GetTypeByteLength = function (type) {
  84190. switch (type) {
  84191. case VertexBuffer.BYTE:
  84192. case VertexBuffer.UNSIGNED_BYTE:
  84193. return 1;
  84194. case VertexBuffer.SHORT:
  84195. case VertexBuffer.UNSIGNED_SHORT:
  84196. return 2;
  84197. case VertexBuffer.INT:
  84198. case VertexBuffer.FLOAT:
  84199. return 4;
  84200. default:
  84201. throw new Error("Invalid type '" + type + "'");
  84202. }
  84203. };
  84204. /**
  84205. * Enumerates each value of the given parameters as numbers.
  84206. * @param data the data to enumerate
  84207. * @param byteOffset the byte offset of the data
  84208. * @param byteStride the byte stride of the data
  84209. * @param componentCount the number of components per element
  84210. * @param componentType the type of the component
  84211. * @param count the total number of components
  84212. * @param normalized whether the data is normalized
  84213. * @param callback the callback function called for each value
  84214. */
  84215. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  84216. if (data instanceof Array) {
  84217. var offset = byteOffset / 4;
  84218. var stride = byteStride / 4;
  84219. for (var index = 0; index < count; index += componentCount) {
  84220. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  84221. callback(data[offset + componentIndex], index + componentIndex);
  84222. }
  84223. offset += stride;
  84224. }
  84225. }
  84226. else {
  84227. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  84228. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  84229. for (var index = 0; index < count; index += componentCount) {
  84230. var componentByteOffset = byteOffset;
  84231. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  84232. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  84233. callback(value, index + componentIndex);
  84234. componentByteOffset += componentByteLength;
  84235. }
  84236. byteOffset += byteStride;
  84237. }
  84238. }
  84239. };
  84240. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  84241. switch (type) {
  84242. case VertexBuffer.BYTE: {
  84243. var value = dataView.getInt8(byteOffset);
  84244. if (normalized) {
  84245. value = Math.max(value / 127, -1);
  84246. }
  84247. return value;
  84248. }
  84249. case VertexBuffer.UNSIGNED_BYTE: {
  84250. var value = dataView.getUint8(byteOffset);
  84251. if (normalized) {
  84252. value = value / 255;
  84253. }
  84254. return value;
  84255. }
  84256. case VertexBuffer.SHORT: {
  84257. var value = dataView.getInt16(byteOffset, true);
  84258. if (normalized) {
  84259. value = Math.max(value / 16383, -1);
  84260. }
  84261. return value;
  84262. }
  84263. case VertexBuffer.UNSIGNED_SHORT: {
  84264. var value = dataView.getUint16(byteOffset, true);
  84265. if (normalized) {
  84266. value = value / 65535;
  84267. }
  84268. return value;
  84269. }
  84270. case VertexBuffer.FLOAT: {
  84271. return dataView.getFloat32(byteOffset, true);
  84272. }
  84273. default: {
  84274. throw new Error("Invalid component type " + type);
  84275. }
  84276. }
  84277. };
  84278. /**
  84279. * The byte type.
  84280. */
  84281. VertexBuffer.BYTE = 5120;
  84282. /**
  84283. * The unsigned byte type.
  84284. */
  84285. VertexBuffer.UNSIGNED_BYTE = 5121;
  84286. /**
  84287. * The short type.
  84288. */
  84289. VertexBuffer.SHORT = 5122;
  84290. /**
  84291. * The unsigned short type.
  84292. */
  84293. VertexBuffer.UNSIGNED_SHORT = 5123;
  84294. /**
  84295. * The integer type.
  84296. */
  84297. VertexBuffer.INT = 5124;
  84298. /**
  84299. * The unsigned integer type.
  84300. */
  84301. VertexBuffer.UNSIGNED_INT = 5125;
  84302. /**
  84303. * The float type.
  84304. */
  84305. VertexBuffer.FLOAT = 5126;
  84306. // Enums
  84307. /**
  84308. * Positions
  84309. */
  84310. VertexBuffer.PositionKind = "position";
  84311. /**
  84312. * Normals
  84313. */
  84314. VertexBuffer.NormalKind = "normal";
  84315. /**
  84316. * Tangents
  84317. */
  84318. VertexBuffer.TangentKind = "tangent";
  84319. /**
  84320. * Texture coordinates
  84321. */
  84322. VertexBuffer.UVKind = "uv";
  84323. /**
  84324. * Texture coordinates 2
  84325. */
  84326. VertexBuffer.UV2Kind = "uv2";
  84327. /**
  84328. * Texture coordinates 3
  84329. */
  84330. VertexBuffer.UV3Kind = "uv3";
  84331. /**
  84332. * Texture coordinates 4
  84333. */
  84334. VertexBuffer.UV4Kind = "uv4";
  84335. /**
  84336. * Texture coordinates 5
  84337. */
  84338. VertexBuffer.UV5Kind = "uv5";
  84339. /**
  84340. * Texture coordinates 6
  84341. */
  84342. VertexBuffer.UV6Kind = "uv6";
  84343. /**
  84344. * Colors
  84345. */
  84346. VertexBuffer.ColorKind = "color";
  84347. /**
  84348. * Matrix indices (for bones)
  84349. */
  84350. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  84351. /**
  84352. * Matrix weights (for bones)
  84353. */
  84354. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  84355. /**
  84356. * Additional matrix indices (for bones)
  84357. */
  84358. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  84359. /**
  84360. * Additional matrix weights (for bones)
  84361. */
  84362. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  84363. return VertexBuffer;
  84364. }());
  84365. /***/ }),
  84366. /***/ "./Meshes/csg.ts":
  84367. /*!***********************!*\
  84368. !*** ./Meshes/csg.ts ***!
  84369. \***********************/
  84370. /*! exports provided: CSG */
  84371. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  84372. "use strict";
  84373. __webpack_require__.r(__webpack_exports__);
  84374. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  84375. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  84376. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  84377. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  84378. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  84379. /**
  84380. * Unique ID when we import meshes from Babylon to CSG
  84381. */
  84382. var currentCSGMeshId = 0;
  84383. /**
  84384. * Represents a vertex of a polygon. Use your own vertex class instead of this
  84385. * one to provide additional features like texture coordinates and vertex
  84386. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  84387. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  84388. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  84389. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  84390. * is not used anywhere else.
  84391. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  84392. */
  84393. var Vertex = /** @class */ (function () {
  84394. /**
  84395. * Initializes the vertex
  84396. * @param pos The position of the vertex
  84397. * @param normal The normal of the vertex
  84398. * @param uv The texture coordinate of the vertex
  84399. */
  84400. function Vertex(
  84401. /**
  84402. * The position of the vertex
  84403. */
  84404. pos,
  84405. /**
  84406. * The normal of the vertex
  84407. */
  84408. normal,
  84409. /**
  84410. * The texture coordinate of the vertex
  84411. */
  84412. uv) {
  84413. this.pos = pos;
  84414. this.normal = normal;
  84415. this.uv = uv;
  84416. }
  84417. /**
  84418. * Make a clone, or deep copy, of the vertex
  84419. * @returns A new Vertex
  84420. */
  84421. Vertex.prototype.clone = function () {
  84422. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  84423. };
  84424. /**
  84425. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  84426. * orientation of a polygon is flipped.
  84427. */
  84428. Vertex.prototype.flip = function () {
  84429. this.normal = this.normal.scale(-1);
  84430. };
  84431. /**
  84432. * Create a new vertex between this vertex and `other` by linearly
  84433. * interpolating all properties using a parameter of `t`. Subclasses should
  84434. * override this to interpolate additional properties.
  84435. * @param other the vertex to interpolate against
  84436. * @param t The factor used to linearly interpolate between the vertices
  84437. */
  84438. Vertex.prototype.interpolate = function (other, t) {
  84439. 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));
  84440. };
  84441. return Vertex;
  84442. }());
  84443. /**
  84444. * Represents a plane in 3D space.
  84445. */
  84446. var Plane = /** @class */ (function () {
  84447. /**
  84448. * Initializes the plane
  84449. * @param normal The normal for the plane
  84450. * @param w
  84451. */
  84452. function Plane(normal, w) {
  84453. this.normal = normal;
  84454. this.w = w;
  84455. }
  84456. /**
  84457. * Construct a plane from three points
  84458. * @param a Point a
  84459. * @param b Point b
  84460. * @param c Point c
  84461. */
  84462. Plane.FromPoints = function (a, b, c) {
  84463. var v0 = c.subtract(a);
  84464. var v1 = b.subtract(a);
  84465. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  84466. return null;
  84467. }
  84468. var n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  84469. return new Plane(n, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  84470. };
  84471. /**
  84472. * Clone, or make a deep copy of the plane
  84473. * @returns a new Plane
  84474. */
  84475. Plane.prototype.clone = function () {
  84476. return new Plane(this.normal.clone(), this.w);
  84477. };
  84478. /**
  84479. * Flip the face of the plane
  84480. */
  84481. Plane.prototype.flip = function () {
  84482. this.normal.scaleInPlace(-1);
  84483. this.w = -this.w;
  84484. };
  84485. /**
  84486. * Split `polygon` by this plane if needed, then put the polygon or polygon
  84487. * fragments in the appropriate lists. Coplanar polygons go into either
  84488. `* coplanarFront` or `coplanarBack` depending on their orientation with
  84489. * respect to this plane. Polygons in front or in back of this plane go into
  84490. * either `front` or `back`
  84491. * @param polygon The polygon to be split
  84492. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  84493. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  84494. * @param front Will contain the polygons in front of the plane
  84495. * @param back Will contain the polygons begind the plane
  84496. */
  84497. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  84498. var COPLANAR = 0;
  84499. var FRONT = 1;
  84500. var BACK = 2;
  84501. var SPANNING = 3;
  84502. // Classify each point as well as the entire polygon into one of the above
  84503. // four classes.
  84504. var polygonType = 0;
  84505. var types = [];
  84506. var i;
  84507. var t;
  84508. for (i = 0; i < polygon.vertices.length; i++) {
  84509. t = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  84510. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  84511. polygonType |= type;
  84512. types.push(type);
  84513. }
  84514. // Put the polygon in the correct list, splitting it when necessary
  84515. switch (polygonType) {
  84516. case COPLANAR:
  84517. (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  84518. break;
  84519. case FRONT:
  84520. front.push(polygon);
  84521. break;
  84522. case BACK:
  84523. back.push(polygon);
  84524. break;
  84525. case SPANNING:
  84526. var f = [], b = [];
  84527. for (i = 0; i < polygon.vertices.length; i++) {
  84528. var j = (i + 1) % polygon.vertices.length;
  84529. var ti = types[i], tj = types[j];
  84530. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  84531. if (ti !== BACK) {
  84532. f.push(vi);
  84533. }
  84534. if (ti !== FRONT) {
  84535. b.push(ti !== BACK ? vi.clone() : vi);
  84536. }
  84537. if ((ti | tj) === SPANNING) {
  84538. 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));
  84539. var v = vi.interpolate(vj, t);
  84540. f.push(v);
  84541. b.push(v.clone());
  84542. }
  84543. }
  84544. var poly;
  84545. if (f.length >= 3) {
  84546. poly = new Polygon(f, polygon.shared);
  84547. if (poly.plane) {
  84548. front.push(poly);
  84549. }
  84550. }
  84551. if (b.length >= 3) {
  84552. poly = new Polygon(b, polygon.shared);
  84553. if (poly.plane) {
  84554. back.push(poly);
  84555. }
  84556. }
  84557. break;
  84558. }
  84559. };
  84560. /**
  84561. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  84562. * point is on the plane
  84563. */
  84564. Plane.EPSILON = 1e-5;
  84565. return Plane;
  84566. }());
  84567. /**
  84568. * Represents a convex polygon. The vertices used to initialize a polygon must
  84569. * be coplanar and form a convex loop.
  84570. *
  84571. * Each convex polygon has a `shared` property, which is shared between all
  84572. * polygons that are clones of each other or were split from the same polygon.
  84573. * This can be used to define per-polygon properties (such as surface color)
  84574. */
  84575. var Polygon = /** @class */ (function () {
  84576. /**
  84577. * Initializes the polygon
  84578. * @param vertices The vertices of the polygon
  84579. * @param shared The properties shared across all polygons
  84580. */
  84581. function Polygon(vertices, shared) {
  84582. this.vertices = vertices;
  84583. this.shared = shared;
  84584. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  84585. }
  84586. /**
  84587. * Clones, or makes a deep copy, or the polygon
  84588. */
  84589. Polygon.prototype.clone = function () {
  84590. var vertices = this.vertices.map(function (v) { return v.clone(); });
  84591. return new Polygon(vertices, this.shared);
  84592. };
  84593. /**
  84594. * Flips the faces of the polygon
  84595. */
  84596. Polygon.prototype.flip = function () {
  84597. this.vertices.reverse().map(function (v) { v.flip(); });
  84598. this.plane.flip();
  84599. };
  84600. return Polygon;
  84601. }());
  84602. /**
  84603. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  84604. * by picking a polygon to split along. That polygon (and all other coplanar
  84605. * polygons) are added directly to that node and the other polygons are added to
  84606. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  84607. * no distinction between internal and leaf nodes
  84608. */
  84609. var Node = /** @class */ (function () {
  84610. /**
  84611. * Initializes the node
  84612. * @param polygons A collection of polygons held in the node
  84613. */
  84614. function Node(polygons) {
  84615. this.plane = null;
  84616. this.front = null;
  84617. this.back = null;
  84618. this.polygons = new Array();
  84619. if (polygons) {
  84620. this.build(polygons);
  84621. }
  84622. }
  84623. /**
  84624. * Clones, or makes a deep copy, of the node
  84625. * @returns The cloned node
  84626. */
  84627. Node.prototype.clone = function () {
  84628. var node = new Node();
  84629. node.plane = this.plane && this.plane.clone();
  84630. node.front = this.front && this.front.clone();
  84631. node.back = this.back && this.back.clone();
  84632. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  84633. return node;
  84634. };
  84635. /**
  84636. * Convert solid space to empty space and empty space to solid space
  84637. */
  84638. Node.prototype.invert = function () {
  84639. for (var i = 0; i < this.polygons.length; i++) {
  84640. this.polygons[i].flip();
  84641. }
  84642. if (this.plane) {
  84643. this.plane.flip();
  84644. }
  84645. if (this.front) {
  84646. this.front.invert();
  84647. }
  84648. if (this.back) {
  84649. this.back.invert();
  84650. }
  84651. var temp = this.front;
  84652. this.front = this.back;
  84653. this.back = temp;
  84654. };
  84655. /**
  84656. * Recursively remove all polygons in `polygons` that are inside this BSP
  84657. * tree.
  84658. * @param polygons Polygons to remove from the BSP
  84659. * @returns Polygons clipped from the BSP
  84660. */
  84661. Node.prototype.clipPolygons = function (polygons) {
  84662. if (!this.plane) {
  84663. return polygons.slice();
  84664. }
  84665. var front = new Array(), back = new Array();
  84666. for (var i = 0; i < polygons.length; i++) {
  84667. this.plane.splitPolygon(polygons[i], front, back, front, back);
  84668. }
  84669. if (this.front) {
  84670. front = this.front.clipPolygons(front);
  84671. }
  84672. if (this.back) {
  84673. back = this.back.clipPolygons(back);
  84674. }
  84675. else {
  84676. back = [];
  84677. }
  84678. return front.concat(back);
  84679. };
  84680. /**
  84681. * Remove all polygons in this BSP tree that are inside the other BSP tree
  84682. * `bsp`.
  84683. * @param bsp BSP containing polygons to remove from this BSP
  84684. */
  84685. Node.prototype.clipTo = function (bsp) {
  84686. this.polygons = bsp.clipPolygons(this.polygons);
  84687. if (this.front) {
  84688. this.front.clipTo(bsp);
  84689. }
  84690. if (this.back) {
  84691. this.back.clipTo(bsp);
  84692. }
  84693. };
  84694. /**
  84695. * Return a list of all polygons in this BSP tree
  84696. * @returns List of all polygons in this BSP tree
  84697. */
  84698. Node.prototype.allPolygons = function () {
  84699. var polygons = this.polygons.slice();
  84700. if (this.front) {
  84701. polygons = polygons.concat(this.front.allPolygons());
  84702. }
  84703. if (this.back) {
  84704. polygons = polygons.concat(this.back.allPolygons());
  84705. }
  84706. return polygons;
  84707. };
  84708. /**
  84709. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  84710. * new polygons are filtered down to the bottom of the tree and become new
  84711. * nodes there. Each set of polygons is partitioned using the first polygon
  84712. * (no heuristic is used to pick a good split)
  84713. * @param polygons Polygons used to construct the BSP tree
  84714. */
  84715. Node.prototype.build = function (polygons) {
  84716. if (!polygons.length) {
  84717. return;
  84718. }
  84719. if (!this.plane) {
  84720. this.plane = polygons[0].plane.clone();
  84721. }
  84722. var front = new Array(), back = new Array();
  84723. for (var i = 0; i < polygons.length; i++) {
  84724. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  84725. }
  84726. if (front.length) {
  84727. if (!this.front) {
  84728. this.front = new Node();
  84729. }
  84730. this.front.build(front);
  84731. }
  84732. if (back.length) {
  84733. if (!this.back) {
  84734. this.back = new Node();
  84735. }
  84736. this.back.build(back);
  84737. }
  84738. };
  84739. return Node;
  84740. }());
  84741. /**
  84742. * Class for building Constructive Solid Geometry
  84743. */
  84744. var CSG = /** @class */ (function () {
  84745. function CSG() {
  84746. this.polygons = new Array();
  84747. }
  84748. /**
  84749. * Convert the Mesh to CSG
  84750. * @param mesh The Mesh to convert to CSG
  84751. * @returns A new CSG from the Mesh
  84752. */
  84753. CSG.FromMesh = function (mesh) {
  84754. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  84755. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  84756. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  84757. mesh.computeWorldMatrix(true);
  84758. matrix = mesh.getWorldMatrix();
  84759. meshPosition = mesh.position.clone();
  84760. meshRotation = mesh.rotation.clone();
  84761. if (mesh.rotationQuaternion) {
  84762. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  84763. }
  84764. meshScaling = mesh.scaling.clone();
  84765. }
  84766. else {
  84767. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  84768. }
  84769. 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);
  84770. var subMeshes = mesh.subMeshes;
  84771. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  84772. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  84773. vertices = [];
  84774. for (var j = 0; j < 3; j++) {
  84775. 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]);
  84776. uv = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  84777. 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]);
  84778. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  84779. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  84780. vertex = new Vertex(position, normal, uv);
  84781. vertices.push(vertex);
  84782. }
  84783. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  84784. // To handle the case of degenerated triangle
  84785. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  84786. if (polygon.plane) {
  84787. polygons.push(polygon);
  84788. }
  84789. }
  84790. }
  84791. var csg = CSG.FromPolygons(polygons);
  84792. csg.matrix = matrix;
  84793. csg.position = meshPosition;
  84794. csg.rotation = meshRotation;
  84795. csg.scaling = meshScaling;
  84796. csg.rotationQuaternion = meshRotationQuaternion;
  84797. currentCSGMeshId++;
  84798. return csg;
  84799. };
  84800. /**
  84801. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  84802. * @param polygons Polygons used to construct a CSG solid
  84803. */
  84804. CSG.FromPolygons = function (polygons) {
  84805. var csg = new CSG();
  84806. csg.polygons = polygons;
  84807. return csg;
  84808. };
  84809. /**
  84810. * Clones, or makes a deep copy, of the CSG
  84811. * @returns A new CSG
  84812. */
  84813. CSG.prototype.clone = function () {
  84814. var csg = new CSG();
  84815. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  84816. csg.copyTransformAttributes(this);
  84817. return csg;
  84818. };
  84819. /**
  84820. * Unions this CSG with another CSG
  84821. * @param csg The CSG to union against this CSG
  84822. * @returns The unioned CSG
  84823. */
  84824. CSG.prototype.union = function (csg) {
  84825. var a = new Node(this.clone().polygons);
  84826. var b = new Node(csg.clone().polygons);
  84827. a.clipTo(b);
  84828. b.clipTo(a);
  84829. b.invert();
  84830. b.clipTo(a);
  84831. b.invert();
  84832. a.build(b.allPolygons());
  84833. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  84834. };
  84835. /**
  84836. * Unions this CSG with another CSG in place
  84837. * @param csg The CSG to union against this CSG
  84838. */
  84839. CSG.prototype.unionInPlace = function (csg) {
  84840. var a = new Node(this.polygons);
  84841. var b = new Node(csg.polygons);
  84842. a.clipTo(b);
  84843. b.clipTo(a);
  84844. b.invert();
  84845. b.clipTo(a);
  84846. b.invert();
  84847. a.build(b.allPolygons());
  84848. this.polygons = a.allPolygons();
  84849. };
  84850. /**
  84851. * Subtracts this CSG with another CSG
  84852. * @param csg The CSG to subtract against this CSG
  84853. * @returns A new CSG
  84854. */
  84855. CSG.prototype.subtract = function (csg) {
  84856. var a = new Node(this.clone().polygons);
  84857. var b = new Node(csg.clone().polygons);
  84858. a.invert();
  84859. a.clipTo(b);
  84860. b.clipTo(a);
  84861. b.invert();
  84862. b.clipTo(a);
  84863. b.invert();
  84864. a.build(b.allPolygons());
  84865. a.invert();
  84866. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  84867. };
  84868. /**
  84869. * Subtracts this CSG with another CSG in place
  84870. * @param csg The CSG to subtact against this CSG
  84871. */
  84872. CSG.prototype.subtractInPlace = function (csg) {
  84873. var a = new Node(this.polygons);
  84874. var b = new Node(csg.polygons);
  84875. a.invert();
  84876. a.clipTo(b);
  84877. b.clipTo(a);
  84878. b.invert();
  84879. b.clipTo(a);
  84880. b.invert();
  84881. a.build(b.allPolygons());
  84882. a.invert();
  84883. this.polygons = a.allPolygons();
  84884. };
  84885. /**
  84886. * Intersect this CSG with another CSG
  84887. * @param csg The CSG to intersect against this CSG
  84888. * @returns A new CSG
  84889. */
  84890. CSG.prototype.intersect = function (csg) {
  84891. var a = new Node(this.clone().polygons);
  84892. var b = new Node(csg.clone().polygons);
  84893. a.invert();
  84894. b.clipTo(a);
  84895. b.invert();
  84896. a.clipTo(b);
  84897. b.clipTo(a);
  84898. a.build(b.allPolygons());
  84899. a.invert();
  84900. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  84901. };
  84902. /**
  84903. * Intersects this CSG with another CSG in place
  84904. * @param csg The CSG to intersect against this CSG
  84905. */
  84906. CSG.prototype.intersectInPlace = function (csg) {
  84907. var a = new Node(this.polygons);
  84908. var b = new Node(csg.polygons);
  84909. a.invert();
  84910. b.clipTo(a);
  84911. b.invert();
  84912. a.clipTo(b);
  84913. b.clipTo(a);
  84914. a.build(b.allPolygons());
  84915. a.invert();
  84916. this.polygons = a.allPolygons();
  84917. };
  84918. /**
  84919. * Return a new CSG solid with solid and empty space switched. This solid is
  84920. * not modified.
  84921. * @returns A new CSG solid with solid and empty space switched
  84922. */
  84923. CSG.prototype.inverse = function () {
  84924. var csg = this.clone();
  84925. csg.inverseInPlace();
  84926. return csg;
  84927. };
  84928. /**
  84929. * Inverses the CSG in place
  84930. */
  84931. CSG.prototype.inverseInPlace = function () {
  84932. this.polygons.map(function (p) { p.flip(); });
  84933. };
  84934. /**
  84935. * This is used to keep meshes transformations so they can be restored
  84936. * when we build back a Babylon Mesh
  84937. * NB : All CSG operations are performed in world coordinates
  84938. * @param csg The CSG to copy the transform attributes from
  84939. * @returns This CSG
  84940. */
  84941. CSG.prototype.copyTransformAttributes = function (csg) {
  84942. this.matrix = csg.matrix;
  84943. this.position = csg.position;
  84944. this.rotation = csg.rotation;
  84945. this.scaling = csg.scaling;
  84946. this.rotationQuaternion = csg.rotationQuaternion;
  84947. return this;
  84948. };
  84949. /**
  84950. * Build Raw mesh from CSG
  84951. * Coordinates here are in world space
  84952. * @param name The name of the mesh geometry
  84953. * @param scene The Scene
  84954. * @param keepSubMeshes Specifies if the submeshes should be kept
  84955. * @returns A new Mesh
  84956. */
  84957. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  84958. var matrix = this.matrix.clone();
  84959. matrix.invert();
  84960. 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;
  84961. if (keepSubMeshes) {
  84962. // Sort Polygons, since subMeshes are indices range
  84963. polygons.sort(function (a, b) {
  84964. if (a.shared.meshId === b.shared.meshId) {
  84965. return a.shared.subMeshId - b.shared.subMeshId;
  84966. }
  84967. else {
  84968. return a.shared.meshId - b.shared.meshId;
  84969. }
  84970. });
  84971. }
  84972. for (var i = 0, il = polygons.length; i < il; i++) {
  84973. polygon = polygons[i];
  84974. // Building SubMeshes
  84975. if (!subMesh_dict[polygon.shared.meshId]) {
  84976. subMesh_dict[polygon.shared.meshId] = {};
  84977. }
  84978. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  84979. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  84980. indexStart: +Infinity,
  84981. indexEnd: -Infinity,
  84982. materialIndex: polygon.shared.materialIndex
  84983. };
  84984. }
  84985. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  84986. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  84987. polygonIndices[0] = 0;
  84988. polygonIndices[1] = j - 1;
  84989. polygonIndices[2] = j;
  84990. for (var k = 0; k < 3; k++) {
  84991. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  84992. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  84993. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  84994. var localVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  84995. var localNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  84996. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  84997. // Check if 2 points can be merged
  84998. if (!(typeof vertex_idx !== 'undefined' &&
  84999. normals[vertex_idx * 3] === localNormal.x &&
  85000. normals[vertex_idx * 3 + 1] === localNormal.y &&
  85001. normals[vertex_idx * 3 + 2] === localNormal.z &&
  85002. uvs[vertex_idx * 2] === uv.x &&
  85003. uvs[vertex_idx * 2 + 1] === uv.y)) {
  85004. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  85005. uvs.push(uv.x, uv.y);
  85006. normals.push(normal.x, normal.y, normal.z);
  85007. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  85008. }
  85009. indices.push(vertex_idx);
  85010. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  85011. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  85012. currentIndex++;
  85013. }
  85014. }
  85015. }
  85016. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  85017. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  85018. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  85019. mesh.setIndices(indices, null);
  85020. if (keepSubMeshes) {
  85021. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  85022. var materialIndexOffset = 0, materialMaxIndex;
  85023. mesh.subMeshes = new Array();
  85024. for (var m in subMesh_dict) {
  85025. materialMaxIndex = -1;
  85026. for (var sm in subMesh_dict[m]) {
  85027. subMesh_obj = subMesh_dict[m][sm];
  85028. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  85029. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  85030. }
  85031. materialIndexOffset += ++materialMaxIndex;
  85032. }
  85033. }
  85034. return mesh;
  85035. };
  85036. /**
  85037. * Build Mesh from CSG taking material and transforms into account
  85038. * @param name The name of the Mesh
  85039. * @param material The material of the Mesh
  85040. * @param scene The Scene
  85041. * @param keepSubMeshes Specifies if submeshes should be kept
  85042. * @returns The new Mesh
  85043. */
  85044. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  85045. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  85046. mesh.material = material;
  85047. mesh.position.copyFrom(this.position);
  85048. mesh.rotation.copyFrom(this.rotation);
  85049. if (this.rotationQuaternion) {
  85050. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  85051. }
  85052. mesh.scaling.copyFrom(this.scaling);
  85053. mesh.computeWorldMatrix(true);
  85054. return mesh;
  85055. };
  85056. return CSG;
  85057. }());
  85058. /***/ }),
  85059. /***/ "./Meshes/geometry.ts":
  85060. /*!****************************!*\
  85061. !*** ./Meshes/geometry.ts ***!
  85062. \****************************/
  85063. /*! exports provided: Geometry */
  85064. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  85065. "use strict";
  85066. __webpack_require__.r(__webpack_exports__);
  85067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  85068. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  85069. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  85070. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  85071. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  85072. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  85073. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  85074. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  85075. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  85076. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  85077. /**
  85078. * Class used to store geometry data (vertex buffers + index buffer)
  85079. */
  85080. var Geometry = /** @class */ (function () {
  85081. /**
  85082. * Creates a new geometry
  85083. * @param id defines the unique ID
  85084. * @param scene defines the hosting scene
  85085. * @param vertexData defines the VertexData used to get geometry data
  85086. * @param updatable defines if geometry must be updatable (false by default)
  85087. * @param mesh defines the mesh that will be associated with the geometry
  85088. */
  85089. function Geometry(id, scene, vertexData, updatable, mesh) {
  85090. if (updatable === void 0) { updatable = false; }
  85091. if (mesh === void 0) { mesh = null; }
  85092. /**
  85093. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85094. */
  85095. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  85096. this._totalVertices = 0;
  85097. this._isDisposed = false;
  85098. this._indexBufferIsUpdatable = false;
  85099. this.id = id;
  85100. this.uniqueId = scene.getUniqueId();
  85101. this._engine = scene.getEngine();
  85102. this._meshes = [];
  85103. this._scene = scene;
  85104. //Init vertex buffer cache
  85105. this._vertexBuffers = {};
  85106. this._indices = [];
  85107. this._updatable = updatable;
  85108. // vertexData
  85109. if (vertexData) {
  85110. this.setAllVerticesData(vertexData, updatable);
  85111. }
  85112. else {
  85113. this._totalVertices = 0;
  85114. this._indices = [];
  85115. }
  85116. if (this._engine.getCaps().vertexArrayObject) {
  85117. this._vertexArrayObjects = {};
  85118. }
  85119. // applyToMesh
  85120. if (mesh) {
  85121. this.applyToMesh(mesh);
  85122. mesh.computeWorldMatrix(true);
  85123. }
  85124. }
  85125. Object.defineProperty(Geometry.prototype, "boundingBias", {
  85126. /**
  85127. * 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
  85128. */
  85129. get: function () {
  85130. return this._boundingBias;
  85131. },
  85132. /**
  85133. * 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
  85134. */
  85135. set: function (value) {
  85136. if (this._boundingBias) {
  85137. this._boundingBias.copyFrom(value);
  85138. }
  85139. else {
  85140. this._boundingBias = value.clone();
  85141. }
  85142. this._updateBoundingInfo(true, null);
  85143. },
  85144. enumerable: true,
  85145. configurable: true
  85146. });
  85147. /**
  85148. * Static function used to attach a new empty geometry to a mesh
  85149. * @param mesh defines the mesh to attach the geometry to
  85150. * @returns the new Geometry
  85151. */
  85152. Geometry.CreateGeometryForMesh = function (mesh) {
  85153. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  85154. geometry.applyToMesh(mesh);
  85155. return geometry;
  85156. };
  85157. Object.defineProperty(Geometry.prototype, "extend", {
  85158. /**
  85159. * Gets the current extend of the geometry
  85160. */
  85161. get: function () {
  85162. return this._extend;
  85163. },
  85164. enumerable: true,
  85165. configurable: true
  85166. });
  85167. /**
  85168. * Gets the hosting scene
  85169. * @returns the hosting Scene
  85170. */
  85171. Geometry.prototype.getScene = function () {
  85172. return this._scene;
  85173. };
  85174. /**
  85175. * Gets the hosting engine
  85176. * @returns the hosting Engine
  85177. */
  85178. Geometry.prototype.getEngine = function () {
  85179. return this._engine;
  85180. };
  85181. /**
  85182. * Defines if the geometry is ready to use
  85183. * @returns true if the geometry is ready to be used
  85184. */
  85185. Geometry.prototype.isReady = function () {
  85186. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  85187. };
  85188. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  85189. /**
  85190. * Gets a value indicating that the geometry should not be serialized
  85191. */
  85192. get: function () {
  85193. for (var index = 0; index < this._meshes.length; index++) {
  85194. if (!this._meshes[index].doNotSerialize) {
  85195. return false;
  85196. }
  85197. }
  85198. return true;
  85199. },
  85200. enumerable: true,
  85201. configurable: true
  85202. });
  85203. /** @hidden */
  85204. Geometry.prototype._rebuild = function () {
  85205. if (this._vertexArrayObjects) {
  85206. this._vertexArrayObjects = {};
  85207. }
  85208. // Index buffer
  85209. if (this._meshes.length !== 0 && this._indices) {
  85210. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  85211. }
  85212. // Vertex buffers
  85213. for (var key in this._vertexBuffers) {
  85214. var vertexBuffer = this._vertexBuffers[key];
  85215. vertexBuffer._rebuild();
  85216. }
  85217. };
  85218. /**
  85219. * Affects all geometry data in one call
  85220. * @param vertexData defines the geometry data
  85221. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85222. */
  85223. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  85224. vertexData.applyToGeometry(this, updatable);
  85225. this.notifyUpdate();
  85226. };
  85227. /**
  85228. * Set specific vertex data
  85229. * @param kind defines the data kind (Position, normal, etc...)
  85230. * @param data defines the vertex data to use
  85231. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85232. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85233. */
  85234. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  85235. if (updatable === void 0) { updatable = false; }
  85236. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  85237. this.setVerticesBuffer(buffer);
  85238. };
  85239. /**
  85240. * Removes a specific vertex data
  85241. * @param kind defines the data kind (Position, normal, etc...)
  85242. */
  85243. Geometry.prototype.removeVerticesData = function (kind) {
  85244. if (this._vertexBuffers[kind]) {
  85245. this._vertexBuffers[kind].dispose();
  85246. delete this._vertexBuffers[kind];
  85247. }
  85248. };
  85249. /**
  85250. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85251. * @param buffer defines the vertex buffer to use
  85252. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85253. */
  85254. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  85255. if (totalVertices === void 0) { totalVertices = null; }
  85256. var kind = buffer.getKind();
  85257. if (this._vertexBuffers[kind]) {
  85258. this._vertexBuffers[kind].dispose();
  85259. }
  85260. this._vertexBuffers[kind] = buffer;
  85261. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  85262. var data = buffer.getData();
  85263. if (totalVertices != null) {
  85264. this._totalVertices = totalVertices;
  85265. }
  85266. else {
  85267. if (data != null) {
  85268. this._totalVertices = data.length / (buffer.byteStride / 4);
  85269. }
  85270. }
  85271. this._updateExtend(data);
  85272. this._resetPointsArrayCache();
  85273. var meshes = this._meshes;
  85274. var numOfMeshes = meshes.length;
  85275. for (var index = 0; index < numOfMeshes; index++) {
  85276. var mesh = meshes[index];
  85277. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  85278. mesh._createGlobalSubMesh(false);
  85279. mesh.computeWorldMatrix(true);
  85280. }
  85281. }
  85282. this.notifyUpdate(kind);
  85283. if (this._vertexArrayObjects) {
  85284. this._disposeVertexArrayObjects();
  85285. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  85286. }
  85287. };
  85288. /**
  85289. * Update a specific vertex buffer
  85290. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  85291. * It will do nothing if the buffer is not updatable
  85292. * @param kind defines the data kind (Position, normal, etc...)
  85293. * @param data defines the data to use
  85294. * @param offset defines the offset in the target buffer where to store the data
  85295. * @param useBytes set to true if the offset is in bytes
  85296. */
  85297. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  85298. if (useBytes === void 0) { useBytes = false; }
  85299. var vertexBuffer = this.getVertexBuffer(kind);
  85300. if (!vertexBuffer) {
  85301. return;
  85302. }
  85303. vertexBuffer.updateDirectly(data, offset, useBytes);
  85304. this.notifyUpdate(kind);
  85305. };
  85306. /**
  85307. * Update a specific vertex buffer
  85308. * This function will create a new buffer if the current one is not updatable
  85309. * @param kind defines the data kind (Position, normal, etc...)
  85310. * @param data defines the data to use
  85311. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85312. */
  85313. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  85314. if (updateExtends === void 0) { updateExtends = false; }
  85315. var vertexBuffer = this.getVertexBuffer(kind);
  85316. if (!vertexBuffer) {
  85317. return;
  85318. }
  85319. vertexBuffer.update(data);
  85320. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  85321. this._updateBoundingInfo(updateExtends, data);
  85322. }
  85323. this.notifyUpdate(kind);
  85324. };
  85325. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  85326. if (updateExtends) {
  85327. this._updateExtend(data);
  85328. }
  85329. this._resetPointsArrayCache();
  85330. if (updateExtends) {
  85331. var meshes = this._meshes;
  85332. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  85333. var mesh = meshes_1[_i];
  85334. if (mesh._boundingInfo) {
  85335. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  85336. }
  85337. else {
  85338. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  85339. }
  85340. var subMeshes = mesh.subMeshes;
  85341. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  85342. var subMesh = subMeshes_1[_a];
  85343. subMesh.refreshBoundingInfo();
  85344. }
  85345. }
  85346. }
  85347. };
  85348. /** @hidden */
  85349. Geometry.prototype._bind = function (effect, indexToBind) {
  85350. if (!effect) {
  85351. return;
  85352. }
  85353. if (indexToBind === undefined) {
  85354. indexToBind = this._indexBuffer;
  85355. }
  85356. var vbs = this.getVertexBuffers();
  85357. if (!vbs) {
  85358. return;
  85359. }
  85360. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  85361. this._engine.bindBuffers(vbs, indexToBind, effect);
  85362. return;
  85363. }
  85364. // Using VAO
  85365. if (!this._vertexArrayObjects[effect.key]) {
  85366. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  85367. }
  85368. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  85369. };
  85370. /**
  85371. * Gets total number of vertices
  85372. * @returns the total number of vertices
  85373. */
  85374. Geometry.prototype.getTotalVertices = function () {
  85375. if (!this.isReady()) {
  85376. return 0;
  85377. }
  85378. return this._totalVertices;
  85379. };
  85380. /**
  85381. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85382. * @param kind defines the data kind (Position, normal, etc...)
  85383. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85384. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85385. * @returns a float array containing vertex data
  85386. */
  85387. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  85388. var vertexBuffer = this.getVertexBuffer(kind);
  85389. if (!vertexBuffer) {
  85390. return null;
  85391. }
  85392. var data = vertexBuffer.getData();
  85393. if (!data) {
  85394. return null;
  85395. }
  85396. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  85397. var count = this._totalVertices * vertexBuffer.getSize();
  85398. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  85399. var copy_1 = [];
  85400. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  85401. return copy_1;
  85402. }
  85403. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  85404. if (data instanceof Array) {
  85405. var offset = vertexBuffer.byteOffset / 4;
  85406. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data, offset, offset + count);
  85407. }
  85408. else if (data instanceof ArrayBuffer) {
  85409. return new Float32Array(data, vertexBuffer.byteOffset, count);
  85410. }
  85411. else {
  85412. var offset = data.byteOffset + vertexBuffer.byteOffset;
  85413. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  85414. var result = new Float32Array(count);
  85415. var source = new Float32Array(data.buffer, offset, count);
  85416. result.set(source);
  85417. return result;
  85418. }
  85419. return new Float32Array(data.buffer, offset, count);
  85420. }
  85421. }
  85422. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  85423. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data);
  85424. }
  85425. return data;
  85426. };
  85427. /**
  85428. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85429. * @param kind defines the data kind (Position, normal, etc...)
  85430. * @returns true if the vertex buffer with the specified kind is updatable
  85431. */
  85432. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  85433. var vb = this._vertexBuffers[kind];
  85434. if (!vb) {
  85435. return false;
  85436. }
  85437. return vb.isUpdatable();
  85438. };
  85439. /**
  85440. * Gets a specific vertex buffer
  85441. * @param kind defines the data kind (Position, normal, etc...)
  85442. * @returns a VertexBuffer
  85443. */
  85444. Geometry.prototype.getVertexBuffer = function (kind) {
  85445. if (!this.isReady()) {
  85446. return null;
  85447. }
  85448. return this._vertexBuffers[kind];
  85449. };
  85450. /**
  85451. * Returns all vertex buffers
  85452. * @return an object holding all vertex buffers indexed by kind
  85453. */
  85454. Geometry.prototype.getVertexBuffers = function () {
  85455. if (!this.isReady()) {
  85456. return null;
  85457. }
  85458. return this._vertexBuffers;
  85459. };
  85460. /**
  85461. * Gets a boolean indicating if specific vertex buffer is present
  85462. * @param kind defines the data kind (Position, normal, etc...)
  85463. * @returns true if data is present
  85464. */
  85465. Geometry.prototype.isVerticesDataPresent = function (kind) {
  85466. if (!this._vertexBuffers) {
  85467. if (this._delayInfo) {
  85468. return this._delayInfo.indexOf(kind) !== -1;
  85469. }
  85470. return false;
  85471. }
  85472. return this._vertexBuffers[kind] !== undefined;
  85473. };
  85474. /**
  85475. * Gets a list of all attached data kinds (Position, normal, etc...)
  85476. * @returns a list of string containing all kinds
  85477. */
  85478. Geometry.prototype.getVerticesDataKinds = function () {
  85479. var result = [];
  85480. var kind;
  85481. if (!this._vertexBuffers && this._delayInfo) {
  85482. for (kind in this._delayInfo) {
  85483. result.push(kind);
  85484. }
  85485. }
  85486. else {
  85487. for (kind in this._vertexBuffers) {
  85488. result.push(kind);
  85489. }
  85490. }
  85491. return result;
  85492. };
  85493. /**
  85494. * Update index buffer
  85495. * @param indices defines the indices to store in the index buffer
  85496. * @param offset defines the offset in the target buffer where to store the data
  85497. * @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)
  85498. */
  85499. Geometry.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  85500. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  85501. if (!this._indexBuffer) {
  85502. return;
  85503. }
  85504. if (!this._indexBufferIsUpdatable) {
  85505. this.setIndices(indices, null, true);
  85506. }
  85507. else {
  85508. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  85509. if (!gpuMemoryOnly) {
  85510. this._indices = indices.slice();
  85511. }
  85512. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  85513. if (needToUpdateSubMeshes) {
  85514. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  85515. var mesh = _a[_i];
  85516. mesh._createGlobalSubMesh(true);
  85517. }
  85518. }
  85519. }
  85520. };
  85521. /**
  85522. * Creates a new index buffer
  85523. * @param indices defines the indices to store in the index buffer
  85524. * @param totalVertices defines the total number of vertices (could be null)
  85525. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85526. */
  85527. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  85528. if (totalVertices === void 0) { totalVertices = null; }
  85529. if (updatable === void 0) { updatable = false; }
  85530. if (this._indexBuffer) {
  85531. this._engine._releaseBuffer(this._indexBuffer);
  85532. }
  85533. this._disposeVertexArrayObjects();
  85534. this._indices = indices;
  85535. this._indexBufferIsUpdatable = updatable;
  85536. if (this._meshes.length !== 0 && this._indices) {
  85537. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  85538. }
  85539. if (totalVertices != undefined) { // including null and undefined
  85540. this._totalVertices = totalVertices;
  85541. }
  85542. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  85543. var mesh = _a[_i];
  85544. mesh._createGlobalSubMesh(true);
  85545. }
  85546. this.notifyUpdate();
  85547. };
  85548. /**
  85549. * Return the total number of indices
  85550. * @returns the total number of indices
  85551. */
  85552. Geometry.prototype.getTotalIndices = function () {
  85553. if (!this.isReady()) {
  85554. return 0;
  85555. }
  85556. return this._indices.length;
  85557. };
  85558. /**
  85559. * Gets the index buffer array
  85560. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85561. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85562. * @returns the index buffer array
  85563. */
  85564. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  85565. if (!this.isReady()) {
  85566. return null;
  85567. }
  85568. var orig = this._indices;
  85569. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  85570. return orig;
  85571. }
  85572. else {
  85573. var len = orig.length;
  85574. var copy = [];
  85575. for (var i = 0; i < len; i++) {
  85576. copy.push(orig[i]);
  85577. }
  85578. return copy;
  85579. }
  85580. };
  85581. /**
  85582. * Gets the index buffer
  85583. * @return the index buffer
  85584. */
  85585. Geometry.prototype.getIndexBuffer = function () {
  85586. if (!this.isReady()) {
  85587. return null;
  85588. }
  85589. return this._indexBuffer;
  85590. };
  85591. /** @hidden */
  85592. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  85593. if (effect === void 0) { effect = null; }
  85594. if (!effect || !this._vertexArrayObjects) {
  85595. return;
  85596. }
  85597. if (this._vertexArrayObjects[effect.key]) {
  85598. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  85599. delete this._vertexArrayObjects[effect.key];
  85600. }
  85601. };
  85602. /**
  85603. * Release the associated resources for a specific mesh
  85604. * @param mesh defines the source mesh
  85605. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85606. */
  85607. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  85608. var meshes = this._meshes;
  85609. var index = meshes.indexOf(mesh);
  85610. if (index === -1) {
  85611. return;
  85612. }
  85613. meshes.splice(index, 1);
  85614. mesh._geometry = null;
  85615. if (meshes.length === 0 && shouldDispose) {
  85616. this.dispose();
  85617. }
  85618. };
  85619. /**
  85620. * Apply current geometry to a given mesh
  85621. * @param mesh defines the mesh to apply geometry to
  85622. */
  85623. Geometry.prototype.applyToMesh = function (mesh) {
  85624. if (mesh._geometry === this) {
  85625. return;
  85626. }
  85627. var previousGeometry = mesh._geometry;
  85628. if (previousGeometry) {
  85629. previousGeometry.releaseForMesh(mesh);
  85630. }
  85631. var meshes = this._meshes;
  85632. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  85633. mesh._geometry = this;
  85634. this._scene.pushGeometry(this);
  85635. meshes.push(mesh);
  85636. if (this.isReady()) {
  85637. this._applyToMesh(mesh);
  85638. }
  85639. else {
  85640. mesh._boundingInfo = this._boundingInfo;
  85641. }
  85642. };
  85643. Geometry.prototype._updateExtend = function (data) {
  85644. if (data === void 0) { data = null; }
  85645. if (!data) {
  85646. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  85647. }
  85648. this._extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].ExtractMinAndMax(data, 0, this._totalVertices, this.boundingBias, 3);
  85649. };
  85650. Geometry.prototype._applyToMesh = function (mesh) {
  85651. var numOfMeshes = this._meshes.length;
  85652. // vertexBuffers
  85653. for (var kind in this._vertexBuffers) {
  85654. if (numOfMeshes === 1) {
  85655. this._vertexBuffers[kind].create();
  85656. }
  85657. var buffer = this._vertexBuffers[kind].getBuffer();
  85658. if (buffer) {
  85659. buffer.references = numOfMeshes;
  85660. }
  85661. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  85662. if (!this._extend) {
  85663. this._updateExtend();
  85664. }
  85665. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  85666. mesh._createGlobalSubMesh(false);
  85667. //bounding info was just created again, world matrix should be applied again.
  85668. mesh._updateBoundingInfo();
  85669. }
  85670. }
  85671. // indexBuffer
  85672. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  85673. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  85674. }
  85675. if (this._indexBuffer) {
  85676. this._indexBuffer.references = numOfMeshes;
  85677. }
  85678. // morphTargets
  85679. mesh._syncGeometryWithMorphTargetManager();
  85680. // instances
  85681. mesh.synchronizeInstances();
  85682. };
  85683. Geometry.prototype.notifyUpdate = function (kind) {
  85684. if (this.onGeometryUpdated) {
  85685. this.onGeometryUpdated(this, kind);
  85686. }
  85687. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  85688. var mesh = _a[_i];
  85689. mesh._markSubMeshesAsAttributesDirty();
  85690. }
  85691. };
  85692. /**
  85693. * Load the geometry if it was flagged as delay loaded
  85694. * @param scene defines the hosting scene
  85695. * @param onLoaded defines a callback called when the geometry is loaded
  85696. */
  85697. Geometry.prototype.load = function (scene, onLoaded) {
  85698. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING) {
  85699. return;
  85700. }
  85701. if (this.isReady()) {
  85702. if (onLoaded) {
  85703. onLoaded();
  85704. }
  85705. return;
  85706. }
  85707. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING;
  85708. this._queueLoad(scene, onLoaded);
  85709. };
  85710. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  85711. var _this = this;
  85712. if (!this.delayLoadingFile) {
  85713. return;
  85714. }
  85715. scene._addPendingData(this);
  85716. scene._loadFile(this.delayLoadingFile, function (data) {
  85717. if (!_this._delayLoadingFunction) {
  85718. return;
  85719. }
  85720. _this._delayLoadingFunction(JSON.parse(data), _this);
  85721. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  85722. _this._delayInfo = [];
  85723. scene._removePendingData(_this);
  85724. var meshes = _this._meshes;
  85725. var numOfMeshes = meshes.length;
  85726. for (var index = 0; index < numOfMeshes; index++) {
  85727. _this._applyToMesh(meshes[index]);
  85728. }
  85729. if (onLoaded) {
  85730. onLoaded();
  85731. }
  85732. }, undefined, true);
  85733. };
  85734. /**
  85735. * Invert the geometry to move from a right handed system to a left handed one.
  85736. */
  85737. Geometry.prototype.toLeftHanded = function () {
  85738. // Flip faces
  85739. var tIndices = this.getIndices(false);
  85740. if (tIndices != null && tIndices.length > 0) {
  85741. for (var i = 0; i < tIndices.length; i += 3) {
  85742. var tTemp = tIndices[i + 0];
  85743. tIndices[i + 0] = tIndices[i + 2];
  85744. tIndices[i + 2] = tTemp;
  85745. }
  85746. this.setIndices(tIndices);
  85747. }
  85748. // Negate position.z
  85749. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, false);
  85750. if (tPositions != null && tPositions.length > 0) {
  85751. for (var i = 0; i < tPositions.length; i += 3) {
  85752. tPositions[i + 2] = -tPositions[i + 2];
  85753. }
  85754. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, tPositions, false);
  85755. }
  85756. // Negate normal.z
  85757. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, false);
  85758. if (tNormals != null && tNormals.length > 0) {
  85759. for (var i = 0; i < tNormals.length; i += 3) {
  85760. tNormals[i + 2] = -tNormals[i + 2];
  85761. }
  85762. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, tNormals, false);
  85763. }
  85764. };
  85765. // Cache
  85766. /** @hidden */
  85767. Geometry.prototype._resetPointsArrayCache = function () {
  85768. this._positions = null;
  85769. };
  85770. /** @hidden */
  85771. Geometry.prototype._generatePointsArray = function () {
  85772. if (this._positions) {
  85773. return true;
  85774. }
  85775. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  85776. if (!data || data.length === 0) {
  85777. return false;
  85778. }
  85779. this._positions = [];
  85780. for (var index = 0; index < data.length; index += 3) {
  85781. this._positions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(data, index));
  85782. }
  85783. return true;
  85784. };
  85785. /**
  85786. * Gets a value indicating if the geometry is disposed
  85787. * @returns true if the geometry was disposed
  85788. */
  85789. Geometry.prototype.isDisposed = function () {
  85790. return this._isDisposed;
  85791. };
  85792. Geometry.prototype._disposeVertexArrayObjects = function () {
  85793. if (this._vertexArrayObjects) {
  85794. for (var kind in this._vertexArrayObjects) {
  85795. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  85796. }
  85797. this._vertexArrayObjects = {};
  85798. }
  85799. };
  85800. /**
  85801. * Free all associated resources
  85802. */
  85803. Geometry.prototype.dispose = function () {
  85804. var meshes = this._meshes;
  85805. var numOfMeshes = meshes.length;
  85806. var index;
  85807. for (index = 0; index < numOfMeshes; index++) {
  85808. this.releaseForMesh(meshes[index]);
  85809. }
  85810. this._meshes = [];
  85811. this._disposeVertexArrayObjects();
  85812. for (var kind in this._vertexBuffers) {
  85813. this._vertexBuffers[kind].dispose();
  85814. }
  85815. this._vertexBuffers = {};
  85816. this._totalVertices = 0;
  85817. if (this._indexBuffer) {
  85818. this._engine._releaseBuffer(this._indexBuffer);
  85819. }
  85820. this._indexBuffer = null;
  85821. this._indices = [];
  85822. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  85823. this.delayLoadingFile = null;
  85824. this._delayLoadingFunction = null;
  85825. this._delayInfo = [];
  85826. this._boundingInfo = null;
  85827. this._scene.removeGeometry(this);
  85828. this._isDisposed = true;
  85829. };
  85830. /**
  85831. * Clone the current geometry into a new geometry
  85832. * @param id defines the unique ID of the new geometry
  85833. * @returns a new geometry object
  85834. */
  85835. Geometry.prototype.copy = function (id) {
  85836. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  85837. vertexData.indices = [];
  85838. var indices = this.getIndices();
  85839. if (indices) {
  85840. for (var index = 0; index < indices.length; index++) {
  85841. vertexData.indices.push(indices[index]);
  85842. }
  85843. }
  85844. var updatable = false;
  85845. var stopChecking = false;
  85846. var kind;
  85847. for (kind in this._vertexBuffers) {
  85848. // using slice() to make a copy of the array and not just reference it
  85849. var data = this.getVerticesData(kind);
  85850. if (data) {
  85851. if (data instanceof Float32Array) {
  85852. vertexData.set(new Float32Array(data), kind);
  85853. }
  85854. else {
  85855. vertexData.set(data.slice(0), kind);
  85856. }
  85857. if (!stopChecking) {
  85858. var vb = this.getVertexBuffer(kind);
  85859. if (vb) {
  85860. updatable = vb.isUpdatable();
  85861. stopChecking = !updatable;
  85862. }
  85863. }
  85864. }
  85865. }
  85866. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  85867. geometry.delayLoadState = this.delayLoadState;
  85868. geometry.delayLoadingFile = this.delayLoadingFile;
  85869. geometry._delayLoadingFunction = this._delayLoadingFunction;
  85870. for (kind in this._delayInfo) {
  85871. geometry._delayInfo = geometry._delayInfo || [];
  85872. geometry._delayInfo.push(kind);
  85873. }
  85874. // Bounding info
  85875. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  85876. return geometry;
  85877. };
  85878. /**
  85879. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85880. * @return a JSON representation of the current geometry data (without the vertices data)
  85881. */
  85882. Geometry.prototype.serialize = function () {
  85883. var serializationObject = {};
  85884. serializationObject.id = this.id;
  85885. serializationObject.updatable = this._updatable;
  85886. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].HasTags(this)) {
  85887. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].GetTags(this);
  85888. }
  85889. return serializationObject;
  85890. };
  85891. Geometry.prototype.toNumberArray = function (origin) {
  85892. if (Array.isArray(origin)) {
  85893. return origin;
  85894. }
  85895. else {
  85896. return Array.prototype.slice.call(origin);
  85897. }
  85898. };
  85899. /**
  85900. * Serialize all vertices data into a JSON oject
  85901. * @returns a JSON representation of the current geometry data
  85902. */
  85903. Geometry.prototype.serializeVerticeData = function () {
  85904. var serializationObject = this.serialize();
  85905. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  85906. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  85907. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  85908. serializationObject.positions._updatable = true;
  85909. }
  85910. }
  85911. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  85912. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind));
  85913. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  85914. serializationObject.normals._updatable = true;
  85915. }
  85916. }
  85917. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  85918. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind));
  85919. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  85920. serializationObject.tangets._updatable = true;
  85921. }
  85922. }
  85923. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  85924. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind));
  85925. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  85926. serializationObject.uvs._updatable = true;
  85927. }
  85928. }
  85929. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  85930. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind));
  85931. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  85932. serializationObject.uv2s._updatable = true;
  85933. }
  85934. }
  85935. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  85936. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind));
  85937. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  85938. serializationObject.uv3s._updatable = true;
  85939. }
  85940. }
  85941. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  85942. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind));
  85943. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  85944. serializationObject.uv4s._updatable = true;
  85945. }
  85946. }
  85947. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  85948. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind));
  85949. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  85950. serializationObject.uv5s._updatable = true;
  85951. }
  85952. }
  85953. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  85954. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind));
  85955. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  85956. serializationObject.uv6s._updatable = true;
  85957. }
  85958. }
  85959. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  85960. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind));
  85961. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  85962. serializationObject.colors._updatable = true;
  85963. }
  85964. }
  85965. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  85966. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind));
  85967. serializationObject.matricesIndices._isExpanded = true;
  85968. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  85969. serializationObject.matricesIndices._updatable = true;
  85970. }
  85971. }
  85972. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  85973. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind));
  85974. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  85975. serializationObject.matricesWeights._updatable = true;
  85976. }
  85977. }
  85978. serializationObject.indices = this.toNumberArray(this.getIndices());
  85979. return serializationObject;
  85980. };
  85981. // Statics
  85982. /**
  85983. * Extracts a clone of a mesh geometry
  85984. * @param mesh defines the source mesh
  85985. * @param id defines the unique ID of the new geometry object
  85986. * @returns the new geometry object
  85987. */
  85988. Geometry.ExtractFromMesh = function (mesh, id) {
  85989. var geometry = mesh._geometry;
  85990. if (!geometry) {
  85991. return null;
  85992. }
  85993. return geometry.copy(id);
  85994. };
  85995. /**
  85996. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85997. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85998. * Be aware Math.random() could cause collisions, but:
  85999. * "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"
  86000. * @returns a string containing a new GUID
  86001. */
  86002. Geometry.RandomId = function () {
  86003. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].RandomId();
  86004. };
  86005. /** @hidden */
  86006. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  86007. var scene = mesh.getScene();
  86008. // Geometry
  86009. var geometryId = parsedGeometry.geometryId;
  86010. if (geometryId) {
  86011. var geometry = scene.getGeometryByID(geometryId);
  86012. if (geometry) {
  86013. geometry.applyToMesh(mesh);
  86014. }
  86015. }
  86016. else if (parsedGeometry instanceof ArrayBuffer) {
  86017. var binaryInfo = mesh._binaryInfo;
  86018. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  86019. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  86020. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positionsData, false);
  86021. }
  86022. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  86023. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  86024. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normalsData, false);
  86025. }
  86026. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  86027. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  86028. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, tangentsData, false);
  86029. }
  86030. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  86031. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  86032. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvsData, false);
  86033. }
  86034. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  86035. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  86036. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, uvs2Data, false);
  86037. }
  86038. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  86039. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  86040. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, uvs3Data, false);
  86041. }
  86042. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  86043. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  86044. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, uvs4Data, false);
  86045. }
  86046. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  86047. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  86048. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, uvs5Data, false);
  86049. }
  86050. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  86051. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  86052. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, uvs6Data, false);
  86053. }
  86054. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  86055. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  86056. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  86057. }
  86058. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  86059. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  86060. var floatIndices = [];
  86061. for (var i = 0; i < matricesIndicesData.length; i++) {
  86062. var index = matricesIndicesData[i];
  86063. floatIndices.push(index & 0x000000FF);
  86064. floatIndices.push((index & 0x0000FF00) >> 8);
  86065. floatIndices.push((index & 0x00FF0000) >> 16);
  86066. floatIndices.push(index >> 24);
  86067. }
  86068. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  86069. }
  86070. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  86071. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  86072. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  86073. }
  86074. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  86075. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  86076. mesh.setIndices(indicesData, null);
  86077. }
  86078. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  86079. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  86080. mesh.subMeshes = [];
  86081. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  86082. var materialIndex = subMeshesData[(i * 5) + 0];
  86083. var verticesStart = subMeshesData[(i * 5) + 1];
  86084. var verticesCount = subMeshesData[(i * 5) + 2];
  86085. var indexStart = subMeshesData[(i * 5) + 3];
  86086. var indexCount = subMeshesData[(i * 5) + 4];
  86087. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  86088. }
  86089. }
  86090. }
  86091. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  86092. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  86093. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  86094. if (parsedGeometry.tangents) {
  86095. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  86096. }
  86097. if (parsedGeometry.uvs) {
  86098. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  86099. }
  86100. if (parsedGeometry.uvs2) {
  86101. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  86102. }
  86103. if (parsedGeometry.uvs3) {
  86104. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  86105. }
  86106. if (parsedGeometry.uvs4) {
  86107. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  86108. }
  86109. if (parsedGeometry.uvs5) {
  86110. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  86111. }
  86112. if (parsedGeometry.uvs6) {
  86113. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  86114. }
  86115. if (parsedGeometry.colors) {
  86116. 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);
  86117. }
  86118. if (parsedGeometry.matricesIndices) {
  86119. if (!parsedGeometry.matricesIndices._isExpanded) {
  86120. var floatIndices = [];
  86121. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  86122. var matricesIndex = parsedGeometry.matricesIndices[i];
  86123. floatIndices.push(matricesIndex & 0x000000FF);
  86124. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  86125. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  86126. floatIndices.push(matricesIndex >> 24);
  86127. }
  86128. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  86129. }
  86130. else {
  86131. delete parsedGeometry.matricesIndices._isExpanded;
  86132. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  86133. }
  86134. }
  86135. if (parsedGeometry.matricesIndicesExtra) {
  86136. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  86137. var floatIndices = [];
  86138. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  86139. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  86140. floatIndices.push(matricesIndex & 0x000000FF);
  86141. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  86142. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  86143. floatIndices.push(matricesIndex >> 24);
  86144. }
  86145. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  86146. }
  86147. else {
  86148. delete parsedGeometry.matricesIndices._isExpanded;
  86149. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  86150. }
  86151. }
  86152. if (parsedGeometry.matricesWeights) {
  86153. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  86154. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  86155. }
  86156. if (parsedGeometry.matricesWeightsExtra) {
  86157. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  86158. }
  86159. mesh.setIndices(parsedGeometry.indices, null);
  86160. }
  86161. // SubMeshes
  86162. if (parsedGeometry.subMeshes) {
  86163. mesh.subMeshes = [];
  86164. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  86165. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  86166. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  86167. }
  86168. }
  86169. // Flat shading
  86170. if (mesh._shouldGenerateFlatShading) {
  86171. mesh.convertToFlatShadedMesh();
  86172. delete mesh._shouldGenerateFlatShading;
  86173. }
  86174. // Update
  86175. mesh.computeWorldMatrix(true);
  86176. scene.onMeshImportedObservable.notifyObservers(mesh);
  86177. };
  86178. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  86179. var epsilon = 1e-3;
  86180. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  86181. return;
  86182. }
  86183. var noInfluenceBoneIndex = 0.0;
  86184. if (parsedGeometry.skeletonId > -1) {
  86185. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  86186. if (!skeleton) {
  86187. return;
  86188. }
  86189. noInfluenceBoneIndex = skeleton.bones.length;
  86190. }
  86191. else {
  86192. return;
  86193. }
  86194. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  86195. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  86196. var matricesWeights = parsedGeometry.matricesWeights;
  86197. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  86198. var influencers = parsedGeometry.numBoneInfluencer;
  86199. var size = matricesWeights.length;
  86200. for (var i = 0; i < size; i += 4) {
  86201. var weight = 0.0;
  86202. var firstZeroWeight = -1;
  86203. for (var j = 0; j < 4; j++) {
  86204. var w = matricesWeights[i + j];
  86205. weight += w;
  86206. if (w < epsilon && firstZeroWeight < 0) {
  86207. firstZeroWeight = j;
  86208. }
  86209. }
  86210. if (matricesWeightsExtra) {
  86211. for (var j = 0; j < 4; j++) {
  86212. var w = matricesWeightsExtra[i + j];
  86213. weight += w;
  86214. if (w < epsilon && firstZeroWeight < 0) {
  86215. firstZeroWeight = j + 4;
  86216. }
  86217. }
  86218. }
  86219. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  86220. firstZeroWeight = influencers - 1;
  86221. }
  86222. if (weight > epsilon) {
  86223. var mweight = 1.0 / weight;
  86224. for (var j = 0; j < 4; j++) {
  86225. matricesWeights[i + j] *= mweight;
  86226. }
  86227. if (matricesWeightsExtra) {
  86228. for (var j = 0; j < 4; j++) {
  86229. matricesWeightsExtra[i + j] *= mweight;
  86230. }
  86231. }
  86232. }
  86233. else {
  86234. if (firstZeroWeight >= 4) {
  86235. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  86236. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  86237. }
  86238. else {
  86239. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  86240. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  86241. }
  86242. }
  86243. }
  86244. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  86245. if (parsedGeometry.matricesWeightsExtra) {
  86246. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  86247. }
  86248. };
  86249. /**
  86250. * Create a new geometry from persisted data (Using .babylon file format)
  86251. * @param parsedVertexData defines the persisted data
  86252. * @param scene defines the hosting scene
  86253. * @param rootUrl defines the root url to use to load assets (like delayed data)
  86254. * @returns the new geometry object
  86255. */
  86256. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  86257. if (scene.getGeometryByID(parsedVertexData.id)) {
  86258. return null; // null since geometry could be something else than a box...
  86259. }
  86260. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  86261. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"]) {
  86262. _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  86263. }
  86264. if (parsedVertexData.delayLoadingFile) {
  86265. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  86266. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  86267. 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));
  86268. geometry._delayInfo = [];
  86269. if (parsedVertexData.hasUVs) {
  86270. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  86271. }
  86272. if (parsedVertexData.hasUVs2) {
  86273. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  86274. }
  86275. if (parsedVertexData.hasUVs3) {
  86276. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind);
  86277. }
  86278. if (parsedVertexData.hasUVs4) {
  86279. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind);
  86280. }
  86281. if (parsedVertexData.hasUVs5) {
  86282. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind);
  86283. }
  86284. if (parsedVertexData.hasUVs6) {
  86285. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind);
  86286. }
  86287. if (parsedVertexData.hasColors) {
  86288. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  86289. }
  86290. if (parsedVertexData.hasMatricesIndices) {
  86291. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  86292. }
  86293. if (parsedVertexData.hasMatricesWeights) {
  86294. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  86295. }
  86296. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData;
  86297. }
  86298. else {
  86299. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  86300. }
  86301. scene.pushGeometry(geometry, true);
  86302. return geometry;
  86303. };
  86304. return Geometry;
  86305. }());
  86306. /***/ }),
  86307. /***/ "./Meshes/groundMesh.ts":
  86308. /*!******************************!*\
  86309. !*** ./Meshes/groundMesh.ts ***!
  86310. \******************************/
  86311. /*! exports provided: GroundMesh */
  86312. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86313. "use strict";
  86314. __webpack_require__.r(__webpack_exports__);
  86315. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  86316. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  86317. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  86318. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  86319. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  86320. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  86321. return GroundMesh.Parse(parsedMesh, scene);
  86322. };
  86323. /**
  86324. * Mesh representing the gorund
  86325. */
  86326. var GroundMesh = /** @class */ (function (_super) {
  86327. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  86328. function GroundMesh(name, scene) {
  86329. var _this = _super.call(this, name, scene) || this;
  86330. /** If octree should be generated */
  86331. _this.generateOctree = false;
  86332. return _this;
  86333. }
  86334. /**
  86335. * "GroundMesh"
  86336. * @returns "GroundMesh"
  86337. */
  86338. GroundMesh.prototype.getClassName = function () {
  86339. return "GroundMesh";
  86340. };
  86341. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  86342. /**
  86343. * The minimum of x and y subdivisions
  86344. */
  86345. get: function () {
  86346. return Math.min(this._subdivisionsX, this._subdivisionsY);
  86347. },
  86348. enumerable: true,
  86349. configurable: true
  86350. });
  86351. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  86352. /**
  86353. * X subdivisions
  86354. */
  86355. get: function () {
  86356. return this._subdivisionsX;
  86357. },
  86358. enumerable: true,
  86359. configurable: true
  86360. });
  86361. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  86362. /**
  86363. * Y subdivisions
  86364. */
  86365. get: function () {
  86366. return this._subdivisionsY;
  86367. },
  86368. enumerable: true,
  86369. configurable: true
  86370. });
  86371. /**
  86372. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  86373. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  86374. * @param chunksCount the number of subdivisions for x and y
  86375. * @param octreeBlocksSize (Default: 32)
  86376. */
  86377. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  86378. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  86379. this._subdivisionsX = chunksCount;
  86380. this._subdivisionsY = chunksCount;
  86381. this.subdivide(chunksCount);
  86382. // Call the octree system optimization if it is defined.
  86383. var thisAsAny = this;
  86384. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  86385. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  86386. }
  86387. };
  86388. /**
  86389. * Returns a height (y) value in the Worl system :
  86390. * the ground altitude at the coordinates (x, z) expressed in the World system.
  86391. * @param x x coordinate
  86392. * @param z z coordinate
  86393. * @returns the ground y position if (x, z) are outside the ground surface.
  86394. */
  86395. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  86396. var world = this.getWorldMatrix();
  86397. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  86398. world.invertToRef(invMat);
  86399. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  86400. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  86401. x = tmpVect.x;
  86402. z = tmpVect.z;
  86403. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  86404. return this.position.y;
  86405. }
  86406. if (!this._heightQuads || this._heightQuads.length == 0) {
  86407. this._initHeightQuads();
  86408. this._computeHeightQuads();
  86409. }
  86410. var facet = this._getFacetAt(x, z);
  86411. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  86412. // return y in the World system
  86413. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  86414. return tmpVect.y;
  86415. };
  86416. /**
  86417. * Returns a normalized vector (Vector3) orthogonal to the ground
  86418. * at the ground coordinates (x, z) expressed in the World system.
  86419. * @param x x coordinate
  86420. * @param z z coordinate
  86421. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  86422. */
  86423. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  86424. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  86425. this.getNormalAtCoordinatesToRef(x, z, normal);
  86426. return normal;
  86427. };
  86428. /**
  86429. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  86430. * at the ground coordinates (x, z) expressed in the World system.
  86431. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  86432. * @param x x coordinate
  86433. * @param z z coordinate
  86434. * @param ref vector to store the result
  86435. * @returns the GroundMesh.
  86436. */
  86437. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  86438. var world = this.getWorldMatrix();
  86439. var tmpMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  86440. world.invertToRef(tmpMat);
  86441. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  86442. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  86443. x = tmpVect.x;
  86444. z = tmpVect.z;
  86445. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  86446. return this;
  86447. }
  86448. if (!this._heightQuads || this._heightQuads.length == 0) {
  86449. this._initHeightQuads();
  86450. this._computeHeightQuads();
  86451. }
  86452. var facet = this._getFacetAt(x, z);
  86453. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  86454. return this;
  86455. };
  86456. /**
  86457. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  86458. * if the ground has been updated.
  86459. * This can be used in the render loop.
  86460. * @returns the GroundMesh.
  86461. */
  86462. GroundMesh.prototype.updateCoordinateHeights = function () {
  86463. if (!this._heightQuads || this._heightQuads.length == 0) {
  86464. this._initHeightQuads();
  86465. }
  86466. this._computeHeightQuads();
  86467. return this;
  86468. };
  86469. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  86470. GroundMesh.prototype._getFacetAt = function (x, z) {
  86471. // retrieve col and row from x, z coordinates in the ground local system
  86472. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  86473. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  86474. var quad = this._heightQuads[row * this._subdivisionsX + col];
  86475. var facet;
  86476. if (z < quad.slope.x * x + quad.slope.y) {
  86477. facet = quad.facet1;
  86478. }
  86479. else {
  86480. facet = quad.facet2;
  86481. }
  86482. return facet;
  86483. };
  86484. // Creates and populates the heightMap array with "facet" elements :
  86485. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  86486. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  86487. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  86488. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  86489. // Returns the GroundMesh.
  86490. GroundMesh.prototype._initHeightQuads = function () {
  86491. var subdivisionsX = this._subdivisionsX;
  86492. var subdivisionsY = this._subdivisionsY;
  86493. this._heightQuads = new Array();
  86494. for (var row = 0; row < subdivisionsY; row++) {
  86495. for (var col = 0; col < subdivisionsX; col++) {
  86496. 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) };
  86497. this._heightQuads[row * subdivisionsX + col] = quad;
  86498. }
  86499. }
  86500. return this;
  86501. };
  86502. // Compute each quad element values and update the the heightMap array :
  86503. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  86504. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  86505. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  86506. // Returns the GroundMesh.
  86507. GroundMesh.prototype._computeHeightQuads = function () {
  86508. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  86509. if (!positions) {
  86510. return this;
  86511. }
  86512. var v1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  86513. var v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  86514. var v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  86515. var v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  86516. var v1v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  86517. var v1v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  86518. var v1v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  86519. var norm1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[7];
  86520. var norm2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  86521. var i = 0;
  86522. var j = 0;
  86523. var k = 0;
  86524. var cd = 0; // 2D slope coefficient : z = cd * x + h
  86525. var h = 0;
  86526. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  86527. var d2 = 0;
  86528. var subdivisionsX = this._subdivisionsX;
  86529. var subdivisionsY = this._subdivisionsY;
  86530. for (var row = 0; row < subdivisionsY; row++) {
  86531. for (var col = 0; col < subdivisionsX; col++) {
  86532. i = col * 3;
  86533. j = row * (subdivisionsX + 1) * 3;
  86534. k = (row + 1) * (subdivisionsX + 1) * 3;
  86535. v1.x = positions[j + i];
  86536. v1.y = positions[j + i + 1];
  86537. v1.z = positions[j + i + 2];
  86538. v2.x = positions[j + i + 3];
  86539. v2.y = positions[j + i + 4];
  86540. v2.z = positions[j + i + 5];
  86541. v3.x = positions[k + i];
  86542. v3.y = positions[k + i + 1];
  86543. v3.z = positions[k + i + 2];
  86544. v4.x = positions[k + i + 3];
  86545. v4.y = positions[k + i + 4];
  86546. v4.z = positions[k + i + 5];
  86547. // 2D slope V1V4
  86548. cd = (v4.z - v1.z) / (v4.x - v1.x);
  86549. h = v1.z - cd * v1.x; // v1 belongs to the slope
  86550. // facet equations :
  86551. // we compute each facet normal vector
  86552. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  86553. // we compute the value d by applying the equation to v1 which belongs to the plane
  86554. // then we store the facet equation in a Vector4
  86555. v2.subtractToRef(v1, v1v2);
  86556. v3.subtractToRef(v1, v1v3);
  86557. v4.subtractToRef(v1, v1v4);
  86558. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  86559. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  86560. norm1.normalize();
  86561. norm2.normalize();
  86562. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  86563. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  86564. var quad = this._heightQuads[row * subdivisionsX + col];
  86565. quad.slope.copyFromFloats(cd, h);
  86566. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  86567. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  86568. }
  86569. }
  86570. return this;
  86571. };
  86572. /**
  86573. * Serializes this ground mesh
  86574. * @param serializationObject object to write serialization to
  86575. */
  86576. GroundMesh.prototype.serialize = function (serializationObject) {
  86577. _super.prototype.serialize.call(this, serializationObject);
  86578. serializationObject.subdivisionsX = this._subdivisionsX;
  86579. serializationObject.subdivisionsY = this._subdivisionsY;
  86580. serializationObject.minX = this._minX;
  86581. serializationObject.maxX = this._maxX;
  86582. serializationObject.minZ = this._minZ;
  86583. serializationObject.maxZ = this._maxZ;
  86584. serializationObject.width = this._width;
  86585. serializationObject.height = this._height;
  86586. };
  86587. /**
  86588. * Parses a serialized ground mesh
  86589. * @param parsedMesh the serialized mesh
  86590. * @param scene the scene to create the ground mesh in
  86591. * @returns the created ground mesh
  86592. */
  86593. GroundMesh.Parse = function (parsedMesh, scene) {
  86594. var result = new GroundMesh(parsedMesh.name, scene);
  86595. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  86596. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  86597. result._minX = parsedMesh.minX;
  86598. result._maxX = parsedMesh.maxX;
  86599. result._minZ = parsedMesh.minZ;
  86600. result._maxZ = parsedMesh.maxZ;
  86601. result._width = parsedMesh.width;
  86602. result._height = parsedMesh.height;
  86603. return result;
  86604. };
  86605. return GroundMesh;
  86606. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  86607. /***/ }),
  86608. /***/ "./Meshes/index.ts":
  86609. /*!*************************!*\
  86610. !*** ./Meshes/index.ts ***!
  86611. \*************************/
  86612. /*! 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, LinesBuilder, PlaneBuilder, DracoCompression, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  86613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86614. "use strict";
  86615. __webpack_require__.r(__webpack_exports__);
  86616. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  86617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  86618. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  86619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  86620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  86621. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  86622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  86623. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  86624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  86625. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  86626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  86627. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  86628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  86629. /* harmony import */ var _trailMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./trailMesh */ "./Meshes/trailMesh.ts");
  86630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _trailMesh__WEBPACK_IMPORTED_MODULE_6__["TrailMesh"]; });
  86631. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  86632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedMesh"]; });
  86633. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  86634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["LinesMesh"]; });
  86635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["InstancedLinesMesh"]; });
  86636. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  86637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["MeshLODLevel"]; });
  86638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_CreationDataStorage"]; });
  86639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_InstancesBatch"]; });
  86640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["Mesh"]; });
  86641. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  86642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__["VertexData"]; });
  86643. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  86644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_11__["MeshBuilder"]; });
  86645. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  86646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationSettings"]; });
  86647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationQueue"]; });
  86648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationType"]; });
  86649. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  86650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__["SimplicationQueueSceneComponent"]; });
  86651. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  86652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["Polygon"]; });
  86653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["PolygonMeshBuilder"]; });
  86654. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  86655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["BaseSubMesh"]; });
  86656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["SubMesh"]; });
  86657. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  86658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_16__["TransformNode"]; });
  86659. /* harmony import */ var _Builders_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Builders/index */ "./Meshes/Builders/index.ts");
  86660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["BoxBuilder"]; });
  86661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["SphereBuilder"]; });
  86662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["CylinderBuilder"]; });
  86663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["LinesBuilder"]; });
  86664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PlaneBuilder"]; });
  86665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["DiscBuilder"]; });
  86666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["RibbonBuilder"]; });
  86667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["HemisphereBuilder"]; });
  86668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TorusBuilder"]; });
  86669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TorusKnotBuilder"]; });
  86670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PolygonBuilder"]; });
  86671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["ShapeBuilder"]; });
  86672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["LatheBuilder"]; });
  86673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["GroundBuilder"]; });
  86674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TubeBuilder"]; });
  86675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PolyhedronBuilder"]; });
  86676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["IcoSphereBuilder"]; });
  86677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["DecalBuilder"]; });
  86678. /***/ }),
  86679. /***/ "./Meshes/instancedMesh.ts":
  86680. /*!*********************************!*\
  86681. !*** ./Meshes/instancedMesh.ts ***!
  86682. \*********************************/
  86683. /*! exports provided: InstancedMesh */
  86684. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  86685. "use strict";
  86686. __webpack_require__.r(__webpack_exports__);
  86687. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  86688. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  86689. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  86690. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  86691. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  86692. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  86693. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  86694. return new InstancedMesh(name, mesh);
  86695. };
  86696. /**
  86697. * Creates an instance based on a source mesh.
  86698. */
  86699. var InstancedMesh = /** @class */ (function (_super) {
  86700. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  86701. function InstancedMesh(name, source) {
  86702. var _this = _super.call(this, name, source.getScene()) || this;
  86703. /** @hidden */
  86704. _this._indexInSourceMeshInstanceArray = -1;
  86705. source.addInstance(_this);
  86706. _this._sourceMesh = source;
  86707. _this.position.copyFrom(source.position);
  86708. _this.rotation.copyFrom(source.rotation);
  86709. _this.scaling.copyFrom(source.scaling);
  86710. if (source.rotationQuaternion) {
  86711. _this.rotationQuaternion = source.rotationQuaternion.clone();
  86712. }
  86713. _this.infiniteDistance = source.infiniteDistance;
  86714. _this.setPivotMatrix(source.getPivotMatrix());
  86715. _this.refreshBoundingInfo();
  86716. _this._syncSubMeshes();
  86717. return _this;
  86718. }
  86719. /**
  86720. * Returns the string "InstancedMesh".
  86721. */
  86722. InstancedMesh.prototype.getClassName = function () {
  86723. return "InstancedMesh";
  86724. };
  86725. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  86726. // Methods
  86727. /**
  86728. * If the source mesh receives shadows
  86729. */
  86730. get: function () {
  86731. return this._sourceMesh.receiveShadows;
  86732. },
  86733. enumerable: true,
  86734. configurable: true
  86735. });
  86736. Object.defineProperty(InstancedMesh.prototype, "material", {
  86737. /**
  86738. * The material of the source mesh
  86739. */
  86740. get: function () {
  86741. return this._sourceMesh.material;
  86742. },
  86743. enumerable: true,
  86744. configurable: true
  86745. });
  86746. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  86747. /**
  86748. * Visibility of the source mesh
  86749. */
  86750. get: function () {
  86751. return this._sourceMesh.visibility;
  86752. },
  86753. enumerable: true,
  86754. configurable: true
  86755. });
  86756. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  86757. /**
  86758. * Skeleton of the source mesh
  86759. */
  86760. get: function () {
  86761. return this._sourceMesh.skeleton;
  86762. },
  86763. enumerable: true,
  86764. configurable: true
  86765. });
  86766. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  86767. /**
  86768. * Rendering ground id of the source mesh
  86769. */
  86770. get: function () {
  86771. return this._sourceMesh.renderingGroupId;
  86772. },
  86773. set: function (value) {
  86774. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  86775. return;
  86776. }
  86777. //no-op with warning
  86778. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  86779. },
  86780. enumerable: true,
  86781. configurable: true
  86782. });
  86783. /**
  86784. * Returns the total number of vertices (integer).
  86785. */
  86786. InstancedMesh.prototype.getTotalVertices = function () {
  86787. return this._sourceMesh.getTotalVertices();
  86788. };
  86789. /**
  86790. * Returns a positive integer : the total number of indices in this mesh geometry.
  86791. * @returns the numner of indices or zero if the mesh has no geometry.
  86792. */
  86793. InstancedMesh.prototype.getTotalIndices = function () {
  86794. return this._sourceMesh.getTotalIndices();
  86795. };
  86796. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  86797. /**
  86798. * The source mesh of the instance
  86799. */
  86800. get: function () {
  86801. return this._sourceMesh;
  86802. },
  86803. enumerable: true,
  86804. configurable: true
  86805. });
  86806. /**
  86807. * Is this node ready to be used/rendered
  86808. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  86809. * @return {boolean} is it ready
  86810. */
  86811. InstancedMesh.prototype.isReady = function (completeCheck) {
  86812. if (completeCheck === void 0) { completeCheck = false; }
  86813. return this._sourceMesh.isReady(completeCheck, true);
  86814. };
  86815. /**
  86816. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  86817. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  86818. * @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.
  86819. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  86820. */
  86821. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  86822. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  86823. };
  86824. /**
  86825. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86826. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86827. * The `data` are either a numeric array either a Float32Array.
  86828. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  86829. * 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).
  86830. * Note that a new underlying VertexBuffer object is created each call.
  86831. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86832. *
  86833. * Possible `kind` values :
  86834. * - VertexBuffer.PositionKind
  86835. * - VertexBuffer.UVKind
  86836. * - VertexBuffer.UV2Kind
  86837. * - VertexBuffer.UV3Kind
  86838. * - VertexBuffer.UV4Kind
  86839. * - VertexBuffer.UV5Kind
  86840. * - VertexBuffer.UV6Kind
  86841. * - VertexBuffer.ColorKind
  86842. * - VertexBuffer.MatricesIndicesKind
  86843. * - VertexBuffer.MatricesIndicesExtraKind
  86844. * - VertexBuffer.MatricesWeightsKind
  86845. * - VertexBuffer.MatricesWeightsExtraKind
  86846. *
  86847. * Returns the Mesh.
  86848. */
  86849. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  86850. if (this.sourceMesh) {
  86851. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  86852. }
  86853. return this.sourceMesh;
  86854. };
  86855. /**
  86856. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  86857. * If the mesh has no geometry, it is simply returned as it is.
  86858. * The `data` are either a numeric array either a Float32Array.
  86859. * No new underlying VertexBuffer object is created.
  86860. * 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.
  86861. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  86862. *
  86863. * Possible `kind` values :
  86864. * - VertexBuffer.PositionKind
  86865. * - VertexBuffer.UVKind
  86866. * - VertexBuffer.UV2Kind
  86867. * - VertexBuffer.UV3Kind
  86868. * - VertexBuffer.UV4Kind
  86869. * - VertexBuffer.UV5Kind
  86870. * - VertexBuffer.UV6Kind
  86871. * - VertexBuffer.ColorKind
  86872. * - VertexBuffer.MatricesIndicesKind
  86873. * - VertexBuffer.MatricesIndicesExtraKind
  86874. * - VertexBuffer.MatricesWeightsKind
  86875. * - VertexBuffer.MatricesWeightsExtraKind
  86876. *
  86877. * Returns the Mesh.
  86878. */
  86879. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  86880. if (this.sourceMesh) {
  86881. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  86882. }
  86883. return this.sourceMesh;
  86884. };
  86885. /**
  86886. * Sets the mesh indices.
  86887. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  86888. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  86889. * This method creates a new index buffer each call.
  86890. * Returns the Mesh.
  86891. */
  86892. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  86893. if (totalVertices === void 0) { totalVertices = null; }
  86894. if (this.sourceMesh) {
  86895. this.sourceMesh.setIndices(indices, totalVertices);
  86896. }
  86897. return this.sourceMesh;
  86898. };
  86899. /**
  86900. * Boolean : True if the mesh owns the requested kind of data.
  86901. */
  86902. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  86903. return this._sourceMesh.isVerticesDataPresent(kind);
  86904. };
  86905. /**
  86906. * Returns an array of indices (IndicesArray).
  86907. */
  86908. InstancedMesh.prototype.getIndices = function () {
  86909. return this._sourceMesh.getIndices();
  86910. };
  86911. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  86912. get: function () {
  86913. return this._sourceMesh._positions;
  86914. },
  86915. enumerable: true,
  86916. configurable: true
  86917. });
  86918. /**
  86919. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86920. * This means the mesh underlying bounding box and sphere are recomputed.
  86921. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86922. * @returns the current mesh
  86923. */
  86924. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  86925. if (applySkeleton === void 0) { applySkeleton = false; }
  86926. if (this._boundingInfo && this._boundingInfo.isLocked) {
  86927. return this;
  86928. }
  86929. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  86930. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  86931. return this;
  86932. };
  86933. /** @hidden */
  86934. InstancedMesh.prototype._preActivate = function () {
  86935. if (this._currentLOD) {
  86936. this._currentLOD._preActivate();
  86937. }
  86938. return this;
  86939. };
  86940. /** @hidden */
  86941. InstancedMesh.prototype._activate = function (renderId) {
  86942. if (this._currentLOD) {
  86943. this._currentLOD._registerInstanceForRenderId(this, renderId);
  86944. }
  86945. return this;
  86946. };
  86947. /**
  86948. * Returns the current associated LOD AbstractMesh.
  86949. */
  86950. InstancedMesh.prototype.getLOD = function (camera) {
  86951. if (!camera) {
  86952. return this;
  86953. }
  86954. var boundingInfo = this.getBoundingInfo();
  86955. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  86956. if (this._currentLOD === this.sourceMesh) {
  86957. return this;
  86958. }
  86959. return this._currentLOD;
  86960. };
  86961. /** @hidden */
  86962. InstancedMesh.prototype._syncSubMeshes = function () {
  86963. this.releaseSubMeshes();
  86964. if (this._sourceMesh.subMeshes) {
  86965. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  86966. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  86967. }
  86968. }
  86969. return this;
  86970. };
  86971. /** @hidden */
  86972. InstancedMesh.prototype._generatePointsArray = function () {
  86973. return this._sourceMesh._generatePointsArray();
  86974. };
  86975. /**
  86976. * Creates a new InstancedMesh from the current mesh.
  86977. * - name (string) : the cloned mesh name
  86978. * - newParent (optional Node) : the optional Node to parent the clone to.
  86979. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  86980. *
  86981. * Returns the clone.
  86982. */
  86983. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  86984. var result = this._sourceMesh.createInstance(name);
  86985. // Deep copy
  86986. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  86987. // Bounding info
  86988. this.refreshBoundingInfo();
  86989. // Parent
  86990. if (newParent) {
  86991. result.parent = newParent;
  86992. }
  86993. if (!doNotCloneChildren) {
  86994. // Children
  86995. for (var index = 0; index < this.getScene().meshes.length; index++) {
  86996. var mesh = this.getScene().meshes[index];
  86997. if (mesh.parent === this) {
  86998. mesh.clone(mesh.name, result);
  86999. }
  87000. }
  87001. }
  87002. result.computeWorldMatrix(true);
  87003. return result;
  87004. };
  87005. /**
  87006. * Disposes the InstancedMesh.
  87007. * Returns nothing.
  87008. */
  87009. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  87010. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  87011. // Remove from mesh
  87012. this._sourceMesh.removeInstance(this);
  87013. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  87014. };
  87015. return InstancedMesh;
  87016. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]));
  87017. /***/ }),
  87018. /***/ "./Meshes/linesMesh.ts":
  87019. /*!*****************************!*\
  87020. !*** ./Meshes/linesMesh.ts ***!
  87021. \*****************************/
  87022. /*! exports provided: LinesMesh, InstancedLinesMesh */
  87023. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  87024. "use strict";
  87025. __webpack_require__.r(__webpack_exports__);
  87026. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  87027. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  87028. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  87029. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  87030. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  87031. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  87032. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  87033. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  87034. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  87035. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  87036. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  87037. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  87038. /**
  87039. * Line mesh
  87040. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  87041. */
  87042. var LinesMesh = /** @class */ (function (_super) {
  87043. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  87044. /**
  87045. * Creates a new LinesMesh
  87046. * @param name defines the name
  87047. * @param scene defines the hosting scene
  87048. * @param parent defines the parent mesh if any
  87049. * @param source defines the optional source LinesMesh used to clone data from
  87050. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87051. * When false, achieved by calling a clone(), also passing False.
  87052. * This will make creation of children, recursive.
  87053. * @param useVertexColor defines if this LinesMesh supports vertex color
  87054. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  87055. */
  87056. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  87057. /**
  87058. * If vertex color should be applied to the mesh
  87059. */
  87060. useVertexColor,
  87061. /**
  87062. * If vertex alpha should be applied to the mesh
  87063. */
  87064. useVertexAlpha) {
  87065. if (scene === void 0) { scene = null; }
  87066. if (parent === void 0) { parent = null; }
  87067. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  87068. _this.useVertexColor = useVertexColor;
  87069. _this.useVertexAlpha = useVertexAlpha;
  87070. /**
  87071. * Color of the line (Default: White)
  87072. */
  87073. _this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  87074. /**
  87075. * Alpha of the line (Default: 1)
  87076. */
  87077. _this.alpha = 1;
  87078. if (source) {
  87079. _this.color = source.color.clone();
  87080. _this.alpha = source.alpha;
  87081. _this.useVertexColor = source.useVertexColor;
  87082. _this.useVertexAlpha = source.useVertexAlpha;
  87083. }
  87084. _this.intersectionThreshold = 0.1;
  87085. var defines = [];
  87086. var options = {
  87087. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  87088. uniforms: ["vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "world", "viewProjection"],
  87089. needAlphaBlending: true,
  87090. defines: defines
  87091. };
  87092. if (useVertexAlpha === false) {
  87093. options.needAlphaBlending = false;
  87094. }
  87095. if (!useVertexColor) {
  87096. options.uniforms.push("color");
  87097. }
  87098. else {
  87099. options.defines.push("#define VERTEXCOLOR");
  87100. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  87101. }
  87102. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  87103. return _this;
  87104. }
  87105. LinesMesh.prototype._addClipPlaneDefine = function (label) {
  87106. var define = "#define " + label;
  87107. var index = this._colorShader.options.defines.indexOf(define);
  87108. if (index !== -1) {
  87109. return;
  87110. }
  87111. this._colorShader.options.defines.push(define);
  87112. };
  87113. LinesMesh.prototype._removeClipPlaneDefine = function (label) {
  87114. var define = "#define " + label;
  87115. var index = this._colorShader.options.defines.indexOf(define);
  87116. if (index === -1) {
  87117. return;
  87118. }
  87119. this._colorShader.options.defines.splice(index, 1);
  87120. };
  87121. LinesMesh.prototype.isReady = function () {
  87122. var scene = this.getScene();
  87123. // Clip planes
  87124. scene.clipPlane ? this._addClipPlaneDefine("CLIPPLANE") : this._removeClipPlaneDefine("CLIPPLANE");
  87125. scene.clipPlane2 ? this._addClipPlaneDefine("CLIPPLANE2") : this._removeClipPlaneDefine("CLIPPLANE2");
  87126. scene.clipPlane3 ? this._addClipPlaneDefine("CLIPPLANE3") : this._removeClipPlaneDefine("CLIPPLANE3");
  87127. scene.clipPlane4 ? this._addClipPlaneDefine("CLIPPLANE4") : this._removeClipPlaneDefine("CLIPPLANE4");
  87128. if (!this._colorShader.isReady()) {
  87129. return false;
  87130. }
  87131. return _super.prototype.isReady.call(this);
  87132. };
  87133. /**
  87134. * Returns the string "LineMesh"
  87135. */
  87136. LinesMesh.prototype.getClassName = function () {
  87137. return "LinesMesh";
  87138. };
  87139. Object.defineProperty(LinesMesh.prototype, "material", {
  87140. /**
  87141. * @hidden
  87142. */
  87143. get: function () {
  87144. return this._colorShader;
  87145. },
  87146. /**
  87147. * @hidden
  87148. */
  87149. set: function (value) {
  87150. // Do nothing
  87151. },
  87152. enumerable: true,
  87153. configurable: true
  87154. });
  87155. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  87156. /**
  87157. * @hidden
  87158. */
  87159. get: function () {
  87160. return false;
  87161. },
  87162. enumerable: true,
  87163. configurable: true
  87164. });
  87165. /** @hidden */
  87166. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  87167. if (!this._geometry) {
  87168. return this;
  87169. }
  87170. var colorEffect = this._colorShader.getEffect();
  87171. // VBOs
  87172. this._geometry._bind(colorEffect);
  87173. // Color
  87174. if (!this.useVertexColor) {
  87175. this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
  87176. }
  87177. // Clip planes
  87178. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_9__["MaterialHelper"].BindClipPlane(colorEffect, this.getScene());
  87179. return this;
  87180. };
  87181. /** @hidden */
  87182. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  87183. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  87184. return this;
  87185. }
  87186. var engine = this.getScene().getEngine();
  87187. // Draw order
  87188. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  87189. return this;
  87190. };
  87191. /**
  87192. * Disposes of the line mesh
  87193. * @param doNotRecurse If children should be disposed
  87194. */
  87195. LinesMesh.prototype.dispose = function (doNotRecurse) {
  87196. this._colorShader.dispose(false, false, true);
  87197. _super.prototype.dispose.call(this, doNotRecurse);
  87198. };
  87199. /**
  87200. * Returns a new LineMesh object cloned from the current one.
  87201. */
  87202. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  87203. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  87204. };
  87205. /**
  87206. * Creates a new InstancedLinesMesh object from the mesh model.
  87207. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87208. * @param name defines the name of the new instance
  87209. * @returns a new InstancedLinesMesh
  87210. */
  87211. LinesMesh.prototype.createInstance = function (name) {
  87212. return new InstancedLinesMesh(name, this);
  87213. };
  87214. return LinesMesh;
  87215. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  87216. /**
  87217. * Creates an instance based on a source LinesMesh
  87218. */
  87219. var InstancedLinesMesh = /** @class */ (function (_super) {
  87220. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  87221. function InstancedLinesMesh(name, source) {
  87222. var _this = _super.call(this, name, source) || this;
  87223. _this.intersectionThreshold = source.intersectionThreshold;
  87224. return _this;
  87225. }
  87226. /**
  87227. * Returns the string "InstancedLinesMesh".
  87228. */
  87229. InstancedLinesMesh.prototype.getClassName = function () {
  87230. return "InstancedLinesMesh";
  87231. };
  87232. return InstancedLinesMesh;
  87233. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  87234. /***/ }),
  87235. /***/ "./Meshes/mesh.ts":
  87236. /*!************************!*\
  87237. !*** ./Meshes/mesh.ts ***!
  87238. \************************/
  87239. /*! exports provided: MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh */
  87240. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  87241. "use strict";
  87242. __webpack_require__.r(__webpack_exports__);
  87243. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  87244. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  87245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  87246. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  87247. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  87248. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  87249. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  87250. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  87251. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  87252. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  87253. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  87254. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  87255. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  87256. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  87257. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  87258. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  87259. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  87260. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  87261. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  87262. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  87263. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  87264. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  87265. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  87266. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  87267. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  87268. /**
  87269. * Class used to represent a specific level of detail of a mesh
  87270. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87271. */
  87272. var MeshLODLevel = /** @class */ (function () {
  87273. /**
  87274. * Creates a new LOD level
  87275. * @param distance defines the distance where this level should star being displayed
  87276. * @param mesh defines the mesh to use to render this level
  87277. */
  87278. function MeshLODLevel(
  87279. /** Defines the distance where this level should star being displayed */
  87280. distance,
  87281. /** Defines the mesh to use to render this level */
  87282. mesh) {
  87283. this.distance = distance;
  87284. this.mesh = mesh;
  87285. }
  87286. return MeshLODLevel;
  87287. }());
  87288. /**
  87289. * @hidden
  87290. **/
  87291. var _CreationDataStorage = /** @class */ (function () {
  87292. function _CreationDataStorage() {
  87293. }
  87294. return _CreationDataStorage;
  87295. }());
  87296. /**
  87297. * @hidden
  87298. **/
  87299. var _InstanceDataStorage = /** @class */ (function () {
  87300. function _InstanceDataStorage() {
  87301. this.visibleInstances = {};
  87302. this.renderIdForInstances = new Array();
  87303. this.batchCache = new _InstancesBatch();
  87304. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  87305. }
  87306. return _InstanceDataStorage;
  87307. }());
  87308. /**
  87309. * @hidden
  87310. **/
  87311. var _InstancesBatch = /** @class */ (function () {
  87312. function _InstancesBatch() {
  87313. this.mustReturn = false;
  87314. this.visibleInstances = new Array();
  87315. this.renderSelf = new Array();
  87316. }
  87317. return _InstancesBatch;
  87318. }());
  87319. /**
  87320. * Class used to represent renderable models
  87321. */
  87322. var Mesh = /** @class */ (function (_super) {
  87323. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  87324. /**
  87325. * @constructor
  87326. * @param name The value used by scene.getMeshByName() to do a lookup.
  87327. * @param scene The scene to add this mesh to.
  87328. * @param parent The parent of this mesh, if it has one
  87329. * @param source An optional Mesh from which geometry is shared, cloned.
  87330. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87331. * When false, achieved by calling a clone(), also passing False.
  87332. * This will make creation of children, recursive.
  87333. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  87334. */
  87335. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  87336. if (scene === void 0) { scene = null; }
  87337. if (parent === void 0) { parent = null; }
  87338. if (source === void 0) { source = null; }
  87339. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  87340. var _this = _super.call(this, name, scene) || this;
  87341. // Members
  87342. /**
  87343. * Gets the delay loading state of the mesh (when delay loading is turned on)
  87344. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  87345. */
  87346. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NONE;
  87347. /**
  87348. * Gets the list of instances created from this mesh
  87349. * it is not supposed to be modified manually.
  87350. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  87351. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87352. */
  87353. _this.instances = new Array();
  87354. _this._LODLevels = new Array();
  87355. /** @hidden */
  87356. _this._instanceDataStorage = new _InstanceDataStorage();
  87357. // Use by builder only to know what orientation were the mesh build in.
  87358. /** @hidden */
  87359. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  87360. /**
  87361. * Use this property to change the original side orientation defined at construction time
  87362. */
  87363. _this.overrideMaterialSideOrientation = null;
  87364. _this._areNormalsFrozen = false; // Will be used by ribbons mainly
  87365. // Will be used to save a source mesh reference, If any
  87366. _this._source = null;
  87367. /** @hidden */
  87368. _this._isMesh = true;
  87369. scene = _this.getScene();
  87370. if (source) {
  87371. // Geometry
  87372. if (source._geometry) {
  87373. source._geometry.applyToMesh(_this);
  87374. }
  87375. // Deep copy
  87376. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  87377. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  87378. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  87379. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  87380. "onDisposeObservable"
  87381. ], ["_poseMatrix"]);
  87382. // Source mesh
  87383. _this._source = source;
  87384. if (scene.useClonedMeshhMap) {
  87385. if (!source.meshMap) {
  87386. source.meshMap = {};
  87387. }
  87388. source.meshMap[_this.uniqueId] = _this;
  87389. }
  87390. // Construction Params
  87391. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  87392. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  87393. _this._creationDataStorage = source._creationDataStorage;
  87394. // Animation ranges
  87395. if (_this._source._ranges) {
  87396. var ranges = _this._source._ranges;
  87397. for (var name in ranges) {
  87398. if (!ranges.hasOwnProperty(name)) {
  87399. continue;
  87400. }
  87401. if (!ranges[name]) {
  87402. continue;
  87403. }
  87404. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  87405. }
  87406. }
  87407. // Metadata
  87408. if (source.metadata && source.metadata.clone) {
  87409. _this.metadata = source.metadata.clone();
  87410. }
  87411. else {
  87412. _this.metadata = source.metadata;
  87413. }
  87414. // Tags
  87415. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  87416. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  87417. }
  87418. // Parent
  87419. _this.parent = source.parent;
  87420. // Pivot
  87421. _this.setPivotMatrix(source.getPivotMatrix());
  87422. _this.id = name + "." + source.id;
  87423. // Material
  87424. _this.material = source.material;
  87425. var index;
  87426. if (!doNotCloneChildren) {
  87427. // Children
  87428. var directDescendants = source.getDescendants(true);
  87429. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  87430. var child = directDescendants[index_1];
  87431. if (child.clone) {
  87432. child.clone(name + "." + child.name, _this);
  87433. }
  87434. }
  87435. }
  87436. // Physics clone
  87437. var physicsEngine = _this.getScene().getPhysicsEngine();
  87438. if (clonePhysicsImpostor && physicsEngine) {
  87439. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  87440. if (impostor) {
  87441. _this.physicsImpostor = impostor.clone(_this);
  87442. }
  87443. }
  87444. // Particles
  87445. for (index = 0; index < scene.particleSystems.length; index++) {
  87446. var system = scene.particleSystems[index];
  87447. if (system.emitter === source) {
  87448. system.clone(system.name, _this);
  87449. }
  87450. }
  87451. _this.refreshBoundingInfo();
  87452. _this.computeWorldMatrix(true);
  87453. }
  87454. // Parent
  87455. if (parent !== null) {
  87456. _this.parent = parent;
  87457. }
  87458. return _this;
  87459. }
  87460. /**
  87461. * Gets the default side orientation.
  87462. * @param orientation the orientation to value to attempt to get
  87463. * @returns the default orientation
  87464. * @hidden
  87465. */
  87466. Mesh._GetDefaultSideOrientation = function (orientation) {
  87467. return orientation || Mesh.FRONTSIDE; // works as Mesh.FRONTSIDE is 0
  87468. };
  87469. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  87470. /**
  87471. * An event triggered before rendering the mesh
  87472. */
  87473. get: function () {
  87474. if (!this._onBeforeRenderObservable) {
  87475. this._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  87476. }
  87477. return this._onBeforeRenderObservable;
  87478. },
  87479. enumerable: true,
  87480. configurable: true
  87481. });
  87482. Object.defineProperty(Mesh.prototype, "onBeforeBindObservable", {
  87483. /**
  87484. * An event triggered before binding the mesh
  87485. */
  87486. get: function () {
  87487. if (!this._onBeforeBindObservable) {
  87488. this._onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  87489. }
  87490. return this._onBeforeBindObservable;
  87491. },
  87492. enumerable: true,
  87493. configurable: true
  87494. });
  87495. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  87496. /**
  87497. * An event triggered after rendering the mesh
  87498. */
  87499. get: function () {
  87500. if (!this._onAfterRenderObservable) {
  87501. this._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  87502. }
  87503. return this._onAfterRenderObservable;
  87504. },
  87505. enumerable: true,
  87506. configurable: true
  87507. });
  87508. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  87509. /**
  87510. * An event triggered before drawing the mesh
  87511. */
  87512. get: function () {
  87513. if (!this._onBeforeDrawObservable) {
  87514. this._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  87515. }
  87516. return this._onBeforeDrawObservable;
  87517. },
  87518. enumerable: true,
  87519. configurable: true
  87520. });
  87521. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  87522. /**
  87523. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  87524. */
  87525. set: function (callback) {
  87526. if (this._onBeforeDrawObserver) {
  87527. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  87528. }
  87529. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  87530. },
  87531. enumerable: true,
  87532. configurable: true
  87533. });
  87534. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  87535. /**
  87536. * Gets or sets the morph target manager
  87537. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87538. */
  87539. get: function () {
  87540. return this._morphTargetManager;
  87541. },
  87542. set: function (value) {
  87543. if (this._morphTargetManager === value) {
  87544. return;
  87545. }
  87546. this._morphTargetManager = value;
  87547. this._syncGeometryWithMorphTargetManager();
  87548. },
  87549. enumerable: true,
  87550. configurable: true
  87551. });
  87552. Object.defineProperty(Mesh.prototype, "source", {
  87553. /**
  87554. * Gets the source mesh (the one used to clone this one from)
  87555. */
  87556. get: function () {
  87557. return this._source;
  87558. },
  87559. enumerable: true,
  87560. configurable: true
  87561. });
  87562. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  87563. /**
  87564. * Gets or sets a boolean indicating that this mesh does not use index buffer
  87565. */
  87566. get: function () {
  87567. return this._unIndexed;
  87568. },
  87569. set: function (value) {
  87570. if (this._unIndexed !== value) {
  87571. this._unIndexed = value;
  87572. this._markSubMeshesAsAttributesDirty();
  87573. }
  87574. },
  87575. enumerable: true,
  87576. configurable: true
  87577. });
  87578. // Methods
  87579. /**
  87580. * Gets the class name
  87581. * @returns the string "Mesh".
  87582. */
  87583. Mesh.prototype.getClassName = function () {
  87584. return "Mesh";
  87585. };
  87586. /**
  87587. * Returns a description of this mesh
  87588. * @param fullDetails define if full details about this mesh must be used
  87589. * @returns a descriptive string representing this mesh
  87590. */
  87591. Mesh.prototype.toString = function (fullDetails) {
  87592. var ret = _super.prototype.toString.call(this, fullDetails);
  87593. ret += ", n vertices: " + this.getTotalVertices();
  87594. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  87595. if (this.animations) {
  87596. for (var i = 0; i < this.animations.length; i++) {
  87597. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  87598. }
  87599. }
  87600. if (fullDetails) {
  87601. if (this._geometry) {
  87602. var ib = this.getIndices();
  87603. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  87604. if (vb && ib) {
  87605. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  87606. }
  87607. }
  87608. else {
  87609. ret += ", flat shading: UNKNOWN";
  87610. }
  87611. }
  87612. return ret;
  87613. };
  87614. /** @hidden */
  87615. Mesh.prototype._unBindEffect = function () {
  87616. _super.prototype._unBindEffect.call(this);
  87617. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  87618. var instance = _a[_i];
  87619. instance._unBindEffect();
  87620. }
  87621. };
  87622. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  87623. /**
  87624. * Gets a boolean indicating if this mesh has LOD
  87625. */
  87626. get: function () {
  87627. return this._LODLevels.length > 0;
  87628. },
  87629. enumerable: true,
  87630. configurable: true
  87631. });
  87632. /**
  87633. * Gets the list of MeshLODLevel associated with the current mesh
  87634. * @returns an array of MeshLODLevel
  87635. */
  87636. Mesh.prototype.getLODLevels = function () {
  87637. return this._LODLevels;
  87638. };
  87639. Mesh.prototype._sortLODLevels = function () {
  87640. this._LODLevels.sort(function (a, b) {
  87641. if (a.distance < b.distance) {
  87642. return 1;
  87643. }
  87644. if (a.distance > b.distance) {
  87645. return -1;
  87646. }
  87647. return 0;
  87648. });
  87649. };
  87650. /**
  87651. * Add a mesh as LOD level triggered at the given distance.
  87652. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87653. * @param distance The distance from the center of the object to show this level
  87654. * @param mesh The mesh to be added as LOD level (can be null)
  87655. * @return This mesh (for chaining)
  87656. */
  87657. Mesh.prototype.addLODLevel = function (distance, mesh) {
  87658. if (mesh && mesh._masterMesh) {
  87659. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  87660. return this;
  87661. }
  87662. var level = new MeshLODLevel(distance, mesh);
  87663. this._LODLevels.push(level);
  87664. if (mesh) {
  87665. mesh._masterMesh = this;
  87666. }
  87667. this._sortLODLevels();
  87668. return this;
  87669. };
  87670. /**
  87671. * Returns the LOD level mesh at the passed distance or null if not found.
  87672. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87673. * @param distance The distance from the center of the object to show this level
  87674. * @returns a Mesh or `null`
  87675. */
  87676. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  87677. for (var index = 0; index < this._LODLevels.length; index++) {
  87678. var level = this._LODLevels[index];
  87679. if (level.distance === distance) {
  87680. return level.mesh;
  87681. }
  87682. }
  87683. return null;
  87684. };
  87685. /**
  87686. * Remove a mesh from the LOD array
  87687. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87688. * @param mesh defines the mesh to be removed
  87689. * @return This mesh (for chaining)
  87690. */
  87691. Mesh.prototype.removeLODLevel = function (mesh) {
  87692. for (var index = 0; index < this._LODLevels.length; index++) {
  87693. if (this._LODLevels[index].mesh === mesh) {
  87694. this._LODLevels.splice(index, 1);
  87695. if (mesh) {
  87696. mesh._masterMesh = null;
  87697. }
  87698. }
  87699. }
  87700. this._sortLODLevels();
  87701. return this;
  87702. };
  87703. /**
  87704. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  87705. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87706. * @param camera defines the camera to use to compute distance
  87707. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  87708. * @return This mesh (for chaining)
  87709. */
  87710. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  87711. if (!this._LODLevels || this._LODLevels.length === 0) {
  87712. return this;
  87713. }
  87714. var bSphere;
  87715. if (boundingSphere) {
  87716. bSphere = boundingSphere;
  87717. }
  87718. else {
  87719. var boundingInfo = this.getBoundingInfo();
  87720. bSphere = boundingInfo.boundingSphere;
  87721. }
  87722. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  87723. if (this._LODLevels[this._LODLevels.length - 1].distance > distanceToCamera) {
  87724. if (this.onLODLevelSelection) {
  87725. this.onLODLevelSelection(distanceToCamera, this, this._LODLevels[this._LODLevels.length - 1].mesh);
  87726. }
  87727. return this;
  87728. }
  87729. for (var index = 0; index < this._LODLevels.length; index++) {
  87730. var level = this._LODLevels[index];
  87731. if (level.distance < distanceToCamera) {
  87732. if (level.mesh) {
  87733. level.mesh._preActivate();
  87734. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  87735. }
  87736. if (this.onLODLevelSelection) {
  87737. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  87738. }
  87739. return level.mesh;
  87740. }
  87741. }
  87742. if (this.onLODLevelSelection) {
  87743. this.onLODLevelSelection(distanceToCamera, this, this);
  87744. }
  87745. return this;
  87746. };
  87747. Object.defineProperty(Mesh.prototype, "geometry", {
  87748. /**
  87749. * Gets the mesh internal Geometry object
  87750. */
  87751. get: function () {
  87752. return this._geometry;
  87753. },
  87754. enumerable: true,
  87755. configurable: true
  87756. });
  87757. /**
  87758. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  87759. * @returns the total number of vertices
  87760. */
  87761. Mesh.prototype.getTotalVertices = function () {
  87762. if (this._geometry === null || this._geometry === undefined) {
  87763. return 0;
  87764. }
  87765. return this._geometry.getTotalVertices();
  87766. };
  87767. /**
  87768. * Returns the content of an associated vertex buffer
  87769. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87770. * - VertexBuffer.PositionKind
  87771. * - VertexBuffer.UVKind
  87772. * - VertexBuffer.UV2Kind
  87773. * - VertexBuffer.UV3Kind
  87774. * - VertexBuffer.UV4Kind
  87775. * - VertexBuffer.UV5Kind
  87776. * - VertexBuffer.UV6Kind
  87777. * - VertexBuffer.ColorKind
  87778. * - VertexBuffer.MatricesIndicesKind
  87779. * - VertexBuffer.MatricesIndicesExtraKind
  87780. * - VertexBuffer.MatricesWeightsKind
  87781. * - VertexBuffer.MatricesWeightsExtraKind
  87782. * @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
  87783. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  87784. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  87785. */
  87786. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  87787. if (!this._geometry) {
  87788. return null;
  87789. }
  87790. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  87791. };
  87792. /**
  87793. * Returns the mesh VertexBuffer object from the requested `kind`
  87794. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87795. * - VertexBuffer.PositionKind
  87796. * - VertexBuffer.UVKind
  87797. * - VertexBuffer.UV2Kind
  87798. * - VertexBuffer.UV3Kind
  87799. * - VertexBuffer.UV4Kind
  87800. * - VertexBuffer.UV5Kind
  87801. * - VertexBuffer.UV6Kind
  87802. * - VertexBuffer.ColorKind
  87803. * - VertexBuffer.MatricesIndicesKind
  87804. * - VertexBuffer.MatricesIndicesExtraKind
  87805. * - VertexBuffer.MatricesWeightsKind
  87806. * - VertexBuffer.MatricesWeightsExtraKind
  87807. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  87808. */
  87809. Mesh.prototype.getVertexBuffer = function (kind) {
  87810. if (!this._geometry) {
  87811. return null;
  87812. }
  87813. return this._geometry.getVertexBuffer(kind);
  87814. };
  87815. /**
  87816. * Tests if a specific vertex buffer is associated with this mesh
  87817. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87818. * - VertexBuffer.PositionKind
  87819. * - VertexBuffer.UVKind
  87820. * - VertexBuffer.UV2Kind
  87821. * - VertexBuffer.UV3Kind
  87822. * - VertexBuffer.UV4Kind
  87823. * - VertexBuffer.UV5Kind
  87824. * - VertexBuffer.UV6Kind
  87825. * - VertexBuffer.ColorKind
  87826. * - VertexBuffer.MatricesIndicesKind
  87827. * - VertexBuffer.MatricesIndicesExtraKind
  87828. * - VertexBuffer.MatricesWeightsKind
  87829. * - VertexBuffer.MatricesWeightsExtraKind
  87830. * @returns a boolean
  87831. */
  87832. Mesh.prototype.isVerticesDataPresent = function (kind) {
  87833. if (!this._geometry) {
  87834. if (this._delayInfo) {
  87835. return this._delayInfo.indexOf(kind) !== -1;
  87836. }
  87837. return false;
  87838. }
  87839. return this._geometry.isVerticesDataPresent(kind);
  87840. };
  87841. /**
  87842. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  87843. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87844. * - VertexBuffer.PositionKind
  87845. * - VertexBuffer.UVKind
  87846. * - VertexBuffer.UV2Kind
  87847. * - VertexBuffer.UV3Kind
  87848. * - VertexBuffer.UV4Kind
  87849. * - VertexBuffer.UV5Kind
  87850. * - VertexBuffer.UV6Kind
  87851. * - VertexBuffer.ColorKind
  87852. * - VertexBuffer.MatricesIndicesKind
  87853. * - VertexBuffer.MatricesIndicesExtraKind
  87854. * - VertexBuffer.MatricesWeightsKind
  87855. * - VertexBuffer.MatricesWeightsExtraKind
  87856. * @returns a boolean
  87857. */
  87858. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  87859. if (!this._geometry) {
  87860. if (this._delayInfo) {
  87861. return this._delayInfo.indexOf(kind) !== -1;
  87862. }
  87863. return false;
  87864. }
  87865. return this._geometry.isVertexBufferUpdatable(kind);
  87866. };
  87867. /**
  87868. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  87869. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87870. * - VertexBuffer.PositionKind
  87871. * - VertexBuffer.UVKind
  87872. * - VertexBuffer.UV2Kind
  87873. * - VertexBuffer.UV3Kind
  87874. * - VertexBuffer.UV4Kind
  87875. * - VertexBuffer.UV5Kind
  87876. * - VertexBuffer.UV6Kind
  87877. * - VertexBuffer.ColorKind
  87878. * - VertexBuffer.MatricesIndicesKind
  87879. * - VertexBuffer.MatricesIndicesExtraKind
  87880. * - VertexBuffer.MatricesWeightsKind
  87881. * - VertexBuffer.MatricesWeightsExtraKind
  87882. * @returns an array of strings
  87883. */
  87884. Mesh.prototype.getVerticesDataKinds = function () {
  87885. if (!this._geometry) {
  87886. var result = new Array();
  87887. if (this._delayInfo) {
  87888. this._delayInfo.forEach(function (kind) {
  87889. result.push(kind);
  87890. });
  87891. }
  87892. return result;
  87893. }
  87894. return this._geometry.getVerticesDataKinds();
  87895. };
  87896. /**
  87897. * Returns a positive integer : the total number of indices in this mesh geometry.
  87898. * @returns the numner of indices or zero if the mesh has no geometry.
  87899. */
  87900. Mesh.prototype.getTotalIndices = function () {
  87901. if (!this._geometry) {
  87902. return 0;
  87903. }
  87904. return this._geometry.getTotalIndices();
  87905. };
  87906. /**
  87907. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87908. * @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.
  87909. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87910. * @returns the indices array or an empty array if the mesh has no geometry
  87911. */
  87912. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  87913. if (!this._geometry) {
  87914. return [];
  87915. }
  87916. return this._geometry.getIndices(copyWhenShared, forceCopy);
  87917. };
  87918. Object.defineProperty(Mesh.prototype, "isBlocked", {
  87919. get: function () {
  87920. return this._masterMesh !== null && this._masterMesh !== undefined;
  87921. },
  87922. enumerable: true,
  87923. configurable: true
  87924. });
  87925. /**
  87926. * Determine if the current mesh is ready to be rendered
  87927. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87928. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  87929. * @returns true if all associated assets are ready (material, textures, shaders)
  87930. */
  87931. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  87932. if (completeCheck === void 0) { completeCheck = false; }
  87933. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  87934. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  87935. return false;
  87936. }
  87937. if (!_super.prototype.isReady.call(this, completeCheck)) {
  87938. return false;
  87939. }
  87940. if (!this.subMeshes || this.subMeshes.length === 0) {
  87941. return true;
  87942. }
  87943. if (!completeCheck) {
  87944. return true;
  87945. }
  87946. var engine = this.getEngine();
  87947. var scene = this.getScene();
  87948. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  87949. this.computeWorldMatrix();
  87950. var mat = this.material || scene.defaultMaterial;
  87951. if (mat) {
  87952. if (mat._storeEffectOnSubMeshes) {
  87953. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  87954. var subMesh = _a[_i];
  87955. var effectiveMaterial = subMesh.getMaterial();
  87956. if (effectiveMaterial) {
  87957. if (effectiveMaterial._storeEffectOnSubMeshes) {
  87958. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  87959. return false;
  87960. }
  87961. }
  87962. else {
  87963. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  87964. return false;
  87965. }
  87966. }
  87967. }
  87968. }
  87969. }
  87970. else {
  87971. if (!mat.isReady(this, hardwareInstancedRendering)) {
  87972. return false;
  87973. }
  87974. }
  87975. }
  87976. // Shadows
  87977. for (var _b = 0, _c = this._lightSources; _b < _c.length; _b++) {
  87978. var light = _c[_b];
  87979. var generator = light.getShadowGenerator();
  87980. if (generator) {
  87981. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  87982. var subMesh = _e[_d];
  87983. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  87984. return false;
  87985. }
  87986. }
  87987. }
  87988. }
  87989. // LOD
  87990. for (var _f = 0, _g = this._LODLevels; _f < _g.length; _f++) {
  87991. var lod = _g[_f];
  87992. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  87993. return false;
  87994. }
  87995. }
  87996. return true;
  87997. };
  87998. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  87999. /**
  88000. * 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.
  88001. */
  88002. get: function () {
  88003. return this._areNormalsFrozen;
  88004. },
  88005. enumerable: true,
  88006. configurable: true
  88007. });
  88008. /**
  88009. * 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.
  88010. * @returns the current mesh
  88011. */
  88012. Mesh.prototype.freezeNormals = function () {
  88013. this._areNormalsFrozen = true;
  88014. return this;
  88015. };
  88016. /**
  88017. * 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
  88018. * @returns the current mesh
  88019. */
  88020. Mesh.prototype.unfreezeNormals = function () {
  88021. this._areNormalsFrozen = false;
  88022. return this;
  88023. };
  88024. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  88025. /**
  88026. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  88027. */
  88028. set: function (count) {
  88029. this._instanceDataStorage.overridenInstanceCount = count;
  88030. },
  88031. enumerable: true,
  88032. configurable: true
  88033. });
  88034. // Methods
  88035. /** @hidden */
  88036. Mesh.prototype._preActivate = function () {
  88037. var sceneRenderId = this.getScene().getRenderId();
  88038. if (this._preActivateId === sceneRenderId) {
  88039. return this;
  88040. }
  88041. this._preActivateId = sceneRenderId;
  88042. this._instanceDataStorage.visibleInstances = null;
  88043. return this;
  88044. };
  88045. /** @hidden */
  88046. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  88047. if (this._instanceDataStorage.visibleInstances) {
  88048. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  88049. }
  88050. return this;
  88051. };
  88052. /** @hidden */
  88053. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  88054. if (!this._instanceDataStorage.visibleInstances) {
  88055. this._instanceDataStorage.visibleInstances = {
  88056. defaultRenderId: renderId,
  88057. selfDefaultRenderId: this._renderId
  88058. };
  88059. }
  88060. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  88061. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  88062. }
  88063. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  88064. return this;
  88065. };
  88066. /**
  88067. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88068. * This means the mesh underlying bounding box and sphere are recomputed.
  88069. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88070. * @returns the current mesh
  88071. */
  88072. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  88073. if (applySkeleton === void 0) { applySkeleton = false; }
  88074. if (this._boundingInfo && this._boundingInfo.isLocked) {
  88075. return this;
  88076. }
  88077. var bias = this.geometry ? this.geometry.boundingBias : null;
  88078. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  88079. return this;
  88080. };
  88081. /** @hidden */
  88082. Mesh.prototype._createGlobalSubMesh = function (force) {
  88083. var totalVertices = this.getTotalVertices();
  88084. if (!totalVertices || !this.getIndices()) {
  88085. return null;
  88086. }
  88087. // Check if we need to recreate the submeshes
  88088. if (this.subMeshes && this.subMeshes.length > 0) {
  88089. var ib = this.getIndices();
  88090. if (!ib) {
  88091. return null;
  88092. }
  88093. var totalIndices = ib.length;
  88094. var needToRecreate = false;
  88095. if (force) {
  88096. needToRecreate = true;
  88097. }
  88098. else {
  88099. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  88100. var submesh = _a[_i];
  88101. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  88102. needToRecreate = true;
  88103. break;
  88104. }
  88105. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  88106. needToRecreate = true;
  88107. break;
  88108. }
  88109. }
  88110. }
  88111. if (!needToRecreate) {
  88112. return this.subMeshes[0];
  88113. }
  88114. }
  88115. this.releaseSubMeshes();
  88116. return new _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  88117. };
  88118. /**
  88119. * This function will subdivide the mesh into multiple submeshes
  88120. * @param count defines the expected number of submeshes
  88121. */
  88122. Mesh.prototype.subdivide = function (count) {
  88123. if (count < 1) {
  88124. return;
  88125. }
  88126. var totalIndices = this.getTotalIndices();
  88127. var subdivisionSize = (totalIndices / count) | 0;
  88128. var offset = 0;
  88129. // Ensure that subdivisionSize is a multiple of 3
  88130. while (subdivisionSize % 3 !== 0) {
  88131. subdivisionSize++;
  88132. }
  88133. this.releaseSubMeshes();
  88134. for (var index = 0; index < count; index++) {
  88135. if (offset >= totalIndices) {
  88136. break;
  88137. }
  88138. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  88139. offset += subdivisionSize;
  88140. }
  88141. this.synchronizeInstances();
  88142. };
  88143. /**
  88144. * Copy a FloatArray into a specific associated vertex buffer
  88145. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88146. * - VertexBuffer.PositionKind
  88147. * - VertexBuffer.UVKind
  88148. * - VertexBuffer.UV2Kind
  88149. * - VertexBuffer.UV3Kind
  88150. * - VertexBuffer.UV4Kind
  88151. * - VertexBuffer.UV5Kind
  88152. * - VertexBuffer.UV6Kind
  88153. * - VertexBuffer.ColorKind
  88154. * - VertexBuffer.MatricesIndicesKind
  88155. * - VertexBuffer.MatricesIndicesExtraKind
  88156. * - VertexBuffer.MatricesWeightsKind
  88157. * - VertexBuffer.MatricesWeightsExtraKind
  88158. * @param data defines the data source
  88159. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88160. * @param stride defines the data stride size (can be null)
  88161. * @returns the current mesh
  88162. */
  88163. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  88164. if (updatable === void 0) { updatable = false; }
  88165. if (!this._geometry) {
  88166. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  88167. vertexData.set(data, kind);
  88168. var scene = this.getScene();
  88169. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  88170. }
  88171. else {
  88172. this._geometry.setVerticesData(kind, data, updatable, stride);
  88173. }
  88174. return this;
  88175. };
  88176. /**
  88177. * Flags an associated vertex buffer as updatable
  88178. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  88179. * - VertexBuffer.PositionKind
  88180. * - VertexBuffer.UVKind
  88181. * - VertexBuffer.UV2Kind
  88182. * - VertexBuffer.UV3Kind
  88183. * - VertexBuffer.UV4Kind
  88184. * - VertexBuffer.UV5Kind
  88185. * - VertexBuffer.UV6Kind
  88186. * - VertexBuffer.ColorKind
  88187. * - VertexBuffer.MatricesIndicesKind
  88188. * - VertexBuffer.MatricesIndicesExtraKind
  88189. * - VertexBuffer.MatricesWeightsKind
  88190. * - VertexBuffer.MatricesWeightsExtraKind
  88191. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  88192. */
  88193. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  88194. if (updatable === void 0) { updatable = true; }
  88195. var vb = this.getVertexBuffer(kind);
  88196. if (!vb || vb.isUpdatable() === updatable) {
  88197. return;
  88198. }
  88199. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  88200. };
  88201. /**
  88202. * Sets the mesh global Vertex Buffer
  88203. * @param buffer defines the buffer to use
  88204. * @returns the current mesh
  88205. */
  88206. Mesh.prototype.setVerticesBuffer = function (buffer) {
  88207. if (!this._geometry) {
  88208. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].CreateGeometryForMesh(this);
  88209. }
  88210. this._geometry.setVerticesBuffer(buffer);
  88211. return this;
  88212. };
  88213. /**
  88214. * Update a specific associated vertex buffer
  88215. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88216. * - VertexBuffer.PositionKind
  88217. * - VertexBuffer.UVKind
  88218. * - VertexBuffer.UV2Kind
  88219. * - VertexBuffer.UV3Kind
  88220. * - VertexBuffer.UV4Kind
  88221. * - VertexBuffer.UV5Kind
  88222. * - VertexBuffer.UV6Kind
  88223. * - VertexBuffer.ColorKind
  88224. * - VertexBuffer.MatricesIndicesKind
  88225. * - VertexBuffer.MatricesIndicesExtraKind
  88226. * - VertexBuffer.MatricesWeightsKind
  88227. * - VertexBuffer.MatricesWeightsExtraKind
  88228. * @param data defines the data source
  88229. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88230. * @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)
  88231. * @returns the current mesh
  88232. */
  88233. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  88234. if (!this._geometry) {
  88235. return this;
  88236. }
  88237. if (!makeItUnique) {
  88238. this._geometry.updateVerticesData(kind, data, updateExtends);
  88239. }
  88240. else {
  88241. this.makeGeometryUnique();
  88242. this.updateVerticesData(kind, data, updateExtends, false);
  88243. }
  88244. return this;
  88245. };
  88246. /**
  88247. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  88248. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  88249. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  88250. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  88251. * @returns the current mesh
  88252. */
  88253. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  88254. if (computeNormals === void 0) { computeNormals = true; }
  88255. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  88256. if (!positions) {
  88257. return this;
  88258. }
  88259. positionFunction(positions);
  88260. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions, false, false);
  88261. if (computeNormals) {
  88262. var indices = this.getIndices();
  88263. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  88264. if (!normals) {
  88265. return this;
  88266. }
  88267. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  88268. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, false, false);
  88269. }
  88270. return this;
  88271. };
  88272. /**
  88273. * Creates a un-shared specific occurence of the geometry for the mesh.
  88274. * @returns the current mesh
  88275. */
  88276. Mesh.prototype.makeGeometryUnique = function () {
  88277. if (!this._geometry) {
  88278. return this;
  88279. }
  88280. var oldGeometry = this._geometry;
  88281. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId());
  88282. oldGeometry.releaseForMesh(this, true);
  88283. geometry.applyToMesh(this);
  88284. return this;
  88285. };
  88286. /**
  88287. * Set the index buffer of this mesh
  88288. * @param indices defines the source data
  88289. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  88290. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  88291. * @returns the current mesh
  88292. */
  88293. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  88294. if (totalVertices === void 0) { totalVertices = null; }
  88295. if (updatable === void 0) { updatable = false; }
  88296. if (!this._geometry) {
  88297. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  88298. vertexData.indices = indices;
  88299. var scene = this.getScene();
  88300. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  88301. }
  88302. else {
  88303. this._geometry.setIndices(indices, totalVertices, updatable);
  88304. }
  88305. return this;
  88306. };
  88307. /**
  88308. * Update the current index buffer
  88309. * @param indices defines the source data
  88310. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  88311. * @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)
  88312. * @returns the current mesh
  88313. */
  88314. Mesh.prototype.updateIndices = function (indices, offset, gpuMemoryOnly) {
  88315. if (gpuMemoryOnly === void 0) { gpuMemoryOnly = false; }
  88316. if (!this._geometry) {
  88317. return this;
  88318. }
  88319. this._geometry.updateIndices(indices, offset, gpuMemoryOnly);
  88320. return this;
  88321. };
  88322. /**
  88323. * Invert the geometry to move from a right handed system to a left handed one.
  88324. * @returns the current mesh
  88325. */
  88326. Mesh.prototype.toLeftHanded = function () {
  88327. if (!this._geometry) {
  88328. return this;
  88329. }
  88330. this._geometry.toLeftHanded();
  88331. return this;
  88332. };
  88333. /** @hidden */
  88334. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  88335. if (!this._geometry) {
  88336. return this;
  88337. }
  88338. var engine = this.getScene().getEngine();
  88339. // Wireframe
  88340. var indexToBind;
  88341. if (this._unIndexed) {
  88342. indexToBind = null;
  88343. }
  88344. else {
  88345. switch (fillMode) {
  88346. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode:
  88347. indexToBind = null;
  88348. break;
  88349. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode:
  88350. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  88351. break;
  88352. default:
  88353. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].TriangleFillMode:
  88354. indexToBind = this._unIndexed ? null : this._geometry.getIndexBuffer();
  88355. break;
  88356. }
  88357. }
  88358. // VBOs
  88359. this._geometry._bind(effect, indexToBind);
  88360. return this;
  88361. };
  88362. /** @hidden */
  88363. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  88364. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  88365. return this;
  88366. }
  88367. if (this._onBeforeDrawObservable) {
  88368. this._onBeforeDrawObservable.notifyObservers(this);
  88369. }
  88370. var scene = this.getScene();
  88371. var engine = scene.getEngine();
  88372. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode) {
  88373. // or triangles as points
  88374. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  88375. }
  88376. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode) {
  88377. // Triangles as wireframe
  88378. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  88379. }
  88380. else {
  88381. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  88382. }
  88383. return this;
  88384. };
  88385. /**
  88386. * Registers for this mesh a javascript function called just before the rendering process
  88387. * @param func defines the function to call before rendering this mesh
  88388. * @returns the current mesh
  88389. */
  88390. Mesh.prototype.registerBeforeRender = function (func) {
  88391. this.onBeforeRenderObservable.add(func);
  88392. return this;
  88393. };
  88394. /**
  88395. * Disposes a previously registered javascript function called before the rendering
  88396. * @param func defines the function to remove
  88397. * @returns the current mesh
  88398. */
  88399. Mesh.prototype.unregisterBeforeRender = function (func) {
  88400. this.onBeforeRenderObservable.removeCallback(func);
  88401. return this;
  88402. };
  88403. /**
  88404. * Registers for this mesh a javascript function called just after the rendering is complete
  88405. * @param func defines the function to call after rendering this mesh
  88406. * @returns the current mesh
  88407. */
  88408. Mesh.prototype.registerAfterRender = function (func) {
  88409. this.onAfterRenderObservable.add(func);
  88410. return this;
  88411. };
  88412. /**
  88413. * Disposes a previously registered javascript function called after the rendering.
  88414. * @param func defines the function to remove
  88415. * @returns the current mesh
  88416. */
  88417. Mesh.prototype.unregisterAfterRender = function (func) {
  88418. this.onAfterRenderObservable.removeCallback(func);
  88419. return this;
  88420. };
  88421. /** @hidden */
  88422. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  88423. var scene = this.getScene();
  88424. var batchCache = this._instanceDataStorage.batchCache;
  88425. batchCache.mustReturn = false;
  88426. batchCache.renderSelf[subMeshId] = this.isEnabled() && this.isVisible;
  88427. batchCache.visibleInstances[subMeshId] = null;
  88428. if (this._instanceDataStorage.visibleInstances) {
  88429. var visibleInstances = this._instanceDataStorage.visibleInstances;
  88430. var currentRenderId = scene.getRenderId();
  88431. var defaultRenderId = (scene._isInIntermediateRendering() ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  88432. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  88433. var selfRenderId = this._renderId;
  88434. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  88435. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  88436. currentRenderId = Math.max(defaultRenderId, currentRenderId);
  88437. selfRenderId = Math.max(visibleInstances.selfDefaultRenderId, currentRenderId);
  88438. }
  88439. var visibleInstancesForSubMesh = batchCache.visibleInstances[subMeshId];
  88440. if (visibleInstancesForSubMesh && visibleInstancesForSubMesh.length) {
  88441. if (this._instanceDataStorage.renderIdForInstances[subMeshId] === currentRenderId) {
  88442. batchCache.mustReturn = true;
  88443. return batchCache;
  88444. }
  88445. if (currentRenderId !== selfRenderId) {
  88446. batchCache.renderSelf[subMeshId] = false;
  88447. }
  88448. }
  88449. this._instanceDataStorage.renderIdForInstances[subMeshId] = currentRenderId;
  88450. }
  88451. return batchCache;
  88452. };
  88453. /** @hidden */
  88454. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  88455. var visibleInstances = batch.visibleInstances[subMesh._id];
  88456. if (!visibleInstances) {
  88457. return this;
  88458. }
  88459. var matricesCount = visibleInstances.length + 1;
  88460. var bufferSize = matricesCount * 16 * 4;
  88461. var instanceStorage = this._instanceDataStorage;
  88462. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  88463. var instancesBuffer = instanceStorage.instancesBuffer;
  88464. while (instanceStorage.instancesBufferSize < bufferSize) {
  88465. instanceStorage.instancesBufferSize *= 2;
  88466. }
  88467. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  88468. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  88469. }
  88470. var offset = 0;
  88471. var instancesCount = 0;
  88472. var world = this._effectiveMesh.getWorldMatrix();
  88473. if (batch.renderSelf[subMesh._id]) {
  88474. world.copyToArray(instanceStorage.instancesData, offset);
  88475. offset += 16;
  88476. instancesCount++;
  88477. }
  88478. if (visibleInstances) {
  88479. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  88480. var instance = visibleInstances[instanceIndex];
  88481. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  88482. offset += 16;
  88483. instancesCount++;
  88484. }
  88485. }
  88486. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  88487. if (instancesBuffer) {
  88488. instancesBuffer.dispose();
  88489. }
  88490. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_7__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  88491. instanceStorage.instancesBuffer = instancesBuffer;
  88492. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  88493. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  88494. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  88495. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  88496. }
  88497. else {
  88498. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  88499. }
  88500. this._bind(subMesh, effect, fillMode);
  88501. this._draw(subMesh, fillMode, instancesCount);
  88502. engine.unbindInstanceAttributes();
  88503. return this;
  88504. };
  88505. /** @hidden */
  88506. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  88507. var scene = this.getScene();
  88508. var engine = scene.getEngine();
  88509. if (hardwareInstancedRendering) {
  88510. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  88511. }
  88512. else {
  88513. if (batch.renderSelf[subMesh._id]) {
  88514. // Draw
  88515. if (onBeforeDraw) {
  88516. onBeforeDraw(false, this._effectiveMesh.getWorldMatrix(), effectiveMaterial);
  88517. }
  88518. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  88519. }
  88520. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  88521. if (visibleInstancesForSubMesh) {
  88522. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  88523. var instance = visibleInstancesForSubMesh[instanceIndex];
  88524. // World
  88525. var world = instance.getWorldMatrix();
  88526. if (onBeforeDraw) {
  88527. onBeforeDraw(true, world, effectiveMaterial);
  88528. }
  88529. // Draw
  88530. this._draw(subMesh, fillMode);
  88531. }
  88532. }
  88533. }
  88534. return this;
  88535. };
  88536. /**
  88537. * 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
  88538. * @param subMesh defines the subMesh to render
  88539. * @param enableAlphaMode defines if alpha mode can be changed
  88540. * @returns the current mesh
  88541. */
  88542. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  88543. if (this._checkOcclusionQuery()) {
  88544. return this;
  88545. }
  88546. var scene = this.getScene();
  88547. // Managing instances
  88548. var batch = this._getInstancesRenderList(subMesh._id);
  88549. if (batch.mustReturn) {
  88550. return this;
  88551. }
  88552. // Checking geometry state
  88553. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  88554. return this;
  88555. }
  88556. if (this._onBeforeRenderObservable) {
  88557. this._onBeforeRenderObservable.notifyObservers(this);
  88558. }
  88559. var engine = scene.getEngine();
  88560. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  88561. // Material
  88562. var material = subMesh.getMaterial();
  88563. if (!material) {
  88564. return this;
  88565. }
  88566. this._effectiveMaterial = material;
  88567. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  88568. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  88569. return this;
  88570. }
  88571. }
  88572. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  88573. return this;
  88574. }
  88575. // Alpha mode
  88576. if (enableAlphaMode) {
  88577. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  88578. }
  88579. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  88580. var step = _a[_i];
  88581. step.action(this, subMesh, batch);
  88582. }
  88583. var effect;
  88584. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  88585. effect = subMesh.effect;
  88586. }
  88587. else {
  88588. effect = this._effectiveMaterial.getEffect();
  88589. }
  88590. if (!effect) {
  88591. return this;
  88592. }
  88593. var effectiveMesh = this._effectiveMesh;
  88594. var sideOrientation = this.overrideMaterialSideOrientation;
  88595. if (sideOrientation == null) {
  88596. sideOrientation = this._effectiveMaterial.sideOrientation;
  88597. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  88598. 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);
  88599. }
  88600. }
  88601. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  88602. if (this._effectiveMaterial.forceDepthWrite) {
  88603. engine.setDepthWrite(true);
  88604. }
  88605. // Bind
  88606. 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);
  88607. if (this._onBeforeBindObservable) {
  88608. this._onBeforeBindObservable.notifyObservers(this);
  88609. }
  88610. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  88611. this._bind(subMesh, effect, fillMode);
  88612. }
  88613. var world = effectiveMesh.getWorldMatrix();
  88614. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  88615. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  88616. }
  88617. else {
  88618. this._effectiveMaterial.bind(world, this);
  88619. }
  88620. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  88621. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  88622. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  88623. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  88624. }
  88625. // Draw
  88626. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  88627. // Unbind
  88628. this._effectiveMaterial.unbind();
  88629. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  88630. var step = _c[_b];
  88631. step.action(this, subMesh, batch);
  88632. }
  88633. if (this._onAfterRenderObservable) {
  88634. this._onAfterRenderObservable.notifyObservers(this);
  88635. }
  88636. return this;
  88637. };
  88638. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  88639. if (isInstance && effectiveMaterial) {
  88640. effectiveMaterial.bindOnlyWorldMatrix(world);
  88641. }
  88642. };
  88643. /**
  88644. * Renormalize the mesh and patch it up if there are no weights
  88645. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  88646. * However in the case of zero weights then we set just a single influence to 1.
  88647. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  88648. */
  88649. Mesh.prototype.cleanMatrixWeights = function () {
  88650. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  88651. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind)) {
  88652. this.normalizeSkinWeightsAndExtra();
  88653. }
  88654. else {
  88655. this.normalizeSkinFourWeights();
  88656. }
  88657. }
  88658. };
  88659. // faster 4 weight version.
  88660. Mesh.prototype.normalizeSkinFourWeights = function () {
  88661. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  88662. var numWeights = matricesWeights.length;
  88663. for (var a = 0; a < numWeights; a += 4) {
  88664. // accumulate weights
  88665. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  88666. // check for invalid weight and just set it to 1.
  88667. if (t === 0) {
  88668. matricesWeights[a] = 1;
  88669. }
  88670. else {
  88671. // renormalize so everything adds to 1 use reciprical
  88672. var recip = 1 / t;
  88673. matricesWeights[a] *= recip;
  88674. matricesWeights[a + 1] *= recip;
  88675. matricesWeights[a + 2] *= recip;
  88676. matricesWeights[a + 3] *= recip;
  88677. }
  88678. }
  88679. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  88680. };
  88681. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  88682. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  88683. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  88684. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  88685. var numWeights = matricesWeights.length;
  88686. for (var a = 0; a < numWeights; a += 4) {
  88687. // accumulate weights
  88688. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  88689. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  88690. // check for invalid weight and just set it to 1.
  88691. if (t === 0) {
  88692. matricesWeights[a] = 1;
  88693. }
  88694. else {
  88695. // renormalize so everything adds to 1 use reciprical
  88696. var recip = 1 / t;
  88697. matricesWeights[a] *= recip;
  88698. matricesWeights[a + 1] *= recip;
  88699. matricesWeights[a + 2] *= recip;
  88700. matricesWeights[a + 3] *= recip;
  88701. // same goes for extras
  88702. matricesWeightsExtra[a] *= recip;
  88703. matricesWeightsExtra[a + 1] *= recip;
  88704. matricesWeightsExtra[a + 2] *= recip;
  88705. matricesWeightsExtra[a + 3] *= recip;
  88706. }
  88707. }
  88708. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  88709. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  88710. };
  88711. /**
  88712. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  88713. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  88714. * the user know there was an issue with importing the mesh
  88715. * @returns a validation object with skinned, valid and report string
  88716. */
  88717. Mesh.prototype.validateSkinning = function () {
  88718. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  88719. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  88720. if (matricesWeights === null || this.skeleton == null) {
  88721. return { skinned: false, valid: true, report: "not skinned" };
  88722. }
  88723. var numWeights = matricesWeights.length;
  88724. var numberNotSorted = 0;
  88725. var missingWeights = 0;
  88726. var maxUsedWeights = 0;
  88727. var numberNotNormalized = 0;
  88728. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  88729. var usedWeightCounts = new Array();
  88730. for (var a = 0; a <= numInfluences; a++) {
  88731. usedWeightCounts[a] = 0;
  88732. }
  88733. var toleranceEpsilon = 0.001;
  88734. for (var a = 0; a < numWeights; a += 4) {
  88735. var lastWeight = matricesWeights[a];
  88736. var t = lastWeight;
  88737. var usedWeights = t === 0 ? 0 : 1;
  88738. for (var b = 1; b < numInfluences; b++) {
  88739. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  88740. if (d > lastWeight) {
  88741. numberNotSorted++;
  88742. }
  88743. if (d !== 0) {
  88744. usedWeights++;
  88745. }
  88746. t += d;
  88747. lastWeight = d;
  88748. }
  88749. // count the buffer weights usage
  88750. usedWeightCounts[usedWeights]++;
  88751. // max influences
  88752. if (usedWeights > maxUsedWeights) {
  88753. maxUsedWeights = usedWeights;
  88754. }
  88755. // check for invalid weight and just set it to 1.
  88756. if (t === 0) {
  88757. missingWeights++;
  88758. }
  88759. else {
  88760. // renormalize so everything adds to 1 use reciprical
  88761. var recip = 1 / t;
  88762. var tolerance = 0;
  88763. for (b = 0; b < numInfluences; b++) {
  88764. if (b < 4) {
  88765. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  88766. }
  88767. else {
  88768. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  88769. }
  88770. }
  88771. // arbitary epsilon value for dicdating not normalized
  88772. if (tolerance > toleranceEpsilon) {
  88773. numberNotNormalized++;
  88774. }
  88775. }
  88776. }
  88777. // validate bone indices are in range of the skeleton
  88778. var numBones = this.skeleton.bones.length;
  88779. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  88780. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  88781. var numBadBoneIndices = 0;
  88782. for (var a = 0; a < numWeights; a++) {
  88783. for (var b = 0; b < numInfluences; b++) {
  88784. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  88785. if (index >= numBones || index < 0) {
  88786. numBadBoneIndices++;
  88787. }
  88788. }
  88789. }
  88790. // log mesh stats
  88791. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  88792. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  88793. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  88794. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  88795. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  88796. };
  88797. /** @hidden */
  88798. Mesh.prototype._checkDelayState = function () {
  88799. var scene = this.getScene();
  88800. if (this._geometry) {
  88801. this._geometry.load(scene);
  88802. }
  88803. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  88804. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING;
  88805. this._queueLoad(scene);
  88806. }
  88807. return this;
  88808. };
  88809. Mesh.prototype._queueLoad = function (scene) {
  88810. var _this = this;
  88811. scene._addPendingData(this);
  88812. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  88813. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  88814. if (data instanceof ArrayBuffer) {
  88815. _this._delayLoadingFunction(data, _this);
  88816. }
  88817. else {
  88818. _this._delayLoadingFunction(JSON.parse(data), _this);
  88819. }
  88820. _this.instances.forEach(function (instance) {
  88821. instance._syncSubMeshes();
  88822. });
  88823. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADED;
  88824. scene._removePendingData(_this);
  88825. }, function () { }, scene.offlineProvider, getBinaryData);
  88826. return this;
  88827. };
  88828. /**
  88829. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  88830. * A mesh is in the frustum if its bounding box intersects the frustum
  88831. * @param frustumPlanes defines the frustum to test
  88832. * @returns true if the mesh is in the frustum planes
  88833. */
  88834. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  88835. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  88836. return false;
  88837. }
  88838. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  88839. return false;
  88840. }
  88841. this._checkDelayState();
  88842. return true;
  88843. };
  88844. /**
  88845. * Sets the mesh material by the material or multiMaterial `id` property
  88846. * @param id is a string identifying the material or the multiMaterial
  88847. * @returns the current mesh
  88848. */
  88849. Mesh.prototype.setMaterialByID = function (id) {
  88850. var materials = this.getScene().materials;
  88851. var index;
  88852. for (index = materials.length - 1; index > -1; index--) {
  88853. if (materials[index].id === id) {
  88854. this.material = materials[index];
  88855. return this;
  88856. }
  88857. }
  88858. // Multi
  88859. var multiMaterials = this.getScene().multiMaterials;
  88860. for (index = multiMaterials.length - 1; index > -1; index--) {
  88861. if (multiMaterials[index].id === id) {
  88862. this.material = multiMaterials[index];
  88863. return this;
  88864. }
  88865. }
  88866. return this;
  88867. };
  88868. /**
  88869. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  88870. * @returns an array of IAnimatable
  88871. */
  88872. Mesh.prototype.getAnimatables = function () {
  88873. var results = new Array();
  88874. if (this.material) {
  88875. results.push(this.material);
  88876. }
  88877. if (this.skeleton) {
  88878. results.push(this.skeleton);
  88879. }
  88880. return results;
  88881. };
  88882. /**
  88883. * Modifies the mesh geometry according to the passed transformation matrix.
  88884. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  88885. * The mesh normals are modified using the same transformation.
  88886. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88887. * @param transform defines the transform matrix to use
  88888. * @see http://doc.babylonjs.com/resources/baking_transformations
  88889. * @returns the current mesh
  88890. */
  88891. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  88892. // Position
  88893. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  88894. return this;
  88895. }
  88896. var submeshes = this.subMeshes.splice(0);
  88897. this._resetPointsArrayCache();
  88898. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  88899. var temp = new Array();
  88900. var index;
  88901. for (index = 0; index < data.length; index += 3) {
  88902. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  88903. }
  88904. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind).isUpdatable());
  88905. // Normals
  88906. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  88907. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  88908. temp = [];
  88909. for (index = 0; index < data.length; index += 3) {
  88910. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  88911. }
  88912. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind).isUpdatable());
  88913. }
  88914. // flip faces?
  88915. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  88916. this.flipFaces();
  88917. }
  88918. // Restore submeshes
  88919. this.releaseSubMeshes();
  88920. this.subMeshes = submeshes;
  88921. return this;
  88922. };
  88923. /**
  88924. * Modifies the mesh geometry according to its own current World Matrix.
  88925. * The mesh World Matrix is then reset.
  88926. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  88927. * Note that, under the hood, this method sets a new VertexBuffer each call.
  88928. * @see http://doc.babylonjs.com/resources/baking_transformations
  88929. * @returns the current mesh
  88930. */
  88931. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  88932. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  88933. this.scaling.copyFromFloats(1, 1, 1);
  88934. this.position.copyFromFloats(0, 0, 0);
  88935. this.rotation.copyFromFloats(0, 0, 0);
  88936. //only if quaternion is already set
  88937. if (this.rotationQuaternion) {
  88938. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  88939. }
  88940. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  88941. return this;
  88942. };
  88943. Object.defineProperty(Mesh.prototype, "_positions", {
  88944. // Cache
  88945. /** @hidden */
  88946. get: function () {
  88947. if (this._geometry) {
  88948. return this._geometry._positions;
  88949. }
  88950. return null;
  88951. },
  88952. enumerable: true,
  88953. configurable: true
  88954. });
  88955. /** @hidden */
  88956. Mesh.prototype._resetPointsArrayCache = function () {
  88957. if (this._geometry) {
  88958. this._geometry._resetPointsArrayCache();
  88959. }
  88960. return this;
  88961. };
  88962. /** @hidden */
  88963. Mesh.prototype._generatePointsArray = function () {
  88964. if (this._geometry) {
  88965. return this._geometry._generatePointsArray();
  88966. }
  88967. return false;
  88968. };
  88969. /**
  88970. * Returns a new Mesh object generated from the current mesh properties.
  88971. * This method must not get confused with createInstance()
  88972. * @param name is a string, the name given to the new mesh
  88973. * @param newParent can be any Node object (default `null`)
  88974. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  88975. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  88976. * @returns a new mesh
  88977. */
  88978. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  88979. if (name === void 0) { name = ""; }
  88980. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  88981. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  88982. };
  88983. /**
  88984. * Releases resources associated with this mesh.
  88985. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88986. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88987. */
  88988. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  88989. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  88990. this.morphTargetManager = null;
  88991. if (this._geometry) {
  88992. this._geometry.releaseForMesh(this, true);
  88993. }
  88994. if (this._onBeforeDrawObservable) {
  88995. this._onBeforeDrawObservable.clear();
  88996. }
  88997. if (this._onBeforeBindObservable) {
  88998. this._onBeforeBindObservable.clear();
  88999. }
  89000. if (this._onBeforeRenderObservable) {
  89001. this._onBeforeRenderObservable.clear();
  89002. }
  89003. if (this._onAfterRenderObservable) {
  89004. this._onAfterRenderObservable.clear();
  89005. }
  89006. // Sources
  89007. if (this._scene.useClonedMeshhMap) {
  89008. if (this.meshMap) {
  89009. for (var uniqueId in this.meshMap) {
  89010. var mesh = this.meshMap[uniqueId];
  89011. if (mesh) {
  89012. mesh._source = null;
  89013. this.meshMap[uniqueId] = undefined;
  89014. }
  89015. }
  89016. }
  89017. if (this._source && this._source.meshMap) {
  89018. this._source.meshMap[this.uniqueId] = undefined;
  89019. }
  89020. }
  89021. else {
  89022. var meshes = this.getScene().meshes;
  89023. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  89024. var abstractMesh = meshes_1[_i];
  89025. var mesh = abstractMesh;
  89026. if (mesh._source && mesh._source === this) {
  89027. mesh._source = null;
  89028. }
  89029. }
  89030. }
  89031. this._source = null;
  89032. // Instances
  89033. if (this._instanceDataStorage.instancesBuffer) {
  89034. this._instanceDataStorage.instancesBuffer.dispose();
  89035. this._instanceDataStorage.instancesBuffer = null;
  89036. }
  89037. while (this.instances.length) {
  89038. this.instances[0].dispose();
  89039. }
  89040. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  89041. };
  89042. /**
  89043. * Modifies the mesh geometry according to a displacement map.
  89044. * 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.
  89045. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89046. * @param url is a string, the URL from the image file is to be downloaded.
  89047. * @param minHeight is the lower limit of the displacement.
  89048. * @param maxHeight is the upper limit of the displacement.
  89049. * @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.
  89050. * @param uvOffset is an optional vector2 used to offset UV.
  89051. * @param uvScale is an optional vector2 used to scale UV.
  89052. * @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.
  89053. * @returns the Mesh.
  89054. */
  89055. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  89056. var _this = this;
  89057. if (forceUpdate === void 0) { forceUpdate = false; }
  89058. var scene = this.getScene();
  89059. var onload = function (img) {
  89060. // Getting height map data
  89061. var canvas = document.createElement("canvas");
  89062. var context = canvas.getContext("2d");
  89063. var heightMapWidth = img.width;
  89064. var heightMapHeight = img.height;
  89065. canvas.width = heightMapWidth;
  89066. canvas.height = heightMapHeight;
  89067. context.drawImage(img, 0, 0);
  89068. // Create VertexData from map data
  89069. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  89070. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  89071. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  89072. //execute success callback, if set
  89073. if (onSuccess) {
  89074. onSuccess(_this);
  89075. }
  89076. };
  89077. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  89078. return this;
  89079. };
  89080. /**
  89081. * Modifies the mesh geometry according to a displacementMap buffer.
  89082. * 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.
  89083. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89084. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  89085. * @param heightMapWidth is the width of the buffer image.
  89086. * @param heightMapHeight is the height of the buffer image.
  89087. * @param minHeight is the lower limit of the displacement.
  89088. * @param maxHeight is the upper limit of the displacement.
  89089. * @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.
  89090. * @param uvOffset is an optional vector2 used to offset UV.
  89091. * @param uvScale is an optional vector2 used to scale UV.
  89092. * @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.
  89093. * @returns the Mesh.
  89094. */
  89095. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  89096. if (forceUpdate === void 0) { forceUpdate = false; }
  89097. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)
  89098. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)
  89099. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  89100. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  89101. return this;
  89102. }
  89103. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, true, true);
  89104. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  89105. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  89106. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  89107. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  89108. var uv = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  89109. uvOffset = uvOffset || _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  89110. uvScale = uvScale || new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  89111. for (var index = 0; index < positions.length; index += 3) {
  89112. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  89113. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  89114. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  89115. // Compute height
  89116. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  89117. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  89118. var pos = (u + v * heightMapWidth) * 4;
  89119. var r = buffer[pos] / 255.0;
  89120. var g = buffer[pos + 1] / 255.0;
  89121. var b = buffer[pos + 2] / 255.0;
  89122. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  89123. normal.normalize();
  89124. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  89125. position = position.add(normal);
  89126. position.toArray(positions, index);
  89127. }
  89128. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  89129. if (forceUpdate) {
  89130. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  89131. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  89132. }
  89133. else {
  89134. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  89135. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  89136. }
  89137. return this;
  89138. };
  89139. /**
  89140. * Modify the mesh to get a flat shading rendering.
  89141. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  89142. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  89143. * @returns current mesh
  89144. */
  89145. Mesh.prototype.convertToFlatShadedMesh = function () {
  89146. var kinds = this.getVerticesDataKinds();
  89147. var vbs = {};
  89148. var data = {};
  89149. var newdata = {};
  89150. var updatableNormals = false;
  89151. var kindIndex;
  89152. var kind;
  89153. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  89154. kind = kinds[kindIndex];
  89155. var vertexBuffer = this.getVertexBuffer(kind);
  89156. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) {
  89157. updatableNormals = vertexBuffer.isUpdatable();
  89158. kinds.splice(kindIndex, 1);
  89159. kindIndex--;
  89160. continue;
  89161. }
  89162. vbs[kind] = vertexBuffer;
  89163. data[kind] = vbs[kind].getData();
  89164. newdata[kind] = [];
  89165. }
  89166. // Save previous submeshes
  89167. var previousSubmeshes = this.subMeshes.slice(0);
  89168. var indices = this.getIndices();
  89169. var totalIndices = this.getTotalIndices();
  89170. // Generating unique vertices per face
  89171. var index;
  89172. for (index = 0; index < totalIndices; index++) {
  89173. var vertexIndex = indices[index];
  89174. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  89175. kind = kinds[kindIndex];
  89176. var stride = vbs[kind].getStrideSize();
  89177. for (var offset = 0; offset < stride; offset++) {
  89178. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  89179. }
  89180. }
  89181. }
  89182. // Updating faces & normal
  89183. var normals = [];
  89184. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  89185. for (index = 0; index < totalIndices; index += 3) {
  89186. indices[index] = index;
  89187. indices[index + 1] = index + 1;
  89188. indices[index + 2] = index + 2;
  89189. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  89190. var p2 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  89191. var p3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  89192. var p1p2 = p1.subtract(p2);
  89193. var p3p2 = p3.subtract(p2);
  89194. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  89195. // Store same normals for every vertex
  89196. for (var localIndex = 0; localIndex < 3; localIndex++) {
  89197. normals.push(normal.x);
  89198. normals.push(normal.y);
  89199. normals.push(normal.z);
  89200. }
  89201. }
  89202. this.setIndices(indices);
  89203. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, updatableNormals);
  89204. // Updating vertex buffers
  89205. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  89206. kind = kinds[kindIndex];
  89207. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  89208. }
  89209. // Updating submeshes
  89210. this.releaseSubMeshes();
  89211. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  89212. var previousOne = previousSubmeshes[submeshIndex];
  89213. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  89214. }
  89215. this.synchronizeInstances();
  89216. return this;
  89217. };
  89218. /**
  89219. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  89220. * In other words, more vertices, no more indices and a single bigger VBO.
  89221. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  89222. * @returns current mesh
  89223. */
  89224. Mesh.prototype.convertToUnIndexedMesh = function () {
  89225. var kinds = this.getVerticesDataKinds();
  89226. var vbs = {};
  89227. var data = {};
  89228. var newdata = {};
  89229. var kindIndex;
  89230. var kind;
  89231. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  89232. kind = kinds[kindIndex];
  89233. var vertexBuffer = this.getVertexBuffer(kind);
  89234. vbs[kind] = vertexBuffer;
  89235. data[kind] = vbs[kind].getData();
  89236. newdata[kind] = [];
  89237. }
  89238. // Save previous submeshes
  89239. var previousSubmeshes = this.subMeshes.slice(0);
  89240. var indices = this.getIndices();
  89241. var totalIndices = this.getTotalIndices();
  89242. // Generating unique vertices per face
  89243. var index;
  89244. for (index = 0; index < totalIndices; index++) {
  89245. var vertexIndex = indices[index];
  89246. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  89247. kind = kinds[kindIndex];
  89248. var stride = vbs[kind].getStrideSize();
  89249. for (var offset = 0; offset < stride; offset++) {
  89250. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  89251. }
  89252. }
  89253. }
  89254. // Updating indices
  89255. for (index = 0; index < totalIndices; index += 3) {
  89256. indices[index] = index;
  89257. indices[index + 1] = index + 1;
  89258. indices[index + 2] = index + 2;
  89259. }
  89260. this.setIndices(indices);
  89261. // Updating vertex buffers
  89262. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  89263. kind = kinds[kindIndex];
  89264. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  89265. }
  89266. // Updating submeshes
  89267. this.releaseSubMeshes();
  89268. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  89269. var previousOne = previousSubmeshes[submeshIndex];
  89270. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  89271. }
  89272. this._unIndexed = true;
  89273. this.synchronizeInstances();
  89274. return this;
  89275. };
  89276. /**
  89277. * Inverses facet orientations.
  89278. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89279. * @param flipNormals will also inverts the normals
  89280. * @returns current mesh
  89281. */
  89282. Mesh.prototype.flipFaces = function (flipNormals) {
  89283. if (flipNormals === void 0) { flipNormals = false; }
  89284. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  89285. var i;
  89286. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  89287. for (i = 0; i < vertex_data.normals.length; i++) {
  89288. vertex_data.normals[i] *= -1;
  89289. }
  89290. }
  89291. if (vertex_data.indices) {
  89292. var temp;
  89293. for (i = 0; i < vertex_data.indices.length; i += 3) {
  89294. // reassign indices
  89295. temp = vertex_data.indices[i + 1];
  89296. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  89297. vertex_data.indices[i + 2] = temp;
  89298. }
  89299. }
  89300. vertex_data.applyToMesh(this);
  89301. return this;
  89302. };
  89303. /**
  89304. * Increase the number of facets and hence vertices in a mesh
  89305. * Vertex normals are interpolated from existing vertex normals
  89306. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89307. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  89308. */
  89309. Mesh.prototype.increaseVertices = function (numberPerEdge) {
  89310. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  89311. var uvs = vertex_data.uvs;
  89312. var currentIndices = vertex_data.indices;
  89313. var positions = vertex_data.positions;
  89314. var normals = vertex_data.normals;
  89315. if (currentIndices === null || positions === null || normals === null || uvs === null) {
  89316. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("VertexData contains null entries");
  89317. }
  89318. else {
  89319. var segments = numberPerEdge + 1; //segments per current facet edge, become sides of new facets
  89320. var tempIndices = new Array();
  89321. for (var i = 0; i < segments + 1; i++) {
  89322. tempIndices[i] = new Array();
  89323. }
  89324. var a; //vertex index of one end of a side
  89325. var b; //vertex index of other end of the side
  89326. var deltaPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 0);
  89327. var deltaNormal = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 0, 0);
  89328. var deltaUV = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](0, 0);
  89329. var indices = new Array();
  89330. var vertexIndex = new Array();
  89331. var side = new Array();
  89332. var len;
  89333. var positionPtr = positions.length;
  89334. var uvPtr = uvs.length;
  89335. for (var i = 0; i < currentIndices.length; i += 3) {
  89336. vertexIndex[0] = currentIndices[i];
  89337. vertexIndex[1] = currentIndices[i + 1];
  89338. vertexIndex[2] = currentIndices[i + 2];
  89339. for (var j = 0; j < 3; j++) {
  89340. a = vertexIndex[j];
  89341. b = vertexIndex[(j + 1) % 3];
  89342. if (side[a] === undefined && side[b] === undefined) {
  89343. side[a] = new Array();
  89344. side[b] = new Array();
  89345. }
  89346. else {
  89347. if (side[a] === undefined) {
  89348. side[a] = new Array();
  89349. }
  89350. if (side[b] === undefined) {
  89351. side[b] = new Array();
  89352. }
  89353. }
  89354. if (side[a][b] === undefined && side[b][a] === undefined) {
  89355. side[a][b] = [];
  89356. deltaPosition.x = (positions[3 * b] - positions[3 * a]) / segments;
  89357. deltaPosition.y = (positions[3 * b + 1] - positions[3 * a + 1]) / segments;
  89358. deltaPosition.z = (positions[3 * b + 2] - positions[3 * a + 2]) / segments;
  89359. deltaNormal.x = (normals[3 * b] - normals[3 * a]) / segments;
  89360. deltaNormal.y = (normals[3 * b + 1] - normals[3 * a + 1]) / segments;
  89361. deltaNormal.z = (normals[3 * b + 2] - normals[3 * a + 2]) / segments;
  89362. deltaUV.x = (uvs[2 * b] - uvs[2 * a]) / segments;
  89363. deltaUV.y = (uvs[2 * b + 1] - uvs[2 * a + 1]) / segments;
  89364. side[a][b].push(a);
  89365. for (var k = 1; k < segments; k++) {
  89366. side[a][b].push(positions.length / 3);
  89367. positions[positionPtr] = positions[3 * a] + k * deltaPosition.x;
  89368. normals[positionPtr++] = normals[3 * a] + k * deltaNormal.x;
  89369. positions[positionPtr] = positions[3 * a + 1] + k * deltaPosition.y;
  89370. normals[positionPtr++] = normals[3 * a + 1] + k * deltaNormal.y;
  89371. positions[positionPtr] = positions[3 * a + 2] + k * deltaPosition.z;
  89372. normals[positionPtr++] = normals[3 * a + 2] + k * deltaNormal.z;
  89373. uvs[uvPtr++] = uvs[2 * a] + k * deltaUV.x;
  89374. uvs[uvPtr++] = uvs[2 * a + 1] + k * deltaUV.y;
  89375. }
  89376. side[a][b].push(b);
  89377. side[b][a] = new Array();
  89378. len = side[a][b].length;
  89379. for (var idx = 0; idx < len; idx++) {
  89380. side[b][a][idx] = side[a][b][len - 1 - idx];
  89381. }
  89382. }
  89383. }
  89384. //Calculate positions, normals and uvs of new internal vertices
  89385. tempIndices[0][0] = currentIndices[i];
  89386. tempIndices[1][0] = side[currentIndices[i]][currentIndices[i + 1]][1];
  89387. tempIndices[1][1] = side[currentIndices[i]][currentIndices[i + 2]][1];
  89388. for (var k = 2; k < segments; k++) {
  89389. tempIndices[k][0] = side[currentIndices[i]][currentIndices[i + 1]][k];
  89390. tempIndices[k][k] = side[currentIndices[i]][currentIndices[i + 2]][k];
  89391. deltaPosition.x = (positions[3 * tempIndices[k][k]] - positions[3 * tempIndices[k][0]]) / k;
  89392. deltaPosition.y = (positions[3 * tempIndices[k][k] + 1] - positions[3 * tempIndices[k][0] + 1]) / k;
  89393. deltaPosition.z = (positions[3 * tempIndices[k][k] + 2] - positions[3 * tempIndices[k][0] + 2]) / k;
  89394. deltaNormal.x = (normals[3 * tempIndices[k][k]] - normals[3 * tempIndices[k][0]]) / k;
  89395. deltaNormal.y = (normals[3 * tempIndices[k][k] + 1] - normals[3 * tempIndices[k][0] + 1]) / k;
  89396. deltaNormal.z = (normals[3 * tempIndices[k][k] + 2] - normals[3 * tempIndices[k][0] + 2]) / k;
  89397. deltaUV.x = (uvs[2 * tempIndices[k][k]] - uvs[2 * tempIndices[k][0]]) / k;
  89398. deltaUV.y = (uvs[2 * tempIndices[k][k] + 1] - uvs[2 * tempIndices[k][0] + 1]) / k;
  89399. for (var j = 1; j < k; j++) {
  89400. tempIndices[k][j] = positions.length / 3;
  89401. positions[positionPtr] = positions[3 * tempIndices[k][0]] + j * deltaPosition.x;
  89402. normals[positionPtr++] = normals[3 * tempIndices[k][0]] + j * deltaNormal.x;
  89403. positions[positionPtr] = positions[3 * tempIndices[k][0] + 1] + j * deltaPosition.y;
  89404. normals[positionPtr++] = normals[3 * tempIndices[k][0] + 1] + j * deltaNormal.y;
  89405. positions[positionPtr] = positions[3 * tempIndices[k][0] + 2] + j * deltaPosition.z;
  89406. normals[positionPtr++] = normals[3 * tempIndices[k][0] + 2] + j * deltaNormal.z;
  89407. uvs[uvPtr++] = uvs[2 * tempIndices[k][0]] + j * deltaUV.x;
  89408. uvs[uvPtr++] = uvs[2 * tempIndices[k][0] + 1] + j * deltaUV.y;
  89409. }
  89410. }
  89411. tempIndices[segments] = side[currentIndices[i + 1]][currentIndices[i + 2]];
  89412. // reform indices
  89413. indices.push(tempIndices[0][0], tempIndices[1][0], tempIndices[1][1]);
  89414. for (var k = 1; k < segments; k++) {
  89415. for (var j = 0; j < k; j++) {
  89416. indices.push(tempIndices[k][j], tempIndices[k + 1][j], tempIndices[k + 1][j + 1]);
  89417. indices.push(tempIndices[k][j], tempIndices[k + 1][j + 1], tempIndices[k][j + 1]);
  89418. }
  89419. indices.push(tempIndices[k][j], tempIndices[k + 1][j], tempIndices[k + 1][j + 1]);
  89420. }
  89421. }
  89422. vertex_data.indices = indices;
  89423. vertex_data.applyToMesh(this);
  89424. }
  89425. };
  89426. /**
  89427. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  89428. * This will undo any application of covertToFlatShadedMesh
  89429. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89430. */
  89431. Mesh.prototype.forceSharedVertices = function () {
  89432. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  89433. var currentUVs = vertex_data.uvs;
  89434. var currentIndices = vertex_data.indices;
  89435. var currentPositions = vertex_data.positions;
  89436. var currentNormals = vertex_data.normals;
  89437. if (currentIndices === null || currentPositions === null || currentNormals === null || currentUVs === null) {
  89438. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("VertexData contains null entries");
  89439. }
  89440. else {
  89441. var positions = new Array();
  89442. var indices = new Array();
  89443. var uvs = new Array();
  89444. var pstring = new Array(); //lists facet vertex positions (a,b,c) as string "a|b|c"
  89445. var indexPtr = 0; // pointer to next available index value
  89446. var uniquePositions = new Array(); // unique vertex positions
  89447. var ptr; // pointer to element in uniquePositions
  89448. var facet;
  89449. for (var i = 0; i < currentIndices.length; i += 3) {
  89450. facet = [currentIndices[i], currentIndices[i + 1], currentIndices[i + 2]]; //facet vertex indices
  89451. pstring = new Array();
  89452. for (var j = 0; j < 3; j++) {
  89453. pstring[j] = "";
  89454. for (var k = 0; k < 3; k++) {
  89455. //small values make 0
  89456. if (Math.abs(currentPositions[3 * facet[j] + k]) < 0.00000001) {
  89457. currentPositions[3 * facet[j] + k] = 0;
  89458. }
  89459. pstring[j] += currentPositions[3 * facet[j] + k] + "|";
  89460. }
  89461. pstring[j] = pstring[j].slice(0, -1);
  89462. }
  89463. //check facet vertices to see that none are repeated
  89464. // do not process any facet that has a repeated vertex, ie is a line
  89465. if (!(pstring[0] == pstring[1] || pstring[0] == pstring[2] || pstring[1] == pstring[2])) {
  89466. //for each facet position check if already listed in uniquePositions
  89467. // if not listed add to uniquePositions and set index pointer
  89468. // if listed use its index in uniquePositions and new index pointer
  89469. for (var j = 0; j < 3; j++) {
  89470. ptr = uniquePositions.indexOf(pstring[j]);
  89471. if (ptr < 0) {
  89472. uniquePositions.push(pstring[j]);
  89473. ptr = indexPtr++;
  89474. //not listed so add individual x, y, z coordinates to positions
  89475. for (var k = 0; k < 3; k++) {
  89476. positions.push(currentPositions[3 * facet[j] + k]);
  89477. }
  89478. for (var k = 0; k < 2; k++) {
  89479. uvs.push(currentUVs[2 * facet[j] + k]);
  89480. }
  89481. }
  89482. // add new index pointer to indices array
  89483. indices.push(ptr);
  89484. }
  89485. }
  89486. }
  89487. var normals = new Array();
  89488. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  89489. //create new vertex data object and update
  89490. vertex_data.positions = positions;
  89491. vertex_data.indices = indices;
  89492. vertex_data.normals = normals;
  89493. vertex_data.uvs = uvs;
  89494. vertex_data.applyToMesh(this);
  89495. }
  89496. };
  89497. // Instances
  89498. /** @hidden */
  89499. Mesh._instancedMeshFactory = function (name, mesh) {
  89500. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("InstancedMesh");
  89501. };
  89502. /** @hidden */
  89503. Mesh._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  89504. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("PhysicsImpostor");
  89505. };
  89506. /**
  89507. * Creates a new InstancedMesh object from the mesh model.
  89508. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89509. * @param name defines the name of the new instance
  89510. * @returns a new InstancedMesh
  89511. */
  89512. Mesh.prototype.createInstance = function (name) {
  89513. return Mesh._instancedMeshFactory(name, this);
  89514. };
  89515. /**
  89516. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  89517. * After this call, all the mesh instances have the same submeshes than the current mesh.
  89518. * @returns the current mesh
  89519. */
  89520. Mesh.prototype.synchronizeInstances = function () {
  89521. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  89522. var instance = this.instances[instanceIndex];
  89523. instance._syncSubMeshes();
  89524. }
  89525. return this;
  89526. };
  89527. /**
  89528. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  89529. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  89530. * This should be used together with the simplification to avoid disappearing triangles.
  89531. * @param successCallback an optional success callback to be called after the optimization finished.
  89532. * @returns the current mesh
  89533. */
  89534. Mesh.prototype.optimizeIndices = function (successCallback) {
  89535. var _this = this;
  89536. var indices = this.getIndices();
  89537. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  89538. if (!positions || !indices) {
  89539. return this;
  89540. }
  89541. var vectorPositions = new Array();
  89542. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  89543. vectorPositions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  89544. }
  89545. var dupes = new Array();
  89546. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  89547. var realPos = vectorPositions.length - 1 - iteration;
  89548. var testedPosition = vectorPositions[realPos];
  89549. for (var j = 0; j < realPos; ++j) {
  89550. var againstPosition = vectorPositions[j];
  89551. if (testedPosition.equals(againstPosition)) {
  89552. dupes[realPos] = j;
  89553. break;
  89554. }
  89555. }
  89556. }, function () {
  89557. for (var i = 0; i < indices.length; ++i) {
  89558. indices[i] = dupes[indices[i]] || indices[i];
  89559. }
  89560. //indices are now reordered
  89561. var originalSubMeshes = _this.subMeshes.slice(0);
  89562. _this.setIndices(indices);
  89563. _this.subMeshes = originalSubMeshes;
  89564. if (successCallback) {
  89565. successCallback(_this);
  89566. }
  89567. });
  89568. return this;
  89569. };
  89570. /**
  89571. * Serialize current mesh
  89572. * @param serializationObject defines the object which will receive the serialization data
  89573. */
  89574. Mesh.prototype.serialize = function (serializationObject) {
  89575. serializationObject.name = this.name;
  89576. serializationObject.id = this.id;
  89577. serializationObject.type = this.getClassName();
  89578. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  89579. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  89580. }
  89581. serializationObject.position = this.position.asArray();
  89582. if (this.rotationQuaternion) {
  89583. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  89584. }
  89585. else if (this.rotation) {
  89586. serializationObject.rotation = this.rotation.asArray();
  89587. }
  89588. serializationObject.scaling = this.scaling.asArray();
  89589. if (this._postMultiplyPivotMatrix) {
  89590. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  89591. }
  89592. else {
  89593. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  89594. }
  89595. serializationObject.isEnabled = this.isEnabled(false);
  89596. serializationObject.isVisible = this.isVisible;
  89597. serializationObject.infiniteDistance = this.infiniteDistance;
  89598. serializationObject.pickable = this.isPickable;
  89599. serializationObject.receiveShadows = this.receiveShadows;
  89600. serializationObject.billboardMode = this.billboardMode;
  89601. serializationObject.visibility = this.visibility;
  89602. serializationObject.checkCollisions = this.checkCollisions;
  89603. serializationObject.isBlocker = this.isBlocker;
  89604. // Parent
  89605. if (this.parent) {
  89606. serializationObject.parentId = this.parent.id;
  89607. }
  89608. // Geometry
  89609. serializationObject.isUnIndexed = this.isUnIndexed;
  89610. var geometry = this._geometry;
  89611. if (geometry) {
  89612. var geometryId = geometry.id;
  89613. serializationObject.geometryId = geometryId;
  89614. // SubMeshes
  89615. serializationObject.subMeshes = [];
  89616. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  89617. var subMesh = this.subMeshes[subIndex];
  89618. serializationObject.subMeshes.push({
  89619. materialIndex: subMesh.materialIndex,
  89620. verticesStart: subMesh.verticesStart,
  89621. verticesCount: subMesh.verticesCount,
  89622. indexStart: subMesh.indexStart,
  89623. indexCount: subMesh.indexCount
  89624. });
  89625. }
  89626. }
  89627. // Material
  89628. if (this.material) {
  89629. serializationObject.materialId = this.material.id;
  89630. }
  89631. else {
  89632. this.material = null;
  89633. }
  89634. // Morph targets
  89635. if (this.morphTargetManager) {
  89636. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  89637. }
  89638. // Skeleton
  89639. if (this.skeleton) {
  89640. serializationObject.skeletonId = this.skeleton.id;
  89641. }
  89642. // Physics
  89643. //TODO implement correct serialization for physics impostors.
  89644. var impostor = this.getPhysicsImpostor();
  89645. if (impostor) {
  89646. serializationObject.physicsMass = impostor.getParam("mass");
  89647. serializationObject.physicsFriction = impostor.getParam("friction");
  89648. serializationObject.physicsRestitution = impostor.getParam("mass");
  89649. serializationObject.physicsImpostor = impostor.type;
  89650. }
  89651. // Metadata
  89652. if (this.metadata) {
  89653. serializationObject.metadata = this.metadata;
  89654. }
  89655. // Instances
  89656. serializationObject.instances = [];
  89657. for (var index = 0; index < this.instances.length; index++) {
  89658. var instance = this.instances[index];
  89659. if (instance.doNotSerialize) {
  89660. continue;
  89661. }
  89662. var serializationInstance = {
  89663. name: instance.name,
  89664. id: instance.id,
  89665. position: instance.position.asArray(),
  89666. scaling: instance.scaling.asArray()
  89667. };
  89668. if (instance.parent) {
  89669. serializationInstance.parentId = instance.parent.id;
  89670. }
  89671. if (instance.rotationQuaternion) {
  89672. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  89673. }
  89674. else if (instance.rotation) {
  89675. serializationInstance.rotation = instance.rotation.asArray();
  89676. }
  89677. serializationObject.instances.push(serializationInstance);
  89678. // Animations
  89679. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  89680. serializationInstance.ranges = instance.serializeAnimationRanges();
  89681. }
  89682. //
  89683. // Animations
  89684. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  89685. serializationObject.ranges = this.serializeAnimationRanges();
  89686. // Layer mask
  89687. serializationObject.layerMask = this.layerMask;
  89688. // Alpha
  89689. serializationObject.alphaIndex = this.alphaIndex;
  89690. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  89691. // Overlay
  89692. serializationObject.overlayAlpha = this.overlayAlpha;
  89693. serializationObject.overlayColor = this.overlayColor.asArray();
  89694. serializationObject.renderOverlay = this.renderOverlay;
  89695. // Fog
  89696. serializationObject.applyFog = this.applyFog;
  89697. // Action Manager
  89698. if (this.actionManager) {
  89699. serializationObject.actions = this.actionManager.serialize(this.name);
  89700. }
  89701. };
  89702. /** @hidden */
  89703. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  89704. if (!this.geometry) {
  89705. return;
  89706. }
  89707. this._markSubMeshesAsAttributesDirty();
  89708. var morphTargetManager = this._morphTargetManager;
  89709. if (morphTargetManager && morphTargetManager.vertexCount) {
  89710. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  89711. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  89712. this.morphTargetManager = null;
  89713. return;
  89714. }
  89715. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  89716. var morphTarget = morphTargetManager.getActiveTarget(index);
  89717. var positions = morphTarget.getPositions();
  89718. if (!positions) {
  89719. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Invalid morph target. Target must have positions.");
  89720. return;
  89721. }
  89722. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index, positions, false, 3);
  89723. var normals = morphTarget.getNormals();
  89724. if (normals) {
  89725. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index, normals, false, 3);
  89726. }
  89727. var tangents = morphTarget.getTangents();
  89728. if (tangents) {
  89729. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  89730. }
  89731. }
  89732. }
  89733. else {
  89734. var index = 0;
  89735. // Positions
  89736. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index)) {
  89737. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index);
  89738. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index)) {
  89739. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index);
  89740. }
  89741. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index)) {
  89742. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index);
  89743. }
  89744. index++;
  89745. }
  89746. }
  89747. };
  89748. /**
  89749. * Returns a new Mesh object parsed from the source provided.
  89750. * @param parsedMesh is the source
  89751. * @param scene defines the hosting scene
  89752. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  89753. * @returns a new Mesh
  89754. */
  89755. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  89756. var mesh;
  89757. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  89758. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  89759. }
  89760. else {
  89761. mesh = new Mesh(parsedMesh.name, scene);
  89762. }
  89763. mesh.id = parsedMesh.id;
  89764. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  89765. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  89766. }
  89767. mesh.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  89768. if (parsedMesh.metadata !== undefined) {
  89769. mesh.metadata = parsedMesh.metadata;
  89770. }
  89771. if (parsedMesh.rotationQuaternion) {
  89772. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  89773. }
  89774. else if (parsedMesh.rotation) {
  89775. mesh.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  89776. }
  89777. mesh.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  89778. if (parsedMesh.localMatrix) {
  89779. mesh.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  89780. }
  89781. else if (parsedMesh.pivotMatrix) {
  89782. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  89783. }
  89784. mesh.setEnabled(parsedMesh.isEnabled);
  89785. mesh.isVisible = parsedMesh.isVisible;
  89786. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  89787. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  89788. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  89789. if (parsedMesh.applyFog !== undefined) {
  89790. mesh.applyFog = parsedMesh.applyFog;
  89791. }
  89792. if (parsedMesh.pickable !== undefined) {
  89793. mesh.isPickable = parsedMesh.pickable;
  89794. }
  89795. if (parsedMesh.alphaIndex !== undefined) {
  89796. mesh.alphaIndex = parsedMesh.alphaIndex;
  89797. }
  89798. mesh.receiveShadows = parsedMesh.receiveShadows;
  89799. mesh.billboardMode = parsedMesh.billboardMode;
  89800. if (parsedMesh.visibility !== undefined) {
  89801. mesh.visibility = parsedMesh.visibility;
  89802. }
  89803. mesh.checkCollisions = parsedMesh.checkCollisions;
  89804. if (parsedMesh.isBlocker !== undefined) {
  89805. mesh.isBlocker = parsedMesh.isBlocker;
  89806. }
  89807. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  89808. // freezeWorldMatrix
  89809. if (parsedMesh.freezeWorldMatrix) {
  89810. mesh._waitingFreezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  89811. }
  89812. // Parent
  89813. if (parsedMesh.parentId) {
  89814. mesh._waitingParentId = parsedMesh.parentId;
  89815. }
  89816. // Actions
  89817. if (parsedMesh.actions !== undefined) {
  89818. mesh._waitingActions = parsedMesh.actions;
  89819. }
  89820. // Overlay
  89821. if (parsedMesh.overlayAlpha !== undefined) {
  89822. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  89823. }
  89824. if (parsedMesh.overlayColor !== undefined) {
  89825. mesh.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].FromArray(parsedMesh.overlayColor);
  89826. }
  89827. if (parsedMesh.renderOverlay !== undefined) {
  89828. mesh.renderOverlay = parsedMesh.renderOverlay;
  89829. }
  89830. // Geometry
  89831. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  89832. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  89833. if (parsedMesh.delayLoadingFile) {
  89834. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED;
  89835. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  89836. 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));
  89837. if (parsedMesh._binaryInfo) {
  89838. mesh._binaryInfo = parsedMesh._binaryInfo;
  89839. }
  89840. mesh._delayInfo = [];
  89841. if (parsedMesh.hasUVs) {
  89842. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  89843. }
  89844. if (parsedMesh.hasUVs2) {
  89845. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  89846. }
  89847. if (parsedMesh.hasUVs3) {
  89848. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV3Kind);
  89849. }
  89850. if (parsedMesh.hasUVs4) {
  89851. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV4Kind);
  89852. }
  89853. if (parsedMesh.hasUVs5) {
  89854. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV5Kind);
  89855. }
  89856. if (parsedMesh.hasUVs6) {
  89857. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV6Kind);
  89858. }
  89859. if (parsedMesh.hasColors) {
  89860. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  89861. }
  89862. if (parsedMesh.hasMatricesIndices) {
  89863. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  89864. }
  89865. if (parsedMesh.hasMatricesWeights) {
  89866. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  89867. }
  89868. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry;
  89869. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  89870. mesh._checkDelayState();
  89871. }
  89872. }
  89873. else {
  89874. _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  89875. }
  89876. // Material
  89877. if (parsedMesh.materialId) {
  89878. mesh.setMaterialByID(parsedMesh.materialId);
  89879. }
  89880. else {
  89881. mesh.material = null;
  89882. }
  89883. // Morph targets
  89884. if (parsedMesh.morphTargetManagerId > -1) {
  89885. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  89886. }
  89887. // Skeleton
  89888. if (parsedMesh.skeletonId > -1) {
  89889. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  89890. if (parsedMesh.numBoneInfluencers) {
  89891. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  89892. }
  89893. }
  89894. // Animations
  89895. if (parsedMesh.animations) {
  89896. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  89897. var parsedAnimation = parsedMesh.animations[animationIndex];
  89898. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  89899. if (internalClass) {
  89900. mesh.animations.push(internalClass.Parse(parsedAnimation));
  89901. }
  89902. }
  89903. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  89904. }
  89905. if (parsedMesh.autoAnimate) {
  89906. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  89907. }
  89908. // Layer Mask
  89909. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  89910. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  89911. }
  89912. else {
  89913. mesh.layerMask = 0x0FFFFFFF;
  89914. }
  89915. // Physics
  89916. if (parsedMesh.physicsImpostor) {
  89917. Mesh._PhysicsImpostorParser(scene, mesh, parsedMesh);
  89918. }
  89919. // Instances
  89920. if (parsedMesh.instances) {
  89921. for (var index = 0; index < parsedMesh.instances.length; index++) {
  89922. var parsedInstance = parsedMesh.instances[index];
  89923. var instance = mesh.createInstance(parsedInstance.name);
  89924. if (parsedInstance.id) {
  89925. instance.id = parsedInstance.id;
  89926. }
  89927. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  89928. if (parsedInstance.tags) {
  89929. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  89930. }
  89931. else {
  89932. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  89933. }
  89934. }
  89935. instance.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  89936. if (parsedInstance.parentId) {
  89937. instance._waitingParentId = parsedInstance.parentId;
  89938. }
  89939. if (parsedInstance.rotationQuaternion) {
  89940. instance.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  89941. }
  89942. else if (parsedInstance.rotation) {
  89943. instance.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  89944. }
  89945. instance.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  89946. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  89947. instance.checkCollisions = parsedInstance.checkCollisions;
  89948. }
  89949. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  89950. instance.isPickable = parsedInstance.pickable;
  89951. }
  89952. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  89953. instance.showBoundingBox = parsedInstance.showBoundingBox;
  89954. }
  89955. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  89956. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  89957. }
  89958. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  89959. instance.alphaIndex = parsedInstance.alphaIndex;
  89960. }
  89961. // Physics
  89962. if (parsedInstance.physicsImpostor) {
  89963. Mesh._PhysicsImpostorParser(scene, instance, parsedInstance);
  89964. }
  89965. // Animation
  89966. if (parsedInstance.animations) {
  89967. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  89968. parsedAnimation = parsedInstance.animations[animationIndex];
  89969. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  89970. if (internalClass) {
  89971. instance.animations.push(internalClass.Parse(parsedAnimation));
  89972. }
  89973. }
  89974. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  89975. if (parsedInstance.autoAnimate) {
  89976. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  89977. }
  89978. }
  89979. }
  89980. }
  89981. return mesh;
  89982. };
  89983. /**
  89984. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  89985. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  89986. * @param name defines the name of the mesh to create
  89987. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  89988. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  89989. * @param closePath creates a seam between the first and the last points of each path of the path array
  89990. * @param offset is taken in account only if the `pathArray` is containing a single path
  89991. * @param scene defines the hosting scene
  89992. * @param updatable defines if the mesh must be flagged as updatable
  89993. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  89994. * @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)
  89995. * @returns a new Mesh
  89996. */
  89997. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  89998. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  89999. };
  90000. /**
  90001. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  90002. * @param name defines the name of the mesh to create
  90003. * @param radius sets the radius size (float) of the polygon (default 0.5)
  90004. * @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
  90005. * @param scene defines the hosting scene
  90006. * @param updatable defines if the mesh must be flagged as updatable
  90007. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90008. * @returns a new Mesh
  90009. */
  90010. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  90011. if (scene === void 0) { scene = null; }
  90012. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90013. };
  90014. /**
  90015. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  90016. * @param name defines the name of the mesh to create
  90017. * @param size sets the size (float) of each box side (default 1)
  90018. * @param scene defines the hosting scene
  90019. * @param updatable defines if the mesh must be flagged as updatable
  90020. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90021. * @returns a new Mesh
  90022. */
  90023. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  90024. if (scene === void 0) { scene = null; }
  90025. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90026. };
  90027. /**
  90028. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  90029. * @param name defines the name of the mesh to create
  90030. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90031. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90032. * @param scene defines the hosting scene
  90033. * @param updatable defines if the mesh must be flagged as updatable
  90034. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90035. * @returns a new Mesh
  90036. */
  90037. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  90038. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90039. };
  90040. /**
  90041. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  90042. * @param name defines the name of the mesh to create
  90043. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90044. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90045. * @param scene defines the hosting scene
  90046. * @returns a new Mesh
  90047. */
  90048. Mesh.CreateHemisphere = function (name, segments, diameter, scene) {
  90049. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90050. };
  90051. /**
  90052. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  90053. * @param name defines the name of the mesh to create
  90054. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  90055. * @param diameterTop set the top cap diameter (floats, default 1)
  90056. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  90057. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  90058. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  90059. * @param scene defines the hosting scene
  90060. * @param updatable defines if the mesh must be flagged as updatable
  90061. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90062. * @returns a new Mesh
  90063. */
  90064. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  90065. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90066. };
  90067. // Torus (Code from SharpDX.org)
  90068. /**
  90069. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  90070. * @param name defines the name of the mesh to create
  90071. * @param diameter sets the diameter size (float) of the torus (default 1)
  90072. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  90073. * @param tessellation sets the number of torus sides (postive integer, default 16)
  90074. * @param scene defines the hosting scene
  90075. * @param updatable defines if the mesh must be flagged as updatable
  90076. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90077. * @returns a new Mesh
  90078. */
  90079. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  90080. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90081. };
  90082. /**
  90083. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  90084. * @param name defines the name of the mesh to create
  90085. * @param radius sets the global radius size (float) of the torus knot (default 2)
  90086. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  90087. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  90088. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  90089. * @param p the number of windings on X axis (positive integers, default 2)
  90090. * @param q the number of windings on Y axis (positive integers, default 3)
  90091. * @param scene defines the hosting scene
  90092. * @param updatable defines if the mesh must be flagged as updatable
  90093. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90094. * @returns a new Mesh
  90095. */
  90096. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  90097. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90098. };
  90099. /**
  90100. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  90101. * @param name defines the name of the mesh to create
  90102. * @param points is an array successive Vector3
  90103. * @param scene defines the hosting scene
  90104. * @param updatable defines if the mesh must be flagged as updatable
  90105. * @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).
  90106. * @returns a new Mesh
  90107. */
  90108. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  90109. if (scene === void 0) { scene = null; }
  90110. if (updatable === void 0) { updatable = false; }
  90111. if (instance === void 0) { instance = null; }
  90112. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90113. };
  90114. /**
  90115. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  90116. * @param name defines the name of the mesh to create
  90117. * @param points is an array successive Vector3
  90118. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  90119. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  90120. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  90121. * @param scene defines the hosting scene
  90122. * @param updatable defines if the mesh must be flagged as updatable
  90123. * @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)
  90124. * @returns a new Mesh
  90125. */
  90126. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  90127. if (scene === void 0) { scene = null; }
  90128. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90129. };
  90130. /**
  90131. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  90132. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  90133. * 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.
  90134. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90135. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90136. * Remember you can only change the shape positions, not their number when updating a polygon.
  90137. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  90138. * @param name defines the name of the mesh to create
  90139. * @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
  90140. * @param scene defines the hosting scene
  90141. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90142. * @param updatable defines if the mesh must be flagged as updatable
  90143. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90144. * @param earcutInjection can be used to inject your own earcut reference
  90145. * @returns a new Mesh
  90146. */
  90147. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  90148. if (earcutInjection === void 0) { earcutInjection = earcut; }
  90149. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90150. };
  90151. /**
  90152. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  90153. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  90154. * @param name defines the name of the mesh to create
  90155. * @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
  90156. * @param depth defines the height of extrusion
  90157. * @param scene defines the hosting scene
  90158. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90159. * @param updatable defines if the mesh must be flagged as updatable
  90160. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90161. * @param earcutInjection can be used to inject your own earcut reference
  90162. * @returns a new Mesh
  90163. */
  90164. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  90165. if (earcutInjection === void 0) { earcutInjection = earcut; }
  90166. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90167. };
  90168. /**
  90169. * Creates an extruded shape mesh.
  90170. * 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
  90171. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90172. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90173. * @param name defines the name of the mesh to create
  90174. * @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
  90175. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90176. * @param scale is the value to scale the shape
  90177. * @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
  90178. * @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
  90179. * @param scene defines the hosting scene
  90180. * @param updatable defines if the mesh must be flagged as updatable
  90181. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90182. * @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)
  90183. * @returns a new Mesh
  90184. */
  90185. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  90186. if (scene === void 0) { scene = null; }
  90187. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90188. };
  90189. /**
  90190. * Creates an custom extruded shape mesh.
  90191. * The custom extrusion is a parametric shape.
  90192. * It has no predefined shape. Its final shape will depend on the input parameters.
  90193. * Please consider using the same method from the MeshBuilder class instead
  90194. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90195. * @param name defines the name of the mesh to create
  90196. * @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
  90197. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90198. * @param scaleFunction is a custom Javascript function called on each path point
  90199. * @param rotationFunction is a custom Javascript function called on each path point
  90200. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  90201. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  90202. * @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
  90203. * @param scene defines the hosting scene
  90204. * @param updatable defines if the mesh must be flagged as updatable
  90205. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90206. * @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)
  90207. * @returns a new Mesh
  90208. */
  90209. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  90210. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90211. };
  90212. /**
  90213. * Creates lathe mesh.
  90214. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  90215. * Please consider using the same method from the MeshBuilder class instead
  90216. * @param name defines the name of the mesh to create
  90217. * @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
  90218. * @param radius is the radius value of the lathe
  90219. * @param tessellation is the side number of the lathe.
  90220. * @param scene defines the hosting scene
  90221. * @param updatable defines if the mesh must be flagged as updatable
  90222. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90223. * @returns a new Mesh
  90224. */
  90225. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  90226. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90227. };
  90228. /**
  90229. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  90230. * @param name defines the name of the mesh to create
  90231. * @param size sets the size (float) of both sides of the plane at once (default 1)
  90232. * @param scene defines the hosting scene
  90233. * @param updatable defines if the mesh must be flagged as updatable
  90234. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90235. * @returns a new Mesh
  90236. */
  90237. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  90238. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90239. };
  90240. /**
  90241. * Creates a ground mesh.
  90242. * Please consider using the same method from the MeshBuilder class instead
  90243. * @param name defines the name of the mesh to create
  90244. * @param width set the width of the ground
  90245. * @param height set the height of the ground
  90246. * @param subdivisions sets the number of subdivisions per side
  90247. * @param scene defines the hosting scene
  90248. * @param updatable defines if the mesh must be flagged as updatable
  90249. * @returns a new Mesh
  90250. */
  90251. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  90252. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90253. };
  90254. /**
  90255. * Creates a tiled ground mesh.
  90256. * Please consider using the same method from the MeshBuilder class instead
  90257. * @param name defines the name of the mesh to create
  90258. * @param xmin set the ground minimum X coordinate
  90259. * @param zmin set the ground minimum Y coordinate
  90260. * @param xmax set the ground maximum X coordinate
  90261. * @param zmax set the ground maximum Z coordinate
  90262. * @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
  90263. * @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
  90264. * @param scene defines the hosting scene
  90265. * @param updatable defines if the mesh must be flagged as updatable
  90266. * @returns a new Mesh
  90267. */
  90268. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  90269. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90270. };
  90271. /**
  90272. * Creates a ground mesh from a height map.
  90273. * Please consider using the same method from the MeshBuilder class instead
  90274. * @see http://doc.babylonjs.com/babylon101/height_map
  90275. * @param name defines the name of the mesh to create
  90276. * @param url sets the URL of the height map image resource
  90277. * @param width set the ground width size
  90278. * @param height set the ground height size
  90279. * @param subdivisions sets the number of subdivision per side
  90280. * @param minHeight is the minimum altitude on the ground
  90281. * @param maxHeight is the maximum altitude on the ground
  90282. * @param scene defines the hosting scene
  90283. * @param updatable defines if the mesh must be flagged as updatable
  90284. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  90285. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  90286. * @returns a new Mesh
  90287. */
  90288. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  90289. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90290. };
  90291. /**
  90292. * Creates a tube mesh.
  90293. * The tube is a parametric shape.
  90294. * It has no predefined shape. Its final shape will depend on the input parameters.
  90295. * Please consider using the same method from the MeshBuilder class instead
  90296. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90297. * @param name defines the name of the mesh to create
  90298. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  90299. * @param radius sets the tube radius size
  90300. * @param tessellation is the number of sides on the tubular surface
  90301. * @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
  90302. * @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
  90303. * @param scene defines the hosting scene
  90304. * @param updatable defines if the mesh must be flagged as updatable
  90305. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90306. * @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)
  90307. * @returns a new Mesh
  90308. */
  90309. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  90310. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90311. };
  90312. /**
  90313. * Creates a polyhedron mesh.
  90314. * Please consider using the same method from the MeshBuilder class instead.
  90315. * * 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
  90316. * * The parameter `size` (positive float, default 1) sets the polygon size
  90317. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90318. * * 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`
  90319. * * 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
  90320. * * 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)`)
  90321. * * 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
  90322. * * 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
  90323. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90324. * * 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
  90325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90326. * @param name defines the name of the mesh to create
  90327. * @param options defines the options used to create the mesh
  90328. * @param scene defines the hosting scene
  90329. * @returns a new Mesh
  90330. */
  90331. Mesh.CreatePolyhedron = function (name, options, scene) {
  90332. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90333. };
  90334. /**
  90335. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  90336. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  90337. * * 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`)
  90338. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  90339. * * 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
  90340. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90341. * * 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
  90342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90343. * @param name defines the name of the mesh
  90344. * @param options defines the options used to create the mesh
  90345. * @param scene defines the hosting scene
  90346. * @returns a new Mesh
  90347. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  90348. */
  90349. Mesh.CreateIcoSphere = function (name, options, scene) {
  90350. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90351. };
  90352. /**
  90353. * Creates a decal mesh.
  90354. * Please consider using the same method from the MeshBuilder class instead.
  90355. * A decal is a mesh usually applied as a model onto the surface of another mesh
  90356. * @param name defines the name of the mesh
  90357. * @param sourceMesh defines the mesh receiving the decal
  90358. * @param position sets the position of the decal in world coordinates
  90359. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  90360. * @param size sets the decal scaling
  90361. * @param angle sets the angle to rotate the decal
  90362. * @returns a new Mesh
  90363. */
  90364. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  90365. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  90366. };
  90367. // Skeletons
  90368. /**
  90369. * Prepare internal position array for software CPU skinning
  90370. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  90371. */
  90372. Mesh.prototype.setPositionsForCPUSkinning = function () {
  90373. if (!this._sourcePositions) {
  90374. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  90375. if (!source) {
  90376. return this._sourcePositions;
  90377. }
  90378. this._sourcePositions = new Float32Array(source);
  90379. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  90380. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, source, true);
  90381. }
  90382. }
  90383. return this._sourcePositions;
  90384. };
  90385. /**
  90386. * Prepare internal normal array for software CPU skinning
  90387. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  90388. */
  90389. Mesh.prototype.setNormalsForCPUSkinning = function () {
  90390. if (!this._sourceNormals) {
  90391. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  90392. if (!source) {
  90393. return this._sourceNormals;
  90394. }
  90395. this._sourceNormals = new Float32Array(source);
  90396. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  90397. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, source, true);
  90398. }
  90399. }
  90400. return this._sourceNormals;
  90401. };
  90402. /**
  90403. * Updates the vertex buffer by applying transformation from the bones
  90404. * @param skeleton defines the skeleton to apply to current mesh
  90405. * @returns the current mesh
  90406. */
  90407. Mesh.prototype.applySkeleton = function (skeleton) {
  90408. if (!this.geometry) {
  90409. return this;
  90410. }
  90411. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  90412. return this;
  90413. }
  90414. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  90415. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  90416. return this;
  90417. }
  90418. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  90419. return this;
  90420. }
  90421. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind)) {
  90422. return this;
  90423. }
  90424. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  90425. return this;
  90426. }
  90427. if (!this._sourcePositions) {
  90428. var submeshes = this.subMeshes.slice();
  90429. this.setPositionsForCPUSkinning();
  90430. this.subMeshes = submeshes;
  90431. }
  90432. if (!this._sourceNormals) {
  90433. this.setNormalsForCPUSkinning();
  90434. }
  90435. // positionsData checks for not being Float32Array will only pass at most once
  90436. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  90437. if (!positionsData) {
  90438. return this;
  90439. }
  90440. if (!(positionsData instanceof Float32Array)) {
  90441. positionsData = new Float32Array(positionsData);
  90442. }
  90443. // normalsData checks for not being Float32Array will only pass at most once
  90444. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  90445. if (!normalsData) {
  90446. return this;
  90447. }
  90448. if (!(normalsData instanceof Float32Array)) {
  90449. normalsData = new Float32Array(normalsData);
  90450. }
  90451. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  90452. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  90453. if (!matricesWeightsData || !matricesIndicesData) {
  90454. return this;
  90455. }
  90456. var needExtras = this.numBoneInfluencers > 4;
  90457. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  90458. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  90459. var skeletonMatrices = skeleton.getTransformMatrices(this);
  90460. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  90461. var finalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  90462. var tempMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  90463. var matWeightIdx = 0;
  90464. var inf;
  90465. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  90466. var weight;
  90467. for (inf = 0; inf < 4; inf++) {
  90468. weight = matricesWeightsData[matWeightIdx + inf];
  90469. if (weight > 0) {
  90470. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  90471. finalMatrix.addToSelf(tempMatrix);
  90472. }
  90473. }
  90474. if (needExtras) {
  90475. for (inf = 0; inf < 4; inf++) {
  90476. weight = matricesWeightsExtraData[matWeightIdx + inf];
  90477. if (weight > 0) {
  90478. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  90479. finalMatrix.addToSelf(tempMatrix);
  90480. }
  90481. }
  90482. }
  90483. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
  90484. tempVector3.toArray(positionsData, index);
  90485. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);
  90486. tempVector3.toArray(normalsData, index);
  90487. finalMatrix.reset();
  90488. }
  90489. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positionsData);
  90490. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normalsData);
  90491. return this;
  90492. };
  90493. // Tools
  90494. /**
  90495. * 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
  90496. * @param meshes defines the list of meshes to scan
  90497. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  90498. */
  90499. Mesh.MinMax = function (meshes) {
  90500. var minVector = null;
  90501. var maxVector = null;
  90502. meshes.forEach(function (mesh) {
  90503. var boundingInfo = mesh.getBoundingInfo();
  90504. var boundingBox = boundingInfo.boundingBox;
  90505. if (!minVector || !maxVector) {
  90506. minVector = boundingBox.minimumWorld;
  90507. maxVector = boundingBox.maximumWorld;
  90508. }
  90509. else {
  90510. minVector.minimizeInPlace(boundingBox.minimumWorld);
  90511. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  90512. }
  90513. });
  90514. if (!minVector || !maxVector) {
  90515. return {
  90516. min: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  90517. max: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  90518. };
  90519. }
  90520. return {
  90521. min: minVector,
  90522. max: maxVector
  90523. };
  90524. };
  90525. /**
  90526. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  90527. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  90528. * @returns a vector3
  90529. */
  90530. Mesh.Center = function (meshesOrMinMaxVector) {
  90531. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  90532. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  90533. };
  90534. /**
  90535. * Merge the array of meshes into a single mesh for performance reasons.
  90536. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  90537. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  90538. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  90539. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  90540. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  90541. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  90542. * @returns a new mesh
  90543. */
  90544. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes, multiMultiMaterials) {
  90545. if (disposeSource === void 0) { disposeSource = true; }
  90546. var index;
  90547. if (!allow32BitsIndices) {
  90548. var totalVertices = 0;
  90549. // Counting vertices
  90550. for (index = 0; index < meshes.length; index++) {
  90551. if (meshes[index]) {
  90552. totalVertices += meshes[index].getTotalVertices();
  90553. if (totalVertices > 65536) {
  90554. _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");
  90555. return null;
  90556. }
  90557. }
  90558. }
  90559. }
  90560. if (multiMultiMaterials) {
  90561. var newMultiMaterial = null;
  90562. var subIndex;
  90563. var matIndex;
  90564. subdivideWithSubMeshes = false;
  90565. }
  90566. var materialArray = new Array();
  90567. var materialIndexArray = new Array();
  90568. // Merge
  90569. var vertexData = null;
  90570. var otherVertexData;
  90571. var indiceArray = new Array();
  90572. var source = null;
  90573. for (index = 0; index < meshes.length; index++) {
  90574. if (meshes[index]) {
  90575. var mesh = meshes[index];
  90576. var wm = mesh.computeWorldMatrix(true);
  90577. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(mesh, true, true);
  90578. otherVertexData.transform(wm);
  90579. if (vertexData) {
  90580. vertexData.merge(otherVertexData, allow32BitsIndices);
  90581. }
  90582. else {
  90583. vertexData = otherVertexData;
  90584. source = mesh;
  90585. }
  90586. if (subdivideWithSubMeshes) {
  90587. indiceArray.push(mesh.getTotalIndices());
  90588. }
  90589. if (multiMultiMaterials) {
  90590. if (mesh.material) {
  90591. var material = mesh.material;
  90592. if (material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"]) {
  90593. for (matIndex = 0; matIndex < material.subMaterials.length; matIndex++) {
  90594. if (materialArray.indexOf(material.subMaterials[matIndex]) < 0) {
  90595. materialArray.push(material.subMaterials[matIndex]);
  90596. }
  90597. }
  90598. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  90599. materialIndexArray.push(materialArray.indexOf(material.subMaterials[mesh.subMeshes[subIndex].materialIndex]));
  90600. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  90601. }
  90602. }
  90603. else {
  90604. if (materialArray.indexOf(material) < 0) {
  90605. materialArray.push(material);
  90606. }
  90607. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  90608. materialIndexArray.push(materialArray.indexOf(material));
  90609. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  90610. }
  90611. }
  90612. }
  90613. else {
  90614. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  90615. materialIndexArray.push(0);
  90616. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  90617. }
  90618. }
  90619. }
  90620. }
  90621. }
  90622. source = source;
  90623. if (!meshSubclass) {
  90624. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  90625. }
  90626. vertexData.applyToMesh(meshSubclass);
  90627. // Setting properties
  90628. meshSubclass.checkCollisions = source.checkCollisions;
  90629. // Cleaning
  90630. if (disposeSource) {
  90631. for (index = 0; index < meshes.length; index++) {
  90632. if (meshes[index]) {
  90633. meshes[index].dispose();
  90634. }
  90635. }
  90636. }
  90637. // Subdivide
  90638. if (subdivideWithSubMeshes || multiMultiMaterials) {
  90639. //-- removal of global submesh
  90640. meshSubclass.releaseSubMeshes();
  90641. index = 0;
  90642. var offset = 0;
  90643. //-- apply subdivision according to index table
  90644. while (index < indiceArray.length) {
  90645. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  90646. offset += indiceArray[index];
  90647. index++;
  90648. }
  90649. }
  90650. if (multiMultiMaterials) {
  90651. newMultiMaterial = new _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"](source.name + "_merged", source.getScene());
  90652. newMultiMaterial.subMaterials = materialArray;
  90653. for (subIndex = 0; subIndex < meshSubclass.subMeshes.length; subIndex++) {
  90654. meshSubclass.subMeshes[subIndex].materialIndex = materialIndexArray[subIndex];
  90655. }
  90656. meshSubclass.material = newMultiMaterial;
  90657. }
  90658. else {
  90659. meshSubclass.material = source.material;
  90660. }
  90661. return meshSubclass;
  90662. };
  90663. /** @hidden */
  90664. Mesh.prototype.addInstance = function (instance) {
  90665. instance._indexInSourceMeshInstanceArray = this.instances.length;
  90666. this.instances.push(instance);
  90667. };
  90668. /** @hidden */
  90669. Mesh.prototype.removeInstance = function (instance) {
  90670. // Remove from mesh
  90671. var index = instance._indexInSourceMeshInstanceArray;
  90672. if (index != -1) {
  90673. if (index !== this.instances.length - 1) {
  90674. var last = this.instances[this.instances.length - 1];
  90675. this.instances[index] = last;
  90676. last._indexInSourceMeshInstanceArray = index;
  90677. }
  90678. instance._indexInSourceMeshInstanceArray = -1;
  90679. this.instances.pop();
  90680. }
  90681. };
  90682. // Consts
  90683. /**
  90684. * Mesh side orientation : usually the external or front surface
  90685. */
  90686. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].FRONTSIDE;
  90687. /**
  90688. * Mesh side orientation : usually the internal or back surface
  90689. */
  90690. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].BACKSIDE;
  90691. /**
  90692. * Mesh side orientation : both internal and external or front and back surfaces
  90693. */
  90694. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DOUBLESIDE;
  90695. /**
  90696. * Mesh side orientation : by default, `FRONTSIDE`
  90697. */
  90698. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DEFAULTSIDE;
  90699. /**
  90700. * Mesh cap setting : no cap
  90701. */
  90702. Mesh.NO_CAP = 0;
  90703. /**
  90704. * Mesh cap setting : one cap at the beginning of the mesh
  90705. */
  90706. Mesh.CAP_START = 1;
  90707. /**
  90708. * Mesh cap setting : one cap at the end of the mesh
  90709. */
  90710. Mesh.CAP_END = 2;
  90711. /**
  90712. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90713. */
  90714. Mesh.CAP_ALL = 3;
  90715. // Statics
  90716. /** @hidden */
  90717. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  90718. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("GroundMesh");
  90719. };
  90720. return Mesh;
  90721. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_10__["AbstractMesh"]));
  90722. /***/ }),
  90723. /***/ "./Meshes/mesh.vertexData.ts":
  90724. /*!***********************************!*\
  90725. !*** ./Meshes/mesh.vertexData.ts ***!
  90726. \***********************************/
  90727. /*! exports provided: VertexData */
  90728. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90729. "use strict";
  90730. __webpack_require__.r(__webpack_exports__);
  90731. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  90732. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  90733. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  90734. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  90735. /**
  90736. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  90737. */
  90738. var VertexData = /** @class */ (function () {
  90739. function VertexData() {
  90740. }
  90741. /**
  90742. * Uses the passed data array to set the set the values for the specified kind of data
  90743. * @param data a linear array of floating numbers
  90744. * @param kind the type of data that is being set, eg positions, colors etc
  90745. */
  90746. VertexData.prototype.set = function (data, kind) {
  90747. switch (kind) {
  90748. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  90749. this.positions = data;
  90750. break;
  90751. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  90752. this.normals = data;
  90753. break;
  90754. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  90755. this.tangents = data;
  90756. break;
  90757. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  90758. this.uvs = data;
  90759. break;
  90760. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  90761. this.uvs2 = data;
  90762. break;
  90763. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  90764. this.uvs3 = data;
  90765. break;
  90766. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  90767. this.uvs4 = data;
  90768. break;
  90769. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  90770. this.uvs5 = data;
  90771. break;
  90772. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  90773. this.uvs6 = data;
  90774. break;
  90775. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  90776. this.colors = data;
  90777. break;
  90778. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  90779. this.matricesIndices = data;
  90780. break;
  90781. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  90782. this.matricesWeights = data;
  90783. break;
  90784. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  90785. this.matricesIndicesExtra = data;
  90786. break;
  90787. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  90788. this.matricesWeightsExtra = data;
  90789. break;
  90790. }
  90791. };
  90792. /**
  90793. * Associates the vertexData to the passed Mesh.
  90794. * Sets it as updatable or not (default `false`)
  90795. * @param mesh the mesh the vertexData is applied to
  90796. * @param updatable when used and having the value true allows new data to update the vertexData
  90797. * @returns the VertexData
  90798. */
  90799. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  90800. this._applyTo(mesh, updatable);
  90801. return this;
  90802. };
  90803. /**
  90804. * Associates the vertexData to the passed Geometry.
  90805. * Sets it as updatable or not (default `false`)
  90806. * @param geometry the geometry the vertexData is applied to
  90807. * @param updatable when used and having the value true allows new data to update the vertexData
  90808. * @returns VertexData
  90809. */
  90810. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  90811. this._applyTo(geometry, updatable);
  90812. return this;
  90813. };
  90814. /**
  90815. * Updates the associated mesh
  90816. * @param mesh the mesh to be updated
  90817. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90818. * @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
  90819. * @returns VertexData
  90820. */
  90821. VertexData.prototype.updateMesh = function (mesh) {
  90822. this._update(mesh);
  90823. return this;
  90824. };
  90825. /**
  90826. * Updates the associated geometry
  90827. * @param geometry the geometry to be updated
  90828. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  90829. * @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
  90830. * @returns VertexData.
  90831. */
  90832. VertexData.prototype.updateGeometry = function (geometry) {
  90833. this._update(geometry);
  90834. return this;
  90835. };
  90836. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  90837. if (updatable === void 0) { updatable = false; }
  90838. if (this.positions) {
  90839. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  90840. }
  90841. if (this.normals) {
  90842. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  90843. }
  90844. if (this.tangents) {
  90845. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  90846. }
  90847. if (this.uvs) {
  90848. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  90849. }
  90850. if (this.uvs2) {
  90851. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  90852. }
  90853. if (this.uvs3) {
  90854. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  90855. }
  90856. if (this.uvs4) {
  90857. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  90858. }
  90859. if (this.uvs5) {
  90860. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  90861. }
  90862. if (this.uvs6) {
  90863. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  90864. }
  90865. if (this.colors) {
  90866. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  90867. }
  90868. if (this.matricesIndices) {
  90869. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  90870. }
  90871. if (this.matricesWeights) {
  90872. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  90873. }
  90874. if (this.matricesIndicesExtra) {
  90875. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  90876. }
  90877. if (this.matricesWeightsExtra) {
  90878. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  90879. }
  90880. if (this.indices) {
  90881. meshOrGeometry.setIndices(this.indices, null, updatable);
  90882. }
  90883. else {
  90884. meshOrGeometry.setIndices([], null);
  90885. }
  90886. return this;
  90887. };
  90888. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  90889. if (this.positions) {
  90890. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  90891. }
  90892. if (this.normals) {
  90893. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  90894. }
  90895. if (this.tangents) {
  90896. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  90897. }
  90898. if (this.uvs) {
  90899. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  90900. }
  90901. if (this.uvs2) {
  90902. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  90903. }
  90904. if (this.uvs3) {
  90905. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  90906. }
  90907. if (this.uvs4) {
  90908. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  90909. }
  90910. if (this.uvs5) {
  90911. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  90912. }
  90913. if (this.uvs6) {
  90914. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  90915. }
  90916. if (this.colors) {
  90917. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  90918. }
  90919. if (this.matricesIndices) {
  90920. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  90921. }
  90922. if (this.matricesWeights) {
  90923. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  90924. }
  90925. if (this.matricesIndicesExtra) {
  90926. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  90927. }
  90928. if (this.matricesWeightsExtra) {
  90929. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  90930. }
  90931. if (this.indices) {
  90932. meshOrGeometry.setIndices(this.indices, null);
  90933. }
  90934. return this;
  90935. };
  90936. /**
  90937. * Transforms each position and each normal of the vertexData according to the passed Matrix
  90938. * @param matrix the transforming matrix
  90939. * @returns the VertexData
  90940. */
  90941. VertexData.prototype.transform = function (matrix) {
  90942. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  90943. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  90944. var index;
  90945. if (this.positions) {
  90946. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  90947. for (index = 0; index < this.positions.length; index += 3) {
  90948. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  90949. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  90950. this.positions[index] = transformed.x;
  90951. this.positions[index + 1] = transformed.y;
  90952. this.positions[index + 2] = transformed.z;
  90953. }
  90954. }
  90955. if (this.normals) {
  90956. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  90957. for (index = 0; index < this.normals.length; index += 3) {
  90958. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  90959. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  90960. this.normals[index] = transformed.x;
  90961. this.normals[index + 1] = transformed.y;
  90962. this.normals[index + 2] = transformed.z;
  90963. }
  90964. }
  90965. if (this.tangents) {
  90966. var tangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  90967. var tangentTransformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  90968. for (index = 0; index < this.tangents.length; index += 4) {
  90969. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  90970. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  90971. this.tangents[index] = tangentTransformed.x;
  90972. this.tangents[index + 1] = tangentTransformed.y;
  90973. this.tangents[index + 2] = tangentTransformed.z;
  90974. this.tangents[index + 3] = tangentTransformed.w;
  90975. }
  90976. }
  90977. if (flip && this.indices) {
  90978. for (index = 0; index < this.indices.length; index += 3) {
  90979. var tmp = this.indices[index + 1];
  90980. this.indices[index + 1] = this.indices[index + 2];
  90981. this.indices[index + 2] = tmp;
  90982. }
  90983. }
  90984. return this;
  90985. };
  90986. /**
  90987. * Merges the passed VertexData into the current one
  90988. * @param other the VertexData to be merged into the current one
  90989. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  90990. * @returns the modified VertexData
  90991. */
  90992. VertexData.prototype.merge = function (other, use32BitsIndices) {
  90993. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  90994. this._validate();
  90995. other._validate();
  90996. if (!this.normals !== !other.normals ||
  90997. !this.tangents !== !other.tangents ||
  90998. !this.uvs !== !other.uvs ||
  90999. !this.uvs2 !== !other.uvs2 ||
  91000. !this.uvs3 !== !other.uvs3 ||
  91001. !this.uvs4 !== !other.uvs4 ||
  91002. !this.uvs5 !== !other.uvs5 ||
  91003. !this.uvs6 !== !other.uvs6 ||
  91004. !this.colors !== !other.colors ||
  91005. !this.matricesIndices !== !other.matricesIndices ||
  91006. !this.matricesWeights !== !other.matricesWeights ||
  91007. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  91008. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  91009. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  91010. }
  91011. if (other.indices) {
  91012. if (!this.indices) {
  91013. this.indices = [];
  91014. }
  91015. var offset = this.positions ? this.positions.length / 3 : 0;
  91016. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  91017. if (isSrcTypedArray) {
  91018. var len = this.indices.length + other.indices.length;
  91019. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  91020. temp.set(this.indices);
  91021. var decal = this.indices.length;
  91022. for (var index = 0; index < other.indices.length; index++) {
  91023. temp[decal + index] = other.indices[index] + offset;
  91024. }
  91025. this.indices = temp;
  91026. }
  91027. else {
  91028. for (var index = 0; index < other.indices.length; index++) {
  91029. this.indices.push(other.indices[index] + offset);
  91030. }
  91031. }
  91032. }
  91033. this.positions = this._mergeElement(this.positions, other.positions);
  91034. this.normals = this._mergeElement(this.normals, other.normals);
  91035. this.tangents = this._mergeElement(this.tangents, other.tangents);
  91036. this.uvs = this._mergeElement(this.uvs, other.uvs);
  91037. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  91038. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  91039. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  91040. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  91041. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  91042. this.colors = this._mergeElement(this.colors, other.colors);
  91043. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  91044. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  91045. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  91046. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  91047. return this;
  91048. };
  91049. VertexData.prototype._mergeElement = function (source, other) {
  91050. if (!source) {
  91051. return other;
  91052. }
  91053. if (!other) {
  91054. return source;
  91055. }
  91056. var len = other.length + source.length;
  91057. var isSrcTypedArray = source instanceof Float32Array;
  91058. var isOthTypedArray = other instanceof Float32Array;
  91059. // use non-loop method when the source is Float32Array
  91060. if (isSrcTypedArray) {
  91061. var ret32 = new Float32Array(len);
  91062. ret32.set(source);
  91063. ret32.set(other, source.length);
  91064. return ret32;
  91065. // source is number[], when other is also use concat
  91066. }
  91067. else if (!isOthTypedArray) {
  91068. return source.concat(other);
  91069. // source is a number[], but other is a Float32Array, loop required
  91070. }
  91071. else {
  91072. var ret = source.slice(0); // copy source to a separate array
  91073. for (var i = 0, len = other.length; i < len; i++) {
  91074. ret.push(other[i]);
  91075. }
  91076. return ret;
  91077. }
  91078. };
  91079. VertexData.prototype._validate = function () {
  91080. if (!this.positions) {
  91081. throw new Error("Positions are required");
  91082. }
  91083. var getElementCount = function (kind, values) {
  91084. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  91085. if ((values.length % stride) !== 0) {
  91086. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  91087. }
  91088. return values.length / stride;
  91089. };
  91090. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  91091. var validateElementCount = function (kind, values) {
  91092. var elementCount = getElementCount(kind, values);
  91093. if (elementCount !== positionsElementCount) {
  91094. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  91095. }
  91096. };
  91097. if (this.normals) {
  91098. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  91099. }
  91100. if (this.tangents) {
  91101. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  91102. }
  91103. if (this.uvs) {
  91104. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  91105. }
  91106. if (this.uvs2) {
  91107. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  91108. }
  91109. if (this.uvs3) {
  91110. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  91111. }
  91112. if (this.uvs4) {
  91113. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  91114. }
  91115. if (this.uvs5) {
  91116. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  91117. }
  91118. if (this.uvs6) {
  91119. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  91120. }
  91121. if (this.colors) {
  91122. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  91123. }
  91124. if (this.matricesIndices) {
  91125. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  91126. }
  91127. if (this.matricesWeights) {
  91128. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  91129. }
  91130. if (this.matricesIndicesExtra) {
  91131. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  91132. }
  91133. if (this.matricesWeightsExtra) {
  91134. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  91135. }
  91136. };
  91137. /**
  91138. * Serializes the VertexData
  91139. * @returns a serialized object
  91140. */
  91141. VertexData.prototype.serialize = function () {
  91142. var serializationObject = this.serialize();
  91143. if (this.positions) {
  91144. serializationObject.positions = this.positions;
  91145. }
  91146. if (this.normals) {
  91147. serializationObject.normals = this.normals;
  91148. }
  91149. if (this.tangents) {
  91150. serializationObject.tangents = this.tangents;
  91151. }
  91152. if (this.uvs) {
  91153. serializationObject.uvs = this.uvs;
  91154. }
  91155. if (this.uvs2) {
  91156. serializationObject.uvs2 = this.uvs2;
  91157. }
  91158. if (this.uvs3) {
  91159. serializationObject.uvs3 = this.uvs3;
  91160. }
  91161. if (this.uvs4) {
  91162. serializationObject.uvs4 = this.uvs4;
  91163. }
  91164. if (this.uvs5) {
  91165. serializationObject.uvs5 = this.uvs5;
  91166. }
  91167. if (this.uvs6) {
  91168. serializationObject.uvs6 = this.uvs6;
  91169. }
  91170. if (this.colors) {
  91171. serializationObject.colors = this.colors;
  91172. }
  91173. if (this.matricesIndices) {
  91174. serializationObject.matricesIndices = this.matricesIndices;
  91175. serializationObject.matricesIndices._isExpanded = true;
  91176. }
  91177. if (this.matricesWeights) {
  91178. serializationObject.matricesWeights = this.matricesWeights;
  91179. }
  91180. if (this.matricesIndicesExtra) {
  91181. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  91182. serializationObject.matricesIndicesExtra._isExpanded = true;
  91183. }
  91184. if (this.matricesWeightsExtra) {
  91185. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  91186. }
  91187. serializationObject.indices = this.indices;
  91188. return serializationObject;
  91189. };
  91190. // Statics
  91191. /**
  91192. * Extracts the vertexData from a mesh
  91193. * @param mesh the mesh from which to extract the VertexData
  91194. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  91195. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  91196. * @returns the object VertexData associated to the passed mesh
  91197. */
  91198. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  91199. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  91200. };
  91201. /**
  91202. * Extracts the vertexData from the geometry
  91203. * @param geometry the geometry from which to extract the VertexData
  91204. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  91205. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  91206. * @returns the object VertexData associated to the passed mesh
  91207. */
  91208. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  91209. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  91210. };
  91211. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  91212. var result = new VertexData();
  91213. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  91214. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  91215. }
  91216. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  91217. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  91218. }
  91219. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  91220. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  91221. }
  91222. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  91223. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  91224. }
  91225. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  91226. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  91227. }
  91228. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  91229. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  91230. }
  91231. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  91232. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  91233. }
  91234. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  91235. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  91236. }
  91237. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  91238. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  91239. }
  91240. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  91241. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  91242. }
  91243. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  91244. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  91245. }
  91246. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  91247. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  91248. }
  91249. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  91250. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  91251. }
  91252. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  91253. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  91254. }
  91255. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  91256. return result;
  91257. };
  91258. /**
  91259. * Creates the VertexData for a Ribbon
  91260. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  91261. * * pathArray array of paths, each of which an array of successive Vector3
  91262. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  91263. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  91264. * * 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
  91265. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91266. * * 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)
  91267. * * 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)
  91268. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  91269. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  91270. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  91271. * @returns the VertexData of the ribbon
  91272. */
  91273. VertexData.CreateRibbon = function (options) {
  91274. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ribbonBuilder");
  91275. };
  91276. /**
  91277. * Creates the VertexData for a box
  91278. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91279. * * size sets the width, height and depth of the box to the value of size, optional default 1
  91280. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  91281. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  91282. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  91283. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  91284. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  91285. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91286. * * 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)
  91287. * * 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)
  91288. * @returns the VertexData of the box
  91289. */
  91290. VertexData.CreateBox = function (options) {
  91291. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("boxBuilder");
  91292. };
  91293. /**
  91294. * Creates the VertexData for an ellipsoid, defaults to a sphere
  91295. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91296. * * segments sets the number of horizontal strips optional, default 32
  91297. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  91298. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  91299. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  91300. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  91301. * * 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
  91302. * * 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
  91303. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91304. * * 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)
  91305. * * 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)
  91306. * @returns the VertexData of the ellipsoid
  91307. */
  91308. VertexData.CreateSphere = function (options) {
  91309. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("sphereBuilder");
  91310. };
  91311. /**
  91312. * Creates the VertexData for a cylinder, cone or prism
  91313. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91314. * * height sets the height (y direction) of the cylinder, optional, default 2
  91315. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  91316. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  91317. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  91318. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  91319. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  91320. * * 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
  91321. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91322. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91323. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  91324. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  91325. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91326. * * 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)
  91327. * * 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)
  91328. * @returns the VertexData of the cylinder, cone or prism
  91329. */
  91330. VertexData.CreateCylinder = function (options) {
  91331. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("cylinderBuilder");
  91332. };
  91333. /**
  91334. * Creates the VertexData for a torus
  91335. * @param options an object used to set the following optional parameters for the box, required but can be empty
  91336. * * diameter the diameter of the torus, optional default 1
  91337. * * thickness the diameter of the tube forming the torus, optional default 0.5
  91338. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  91339. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91340. * * 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)
  91341. * * 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)
  91342. * @returns the VertexData of the torus
  91343. */
  91344. VertexData.CreateTorus = function (options) {
  91345. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusBuilder");
  91346. };
  91347. /**
  91348. * Creates the VertexData of the LineSystem
  91349. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  91350. * - lines an array of lines, each line being an array of successive Vector3
  91351. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  91352. * @returns the VertexData of the LineSystem
  91353. */
  91354. VertexData.CreateLineSystem = function (options) {
  91355. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  91356. };
  91357. /**
  91358. * Create the VertexData for a DashedLines
  91359. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  91360. * - points an array successive Vector3
  91361. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  91362. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  91363. * - dashNb the intended total number of dashes, optional, default 200
  91364. * @returns the VertexData for the DashedLines
  91365. */
  91366. VertexData.CreateDashedLines = function (options) {
  91367. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  91368. };
  91369. /**
  91370. * Creates the VertexData for a Ground
  91371. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  91372. * - width the width (x direction) of the ground, optional, default 1
  91373. * - height the height (z direction) of the ground, optional, default 1
  91374. * - subdivisions the number of subdivisions per side, optional, default 1
  91375. * @returns the VertexData of the Ground
  91376. */
  91377. VertexData.CreateGround = function (options) {
  91378. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  91379. };
  91380. /**
  91381. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  91382. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  91383. * * xmin the ground minimum X coordinate, optional, default -1
  91384. * * zmin the ground minimum Z coordinate, optional, default -1
  91385. * * xmax the ground maximum X coordinate, optional, default 1
  91386. * * zmax the ground maximum Z coordinate, optional, default 1
  91387. * * 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}
  91388. * * 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}
  91389. * @returns the VertexData of the TiledGround
  91390. */
  91391. VertexData.CreateTiledGround = function (options) {
  91392. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  91393. };
  91394. /**
  91395. * Creates the VertexData of the Ground designed from a heightmap
  91396. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  91397. * * width the width (x direction) of the ground
  91398. * * height the height (z direction) of the ground
  91399. * * subdivisions the number of subdivisions per side
  91400. * * minHeight the minimum altitude on the ground, optional, default 0
  91401. * * maxHeight the maximum altitude on the ground, optional default 1
  91402. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  91403. * * buffer the array holding the image color data
  91404. * * bufferWidth the width of image
  91405. * * bufferHeight the height of image
  91406. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  91407. * @returns the VertexData of the Ground designed from a heightmap
  91408. */
  91409. VertexData.CreateGroundFromHeightMap = function (options) {
  91410. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  91411. };
  91412. /**
  91413. * Creates the VertexData for a Plane
  91414. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  91415. * * size sets the width and height of the plane to the value of size, optional default 1
  91416. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  91417. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  91418. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91419. * * 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)
  91420. * * 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)
  91421. * @returns the VertexData of the box
  91422. */
  91423. VertexData.CreatePlane = function (options) {
  91424. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("planeBuilder");
  91425. };
  91426. /**
  91427. * Creates the VertexData of the Disc or regular Polygon
  91428. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  91429. * * radius the radius of the disc, optional default 0.5
  91430. * * tessellation the number of polygon sides, optional, default 64
  91431. * * 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
  91432. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91433. * * 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)
  91434. * * 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)
  91435. * @returns the VertexData of the box
  91436. */
  91437. VertexData.CreateDisc = function (options) {
  91438. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("discBuilder");
  91439. };
  91440. /**
  91441. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  91442. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  91443. * @param polygon a mesh built from polygonTriangulation.build()
  91444. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91445. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91446. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91447. * @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)
  91448. * @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)
  91449. * @returns the VertexData of the Polygon
  91450. */
  91451. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  91452. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polygonBuilder");
  91453. };
  91454. /**
  91455. * Creates the VertexData of the IcoSphere
  91456. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  91457. * * radius the radius of the IcoSphere, optional default 1
  91458. * * radiusX allows stretching in the x direction, optional, default radius
  91459. * * radiusY allows stretching in the y direction, optional, default radius
  91460. * * radiusZ allows stretching in the z direction, optional, default radius
  91461. * * flat when true creates a flat shaded mesh, optional, default true
  91462. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91463. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91464. * * 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)
  91465. * * 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)
  91466. * @returns the VertexData of the IcoSphere
  91467. */
  91468. VertexData.CreateIcoSphere = function (options) {
  91469. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("icoSphereBuilder");
  91470. };
  91471. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  91472. /**
  91473. * Creates the VertexData for a Polyhedron
  91474. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  91475. * * type provided types are:
  91476. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  91477. * * 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)
  91478. * * size the size of the IcoSphere, optional default 1
  91479. * * sizeX allows stretching in the x direction, optional, default size
  91480. * * sizeY allows stretching in the y direction, optional, default size
  91481. * * sizeZ allows stretching in the z direction, optional, default size
  91482. * * 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
  91483. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  91484. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  91485. * * flat when true creates a flat shaded mesh, optional, default true
  91486. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  91487. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91488. * * 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)
  91489. * * 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)
  91490. * @returns the VertexData of the Polyhedron
  91491. */
  91492. VertexData.CreatePolyhedron = function (options) {
  91493. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polyhedronBuilder");
  91494. };
  91495. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  91496. /**
  91497. * Creates the VertexData for a TorusKnot
  91498. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  91499. * * radius the radius of the torus knot, optional, default 2
  91500. * * tube the thickness of the tube, optional, default 0.5
  91501. * * radialSegments the number of sides on each tube segments, optional, default 32
  91502. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  91503. * * p the number of windings around the z axis, optional, default 2
  91504. * * q the number of windings around the x axis, optional, default 3
  91505. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91506. * * 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)
  91507. * * 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)
  91508. * @returns the VertexData of the Torus Knot
  91509. */
  91510. VertexData.CreateTorusKnot = function (options) {
  91511. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusKnotBuilder");
  91512. };
  91513. // Tools
  91514. /**
  91515. * Compute normals for given positions and indices
  91516. * @param positions an array of vertex positions, [...., x, y, z, ......]
  91517. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  91518. * @param normals an array of vertex normals, [...., x, y, z, ......]
  91519. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  91520. * * facetNormals : optional array of facet normals (vector3)
  91521. * * facetPositions : optional array of facet positions (vector3)
  91522. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  91523. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  91524. * * bInfo : optional bounding info, required for facetPartitioning computation
  91525. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  91526. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  91527. * * useRightHandedSystem: optional boolean to for right handed system computation
  91528. * * depthSort : optional boolean to enable the facet depth sort computation
  91529. * * distanceTo : optional Vector3 to compute the facet depth from this location
  91530. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  91531. */
  91532. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  91533. // temporary scalar variables
  91534. var index = 0; // facet index
  91535. var p1p2x = 0.0; // p1p2 vector x coordinate
  91536. var p1p2y = 0.0; // p1p2 vector y coordinate
  91537. var p1p2z = 0.0; // p1p2 vector z coordinate
  91538. var p3p2x = 0.0; // p3p2 vector x coordinate
  91539. var p3p2y = 0.0; // p3p2 vector y coordinate
  91540. var p3p2z = 0.0; // p3p2 vector z coordinate
  91541. var faceNormalx = 0.0; // facet normal x coordinate
  91542. var faceNormaly = 0.0; // facet normal y coordinate
  91543. var faceNormalz = 0.0; // facet normal z coordinate
  91544. var length = 0.0; // facet normal length before normalization
  91545. var v1x = 0; // vector1 x index in the positions array
  91546. var v1y = 0; // vector1 y index in the positions array
  91547. var v1z = 0; // vector1 z index in the positions array
  91548. var v2x = 0; // vector2 x index in the positions array
  91549. var v2y = 0; // vector2 y index in the positions array
  91550. var v2z = 0; // vector2 z index in the positions array
  91551. var v3x = 0; // vector3 x index in the positions array
  91552. var v3y = 0; // vector3 y index in the positions array
  91553. var v3z = 0; // vector3 z index in the positions array
  91554. var computeFacetNormals = false;
  91555. var computeFacetPositions = false;
  91556. var computeFacetPartitioning = false;
  91557. var computeDepthSort = false;
  91558. var faceNormalSign = 1;
  91559. var ratio = 0;
  91560. var distanceTo = null;
  91561. if (options) {
  91562. computeFacetNormals = (options.facetNormals) ? true : false;
  91563. computeFacetPositions = (options.facetPositions) ? true : false;
  91564. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  91565. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  91566. ratio = options.ratio || 0;
  91567. computeDepthSort = (options.depthSort) ? true : false;
  91568. distanceTo = (options.distanceTo);
  91569. if (computeDepthSort) {
  91570. if (distanceTo === undefined) {
  91571. distanceTo = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  91572. }
  91573. var depthSortedFacets = options.depthSortedFacets;
  91574. }
  91575. }
  91576. // facetPartitioning reinit if needed
  91577. var xSubRatio = 0;
  91578. var ySubRatio = 0;
  91579. var zSubRatio = 0;
  91580. var subSq = 0;
  91581. if (computeFacetPartitioning && options && options.bbSize) {
  91582. var ox = 0; // X partitioning index for facet position
  91583. var oy = 0; // Y partinioning index for facet position
  91584. var oz = 0; // Z partinioning index for facet position
  91585. var b1x = 0; // X partitioning index for facet v1 vertex
  91586. var b1y = 0; // Y partitioning index for facet v1 vertex
  91587. var b1z = 0; // z partitioning index for facet v1 vertex
  91588. var b2x = 0; // X partitioning index for facet v2 vertex
  91589. var b2y = 0; // Y partitioning index for facet v2 vertex
  91590. var b2z = 0; // Z partitioning index for facet v2 vertex
  91591. var b3x = 0; // X partitioning index for facet v3 vertex
  91592. var b3y = 0; // Y partitioning index for facet v3 vertex
  91593. var b3z = 0; // Z partitioning index for facet v3 vertex
  91594. var block_idx_o = 0; // facet barycenter block index
  91595. var block_idx_v1 = 0; // v1 vertex block index
  91596. var block_idx_v2 = 0; // v2 vertex block index
  91597. var block_idx_v3 = 0; // v3 vertex block index
  91598. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  91599. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  91600. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  91601. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  91602. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  91603. subSq = options.subDiv.max * options.subDiv.max;
  91604. options.facetPartitioning.length = 0;
  91605. }
  91606. // reset the normals
  91607. for (index = 0; index < positions.length; index++) {
  91608. normals[index] = 0.0;
  91609. }
  91610. // Loop : 1 indice triplet = 1 facet
  91611. var nbFaces = (indices.length / 3) | 0;
  91612. for (index = 0; index < nbFaces; index++) {
  91613. // get the indexes of the coordinates of each vertex of the facet
  91614. v1x = indices[index * 3] * 3;
  91615. v1y = v1x + 1;
  91616. v1z = v1x + 2;
  91617. v2x = indices[index * 3 + 1] * 3;
  91618. v2y = v2x + 1;
  91619. v2z = v2x + 2;
  91620. v3x = indices[index * 3 + 2] * 3;
  91621. v3y = v3x + 1;
  91622. v3z = v3x + 2;
  91623. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  91624. p1p2y = positions[v1y] - positions[v2y];
  91625. p1p2z = positions[v1z] - positions[v2z];
  91626. p3p2x = positions[v3x] - positions[v2x];
  91627. p3p2y = positions[v3y] - positions[v2y];
  91628. p3p2z = positions[v3z] - positions[v2z];
  91629. // compute the face normal with the cross product
  91630. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  91631. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  91632. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  91633. // normalize this normal and store it in the array facetData
  91634. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  91635. length = (length === 0) ? 1.0 : length;
  91636. faceNormalx /= length;
  91637. faceNormaly /= length;
  91638. faceNormalz /= length;
  91639. if (computeFacetNormals && options) {
  91640. options.facetNormals[index].x = faceNormalx;
  91641. options.facetNormals[index].y = faceNormaly;
  91642. options.facetNormals[index].z = faceNormalz;
  91643. }
  91644. if (computeFacetPositions && options) {
  91645. // compute and the facet barycenter coordinates in the array facetPositions
  91646. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  91647. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  91648. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  91649. }
  91650. if (computeFacetPartitioning && options) {
  91651. // store the facet indexes in arrays in the main facetPartitioning array :
  91652. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  91653. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  91654. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  91655. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  91656. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  91657. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  91658. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  91659. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  91660. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  91661. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  91662. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  91663. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  91664. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  91665. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  91666. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  91667. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  91668. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  91669. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  91670. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  91671. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  91672. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  91673. // push each facet index in each block containing the vertex
  91674. options.facetPartitioning[block_idx_v1].push(index);
  91675. if (block_idx_v2 != block_idx_v1) {
  91676. options.facetPartitioning[block_idx_v2].push(index);
  91677. }
  91678. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  91679. options.facetPartitioning[block_idx_v3].push(index);
  91680. }
  91681. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  91682. options.facetPartitioning[block_idx_o].push(index);
  91683. }
  91684. }
  91685. if (computeDepthSort && options && options.facetPositions) {
  91686. var dsf = depthSortedFacets[index];
  91687. dsf.ind = index * 3;
  91688. dsf.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  91689. }
  91690. // compute the normals anyway
  91691. normals[v1x] += faceNormalx; // accumulate all the normals per face
  91692. normals[v1y] += faceNormaly;
  91693. normals[v1z] += faceNormalz;
  91694. normals[v2x] += faceNormalx;
  91695. normals[v2y] += faceNormaly;
  91696. normals[v2z] += faceNormalz;
  91697. normals[v3x] += faceNormalx;
  91698. normals[v3y] += faceNormaly;
  91699. normals[v3z] += faceNormalz;
  91700. }
  91701. // last normalization of each normal
  91702. for (index = 0; index < normals.length / 3; index++) {
  91703. faceNormalx = normals[index * 3];
  91704. faceNormaly = normals[index * 3 + 1];
  91705. faceNormalz = normals[index * 3 + 2];
  91706. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  91707. length = (length === 0) ? 1.0 : length;
  91708. faceNormalx /= length;
  91709. faceNormaly /= length;
  91710. faceNormalz /= length;
  91711. normals[index * 3] = faceNormalx;
  91712. normals[index * 3 + 1] = faceNormaly;
  91713. normals[index * 3 + 2] = faceNormalz;
  91714. }
  91715. };
  91716. /** @hidden */
  91717. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  91718. var li = indices.length;
  91719. var ln = normals.length;
  91720. var i;
  91721. var n;
  91722. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  91723. switch (sideOrientation) {
  91724. case VertexData.FRONTSIDE:
  91725. // nothing changed
  91726. break;
  91727. case VertexData.BACKSIDE:
  91728. var tmp;
  91729. // indices
  91730. for (i = 0; i < li; i += 3) {
  91731. tmp = indices[i];
  91732. indices[i] = indices[i + 2];
  91733. indices[i + 2] = tmp;
  91734. }
  91735. // normals
  91736. for (n = 0; n < ln; n++) {
  91737. normals[n] = -normals[n];
  91738. }
  91739. break;
  91740. case VertexData.DOUBLESIDE:
  91741. // positions
  91742. var lp = positions.length;
  91743. var l = lp / 3;
  91744. for (var p = 0; p < lp; p++) {
  91745. positions[lp + p] = positions[p];
  91746. }
  91747. // indices
  91748. for (i = 0; i < li; i += 3) {
  91749. indices[i + li] = indices[i + 2] + l;
  91750. indices[i + 1 + li] = indices[i + 1] + l;
  91751. indices[i + 2 + li] = indices[i] + l;
  91752. }
  91753. // normals
  91754. for (n = 0; n < ln; n++) {
  91755. normals[ln + n] = -normals[n];
  91756. }
  91757. // uvs
  91758. var lu = uvs.length;
  91759. var u = 0;
  91760. for (u = 0; u < lu; u++) {
  91761. uvs[u + lu] = uvs[u];
  91762. }
  91763. frontUVs = frontUVs ? frontUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  91764. backUVs = backUVs ? backUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  91765. u = 0;
  91766. for (i = 0; i < lu / 2; i++) {
  91767. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  91768. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  91769. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  91770. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  91771. u += 2;
  91772. }
  91773. break;
  91774. }
  91775. };
  91776. /**
  91777. * Applies VertexData created from the imported parameters to the geometry
  91778. * @param parsedVertexData the parsed data from an imported file
  91779. * @param geometry the geometry to apply the VertexData to
  91780. */
  91781. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  91782. var vertexData = new VertexData();
  91783. // positions
  91784. var positions = parsedVertexData.positions;
  91785. if (positions) {
  91786. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  91787. }
  91788. // normals
  91789. var normals = parsedVertexData.normals;
  91790. if (normals) {
  91791. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  91792. }
  91793. // tangents
  91794. var tangents = parsedVertexData.tangents;
  91795. if (tangents) {
  91796. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  91797. }
  91798. // uvs
  91799. var uvs = parsedVertexData.uvs;
  91800. if (uvs) {
  91801. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  91802. }
  91803. // uv2s
  91804. var uv2s = parsedVertexData.uv2s;
  91805. if (uv2s) {
  91806. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  91807. }
  91808. // uv3s
  91809. var uv3s = parsedVertexData.uv3s;
  91810. if (uv3s) {
  91811. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  91812. }
  91813. // uv4s
  91814. var uv4s = parsedVertexData.uv4s;
  91815. if (uv4s) {
  91816. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  91817. }
  91818. // uv5s
  91819. var uv5s = parsedVertexData.uv5s;
  91820. if (uv5s) {
  91821. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  91822. }
  91823. // uv6s
  91824. var uv6s = parsedVertexData.uv6s;
  91825. if (uv6s) {
  91826. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  91827. }
  91828. // colors
  91829. var colors = parsedVertexData.colors;
  91830. if (colors) {
  91831. vertexData.set(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  91832. }
  91833. // matricesIndices
  91834. var matricesIndices = parsedVertexData.matricesIndices;
  91835. if (matricesIndices) {
  91836. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  91837. }
  91838. // matricesWeights
  91839. var matricesWeights = parsedVertexData.matricesWeights;
  91840. if (matricesWeights) {
  91841. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  91842. }
  91843. // indices
  91844. var indices = parsedVertexData.indices;
  91845. if (indices) {
  91846. vertexData.indices = indices;
  91847. }
  91848. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  91849. };
  91850. /**
  91851. * Mesh side orientation : usually the external or front surface
  91852. */
  91853. VertexData.FRONTSIDE = 0;
  91854. /**
  91855. * Mesh side orientation : usually the internal or back surface
  91856. */
  91857. VertexData.BACKSIDE = 1;
  91858. /**
  91859. * Mesh side orientation : both internal and external or front and back surfaces
  91860. */
  91861. VertexData.DOUBLESIDE = 2;
  91862. /**
  91863. * Mesh side orientation : by default, `FRONTSIDE`
  91864. */
  91865. VertexData.DEFAULTSIDE = 0;
  91866. return VertexData;
  91867. }());
  91868. /***/ }),
  91869. /***/ "./Meshes/meshBuilder.ts":
  91870. /*!*******************************!*\
  91871. !*** ./Meshes/meshBuilder.ts ***!
  91872. \*******************************/
  91873. /*! exports provided: MeshBuilder */
  91874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91875. "use strict";
  91876. __webpack_require__.r(__webpack_exports__);
  91877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  91878. /* harmony import */ var _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Builders/ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  91879. /* harmony import */ var _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  91880. /* harmony import */ var _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  91881. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  91882. /* harmony import */ var _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  91883. /* harmony import */ var _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  91884. /* harmony import */ var _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Builders/torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  91885. /* harmony import */ var _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  91886. /* harmony import */ var _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Builders/polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  91887. /* harmony import */ var _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  91888. /* harmony import */ var _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Builders/latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  91889. /* harmony import */ var _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  91890. /* harmony import */ var _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  91891. /* harmony import */ var _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Builders/tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  91892. /* harmony import */ var _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  91893. /* harmony import */ var _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Builders/icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  91894. /* harmony import */ var _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  91895. /**
  91896. * Class containing static functions to help procedurally build meshes
  91897. */
  91898. var MeshBuilder = /** @class */ (function () {
  91899. function MeshBuilder() {
  91900. }
  91901. /**
  91902. * Creates a box mesh
  91903. * * The parameter `size` sets the size (float) of each box side (default 1)
  91904. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  91905. * * 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)
  91906. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  91907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91908. * * 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
  91909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91910. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  91911. * @param name defines the name of the mesh
  91912. * @param options defines the options used to create the mesh
  91913. * @param scene defines the hosting scene
  91914. * @returns the box mesh
  91915. */
  91916. MeshBuilder.CreateBox = function (name, options, scene) {
  91917. if (scene === void 0) { scene = null; }
  91918. return _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(name, options, scene);
  91919. };
  91920. /**
  91921. * Creates a sphere mesh
  91922. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  91923. * * 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`)
  91924. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  91925. * * 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
  91926. * * 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)
  91927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91928. * * 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
  91929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91930. * @param name defines the name of the mesh
  91931. * @param options defines the options used to create the mesh
  91932. * @param scene defines the hosting scene
  91933. * @returns the sphere mesh
  91934. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  91935. */
  91936. MeshBuilder.CreateSphere = function (name, options, scene) {
  91937. if (scene === void 0) { scene = null; }
  91938. return _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere(name, options, scene);
  91939. };
  91940. /**
  91941. * Creates a plane polygonal mesh. By default, this is a disc
  91942. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  91943. * * 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
  91944. * * 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
  91945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91946. * * 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
  91947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91948. * @param name defines the name of the mesh
  91949. * @param options defines the options used to create the mesh
  91950. * @param scene defines the hosting scene
  91951. * @returns the plane polygonal mesh
  91952. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  91953. */
  91954. MeshBuilder.CreateDisc = function (name, options, scene) {
  91955. if (scene === void 0) { scene = null; }
  91956. return _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"].CreateDisc(name, options, scene);
  91957. };
  91958. /**
  91959. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91960. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91961. * * 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`)
  91962. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91963. * * 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
  91964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91965. * * 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
  91966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91967. * @param name defines the name of the mesh
  91968. * @param options defines the options used to create the mesh
  91969. * @param scene defines the hosting scene
  91970. * @returns the icosahedron mesh
  91971. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91972. */
  91973. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  91974. if (scene === void 0) { scene = null; }
  91975. return _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"].CreateIcoSphere(name, options, scene);
  91976. };
  91977. /**
  91978. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  91979. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  91980. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  91981. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  91982. * * 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
  91983. * * 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
  91984. * * 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
  91985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91986. * * 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
  91987. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  91988. * * 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
  91989. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  91990. * * 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
  91991. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  91992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91993. * @param name defines the name of the mesh
  91994. * @param options defines the options used to create the mesh
  91995. * @param scene defines the hosting scene
  91996. * @returns the ribbon mesh
  91997. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  91998. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  91999. */
  92000. MeshBuilder.CreateRibbon = function (name, options, scene) {
  92001. if (scene === void 0) { scene = null; }
  92002. return _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"].CreateRibbon(name, options, scene);
  92003. };
  92004. /**
  92005. * Creates a cylinder or a cone mesh
  92006. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  92007. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  92008. * * 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.
  92009. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  92010. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  92011. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  92012. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  92013. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  92014. * * 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).
  92015. * * 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
  92016. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  92017. * * 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
  92018. * * 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.
  92019. * * If `enclose` is false, a ring surface is one element.
  92020. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  92021. * * 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
  92022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92023. * * 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
  92024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92025. * @param name defines the name of the mesh
  92026. * @param options defines the options used to create the mesh
  92027. * @param scene defines the hosting scene
  92028. * @returns the cylinder mesh
  92029. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  92030. */
  92031. MeshBuilder.CreateCylinder = function (name, options, scene) {
  92032. if (scene === void 0) { scene = null; }
  92033. return _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder(name, options, scene);
  92034. };
  92035. /**
  92036. * Creates a torus mesh
  92037. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  92038. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  92039. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  92040. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92041. * * 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
  92042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92043. * @param name defines the name of the mesh
  92044. * @param options defines the options used to create the mesh
  92045. * @param scene defines the hosting scene
  92046. * @returns the torus mesh
  92047. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  92048. */
  92049. MeshBuilder.CreateTorus = function (name, options, scene) {
  92050. if (scene === void 0) { scene = null; }
  92051. return _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"].CreateTorus(name, options, scene);
  92052. };
  92053. /**
  92054. * Creates a torus knot mesh
  92055. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  92056. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  92057. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  92058. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  92059. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92060. * * 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
  92061. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92062. * @param name defines the name of the mesh
  92063. * @param options defines the options used to create the mesh
  92064. * @param scene defines the hosting scene
  92065. * @returns the torus knot mesh
  92066. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  92067. */
  92068. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  92069. if (scene === void 0) { scene = null; }
  92070. return _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"].CreateTorusKnot(name, options, scene);
  92071. };
  92072. /**
  92073. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  92074. * * 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
  92075. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  92076. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  92077. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  92078. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  92079. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  92080. * * 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
  92081. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  92082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92083. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  92084. * @param name defines the name of the new line system
  92085. * @param options defines the options used to create the line system
  92086. * @param scene defines the hosting scene
  92087. * @returns a new line system mesh
  92088. */
  92089. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  92090. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLineSystem(name, options, scene);
  92091. };
  92092. /**
  92093. * Creates a line mesh
  92094. * 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
  92095. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  92096. * * The parameter `points` is an array successive Vector3
  92097. * * 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
  92098. * * The optional parameter `colors` is an array of successive Color4, one per line point
  92099. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  92100. * * When updating an instance, remember that only point positions can change, not the number of points
  92101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92102. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  92103. * @param name defines the name of the new line system
  92104. * @param options defines the options used to create the line system
  92105. * @param scene defines the hosting scene
  92106. * @returns a new line mesh
  92107. */
  92108. MeshBuilder.CreateLines = function (name, options, scene) {
  92109. if (scene === void 0) { scene = null; }
  92110. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines(name, options, scene);
  92111. };
  92112. /**
  92113. * Creates a dashed line mesh
  92114. * * 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
  92115. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  92116. * * The parameter `points` is an array successive Vector3
  92117. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  92118. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  92119. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  92120. * * 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
  92121. * * When updating an instance, remember that only point positions can change, not the number of points
  92122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92123. * @param name defines the name of the mesh
  92124. * @param options defines the options used to create the mesh
  92125. * @param scene defines the hosting scene
  92126. * @returns the dashed line mesh
  92127. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  92128. */
  92129. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  92130. if (scene === void 0) { scene = null; }
  92131. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateDashedLines(name, options, scene);
  92132. };
  92133. /**
  92134. * 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.
  92135. * * 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.
  92136. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  92137. * * 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.
  92138. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  92139. * * 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
  92140. * * 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
  92141. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  92142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92143. * * 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
  92144. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  92145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92146. * @param name defines the name of the mesh
  92147. * @param options defines the options used to create the mesh
  92148. * @param scene defines the hosting scene
  92149. * @returns the extruded shape mesh
  92150. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  92151. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92152. */
  92153. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  92154. if (scene === void 0) { scene = null; }
  92155. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShape(name, options, scene);
  92156. };
  92157. /**
  92158. * Creates an custom extruded shape mesh.
  92159. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  92160. * * 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.
  92161. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  92162. * * 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
  92163. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  92164. * * 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
  92165. * * It must returns a float value that will be the scale value applied to the shape on each path point
  92166. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  92167. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  92168. * * 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
  92169. * * 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
  92170. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  92171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92172. * * 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
  92173. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  92174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92175. * @param name defines the name of the mesh
  92176. * @param options defines the options used to create the mesh
  92177. * @param scene defines the hosting scene
  92178. * @returns the custom extruded shape mesh
  92179. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  92180. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  92181. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  92182. */
  92183. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  92184. if (scene === void 0) { scene = null; }
  92185. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShapeCustom(name, options, scene);
  92186. };
  92187. /**
  92188. * Creates lathe mesh.
  92189. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  92190. * * 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
  92191. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  92192. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  92193. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  92194. * * 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
  92195. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  92196. * * 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
  92197. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92198. * * 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
  92199. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  92200. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92201. * @param name defines the name of the mesh
  92202. * @param options defines the options used to create the mesh
  92203. * @param scene defines the hosting scene
  92204. * @returns the lathe mesh
  92205. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  92206. */
  92207. MeshBuilder.CreateLathe = function (name, options, scene) {
  92208. if (scene === void 0) { scene = null; }
  92209. return _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"].CreateLathe(name, options, scene);
  92210. };
  92211. /**
  92212. * Creates a plane mesh
  92213. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  92214. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  92215. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  92216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92217. * * 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
  92218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92219. * @param name defines the name of the mesh
  92220. * @param options defines the options used to create the mesh
  92221. * @param scene defines the hosting scene
  92222. * @returns the plane mesh
  92223. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  92224. */
  92225. MeshBuilder.CreatePlane = function (name, options, scene) {
  92226. if (scene === void 0) { scene = null; }
  92227. return _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"].CreatePlane(name, options, scene);
  92228. };
  92229. /**
  92230. * Creates a ground mesh
  92231. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  92232. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  92233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92234. * @param name defines the name of the mesh
  92235. * @param options defines the options used to create the mesh
  92236. * @param scene defines the hosting scene
  92237. * @returns the ground mesh
  92238. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  92239. */
  92240. MeshBuilder.CreateGround = function (name, options, scene) {
  92241. if (scene === void 0) { scene = null; }
  92242. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGround(name, options, scene);
  92243. };
  92244. /**
  92245. * Creates a tiled ground mesh
  92246. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  92247. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  92248. * * 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
  92249. * * 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
  92250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92251. * @param name defines the name of the mesh
  92252. * @param options defines the options used to create the mesh
  92253. * @param scene defines the hosting scene
  92254. * @returns the tiled ground mesh
  92255. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  92256. */
  92257. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  92258. if (scene === void 0) { scene = null; }
  92259. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateTiledGround(name, options, scene);
  92260. };
  92261. /**
  92262. * Creates a ground mesh from a height map
  92263. * * The parameter `url` sets the URL of the height map image resource.
  92264. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  92265. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  92266. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  92267. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  92268. * * 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.
  92269. * * 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).
  92270. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  92271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  92272. * @param name defines the name of the mesh
  92273. * @param url defines the url to the height map
  92274. * @param options defines the options used to create the mesh
  92275. * @param scene defines the hosting scene
  92276. * @returns the ground mesh
  92277. * @see https://doc.babylonjs.com/babylon101/height_map
  92278. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  92279. */
  92280. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  92281. if (scene === void 0) { scene = null; }
  92282. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGroundFromHeightMap(name, url, options, scene);
  92283. };
  92284. /**
  92285. * Creates a polygon mesh
  92286. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  92287. * * 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
  92288. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  92289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92290. * * 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)
  92291. * * Remember you can only change the shape positions, not their number when updating a polygon
  92292. * @param name defines the name of the mesh
  92293. * @param options defines the options used to create the mesh
  92294. * @param scene defines the hosting scene
  92295. * @param earcutInjection can be used to inject your own earcut reference
  92296. * @returns the polygon mesh
  92297. */
  92298. MeshBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  92299. if (scene === void 0) { scene = null; }
  92300. if (earcutInjection === void 0) { earcutInjection = earcut; }
  92301. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].CreatePolygon(name, options, scene, earcutInjection);
  92302. };
  92303. /**
  92304. * Creates an extruded polygon mesh, with depth in the Y direction.
  92305. * * 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)
  92306. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  92307. * @param name defines the name of the mesh
  92308. * @param options defines the options used to create the mesh
  92309. * @param scene defines the hosting scene
  92310. * @param earcutInjection can be used to inject your own earcut reference
  92311. * @returns the polygon mesh
  92312. */
  92313. MeshBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  92314. if (scene === void 0) { scene = null; }
  92315. if (earcutInjection === void 0) { earcutInjection = earcut; }
  92316. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].ExtrudePolygon(name, options, scene, earcutInjection);
  92317. };
  92318. /**
  92319. * Creates a tube mesh.
  92320. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  92321. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  92322. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  92323. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  92324. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  92325. * * 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)
  92326. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  92327. * * 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
  92328. * * 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
  92329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92330. * * 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
  92331. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  92332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92333. * @param name defines the name of the mesh
  92334. * @param options defines the options used to create the mesh
  92335. * @param scene defines the hosting scene
  92336. * @returns the tube mesh
  92337. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  92338. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  92339. */
  92340. MeshBuilder.CreateTube = function (name, options, scene) {
  92341. if (scene === void 0) { scene = null; }
  92342. return _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"].CreateTube(name, options, scene);
  92343. };
  92344. /**
  92345. * Creates a polyhedron mesh
  92346. * * 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
  92347. * * The parameter `size` (positive float, default 1) sets the polygon size
  92348. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  92349. * * 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`
  92350. * * 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
  92351. * * 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)`)
  92352. * * 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
  92353. * * 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
  92354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92355. * * 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
  92356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92357. * @param name defines the name of the mesh
  92358. * @param options defines the options used to create the mesh
  92359. * @param scene defines the hosting scene
  92360. * @returns the polyhedron mesh
  92361. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  92362. */
  92363. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  92364. if (scene === void 0) { scene = null; }
  92365. return _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"].CreatePolyhedron(name, options, scene);
  92366. };
  92367. /**
  92368. * Creates a decal mesh.
  92369. * 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
  92370. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  92371. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  92372. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  92373. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  92374. * @param name defines the name of the mesh
  92375. * @param sourceMesh defines the mesh where the decal must be applied
  92376. * @param options defines the options used to create the mesh
  92377. * @param scene defines the hosting scene
  92378. * @returns the decal mesh
  92379. * @see https://doc.babylonjs.com/how_to/decals
  92380. */
  92381. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  92382. return _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"].CreateDecal(name, sourceMesh, options);
  92383. };
  92384. return MeshBuilder;
  92385. }());
  92386. /***/ }),
  92387. /***/ "./Meshes/meshSimplification.ts":
  92388. /*!**************************************!*\
  92389. !*** ./Meshes/meshSimplification.ts ***!
  92390. \**************************************/
  92391. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  92392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92393. "use strict";
  92394. __webpack_require__.r(__webpack_exports__);
  92395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  92396. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  92397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  92398. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  92399. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  92400. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  92401. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  92402. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  92403. /**
  92404. * Class used to specify simplification options
  92405. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  92406. */
  92407. var SimplificationSettings = /** @class */ (function () {
  92408. /**
  92409. * Creates a SimplificationSettings
  92410. * @param quality expected quality
  92411. * @param distance distance when this optimized version should be used
  92412. * @param optimizeMesh already optimized mesh
  92413. */
  92414. function SimplificationSettings(
  92415. /** expected quality */
  92416. quality,
  92417. /** distance when this optimized version should be used */
  92418. distance,
  92419. /** already optimized mesh */
  92420. optimizeMesh) {
  92421. this.quality = quality;
  92422. this.distance = distance;
  92423. this.optimizeMesh = optimizeMesh;
  92424. }
  92425. return SimplificationSettings;
  92426. }());
  92427. /**
  92428. * Queue used to order the simplification tasks
  92429. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  92430. */
  92431. var SimplificationQueue = /** @class */ (function () {
  92432. /**
  92433. * Creates a new queue
  92434. */
  92435. function SimplificationQueue() {
  92436. this.running = false;
  92437. this._simplificationArray = [];
  92438. }
  92439. /**
  92440. * Adds a new simplification task
  92441. * @param task defines a task to add
  92442. */
  92443. SimplificationQueue.prototype.addTask = function (task) {
  92444. this._simplificationArray.push(task);
  92445. };
  92446. /**
  92447. * Execute next task
  92448. */
  92449. SimplificationQueue.prototype.executeNext = function () {
  92450. var task = this._simplificationArray.pop();
  92451. if (task) {
  92452. this.running = true;
  92453. this.runSimplification(task);
  92454. }
  92455. else {
  92456. this.running = false;
  92457. }
  92458. };
  92459. /**
  92460. * Execute a simplification task
  92461. * @param task defines the task to run
  92462. */
  92463. SimplificationQueue.prototype.runSimplification = function (task) {
  92464. var _this = this;
  92465. if (task.parallelProcessing) {
  92466. //parallel simplifier
  92467. task.settings.forEach(function (setting) {
  92468. var simplifier = _this.getSimplifier(task);
  92469. simplifier.simplify(setting, function (newMesh) {
  92470. task.mesh.addLODLevel(setting.distance, newMesh);
  92471. newMesh.isVisible = true;
  92472. //check if it is the last
  92473. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  92474. //all done, run the success callback.
  92475. task.successCallback();
  92476. }
  92477. _this.executeNext();
  92478. });
  92479. });
  92480. }
  92481. else {
  92482. //single simplifier.
  92483. var simplifier = this.getSimplifier(task);
  92484. var runDecimation = function (setting, callback) {
  92485. simplifier.simplify(setting, function (newMesh) {
  92486. task.mesh.addLODLevel(setting.distance, newMesh);
  92487. newMesh.isVisible = true;
  92488. //run the next quality level
  92489. callback();
  92490. });
  92491. };
  92492. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  92493. runDecimation(task.settings[loop.index], function () {
  92494. loop.executeNext();
  92495. });
  92496. }, function () {
  92497. //execution ended, run the success callback.
  92498. if (task.successCallback) {
  92499. task.successCallback();
  92500. }
  92501. _this.executeNext();
  92502. });
  92503. }
  92504. };
  92505. SimplificationQueue.prototype.getSimplifier = function (task) {
  92506. switch (task.simplificationType) {
  92507. case SimplificationType.QUADRATIC:
  92508. default:
  92509. return new QuadraticErrorSimplification(task.mesh);
  92510. }
  92511. };
  92512. return SimplificationQueue;
  92513. }());
  92514. /**
  92515. * The implemented types of simplification
  92516. * At the moment only Quadratic Error Decimation is implemented
  92517. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  92518. */
  92519. var SimplificationType;
  92520. (function (SimplificationType) {
  92521. /** Quadratic error decimation */
  92522. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  92523. })(SimplificationType || (SimplificationType = {}));
  92524. var DecimationTriangle = /** @class */ (function () {
  92525. function DecimationTriangle(vertices) {
  92526. this.vertices = vertices;
  92527. this.error = new Array(4);
  92528. this.deleted = false;
  92529. this.isDirty = false;
  92530. this.deletePending = false;
  92531. this.borderFactor = 0;
  92532. }
  92533. return DecimationTriangle;
  92534. }());
  92535. var DecimationVertex = /** @class */ (function () {
  92536. function DecimationVertex(position, id) {
  92537. this.position = position;
  92538. this.id = id;
  92539. this.isBorder = true;
  92540. this.q = new QuadraticMatrix();
  92541. this.triangleCount = 0;
  92542. this.triangleStart = 0;
  92543. this.originalOffsets = [];
  92544. }
  92545. DecimationVertex.prototype.updatePosition = function (newPosition) {
  92546. this.position.copyFrom(newPosition);
  92547. };
  92548. return DecimationVertex;
  92549. }());
  92550. var QuadraticMatrix = /** @class */ (function () {
  92551. function QuadraticMatrix(data) {
  92552. this.data = new Array(10);
  92553. for (var i = 0; i < 10; ++i) {
  92554. if (data && data[i]) {
  92555. this.data[i] = data[i];
  92556. }
  92557. else {
  92558. this.data[i] = 0;
  92559. }
  92560. }
  92561. }
  92562. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  92563. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  92564. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  92565. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  92566. return det;
  92567. };
  92568. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  92569. for (var i = 0; i < 10; ++i) {
  92570. this.data[i] += matrix.data[i];
  92571. }
  92572. };
  92573. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  92574. for (var i = 0; i < 10; ++i) {
  92575. this.data[i] += data[i];
  92576. }
  92577. };
  92578. QuadraticMatrix.prototype.add = function (matrix) {
  92579. var m = new QuadraticMatrix();
  92580. for (var i = 0; i < 10; ++i) {
  92581. m.data[i] = this.data[i] + matrix.data[i];
  92582. }
  92583. return m;
  92584. };
  92585. QuadraticMatrix.FromData = function (a, b, c, d) {
  92586. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  92587. };
  92588. //returning an array to avoid garbage collection
  92589. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  92590. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  92591. };
  92592. return QuadraticMatrix;
  92593. }());
  92594. var Reference = /** @class */ (function () {
  92595. function Reference(vertexId, triangleId) {
  92596. this.vertexId = vertexId;
  92597. this.triangleId = triangleId;
  92598. }
  92599. return Reference;
  92600. }());
  92601. /**
  92602. * An implementation of the Quadratic Error simplification algorithm.
  92603. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  92604. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  92605. * @author RaananW
  92606. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  92607. */
  92608. var QuadraticErrorSimplification = /** @class */ (function () {
  92609. function QuadraticErrorSimplification(_mesh) {
  92610. this._mesh = _mesh;
  92611. this.syncIterations = 5000;
  92612. this.aggressiveness = 7;
  92613. this.decimationIterations = 100;
  92614. this.boundingBoxEpsilon = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"];
  92615. }
  92616. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  92617. var _this = this;
  92618. this.initDecimatedMesh();
  92619. //iterating through the submeshes array, one after the other.
  92620. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  92621. _this.initWithMesh(loop.index, function () {
  92622. _this.runDecimation(settings, loop.index, function () {
  92623. loop.executeNext();
  92624. });
  92625. }, settings.optimizeMesh);
  92626. }, function () {
  92627. setTimeout(function () {
  92628. successCallback(_this._reconstructedMesh);
  92629. }, 0);
  92630. });
  92631. };
  92632. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  92633. var _this = this;
  92634. var targetCount = ~~(this.triangles.length * settings.quality);
  92635. var deletedTriangles = 0;
  92636. var triangleCount = this.triangles.length;
  92637. var iterationFunction = function (iteration, callback) {
  92638. setTimeout(function () {
  92639. if (iteration % 5 === 0) {
  92640. _this.updateMesh(iteration === 0);
  92641. }
  92642. for (var i = 0; i < _this.triangles.length; ++i) {
  92643. _this.triangles[i].isDirty = false;
  92644. }
  92645. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  92646. var trianglesIterator = function (i) {
  92647. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  92648. var t = _this.triangles[tIdx];
  92649. if (!t) {
  92650. return;
  92651. }
  92652. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  92653. return;
  92654. }
  92655. for (var j = 0; j < 3; ++j) {
  92656. if (t.error[j] < threshold) {
  92657. var deleted0 = [];
  92658. var deleted1 = [];
  92659. var v0 = t.vertices[j];
  92660. var v1 = t.vertices[(j + 1) % 3];
  92661. if (v0.isBorder || v1.isBorder) {
  92662. continue;
  92663. }
  92664. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  92665. // var n = Vector3.Zero();
  92666. // var uv = Vector2.Zero();
  92667. // var color = new Color4(0, 0, 0, 1);
  92668. _this.calculateError(v0, v1, p);
  92669. var delTr = new Array();
  92670. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  92671. continue;
  92672. }
  92673. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  92674. continue;
  92675. }
  92676. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  92677. continue;
  92678. }
  92679. var uniqueArray = new Array();
  92680. delTr.forEach(function (deletedT) {
  92681. if (uniqueArray.indexOf(deletedT) === -1) {
  92682. deletedT.deletePending = true;
  92683. uniqueArray.push(deletedT);
  92684. }
  92685. });
  92686. if (uniqueArray.length % 2 !== 0) {
  92687. continue;
  92688. }
  92689. v0.q = v1.q.add(v0.q);
  92690. v0.updatePosition(p);
  92691. var tStart = _this.references.length;
  92692. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  92693. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  92694. var tCount = _this.references.length - tStart;
  92695. if (tCount <= v0.triangleCount) {
  92696. if (tCount) {
  92697. for (var c = 0; c < tCount; c++) {
  92698. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  92699. }
  92700. }
  92701. }
  92702. else {
  92703. v0.triangleStart = tStart;
  92704. }
  92705. v0.triangleCount = tCount;
  92706. break;
  92707. }
  92708. }
  92709. };
  92710. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  92711. }, 0);
  92712. };
  92713. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  92714. if (triangleCount - deletedTriangles <= targetCount) {
  92715. loop.breakLoop();
  92716. }
  92717. else {
  92718. iterationFunction(loop.index, function () {
  92719. loop.executeNext();
  92720. });
  92721. }
  92722. }, function () {
  92723. setTimeout(function () {
  92724. //reconstruct this part of the mesh
  92725. _this.reconstructMesh(submeshIndex);
  92726. successCallback();
  92727. }, 0);
  92728. });
  92729. };
  92730. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  92731. var _this = this;
  92732. this.vertices = [];
  92733. this.triangles = [];
  92734. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  92735. var indices = this._mesh.getIndices();
  92736. var submesh = this._mesh.subMeshes[submeshIndex];
  92737. var findInVertices = function (positionToSearch) {
  92738. if (optimizeMesh) {
  92739. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  92740. if (_this.vertices[ii].position.equals(positionToSearch)) {
  92741. return _this.vertices[ii];
  92742. }
  92743. }
  92744. }
  92745. return null;
  92746. };
  92747. var vertexReferences = [];
  92748. var vertexInit = function (i) {
  92749. if (!positionData) {
  92750. return;
  92751. }
  92752. var offset = i + submesh.verticesStart;
  92753. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  92754. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  92755. vertex.originalOffsets.push(offset);
  92756. if (vertex.id === _this.vertices.length) {
  92757. _this.vertices.push(vertex);
  92758. }
  92759. vertexReferences.push(vertex.id);
  92760. };
  92761. //var totalVertices = mesh.getTotalVertices();
  92762. var totalVertices = submesh.verticesCount;
  92763. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  92764. var indicesInit = function (i) {
  92765. if (!indices) {
  92766. return;
  92767. }
  92768. var offset = (submesh.indexStart / 3) + i;
  92769. var pos = (offset * 3);
  92770. var i0 = indices[pos + 0];
  92771. var i1 = indices[pos + 1];
  92772. var i2 = indices[pos + 2];
  92773. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  92774. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  92775. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  92776. var triangle = new DecimationTriangle([v0, v1, v2]);
  92777. triangle.originalOffset = pos;
  92778. _this.triangles.push(triangle);
  92779. };
  92780. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  92781. _this.init(callback);
  92782. });
  92783. });
  92784. };
  92785. QuadraticErrorSimplification.prototype.init = function (callback) {
  92786. var _this = this;
  92787. var triangleInit1 = function (i) {
  92788. var t = _this.triangles[i];
  92789. 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();
  92790. for (var j = 0; j < 3; j++) {
  92791. 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))));
  92792. }
  92793. };
  92794. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  92795. var triangleInit2 = function (i) {
  92796. var t = _this.triangles[i];
  92797. for (var j = 0; j < 3; ++j) {
  92798. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  92799. }
  92800. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  92801. };
  92802. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  92803. callback();
  92804. });
  92805. });
  92806. };
  92807. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  92808. var newTriangles = [];
  92809. var i;
  92810. for (i = 0; i < this.vertices.length; ++i) {
  92811. this.vertices[i].triangleCount = 0;
  92812. }
  92813. var t;
  92814. var j;
  92815. for (i = 0; i < this.triangles.length; ++i) {
  92816. if (!this.triangles[i].deleted) {
  92817. t = this.triangles[i];
  92818. for (j = 0; j < 3; ++j) {
  92819. t.vertices[j].triangleCount = 1;
  92820. }
  92821. newTriangles.push(t);
  92822. }
  92823. }
  92824. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  92825. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  92826. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  92827. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  92828. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  92829. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  92830. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  92831. var vertexCount = 0;
  92832. for (i = 0; i < this.vertices.length; ++i) {
  92833. var vertex = this.vertices[i];
  92834. vertex.id = vertexCount;
  92835. if (vertex.triangleCount) {
  92836. vertex.originalOffsets.forEach(function (originalOffset) {
  92837. if (!normalData) {
  92838. return;
  92839. }
  92840. newPositionData.push(vertex.position.x);
  92841. newPositionData.push(vertex.position.y);
  92842. newPositionData.push(vertex.position.z);
  92843. newNormalData.push(normalData[originalOffset * 3]);
  92844. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  92845. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  92846. if (uvs && uvs.length) {
  92847. newUVsData.push(uvs[(originalOffset * 2)]);
  92848. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  92849. }
  92850. if (colorsData && colorsData.length) {
  92851. newColorsData.push(colorsData[(originalOffset * 4)]);
  92852. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  92853. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  92854. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  92855. }
  92856. ++vertexCount;
  92857. });
  92858. }
  92859. }
  92860. var startingIndex = this._reconstructedMesh.getTotalIndices();
  92861. var startingVertex = this._reconstructedMesh.getTotalVertices();
  92862. var submeshesArray = this._reconstructedMesh.subMeshes;
  92863. this._reconstructedMesh.subMeshes = [];
  92864. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  92865. var originalIndices = this._mesh.getIndices();
  92866. for (i = 0; i < newTriangles.length; ++i) {
  92867. t = newTriangles[i]; //now get the new referencing point for each vertex
  92868. [0, 1, 2].forEach(function (idx) {
  92869. var id = originalIndices[t.originalOffset + idx];
  92870. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  92871. if (offset < 0) {
  92872. offset = 0;
  92873. }
  92874. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  92875. });
  92876. }
  92877. //overwriting the old vertex buffers and indices.
  92878. this._reconstructedMesh.setIndices(newIndicesArray);
  92879. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  92880. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  92881. if (newUVsData.length > 0) {
  92882. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  92883. }
  92884. if (newColorsData.length > 0) {
  92885. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  92886. }
  92887. //create submesh
  92888. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  92889. if (submeshIndex > 0) {
  92890. this._reconstructedMesh.subMeshes = [];
  92891. submeshesArray.forEach(function (submesh) {
  92892. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  92893. });
  92894. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  92895. }
  92896. };
  92897. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  92898. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  92899. this._reconstructedMesh.material = this._mesh.material;
  92900. this._reconstructedMesh.parent = this._mesh.parent;
  92901. this._reconstructedMesh.isVisible = false;
  92902. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  92903. };
  92904. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  92905. for (var i = 0; i < vertex1.triangleCount; ++i) {
  92906. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  92907. if (t.deleted) {
  92908. continue;
  92909. }
  92910. var s = this.references[vertex1.triangleStart + i].vertexId;
  92911. var v1 = t.vertices[(s + 1) % 3];
  92912. var v2 = t.vertices[(s + 2) % 3];
  92913. if ((v1 === vertex2 || v2 === vertex2)) {
  92914. deletedArray[i] = true;
  92915. delTr.push(t);
  92916. continue;
  92917. }
  92918. var d1 = v1.position.subtract(point);
  92919. d1 = d1.normalize();
  92920. var d2 = v2.position.subtract(point);
  92921. d2 = d2.normalize();
  92922. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  92923. return true;
  92924. }
  92925. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  92926. deletedArray[i] = false;
  92927. if (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  92928. return true;
  92929. }
  92930. }
  92931. return false;
  92932. };
  92933. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  92934. var newDeleted = deletedTriangles;
  92935. for (var i = 0; i < vertex.triangleCount; ++i) {
  92936. var ref = this.references[vertex.triangleStart + i];
  92937. var t = this.triangles[ref.triangleId];
  92938. if (t.deleted) {
  92939. continue;
  92940. }
  92941. if (deletedArray[i] && t.deletePending) {
  92942. t.deleted = true;
  92943. newDeleted++;
  92944. continue;
  92945. }
  92946. t.vertices[ref.vertexId] = origVertex;
  92947. t.isDirty = true;
  92948. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  92949. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  92950. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  92951. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  92952. this.references.push(ref);
  92953. }
  92954. return newDeleted;
  92955. };
  92956. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  92957. for (var i = 0; i < this.vertices.length; ++i) {
  92958. var vCount = [];
  92959. var vId = [];
  92960. var v = this.vertices[i];
  92961. var j;
  92962. for (j = 0; j < v.triangleCount; ++j) {
  92963. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  92964. for (var ii = 0; ii < 3; ii++) {
  92965. var ofs = 0;
  92966. var vv = triangle.vertices[ii];
  92967. while (ofs < vCount.length) {
  92968. if (vId[ofs] === vv.id) {
  92969. break;
  92970. }
  92971. ++ofs;
  92972. }
  92973. if (ofs === vCount.length) {
  92974. vCount.push(1);
  92975. vId.push(vv.id);
  92976. }
  92977. else {
  92978. vCount[ofs]++;
  92979. }
  92980. }
  92981. }
  92982. for (j = 0; j < vCount.length; ++j) {
  92983. if (vCount[j] === 1) {
  92984. this.vertices[vId[j]].isBorder = true;
  92985. }
  92986. else {
  92987. this.vertices[vId[j]].isBorder = false;
  92988. }
  92989. }
  92990. }
  92991. };
  92992. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  92993. if (identifyBorders === void 0) { identifyBorders = false; }
  92994. var i;
  92995. if (!identifyBorders) {
  92996. var newTrianglesVector = [];
  92997. for (i = 0; i < this.triangles.length; ++i) {
  92998. if (!this.triangles[i].deleted) {
  92999. newTrianglesVector.push(this.triangles[i]);
  93000. }
  93001. }
  93002. this.triangles = newTrianglesVector;
  93003. }
  93004. for (i = 0; i < this.vertices.length; ++i) {
  93005. this.vertices[i].triangleCount = 0;
  93006. this.vertices[i].triangleStart = 0;
  93007. }
  93008. var t;
  93009. var j;
  93010. var v;
  93011. for (i = 0; i < this.triangles.length; ++i) {
  93012. t = this.triangles[i];
  93013. for (j = 0; j < 3; ++j) {
  93014. v = t.vertices[j];
  93015. v.triangleCount++;
  93016. }
  93017. }
  93018. var tStart = 0;
  93019. for (i = 0; i < this.vertices.length; ++i) {
  93020. this.vertices[i].triangleStart = tStart;
  93021. tStart += this.vertices[i].triangleCount;
  93022. this.vertices[i].triangleCount = 0;
  93023. }
  93024. var newReferences = new Array(this.triangles.length * 3);
  93025. for (i = 0; i < this.triangles.length; ++i) {
  93026. t = this.triangles[i];
  93027. for (j = 0; j < 3; ++j) {
  93028. v = t.vertices[j];
  93029. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  93030. v.triangleCount++;
  93031. }
  93032. }
  93033. this.references = newReferences;
  93034. if (identifyBorders) {
  93035. this.identifyBorder();
  93036. }
  93037. };
  93038. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  93039. var x = point.x;
  93040. var y = point.y;
  93041. var z = point.z;
  93042. 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
  93043. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  93044. };
  93045. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  93046. var q = vertex1.q.add(vertex2.q);
  93047. var border = vertex1.isBorder && vertex2.isBorder;
  93048. var error = 0;
  93049. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  93050. if (qDet !== 0 && !border) {
  93051. if (!pointResult) {
  93052. pointResult = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  93053. }
  93054. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  93055. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  93056. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  93057. error = this.vertexError(q, pointResult);
  93058. }
  93059. else {
  93060. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  93061. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  93062. var error1 = this.vertexError(q, vertex1.position);
  93063. var error2 = this.vertexError(q, vertex2.position);
  93064. var error3 = this.vertexError(q, p3);
  93065. error = Math.min(error1, error2, error3);
  93066. if (error === error1) {
  93067. if (pointResult) {
  93068. pointResult.copyFrom(vertex1.position);
  93069. }
  93070. }
  93071. else if (error === error2) {
  93072. if (pointResult) {
  93073. pointResult.copyFrom(vertex2.position);
  93074. }
  93075. }
  93076. else {
  93077. if (pointResult) {
  93078. pointResult.copyFrom(p3);
  93079. }
  93080. }
  93081. }
  93082. return error;
  93083. };
  93084. return QuadraticErrorSimplification;
  93085. }());
  93086. /***/ }),
  93087. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  93088. /*!****************************************************!*\
  93089. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  93090. \****************************************************/
  93091. /*! exports provided: SimplicationQueueSceneComponent */
  93092. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93093. "use strict";
  93094. __webpack_require__.r(__webpack_exports__);
  93095. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  93096. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  93097. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  93098. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  93099. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  93100. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  93101. get: function () {
  93102. if (!this._simplificationQueue) {
  93103. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  93104. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  93105. if (!component) {
  93106. component = new SimplicationQueueSceneComponent(this);
  93107. this._addComponent(component);
  93108. }
  93109. }
  93110. return this._simplificationQueue;
  93111. },
  93112. set: function (value) {
  93113. this._simplificationQueue = value;
  93114. },
  93115. enumerable: true,
  93116. configurable: true
  93117. });
  93118. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  93119. if (parallelProcessing === void 0) { parallelProcessing = true; }
  93120. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  93121. this.getScene().simplificationQueue.addTask({
  93122. settings: settings,
  93123. parallelProcessing: parallelProcessing,
  93124. mesh: this,
  93125. simplificationType: simplificationType,
  93126. successCallback: successCallback
  93127. });
  93128. return this;
  93129. };
  93130. /**
  93131. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  93132. * created in a scene
  93133. */
  93134. var SimplicationQueueSceneComponent = /** @class */ (function () {
  93135. /**
  93136. * Creates a new instance of the component for the given scene
  93137. * @param scene Defines the scene to register the component in
  93138. */
  93139. function SimplicationQueueSceneComponent(scene) {
  93140. /**
  93141. * The component name helpfull to identify the component in the list of scene components.
  93142. */
  93143. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  93144. this.scene = scene;
  93145. }
  93146. /**
  93147. * Registers the component in a given scene
  93148. */
  93149. SimplicationQueueSceneComponent.prototype.register = function () {
  93150. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  93151. };
  93152. /**
  93153. * Rebuilds the elements related to this component in case of
  93154. * context lost for instance.
  93155. */
  93156. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  93157. // Nothing to do for this component
  93158. };
  93159. /**
  93160. * Disposes the component and the associated ressources
  93161. */
  93162. SimplicationQueueSceneComponent.prototype.dispose = function () {
  93163. // Nothing to do for this component
  93164. };
  93165. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  93166. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  93167. this.scene._simplificationQueue.executeNext();
  93168. }
  93169. };
  93170. return SimplicationQueueSceneComponent;
  93171. }());
  93172. /***/ }),
  93173. /***/ "./Meshes/polygonMesh.ts":
  93174. /*!*******************************!*\
  93175. !*** ./Meshes/polygonMesh.ts ***!
  93176. \*******************************/
  93177. /*! exports provided: Polygon, PolygonMeshBuilder */
  93178. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93179. "use strict";
  93180. __webpack_require__.r(__webpack_exports__);
  93181. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  93182. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  93183. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  93184. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  93185. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  93186. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  93187. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  93188. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  93189. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  93190. /**
  93191. * Vector2 wth index property
  93192. */
  93193. var IndexedVector2 = /** @class */ (function (_super) {
  93194. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  93195. function IndexedVector2(original,
  93196. /** Index of the vector2 */
  93197. index) {
  93198. var _this = _super.call(this, original.x, original.y) || this;
  93199. _this.index = index;
  93200. return _this;
  93201. }
  93202. return IndexedVector2;
  93203. }(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  93204. /**
  93205. * Defines points to create a polygon
  93206. */
  93207. var PolygonPoints = /** @class */ (function () {
  93208. function PolygonPoints() {
  93209. this.elements = new Array();
  93210. }
  93211. PolygonPoints.prototype.add = function (originalPoints) {
  93212. var _this = this;
  93213. var result = new Array();
  93214. originalPoints.forEach(function (point) {
  93215. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  93216. var newPoint = new IndexedVector2(point, _this.elements.length);
  93217. result.push(newPoint);
  93218. _this.elements.push(newPoint);
  93219. }
  93220. });
  93221. return result;
  93222. };
  93223. PolygonPoints.prototype.computeBounds = function () {
  93224. var lmin = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  93225. var lmax = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  93226. this.elements.forEach(function (point) {
  93227. // x
  93228. if (point.x < lmin.x) {
  93229. lmin.x = point.x;
  93230. }
  93231. else if (point.x > lmax.x) {
  93232. lmax.x = point.x;
  93233. }
  93234. // y
  93235. if (point.y < lmin.y) {
  93236. lmin.y = point.y;
  93237. }
  93238. else if (point.y > lmax.y) {
  93239. lmax.y = point.y;
  93240. }
  93241. });
  93242. return {
  93243. min: lmin,
  93244. max: lmax,
  93245. width: lmax.x - lmin.x,
  93246. height: lmax.y - lmin.y
  93247. };
  93248. };
  93249. return PolygonPoints;
  93250. }());
  93251. /**
  93252. * Polygon
  93253. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  93254. */
  93255. var Polygon = /** @class */ (function () {
  93256. function Polygon() {
  93257. }
  93258. /**
  93259. * Creates a rectangle
  93260. * @param xmin bottom X coord
  93261. * @param ymin bottom Y coord
  93262. * @param xmax top X coord
  93263. * @param ymax top Y coord
  93264. * @returns points that make the resulting rectation
  93265. */
  93266. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  93267. return [
  93268. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  93269. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  93270. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  93271. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  93272. ];
  93273. };
  93274. /**
  93275. * Creates a circle
  93276. * @param radius radius of circle
  93277. * @param cx scale in x
  93278. * @param cy scale in y
  93279. * @param numberOfSides number of sides that make up the circle
  93280. * @returns points that make the resulting circle
  93281. */
  93282. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  93283. if (cx === void 0) { cx = 0; }
  93284. if (cy === void 0) { cy = 0; }
  93285. if (numberOfSides === void 0) { numberOfSides = 32; }
  93286. var result = new Array();
  93287. var angle = 0;
  93288. var increment = (Math.PI * 2) / numberOfSides;
  93289. for (var i = 0; i < numberOfSides; i++) {
  93290. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  93291. angle -= increment;
  93292. }
  93293. return result;
  93294. };
  93295. /**
  93296. * Creates a polygon from input string
  93297. * @param input Input polygon data
  93298. * @returns the parsed points
  93299. */
  93300. Polygon.Parse = function (input) {
  93301. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  93302. var i, result = [];
  93303. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  93304. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  93305. }
  93306. return result;
  93307. };
  93308. /**
  93309. * Starts building a polygon from x and y coordinates
  93310. * @param x x coordinate
  93311. * @param y y coordinate
  93312. * @returns the started path2
  93313. */
  93314. Polygon.StartingAt = function (x, y) {
  93315. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"].StartingAt(x, y);
  93316. };
  93317. return Polygon;
  93318. }());
  93319. /**
  93320. * Builds a polygon
  93321. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  93322. */
  93323. var PolygonMeshBuilder = /** @class */ (function () {
  93324. /**
  93325. * Creates a PolygonMeshBuilder
  93326. * @param name name of the builder
  93327. * @param contours Path of the polygon
  93328. * @param scene scene to add to when creating the mesh
  93329. * @param earcutInjection can be used to inject your own earcut reference
  93330. */
  93331. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  93332. if (earcutInjection === void 0) { earcutInjection = earcut; }
  93333. this._points = new PolygonPoints();
  93334. this._outlinepoints = new PolygonPoints();
  93335. this._holes = new Array();
  93336. this._epoints = new Array();
  93337. this._eholes = new Array();
  93338. this.bjsEarcut = earcutInjection;
  93339. this._name = name;
  93340. this._scene = scene || _Engines_engine__WEBPACK_IMPORTED_MODULE_6__["Engine"].LastCreatedScene;
  93341. var points;
  93342. if (contours instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"]) {
  93343. points = contours.getPoints();
  93344. }
  93345. else {
  93346. points = contours;
  93347. }
  93348. this._addToepoint(points);
  93349. this._points.add(points);
  93350. this._outlinepoints.add(points);
  93351. if (typeof this.bjsEarcut === 'undefined') {
  93352. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  93353. }
  93354. }
  93355. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  93356. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  93357. var p = points_1[_i];
  93358. this._epoints.push(p.x, p.y);
  93359. }
  93360. };
  93361. /**
  93362. * Adds a whole within the polygon
  93363. * @param hole Array of points defining the hole
  93364. * @returns this
  93365. */
  93366. PolygonMeshBuilder.prototype.addHole = function (hole) {
  93367. this._points.add(hole);
  93368. var holepoints = new PolygonPoints();
  93369. holepoints.add(hole);
  93370. this._holes.push(holepoints);
  93371. this._eholes.push(this._epoints.length / 2);
  93372. this._addToepoint(hole);
  93373. return this;
  93374. };
  93375. /**
  93376. * Creates the polygon
  93377. * @param updatable If the mesh should be updatable
  93378. * @param depth The depth of the mesh created
  93379. * @returns the created mesh
  93380. */
  93381. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  93382. if (updatable === void 0) { updatable = false; }
  93383. if (depth === void 0) { depth = 0; }
  93384. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  93385. var vertexData = this.buildVertexData(depth);
  93386. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, vertexData.positions, updatable);
  93387. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, vertexData.normals, updatable);
  93388. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, vertexData.uvs, updatable);
  93389. result.setIndices(vertexData.indices);
  93390. return result;
  93391. };
  93392. /**
  93393. * Creates the polygon
  93394. * @param depth The depth of the mesh created
  93395. * @returns the created VertexData
  93396. */
  93397. PolygonMeshBuilder.prototype.buildVertexData = function (depth) {
  93398. var _this = this;
  93399. if (depth === void 0) { depth = 0; }
  93400. var result = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  93401. var normals = new Array();
  93402. var positions = new Array();
  93403. var uvs = new Array();
  93404. var bounds = this._points.computeBounds();
  93405. this._points.elements.forEach(function (p) {
  93406. normals.push(0, 1.0, 0);
  93407. positions.push(p.x, 0, p.y);
  93408. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  93409. });
  93410. var indices = new Array();
  93411. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  93412. for (var i = 0; i < res.length; i++) {
  93413. indices.push(res[i]);
  93414. }
  93415. if (depth > 0) {
  93416. var positionscount = (positions.length / 3); //get the current pointcount
  93417. this._points.elements.forEach(function (p) {
  93418. normals.push(0, -1.0, 0);
  93419. positions.push(p.x, -depth, p.y);
  93420. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  93421. });
  93422. var totalCount = indices.length;
  93423. for (var i = 0; i < totalCount; i += 3) {
  93424. var i0 = indices[i + 0];
  93425. var i1 = indices[i + 1];
  93426. var i2 = indices[i + 2];
  93427. indices.push(i2 + positionscount);
  93428. indices.push(i1 + positionscount);
  93429. indices.push(i0 + positionscount);
  93430. }
  93431. //Add the sides
  93432. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  93433. this._holes.forEach(function (hole) {
  93434. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  93435. });
  93436. }
  93437. result.indices = indices;
  93438. result.positions = positions;
  93439. result.normals = normals;
  93440. result.uvs = uvs;
  93441. return result;
  93442. };
  93443. /**
  93444. * Adds a side to the polygon
  93445. * @param positions points that make the polygon
  93446. * @param normals normals of the polygon
  93447. * @param uvs uvs of the polygon
  93448. * @param indices indices of the polygon
  93449. * @param bounds bounds of the polygon
  93450. * @param points points of the polygon
  93451. * @param depth depth of the polygon
  93452. * @param flip flip of the polygon
  93453. */
  93454. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  93455. var StartIndex = positions.length / 3;
  93456. var ulength = 0;
  93457. for (var i = 0; i < points.elements.length; i++) {
  93458. var p = points.elements[i];
  93459. var p1;
  93460. if ((i + 1) > points.elements.length - 1) {
  93461. p1 = points.elements[0];
  93462. }
  93463. else {
  93464. p1 = points.elements[i + 1];
  93465. }
  93466. positions.push(p.x, 0, p.y);
  93467. positions.push(p.x, -depth, p.y);
  93468. positions.push(p1.x, 0, p1.y);
  93469. positions.push(p1.x, -depth, p1.y);
  93470. var v1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  93471. var v2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  93472. var v3 = v2.subtract(v1);
  93473. var v4 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  93474. var vn = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  93475. vn = vn.normalize();
  93476. uvs.push(ulength / bounds.width, 0);
  93477. uvs.push(ulength / bounds.width, 1);
  93478. ulength += v3.length();
  93479. uvs.push((ulength / bounds.width), 0);
  93480. uvs.push((ulength / bounds.width), 1);
  93481. if (!flip) {
  93482. normals.push(-vn.x, -vn.y, -vn.z);
  93483. normals.push(-vn.x, -vn.y, -vn.z);
  93484. normals.push(-vn.x, -vn.y, -vn.z);
  93485. normals.push(-vn.x, -vn.y, -vn.z);
  93486. indices.push(StartIndex);
  93487. indices.push(StartIndex + 1);
  93488. indices.push(StartIndex + 2);
  93489. indices.push(StartIndex + 1);
  93490. indices.push(StartIndex + 3);
  93491. indices.push(StartIndex + 2);
  93492. }
  93493. else {
  93494. normals.push(vn.x, vn.y, vn.z);
  93495. normals.push(vn.x, vn.y, vn.z);
  93496. normals.push(vn.x, vn.y, vn.z);
  93497. normals.push(vn.x, vn.y, vn.z);
  93498. indices.push(StartIndex);
  93499. indices.push(StartIndex + 2);
  93500. indices.push(StartIndex + 1);
  93501. indices.push(StartIndex + 1);
  93502. indices.push(StartIndex + 2);
  93503. indices.push(StartIndex + 3);
  93504. }
  93505. StartIndex += 4;
  93506. }
  93507. };
  93508. return PolygonMeshBuilder;
  93509. }());
  93510. /***/ }),
  93511. /***/ "./Meshes/subMesh.ts":
  93512. /*!***************************!*\
  93513. !*** ./Meshes/subMesh.ts ***!
  93514. \***************************/
  93515. /*! exports provided: BaseSubMesh, SubMesh */
  93516. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93517. "use strict";
  93518. __webpack_require__.r(__webpack_exports__);
  93519. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  93520. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  93521. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  93522. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  93523. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  93524. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  93525. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  93526. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  93527. /**
  93528. * Base class for submeshes
  93529. */
  93530. var BaseSubMesh = /** @class */ (function () {
  93531. function BaseSubMesh() {
  93532. }
  93533. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  93534. /**
  93535. * Gets associated effect
  93536. */
  93537. get: function () {
  93538. return this._materialEffect;
  93539. },
  93540. enumerable: true,
  93541. configurable: true
  93542. });
  93543. /**
  93544. * Sets associated effect (effect used to render this submesh)
  93545. * @param effect defines the effect to associate with
  93546. * @param defines defines the set of defines used to compile this effect
  93547. */
  93548. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  93549. if (defines === void 0) { defines = null; }
  93550. if (this._materialEffect === effect) {
  93551. if (!effect) {
  93552. this._materialDefines = null;
  93553. }
  93554. return;
  93555. }
  93556. this._materialDefines = defines;
  93557. this._materialEffect = effect;
  93558. };
  93559. return BaseSubMesh;
  93560. }());
  93561. /**
  93562. * Defines a subdivision inside a mesh
  93563. */
  93564. var SubMesh = /** @class */ (function (_super) {
  93565. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  93566. /**
  93567. * Creates a new submesh
  93568. * @param materialIndex defines the material index to use
  93569. * @param verticesStart defines vertex index start
  93570. * @param verticesCount defines vertices count
  93571. * @param indexStart defines index start
  93572. * @param indexCount defines indices count
  93573. * @param mesh defines the parent mesh
  93574. * @param renderingMesh defines an optional rendering mesh
  93575. * @param createBoundingBox defines if bounding box should be created for this submesh
  93576. */
  93577. function SubMesh(
  93578. /** the material index to use */
  93579. materialIndex,
  93580. /** vertex index start */
  93581. verticesStart,
  93582. /** vertices count */
  93583. verticesCount,
  93584. /** index start */
  93585. indexStart,
  93586. /** indices count */
  93587. indexCount, mesh, renderingMesh, createBoundingBox) {
  93588. if (createBoundingBox === void 0) { createBoundingBox = true; }
  93589. var _this = _super.call(this) || this;
  93590. _this.materialIndex = materialIndex;
  93591. _this.verticesStart = verticesStart;
  93592. _this.verticesCount = verticesCount;
  93593. _this.indexStart = indexStart;
  93594. _this.indexCount = indexCount;
  93595. /** @hidden */
  93596. _this._renderId = 0;
  93597. _this._mesh = mesh;
  93598. _this._renderingMesh = renderingMesh || mesh;
  93599. mesh.subMeshes.push(_this);
  93600. _this._trianglePlanes = [];
  93601. _this._id = mesh.subMeshes.length - 1;
  93602. if (createBoundingBox) {
  93603. _this.refreshBoundingInfo();
  93604. mesh.computeWorldMatrix(true);
  93605. }
  93606. return _this;
  93607. }
  93608. /**
  93609. * Add a new submesh to a mesh
  93610. * @param materialIndex defines the material index to use
  93611. * @param verticesStart defines vertex index start
  93612. * @param verticesCount defines vertices count
  93613. * @param indexStart defines index start
  93614. * @param indexCount defines indices count
  93615. * @param mesh defines the parent mesh
  93616. * @param renderingMesh defines an optional rendering mesh
  93617. * @param createBoundingBox defines if bounding box should be created for this submesh
  93618. * @returns the new submesh
  93619. */
  93620. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  93621. if (createBoundingBox === void 0) { createBoundingBox = true; }
  93622. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  93623. };
  93624. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  93625. /**
  93626. * Returns true if this submesh covers the entire parent mesh
  93627. * @ignorenaming
  93628. */
  93629. get: function () {
  93630. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  93631. },
  93632. enumerable: true,
  93633. configurable: true
  93634. });
  93635. /**
  93636. * Returns the submesh BoudingInfo object
  93637. * @returns current bounding info (or mesh's one if the submesh is global)
  93638. */
  93639. SubMesh.prototype.getBoundingInfo = function () {
  93640. if (this.IsGlobal) {
  93641. return this._mesh.getBoundingInfo();
  93642. }
  93643. return this._boundingInfo;
  93644. };
  93645. /**
  93646. * Sets the submesh BoundingInfo
  93647. * @param boundingInfo defines the new bounding info to use
  93648. * @returns the SubMesh
  93649. */
  93650. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  93651. this._boundingInfo = boundingInfo;
  93652. return this;
  93653. };
  93654. /**
  93655. * Returns the mesh of the current submesh
  93656. * @return the parent mesh
  93657. */
  93658. SubMesh.prototype.getMesh = function () {
  93659. return this._mesh;
  93660. };
  93661. /**
  93662. * Returns the rendering mesh of the submesh
  93663. * @returns the rendering mesh (could be different from parent mesh)
  93664. */
  93665. SubMesh.prototype.getRenderingMesh = function () {
  93666. return this._renderingMesh;
  93667. };
  93668. /**
  93669. * Returns the submesh material
  93670. * @returns null or the current material
  93671. */
  93672. SubMesh.prototype.getMaterial = function () {
  93673. var rootMaterial = this._renderingMesh.material;
  93674. if (rootMaterial === null || rootMaterial === undefined) {
  93675. return this._mesh.getScene().defaultMaterial;
  93676. }
  93677. else if (rootMaterial.getSubMaterial) {
  93678. var multiMaterial = rootMaterial;
  93679. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  93680. if (this._currentMaterial !== effectiveMaterial) {
  93681. this._currentMaterial = effectiveMaterial;
  93682. this._materialDefines = null;
  93683. }
  93684. return effectiveMaterial;
  93685. }
  93686. return rootMaterial;
  93687. };
  93688. // Methods
  93689. /**
  93690. * Sets a new updated BoundingInfo object to the submesh
  93691. * @returns the SubMesh
  93692. */
  93693. SubMesh.prototype.refreshBoundingInfo = function () {
  93694. this._lastColliderWorldVertices = null;
  93695. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  93696. return this;
  93697. }
  93698. var data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  93699. if (!data) {
  93700. this._boundingInfo = this._mesh.getBoundingInfo();
  93701. return this;
  93702. }
  93703. var indices = this._renderingMesh.getIndices();
  93704. var extend;
  93705. //is this the only submesh?
  93706. if (this.indexStart === 0 && this.indexCount === indices.length) {
  93707. var boundingInfo = this._renderingMesh.getBoundingInfo();
  93708. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  93709. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  93710. }
  93711. else {
  93712. extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  93713. }
  93714. if (this._boundingInfo) {
  93715. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  93716. }
  93717. else {
  93718. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](extend.minimum, extend.maximum);
  93719. }
  93720. return this;
  93721. };
  93722. /** @hidden */
  93723. SubMesh.prototype._checkCollision = function (collider) {
  93724. var boundingInfo = this.getBoundingInfo();
  93725. return boundingInfo._checkCollision(collider);
  93726. };
  93727. /**
  93728. * Updates the submesh BoundingInfo
  93729. * @param world defines the world matrix to use to update the bounding info
  93730. * @returns the submesh
  93731. */
  93732. SubMesh.prototype.updateBoundingInfo = function (world) {
  93733. var boundingInfo = this.getBoundingInfo();
  93734. if (!boundingInfo) {
  93735. this.refreshBoundingInfo();
  93736. boundingInfo = this.getBoundingInfo();
  93737. }
  93738. boundingInfo.update(world);
  93739. return this;
  93740. };
  93741. /**
  93742. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  93743. * @param frustumPlanes defines the frustum planes
  93744. * @returns true if the submesh is intersecting with the frustum
  93745. */
  93746. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  93747. var boundingInfo = this.getBoundingInfo();
  93748. if (!boundingInfo) {
  93749. return false;
  93750. }
  93751. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  93752. };
  93753. /**
  93754. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  93755. * @param frustumPlanes defines the frustum planes
  93756. * @returns true if the submesh is inside the frustum
  93757. */
  93758. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  93759. var boundingInfo = this.getBoundingInfo();
  93760. if (!boundingInfo) {
  93761. return false;
  93762. }
  93763. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  93764. };
  93765. /**
  93766. * Renders the submesh
  93767. * @param enableAlphaMode defines if alpha needs to be used
  93768. * @returns the submesh
  93769. */
  93770. SubMesh.prototype.render = function (enableAlphaMode) {
  93771. this._renderingMesh.render(this, enableAlphaMode);
  93772. return this;
  93773. };
  93774. /**
  93775. * @hidden
  93776. */
  93777. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  93778. if (!this._linesIndexBuffer) {
  93779. var linesIndices = [];
  93780. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  93781. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  93782. }
  93783. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  93784. this._linesIndexCount = linesIndices.length;
  93785. }
  93786. return this._linesIndexBuffer;
  93787. };
  93788. /**
  93789. * Checks if the submesh intersects with a ray
  93790. * @param ray defines the ray to test
  93791. * @returns true is the passed ray intersects the submesh bounding box
  93792. */
  93793. SubMesh.prototype.canIntersects = function (ray) {
  93794. var boundingInfo = this.getBoundingInfo();
  93795. if (!boundingInfo) {
  93796. return false;
  93797. }
  93798. return ray.intersectsBox(boundingInfo.boundingBox);
  93799. };
  93800. /**
  93801. * Intersects current submesh with a ray
  93802. * @param ray defines the ray to test
  93803. * @param positions defines mesh's positions array
  93804. * @param indices defines mesh's indices array
  93805. * @param fastCheck defines if only bounding info should be used
  93806. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93807. * @returns intersection info or null if no intersection
  93808. */
  93809. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck, trianglePredicate) {
  93810. var material = this.getMaterial();
  93811. if (!material) {
  93812. return null;
  93813. }
  93814. switch (material.fillMode) {
  93815. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_PointListDrawMode:
  93816. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineListDrawMode:
  93817. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineLoopDrawMode:
  93818. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineStripDrawMode:
  93819. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleFanDrawMode:
  93820. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleStripDrawMode:
  93821. return null;
  93822. }
  93823. // LineMesh first as it's also a Mesh...
  93824. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  93825. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  93826. }
  93827. return this._intersectTriangles(ray, positions, indices, fastCheck, trianglePredicate);
  93828. };
  93829. /** @hidden */
  93830. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  93831. var intersectInfo = null;
  93832. // Line test
  93833. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  93834. var p0 = positions[indices[index]];
  93835. var p1 = positions[indices[index + 1]];
  93836. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  93837. if (length < 0) {
  93838. continue;
  93839. }
  93840. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  93841. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  93842. intersectInfo.faceId = index / 2;
  93843. if (fastCheck) {
  93844. break;
  93845. }
  93846. }
  93847. }
  93848. return intersectInfo;
  93849. };
  93850. /** @hidden */
  93851. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck, trianglePredicate) {
  93852. var intersectInfo = null;
  93853. // Triangles test
  93854. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  93855. var p0 = positions[indices[index]];
  93856. var p1 = positions[indices[index + 1]];
  93857. var p2 = positions[indices[index + 2]];
  93858. if (trianglePredicate && !trianglePredicate(p0, p1, p2, ray)) {
  93859. continue;
  93860. }
  93861. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  93862. if (currentIntersectInfo) {
  93863. if (currentIntersectInfo.distance < 0) {
  93864. continue;
  93865. }
  93866. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  93867. intersectInfo = currentIntersectInfo;
  93868. intersectInfo.faceId = index / 3;
  93869. if (fastCheck) {
  93870. break;
  93871. }
  93872. }
  93873. }
  93874. }
  93875. return intersectInfo;
  93876. };
  93877. /** @hidden */
  93878. SubMesh.prototype._rebuild = function () {
  93879. if (this._linesIndexBuffer) {
  93880. this._linesIndexBuffer = null;
  93881. }
  93882. };
  93883. // Clone
  93884. /**
  93885. * Creates a new submesh from the passed mesh
  93886. * @param newMesh defines the new hosting mesh
  93887. * @param newRenderingMesh defines an optional rendering mesh
  93888. * @returns the new submesh
  93889. */
  93890. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  93891. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  93892. if (!this.IsGlobal) {
  93893. var boundingInfo = this.getBoundingInfo();
  93894. if (!boundingInfo) {
  93895. return result;
  93896. }
  93897. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  93898. }
  93899. return result;
  93900. };
  93901. // Dispose
  93902. /**
  93903. * Release associated resources
  93904. */
  93905. SubMesh.prototype.dispose = function () {
  93906. if (this._linesIndexBuffer) {
  93907. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  93908. this._linesIndexBuffer = null;
  93909. }
  93910. // Remove from mesh
  93911. var index = this._mesh.subMeshes.indexOf(this);
  93912. this._mesh.subMeshes.splice(index, 1);
  93913. };
  93914. /**
  93915. * Gets the class name
  93916. * @returns the string "SubMesh".
  93917. */
  93918. SubMesh.prototype.getClassName = function () {
  93919. return "SubMesh";
  93920. };
  93921. // Statics
  93922. /**
  93923. * Creates a new submesh from indices data
  93924. * @param materialIndex the index of the main mesh material
  93925. * @param startIndex the index where to start the copy in the mesh indices array
  93926. * @param indexCount the number of indices to copy then from the startIndex
  93927. * @param mesh the main mesh to create the submesh from
  93928. * @param renderingMesh the optional rendering mesh
  93929. * @returns a new submesh
  93930. */
  93931. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  93932. var minVertexIndex = Number.MAX_VALUE;
  93933. var maxVertexIndex = -Number.MAX_VALUE;
  93934. var whatWillRender = (renderingMesh || mesh);
  93935. var indices = whatWillRender.getIndices();
  93936. for (var index = startIndex; index < startIndex + indexCount; index++) {
  93937. var vertexIndex = indices[index];
  93938. if (vertexIndex < minVertexIndex) {
  93939. minVertexIndex = vertexIndex;
  93940. }
  93941. if (vertexIndex > maxVertexIndex) {
  93942. maxVertexIndex = vertexIndex;
  93943. }
  93944. }
  93945. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  93946. };
  93947. return SubMesh;
  93948. }(BaseSubMesh));
  93949. /***/ }),
  93950. /***/ "./Meshes/trailMesh.ts":
  93951. /*!*****************************!*\
  93952. !*** ./Meshes/trailMesh.ts ***!
  93953. \*****************************/
  93954. /*! exports provided: TrailMesh */
  93955. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93956. "use strict";
  93957. __webpack_require__.r(__webpack_exports__);
  93958. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return TrailMesh; });
  93959. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  93960. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  93961. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  93962. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  93963. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  93964. /**
  93965. * Class used to create a trail following a mesh
  93966. */
  93967. var TrailMesh = /** @class */ (function (_super) {
  93968. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TrailMesh, _super);
  93969. /**
  93970. * @constructor
  93971. * @param name The value used by scene.getMeshByName() to do a lookup.
  93972. * @param generator The mesh to generate a trail.
  93973. * @param scene The scene to add this mesh to.
  93974. * @param diameter Diameter of trailing mesh. Default is 1.
  93975. * @param length Length of trailing mesh. Default is 60.
  93976. * @param autoStart Automatically start trailing mesh. Default true.
  93977. */
  93978. function TrailMesh(name, generator, scene, diameter, length, autoStart) {
  93979. if (diameter === void 0) { diameter = 1; }
  93980. if (length === void 0) { length = 60; }
  93981. if (autoStart === void 0) { autoStart = true; }
  93982. var _this = _super.call(this, name, scene) || this;
  93983. _this._sectionPolygonPointsCount = 4;
  93984. _this._running = false;
  93985. _this._autoStart = autoStart;
  93986. _this._generator = generator;
  93987. _this._diameter = diameter;
  93988. _this._length = length;
  93989. _this._sectionVectors = [];
  93990. _this._sectionNormalVectors = [];
  93991. for (var i = 0; i < _this._sectionPolygonPointsCount; i++) {
  93992. _this._sectionVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  93993. _this._sectionNormalVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  93994. }
  93995. _this._createMesh();
  93996. return _this;
  93997. }
  93998. /**
  93999. * "TrailMesh"
  94000. * @returns "TrailMesh"
  94001. */
  94002. TrailMesh.prototype.getClassName = function () {
  94003. return "TrailMesh";
  94004. };
  94005. TrailMesh.prototype._createMesh = function () {
  94006. var data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"]();
  94007. var positions = [];
  94008. var normals = [];
  94009. var indices = [];
  94010. var meshCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  94011. if (this._generator._boundingInfo) {
  94012. meshCenter = this._generator._boundingInfo.boundingBox.centerWorld;
  94013. }
  94014. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  94015. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  94016. positions.push(meshCenter.x + Math.cos(i * alpha) * this._diameter, meshCenter.y + Math.sin(i * alpha) * this._diameter, meshCenter.z);
  94017. }
  94018. for (var i = 1; i <= this._length; i++) {
  94019. for (var j = 0; j < this._sectionPolygonPointsCount; j++) {
  94020. positions.push(meshCenter.x + Math.cos(j * alpha) * this._diameter, meshCenter.y + Math.sin(j * alpha) * this._diameter, meshCenter.z);
  94021. }
  94022. var l = positions.length / 3 - 2 * this._sectionPolygonPointsCount;
  94023. for (var j = 0; j < this._sectionPolygonPointsCount - 1; j++) {
  94024. indices.push(l + j, l + j + this._sectionPolygonPointsCount, l + j + this._sectionPolygonPointsCount + 1);
  94025. indices.push(l + j, l + j + this._sectionPolygonPointsCount + 1, l + j + 1);
  94026. }
  94027. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, l + this._sectionPolygonPointsCount);
  94028. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount, l);
  94029. }
  94030. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"].ComputeNormals(positions, indices, normals);
  94031. data.positions = positions;
  94032. data.normals = normals;
  94033. data.indices = indices;
  94034. data.applyToMesh(this, true);
  94035. if (this._autoStart) {
  94036. this.start();
  94037. }
  94038. };
  94039. /**
  94040. * Start trailing mesh.
  94041. */
  94042. TrailMesh.prototype.start = function () {
  94043. var _this = this;
  94044. if (!this._running) {
  94045. this._running = true;
  94046. this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add(function () {
  94047. _this.update();
  94048. });
  94049. }
  94050. };
  94051. /**
  94052. * Stop trailing mesh.
  94053. */
  94054. TrailMesh.prototype.stop = function () {
  94055. if (this._beforeRenderObserver && this._running) {
  94056. this._running = false;
  94057. this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver);
  94058. }
  94059. };
  94060. /**
  94061. * Update trailing mesh geometry.
  94062. */
  94063. TrailMesh.prototype.update = function () {
  94064. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  94065. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind);
  94066. var wm = this._generator.getWorldMatrix();
  94067. if (positions && normals) {
  94068. for (var i = 3 * this._sectionPolygonPointsCount; i < positions.length; i++) {
  94069. positions[i - 3 * this._sectionPolygonPointsCount] = positions[i] - normals[i] / this._length * this._diameter;
  94070. }
  94071. for (var i = 3 * this._sectionPolygonPointsCount; i < normals.length; i++) {
  94072. normals[i - 3 * this._sectionPolygonPointsCount] = normals[i];
  94073. }
  94074. var l = positions.length - 3 * this._sectionPolygonPointsCount;
  94075. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  94076. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  94077. this._sectionVectors[i].copyFromFloats(Math.cos(i * alpha) * this._diameter, Math.sin(i * alpha) * this._diameter, 0);
  94078. this._sectionNormalVectors[i].copyFromFloats(Math.cos(i * alpha), Math.sin(i * alpha), 0);
  94079. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._sectionVectors[i], wm, this._sectionVectors[i]);
  94080. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this._sectionNormalVectors[i], wm, this._sectionNormalVectors[i]);
  94081. }
  94082. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  94083. positions[l + 3 * i] = this._sectionVectors[i].x;
  94084. positions[l + 3 * i + 1] = this._sectionVectors[i].y;
  94085. positions[l + 3 * i + 2] = this._sectionVectors[i].z;
  94086. normals[l + 3 * i] = this._sectionNormalVectors[i].x;
  94087. normals[l + 3 * i + 1] = this._sectionNormalVectors[i].y;
  94088. normals[l + 3 * i + 2] = this._sectionNormalVectors[i].z;
  94089. }
  94090. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, true, false);
  94091. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, true, false);
  94092. }
  94093. };
  94094. /**
  94095. * Returns a new TrailMesh object.
  94096. * @param name is a string, the name given to the new mesh
  94097. * @param newGenerator use new generator object for cloned trail mesh
  94098. * @returns a new mesh
  94099. */
  94100. TrailMesh.prototype.clone = function (name, newGenerator) {
  94101. if (name === void 0) { name = ""; }
  94102. return new TrailMesh(name, (newGenerator === undefined ? this._generator : newGenerator), this.getScene(), this._diameter, this._length, this._autoStart);
  94103. };
  94104. /**
  94105. * Serializes this trail mesh
  94106. * @param serializationObject object to write serialization to
  94107. */
  94108. TrailMesh.prototype.serialize = function (serializationObject) {
  94109. _super.prototype.serialize.call(this, serializationObject);
  94110. };
  94111. /**
  94112. * Parses a serialized trail mesh
  94113. * @param parsedMesh the serialized mesh
  94114. * @param scene the scene to create the trail mesh in
  94115. * @returns the created trail mesh
  94116. */
  94117. TrailMesh.Parse = function (parsedMesh, scene) {
  94118. return new TrailMesh(parsedMesh.name, parsedMesh._generator, scene, parsedMesh._diameter, parsedMesh._length, parsedMesh._autoStart);
  94119. };
  94120. return TrailMesh;
  94121. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]));
  94122. /***/ }),
  94123. /***/ "./Meshes/transformNode.ts":
  94124. /*!*********************************!*\
  94125. !*** ./Meshes/transformNode.ts ***!
  94126. \*********************************/
  94127. /*! exports provided: TransformNode */
  94128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94129. "use strict";
  94130. __webpack_require__.r(__webpack_exports__);
  94131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  94132. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  94133. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  94134. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  94135. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  94136. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  94137. /**
  94138. * 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.
  94139. * @see https://doc.babylonjs.com/how_to/transformnode
  94140. */
  94141. var TransformNode = /** @class */ (function (_super) {
  94142. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  94143. function TransformNode(name, scene, isPure) {
  94144. if (scene === void 0) { scene = null; }
  94145. if (isPure === void 0) { isPure = true; }
  94146. var _this = _super.call(this, name, scene) || this;
  94147. _this._forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  94148. _this._forwardInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  94149. _this._up = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0);
  94150. _this._right = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  94151. _this._rightInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-1, 0, 0);
  94152. // Properties
  94153. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94154. _this._rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94155. _this._scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].One();
  94156. _this._isDirty = false;
  94157. _this._billboardMode = TransformNode.BILLBOARDMODE_NONE;
  94158. _this._preserveParentRotationForBillboard = false;
  94159. /**
  94160. * 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
  94161. */
  94162. _this.scalingDeterminant = 1;
  94163. /**
  94164. * Sets the distance of the object to max, often used by skybox
  94165. */
  94166. _this.infiniteDistance = false;
  94167. /**
  94168. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  94169. * By default the system will update normals to compensate
  94170. */
  94171. _this.ignoreNonUniformScaling = false;
  94172. /**
  94173. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  94174. */
  94175. _this.reIntegrateRotationIntoRotationQuaternion = false;
  94176. /** @hidden */
  94177. _this._localMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  94178. _this._absolutePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94179. _this._pivotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  94180. _this._postMultiplyPivotMatrix = false;
  94181. _this._isWorldMatrixFrozen = false;
  94182. /** @hidden */
  94183. _this._indexInSceneTransformNodesArray = -1;
  94184. /**
  94185. * An event triggered after the world matrix is updated
  94186. */
  94187. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  94188. _this._nonUniformScaling = false;
  94189. _this._defaultCompositionProcessor = function (scaling, rotation, translation) {
  94190. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ComposeToRef(scaling, rotation, translation, _this._localMatrix);
  94191. };
  94192. _this._pivotCompositionProcessor = function (scaling, rotation, translation) {
  94193. var scaleMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  94194. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(scaling.x, scaling.y, scaling.z, scaleMatrix);
  94195. // Rotation
  94196. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94197. rotation.toRotationMatrix(rotationMatrix);
  94198. // Composing transformations
  94199. _this._pivotMatrix.multiplyToRef(scaleMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4]);
  94200. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4].multiplyToRef(rotationMatrix, _this._localMatrix);
  94201. // Post multiply inverse of pivotMatrix
  94202. if (_this._postMultiplyPivotMatrix) {
  94203. _this._localMatrix.multiplyToRef(_this._pivotMatrixInverse, _this._localMatrix);
  94204. }
  94205. _this._localMatrix.addTranslationFromFloats(translation.x, translation.y, translation.z);
  94206. };
  94207. _this._activeBillboardPostProcessor = function () { };
  94208. _this._defaultParentProcessor = function (parent) {
  94209. if (_this._transformToBoneReferal) {
  94210. _this._localMatrix.multiplyToRef(parent.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  94211. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6].multiplyToRef(_this._transformToBoneReferal.getWorldMatrix(), _this._worldMatrix);
  94212. }
  94213. else {
  94214. _this._localMatrix.multiplyToRef(parent.getWorldMatrix(), _this._worldMatrix);
  94215. }
  94216. };
  94217. _this._billboardParentProcessor = function (parent) {
  94218. if (_this._transformToBoneReferal) {
  94219. parent.getWorldMatrix().multiplyToRef(_this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7]);
  94220. }
  94221. else {
  94222. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].copyFrom(parent.getWorldMatrix());
  94223. }
  94224. // Extract scaling and translation from parent
  94225. var translation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5];
  94226. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[6];
  94227. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].decompose(scale, undefined, translation);
  94228. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(scale.x, scale.y, scale.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7]);
  94229. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7].setTranslation(translation);
  94230. _this._localMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[7], _this._worldMatrix);
  94231. };
  94232. _this._billboardPostProcessor = function () {
  94233. var camera = _this.getScene().activeCamera;
  94234. if (!camera) {
  94235. return;
  94236. }
  94237. var storedTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  94238. _this._worldMatrix.getTranslationToRef(storedTranslation); // Save translation
  94239. // Cancel camera rotation
  94240. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(camera.getViewMatrix());
  94241. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  94242. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  94243. if ((_this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  94244. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0].decompose(undefined, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0], undefined);
  94245. var eulerAngles = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  94246. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0].toEulerAnglesToRef(eulerAngles);
  94247. if ((_this.billboardMode & TransformNode.BILLBOARDMODE_X) !== TransformNode.BILLBOARDMODE_X) {
  94248. eulerAngles.x = 0;
  94249. }
  94250. if ((_this.billboardMode & TransformNode.BILLBOARDMODE_Y) !== TransformNode.BILLBOARDMODE_Y) {
  94251. eulerAngles.y = 0;
  94252. }
  94253. if ((_this.billboardMode & TransformNode.BILLBOARDMODE_Z) !== TransformNode.BILLBOARDMODE_Z) {
  94254. eulerAngles.z = 0;
  94255. }
  94256. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(eulerAngles.y, eulerAngles.x, eulerAngles.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  94257. }
  94258. _this._worldMatrix.setTranslationFromFloats(0, 0, 0);
  94259. _this._worldMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], _this._worldMatrix);
  94260. // Restore translation
  94261. _this._worldMatrix.setTranslation(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  94262. };
  94263. if (isPure) {
  94264. _this.getScene().addTransformNode(_this);
  94265. }
  94266. _this._activeParentProcessor = _this._defaultParentProcessor;
  94267. _this._activeCompositionProcess = _this._defaultCompositionProcessor;
  94268. return _this;
  94269. }
  94270. Object.defineProperty(TransformNode.prototype, "billboardMode", {
  94271. /**
  94272. * Gets or sets the billboard mode. Default is 0.
  94273. *
  94274. * | Value | Type | Description |
  94275. * | --- | --- | --- |
  94276. * | 0 | BILLBOARDMODE_NONE | |
  94277. * | 1 | BILLBOARDMODE_X | |
  94278. * | 2 | BILLBOARDMODE_Y | |
  94279. * | 4 | BILLBOARDMODE_Z | |
  94280. * | 7 | BILLBOARDMODE_ALL | |
  94281. *
  94282. */
  94283. get: function () {
  94284. return this._billboardMode;
  94285. },
  94286. set: function (value) {
  94287. if (this._billboardMode === value) {
  94288. return;
  94289. }
  94290. this._billboardMode = value;
  94291. this._connectBillboardProcessors();
  94292. },
  94293. enumerable: true,
  94294. configurable: true
  94295. });
  94296. Object.defineProperty(TransformNode.prototype, "preserveParentRotationForBillboard", {
  94297. /**
  94298. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  94299. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  94300. */
  94301. get: function () {
  94302. return this._preserveParentRotationForBillboard;
  94303. },
  94304. set: function (value) {
  94305. if (value === this._preserveParentRotationForBillboard) {
  94306. return;
  94307. }
  94308. this._preserveParentRotationForBillboard = value;
  94309. this._connectBillboardProcessors();
  94310. },
  94311. enumerable: true,
  94312. configurable: true
  94313. });
  94314. TransformNode.prototype._connectBillboardProcessors = function () {
  94315. if (this._billboardMode !== TransformNode.BILLBOARDMODE_NONE && !this.preserveParentRotationForBillboard) {
  94316. this._activeParentProcessor = this._billboardParentProcessor;
  94317. this._activeBillboardPostProcessor = this._billboardPostProcessor;
  94318. }
  94319. else {
  94320. this._activeParentProcessor = this._defaultParentProcessor;
  94321. this._activeBillboardPostProcessor = function () { };
  94322. }
  94323. };
  94324. /**
  94325. * Gets a string identifying the name of the class
  94326. * @returns "TransformNode" string
  94327. */
  94328. TransformNode.prototype.getClassName = function () {
  94329. return "TransformNode";
  94330. };
  94331. Object.defineProperty(TransformNode.prototype, "position", {
  94332. /**
  94333. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  94334. */
  94335. get: function () {
  94336. return this._position;
  94337. },
  94338. set: function (newPosition) {
  94339. this._position = newPosition;
  94340. this._isDirty = true;
  94341. },
  94342. enumerable: true,
  94343. configurable: true
  94344. });
  94345. Object.defineProperty(TransformNode.prototype, "rotation", {
  94346. /**
  94347. * 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)).
  94348. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  94349. */
  94350. get: function () {
  94351. return this._rotation;
  94352. },
  94353. set: function (newRotation) {
  94354. this._rotation = newRotation;
  94355. this._rotationQuaternion = null;
  94356. this._isDirty = true;
  94357. },
  94358. enumerable: true,
  94359. configurable: true
  94360. });
  94361. Object.defineProperty(TransformNode.prototype, "scaling", {
  94362. /**
  94363. * 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)).
  94364. */
  94365. get: function () {
  94366. return this._scaling;
  94367. },
  94368. set: function (newScaling) {
  94369. this._scaling = newScaling;
  94370. this._isDirty = true;
  94371. },
  94372. enumerable: true,
  94373. configurable: true
  94374. });
  94375. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  94376. /**
  94377. * 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).
  94378. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  94379. */
  94380. get: function () {
  94381. return this._rotationQuaternion;
  94382. },
  94383. set: function (quaternion) {
  94384. this._rotationQuaternion = quaternion;
  94385. //reset the rotation vector.
  94386. if (quaternion) {
  94387. this.rotation.setAll(0.0);
  94388. }
  94389. this._isDirty = true;
  94390. },
  94391. enumerable: true,
  94392. configurable: true
  94393. });
  94394. Object.defineProperty(TransformNode.prototype, "forward", {
  94395. /**
  94396. * The forward direction of that transform in world space.
  94397. */
  94398. get: function () {
  94399. 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()));
  94400. },
  94401. enumerable: true,
  94402. configurable: true
  94403. });
  94404. Object.defineProperty(TransformNode.prototype, "up", {
  94405. /**
  94406. * The up direction of that transform in world space.
  94407. */
  94408. get: function () {
  94409. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  94410. },
  94411. enumerable: true,
  94412. configurable: true
  94413. });
  94414. Object.defineProperty(TransformNode.prototype, "right", {
  94415. /**
  94416. * The right direction of that transform in world space.
  94417. */
  94418. get: function () {
  94419. 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()));
  94420. },
  94421. enumerable: true,
  94422. configurable: true
  94423. });
  94424. /**
  94425. * Copies the parameter passed Matrix into the mesh Pose matrix.
  94426. * @param matrix the matrix to copy the pose from
  94427. * @returns this TransformNode.
  94428. */
  94429. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  94430. this._poseMatrix.copyFrom(matrix);
  94431. return this;
  94432. };
  94433. /**
  94434. * Returns the mesh Pose matrix.
  94435. * @returns the pose matrix
  94436. */
  94437. TransformNode.prototype.getPoseMatrix = function () {
  94438. return this._poseMatrix;
  94439. };
  94440. /** @hidden */
  94441. TransformNode.prototype._isSynchronized = function () {
  94442. if (this.billboardMode !== this._cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  94443. return false;
  94444. }
  94445. if (this._cache.pivotMatrixUpdated) {
  94446. return false;
  94447. }
  94448. if (this.infiniteDistance) {
  94449. return false;
  94450. }
  94451. if (!this._cache.position.equals(this._position)) {
  94452. return false;
  94453. }
  94454. if (this._rotationQuaternion) {
  94455. if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  94456. return false;
  94457. }
  94458. }
  94459. else if (!this._cache.rotation.equals(this._rotation)) {
  94460. return false;
  94461. }
  94462. if (!this._cache.scaling.equals(this._scaling)) {
  94463. return false;
  94464. }
  94465. return true;
  94466. };
  94467. /** @hidden */
  94468. TransformNode.prototype._initCache = function () {
  94469. _super.prototype._initCache.call(this);
  94470. this._cache.localMatrixUpdated = false;
  94471. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94472. this._cache.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94473. this._cache.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94474. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](0, 0, 0, 0);
  94475. this._cache.billboardMode = -1;
  94476. this._cache.infiniteDistance = false;
  94477. };
  94478. /**
  94479. * Flag the transform node as dirty (Forcing it to update everything)
  94480. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  94481. * @returns this transform node
  94482. */
  94483. TransformNode.prototype.markAsDirty = function (property) {
  94484. this._currentRenderId = Number.MAX_VALUE;
  94485. this._isDirty = true;
  94486. return this;
  94487. };
  94488. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  94489. /**
  94490. * Returns the current mesh absolute position.
  94491. * Returns a Vector3.
  94492. */
  94493. get: function () {
  94494. return this._absolutePosition;
  94495. },
  94496. enumerable: true,
  94497. configurable: true
  94498. });
  94499. /**
  94500. * Sets a new matrix to apply before all other transformation
  94501. * @param matrix defines the transform matrix
  94502. * @returns the current TransformNode
  94503. */
  94504. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  94505. return this.setPivotMatrix(matrix, false);
  94506. };
  94507. /**
  94508. * Sets a new pivot matrix to the current node
  94509. * @param matrix defines the new pivot matrix to use
  94510. * @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
  94511. * @returns the current TransformNode
  94512. */
  94513. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  94514. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  94515. this._pivotMatrix.copyFrom(matrix);
  94516. if (this._pivotMatrix.isIdentity()) {
  94517. this._activeCompositionProcess = this._defaultCompositionProcessor;
  94518. }
  94519. else {
  94520. this._activeCompositionProcess = this._pivotCompositionProcessor;
  94521. }
  94522. this._cache.pivotMatrixUpdated = true;
  94523. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  94524. if (this._postMultiplyPivotMatrix) {
  94525. if (!this._pivotMatrixInverse) {
  94526. this._pivotMatrixInverse = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._pivotMatrix);
  94527. }
  94528. else {
  94529. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  94530. }
  94531. }
  94532. return this;
  94533. };
  94534. /**
  94535. * Returns the mesh pivot matrix.
  94536. * Default : Identity.
  94537. * @returns the matrix
  94538. */
  94539. TransformNode.prototype.getPivotMatrix = function () {
  94540. return this._pivotMatrix;
  94541. };
  94542. /**
  94543. * Prevents the World matrix to be computed any longer.
  94544. * @returns the TransformNode.
  94545. */
  94546. TransformNode.prototype.freezeWorldMatrix = function () {
  94547. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  94548. this.computeWorldMatrix(true);
  94549. this._isWorldMatrixFrozen = true;
  94550. return this;
  94551. };
  94552. /**
  94553. * Allows back the World matrix computation.
  94554. * @returns the TransformNode.
  94555. */
  94556. TransformNode.prototype.unfreezeWorldMatrix = function () {
  94557. this._isWorldMatrixFrozen = false;
  94558. this.computeWorldMatrix(true);
  94559. return this;
  94560. };
  94561. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  94562. /**
  94563. * True if the World matrix has been frozen.
  94564. */
  94565. get: function () {
  94566. return this._isWorldMatrixFrozen;
  94567. },
  94568. enumerable: true,
  94569. configurable: true
  94570. });
  94571. /**
  94572. * Retuns the mesh absolute position in the World.
  94573. * @returns a Vector3.
  94574. */
  94575. TransformNode.prototype.getAbsolutePosition = function () {
  94576. this.computeWorldMatrix();
  94577. return this._absolutePosition;
  94578. };
  94579. /**
  94580. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  94581. * @param absolutePosition the absolute position to set
  94582. * @returns the TransformNode.
  94583. */
  94584. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  94585. if (!absolutePosition) {
  94586. return this;
  94587. }
  94588. var absolutePositionX;
  94589. var absolutePositionY;
  94590. var absolutePositionZ;
  94591. if (absolutePosition.x === undefined) {
  94592. if (arguments.length < 3) {
  94593. return this;
  94594. }
  94595. absolutePositionX = arguments[0];
  94596. absolutePositionY = arguments[1];
  94597. absolutePositionZ = arguments[2];
  94598. }
  94599. else {
  94600. absolutePositionX = absolutePosition.x;
  94601. absolutePositionY = absolutePosition.y;
  94602. absolutePositionZ = absolutePosition.z;
  94603. }
  94604. if (this.parent) {
  94605. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94606. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  94607. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  94608. }
  94609. else {
  94610. this.position.x = absolutePositionX;
  94611. this.position.y = absolutePositionY;
  94612. this.position.z = absolutePositionZ;
  94613. }
  94614. return this;
  94615. };
  94616. /**
  94617. * Sets the mesh position in its local space.
  94618. * @param vector3 the position to set in localspace
  94619. * @returns the TransformNode.
  94620. */
  94621. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  94622. this.computeWorldMatrix();
  94623. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(vector3, this._localMatrix);
  94624. return this;
  94625. };
  94626. /**
  94627. * Returns the mesh position in the local space from the current World matrix values.
  94628. * @returns a new Vector3.
  94629. */
  94630. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  94631. this.computeWorldMatrix();
  94632. var invLocalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94633. this._localMatrix.invertToRef(invLocalWorldMatrix);
  94634. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  94635. };
  94636. /**
  94637. * Translates the mesh along the passed Vector3 in its local space.
  94638. * @param vector3 the distance to translate in localspace
  94639. * @returns the TransformNode.
  94640. */
  94641. TransformNode.prototype.locallyTranslate = function (vector3) {
  94642. this.computeWorldMatrix(true);
  94643. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  94644. return this;
  94645. };
  94646. /**
  94647. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  94648. * @param targetPoint the position (must be in same space as current mesh) to look at
  94649. * @param yawCor optional yaw (y-axis) correction in radians
  94650. * @param pitchCor optional pitch (x-axis) correction in radians
  94651. * @param rollCor optional roll (z-axis) correction in radians
  94652. * @param space the choosen space of the target
  94653. * @returns the TransformNode.
  94654. */
  94655. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  94656. if (yawCor === void 0) { yawCor = 0; }
  94657. if (pitchCor === void 0) { pitchCor = 0; }
  94658. if (rollCor === void 0) { rollCor = 0; }
  94659. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  94660. var dv = TransformNode._lookAtVectorCache;
  94661. var pos = space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  94662. targetPoint.subtractToRef(pos, dv);
  94663. this.setDirection(dv, yawCor, pitchCor, rollCor);
  94664. // Correct for parent's rotation offset
  94665. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD && this.parent) {
  94666. if (this.rotationQuaternion) {
  94667. // Get local rotation matrix of the looking object
  94668. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94669. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  94670. // Offset rotation by parent's inverted rotation matrix to correct in world space
  94671. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  94672. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  94673. parentRotationMatrix.invert();
  94674. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  94675. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  94676. }
  94677. else {
  94678. // Get local rotation matrix of the looking object
  94679. var quaternionRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  94680. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  94681. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94682. quaternionRotation.toRotationMatrix(rotationMatrix);
  94683. // Offset rotation by parent's inverted rotation matrix to correct in world space
  94684. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  94685. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  94686. parentRotationMatrix.invert();
  94687. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  94688. quaternionRotation.fromRotationMatrix(rotationMatrix);
  94689. quaternionRotation.toEulerAnglesToRef(this.rotation);
  94690. }
  94691. }
  94692. return this;
  94693. };
  94694. /**
  94695. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94696. * This Vector3 is expressed in the World space.
  94697. * @param localAxis axis to rotate
  94698. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  94699. */
  94700. TransformNode.prototype.getDirection = function (localAxis) {
  94701. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94702. this.getDirectionToRef(localAxis, result);
  94703. return result;
  94704. };
  94705. /**
  94706. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  94707. * localAxis is expressed in the mesh local space.
  94708. * result is computed in the Wordl space from the mesh World matrix.
  94709. * @param localAxis axis to rotate
  94710. * @param result the resulting transformnode
  94711. * @returns this TransformNode.
  94712. */
  94713. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  94714. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  94715. return this;
  94716. };
  94717. /**
  94718. * Sets this transform node rotation to the given local axis.
  94719. * @param localAxis the axis in local space
  94720. * @param yawCor optional yaw (y-axis) correction in radians
  94721. * @param pitchCor optional pitch (x-axis) correction in radians
  94722. * @param rollCor optional roll (z-axis) correction in radians
  94723. * @returns this TransformNode
  94724. */
  94725. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  94726. if (yawCor === void 0) { yawCor = 0; }
  94727. if (pitchCor === void 0) { pitchCor = 0; }
  94728. if (rollCor === void 0) { rollCor = 0; }
  94729. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  94730. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  94731. var pitch = -Math.atan2(localAxis.y, len);
  94732. if (this.rotationQuaternion) {
  94733. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  94734. }
  94735. else {
  94736. this.rotation.x = pitch + pitchCor;
  94737. this.rotation.y = yaw + yawCor;
  94738. this.rotation.z = rollCor;
  94739. }
  94740. return this;
  94741. };
  94742. /**
  94743. * Sets a new pivot point to the current node
  94744. * @param point defines the new pivot point to use
  94745. * @param space defines if the point is in world or local space (local by default)
  94746. * @returns the current TransformNode
  94747. */
  94748. TransformNode.prototype.setPivotPoint = function (point, space) {
  94749. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  94750. if (this.getScene().getRenderId() == 0) {
  94751. this.computeWorldMatrix(true);
  94752. }
  94753. var wm = this.getWorldMatrix();
  94754. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD) {
  94755. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94756. wm.invertToRef(tmat);
  94757. point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(point, tmat);
  94758. }
  94759. return this.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  94760. };
  94761. /**
  94762. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  94763. * @returns the pivot point
  94764. */
  94765. TransformNode.prototype.getPivotPoint = function () {
  94766. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94767. this.getPivotPointToRef(point);
  94768. return point;
  94769. };
  94770. /**
  94771. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  94772. * @param result the vector3 to store the result
  94773. * @returns this TransformNode.
  94774. */
  94775. TransformNode.prototype.getPivotPointToRef = function (result) {
  94776. result.x = -this._pivotMatrix.m[12];
  94777. result.y = -this._pivotMatrix.m[13];
  94778. result.z = -this._pivotMatrix.m[14];
  94779. return this;
  94780. };
  94781. /**
  94782. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  94783. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  94784. */
  94785. TransformNode.prototype.getAbsolutePivotPoint = function () {
  94786. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  94787. this.getAbsolutePivotPointToRef(point);
  94788. return point;
  94789. };
  94790. /**
  94791. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  94792. * @param result vector3 to store the result
  94793. * @returns this TransformNode.
  94794. */
  94795. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  94796. result.x = this._pivotMatrix.m[12];
  94797. result.y = this._pivotMatrix.m[13];
  94798. result.z = this._pivotMatrix.m[14];
  94799. this.getPivotPointToRef(result);
  94800. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  94801. return this;
  94802. };
  94803. /**
  94804. * Defines the passed node as the parent of the current node.
  94805. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  94806. * @see https://doc.babylonjs.com/how_to/parenting
  94807. * @param node the node ot set as the parent
  94808. * @returns this TransformNode.
  94809. */
  94810. TransformNode.prototype.setParent = function (node) {
  94811. if (!node && !this.parent) {
  94812. return this;
  94813. }
  94814. var quatRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  94815. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  94816. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  94817. if (!node) {
  94818. if (this.parent && this.parent.computeWorldMatrix) {
  94819. this.parent.computeWorldMatrix(true);
  94820. }
  94821. this.computeWorldMatrix(true);
  94822. this.getWorldMatrix().decompose(scale, quatRotation, position);
  94823. }
  94824. else {
  94825. var diffMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94826. var invParentMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  94827. this.computeWorldMatrix(true);
  94828. node.computeWorldMatrix(true);
  94829. node.getWorldMatrix().invertToRef(invParentMatrix);
  94830. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  94831. diffMatrix.decompose(scale, quatRotation, position);
  94832. }
  94833. if (this.rotationQuaternion) {
  94834. this.rotationQuaternion.copyFrom(quatRotation);
  94835. }
  94836. else {
  94837. quatRotation.toEulerAnglesToRef(this.rotation);
  94838. }
  94839. this.scaling.copyFrom(scale);
  94840. this.position.copyFrom(position);
  94841. this.parent = node;
  94842. return this;
  94843. };
  94844. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  94845. /**
  94846. * True if the scaling property of this object is non uniform eg. (1,2,1)
  94847. */
  94848. get: function () {
  94849. return this._nonUniformScaling;
  94850. },
  94851. enumerable: true,
  94852. configurable: true
  94853. });
  94854. /** @hidden */
  94855. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  94856. if (this._nonUniformScaling === value) {
  94857. return false;
  94858. }
  94859. this._nonUniformScaling = value;
  94860. return true;
  94861. };
  94862. /**
  94863. * Attach the current TransformNode to another TransformNode associated with a bone
  94864. * @param bone Bone affecting the TransformNode
  94865. * @param affectedTransformNode TransformNode associated with the bone
  94866. * @returns this object
  94867. */
  94868. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  94869. this._transformToBoneReferal = affectedTransformNode;
  94870. this.parent = bone;
  94871. if (bone.getWorldMatrix().determinant() < 0) {
  94872. this.scalingDeterminant *= -1;
  94873. }
  94874. return this;
  94875. };
  94876. /**
  94877. * Detach the transform node if its associated with a bone
  94878. * @returns this object
  94879. */
  94880. TransformNode.prototype.detachFromBone = function () {
  94881. if (!this.parent) {
  94882. return this;
  94883. }
  94884. if (this.parent.getWorldMatrix().determinant() < 0) {
  94885. this.scalingDeterminant *= -1;
  94886. }
  94887. this._transformToBoneReferal = null;
  94888. this.parent = null;
  94889. return this;
  94890. };
  94891. /**
  94892. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  94893. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94894. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94895. * The passed axis is also normalized.
  94896. * @param axis the axis to rotate around
  94897. * @param amount the amount to rotate in radians
  94898. * @param space Space to rotate in (Default: local)
  94899. * @returns the TransformNode.
  94900. */
  94901. TransformNode.prototype.rotate = function (axis, amount, space) {
  94902. axis.normalize();
  94903. if (!this.rotationQuaternion) {
  94904. this.rotationQuaternion = this.rotation.toQuaternion();
  94905. this.rotation.setAll(0);
  94906. }
  94907. var rotationQuaternion;
  94908. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  94909. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  94910. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  94911. }
  94912. else {
  94913. if (this.parent) {
  94914. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  94915. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  94916. axis = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  94917. }
  94918. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  94919. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  94920. }
  94921. return this;
  94922. };
  94923. /**
  94924. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  94925. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  94926. * The passed axis is also normalized. .
  94927. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  94928. * @param point the point to rotate around
  94929. * @param axis the axis to rotate around
  94930. * @param amount the amount to rotate in radians
  94931. * @returns the TransformNode
  94932. */
  94933. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  94934. axis.normalize();
  94935. if (!this.rotationQuaternion) {
  94936. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  94937. this.rotation.setAll(0);
  94938. }
  94939. var tmpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  94940. var finalScale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  94941. var finalTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[2];
  94942. var finalRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  94943. var translationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]; // T
  94944. var translationMatrixInv = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]; // T'
  94945. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]; // R
  94946. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[3]; // T' x R x T
  94947. point.subtractToRef(this.position, tmpVector);
  94948. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  94949. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  94950. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  94951. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  94952. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  94953. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  94954. this.position.addInPlace(finalTranslation);
  94955. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  94956. return this;
  94957. };
  94958. /**
  94959. * Translates the mesh along the axis vector for the passed distance in the given space.
  94960. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  94961. * @param axis the axis to translate in
  94962. * @param distance the distance to translate
  94963. * @param space Space to rotate in (Default: local)
  94964. * @returns the TransformNode.
  94965. */
  94966. TransformNode.prototype.translate = function (axis, distance, space) {
  94967. var displacementVector = axis.scale(distance);
  94968. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  94969. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  94970. this.setPositionWithLocalVector(tempV3);
  94971. }
  94972. else {
  94973. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  94974. }
  94975. return this;
  94976. };
  94977. /**
  94978. * Adds a rotation step to the mesh current rotation.
  94979. * x, y, z are Euler angles expressed in radians.
  94980. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  94981. * This means this rotation is made in the mesh local space only.
  94982. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  94983. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  94984. * ```javascript
  94985. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  94986. * ```
  94987. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  94988. * 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.
  94989. * @param x Rotation to add
  94990. * @param y Rotation to add
  94991. * @param z Rotation to add
  94992. * @returns the TransformNode.
  94993. */
  94994. TransformNode.prototype.addRotation = function (x, y, z) {
  94995. var rotationQuaternion;
  94996. if (this.rotationQuaternion) {
  94997. rotationQuaternion = this.rotationQuaternion;
  94998. }
  94999. else {
  95000. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[1];
  95001. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  95002. }
  95003. var accumulation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  95004. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  95005. rotationQuaternion.multiplyInPlace(accumulation);
  95006. if (!this.rotationQuaternion) {
  95007. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  95008. }
  95009. return this;
  95010. };
  95011. /**
  95012. * @hidden
  95013. */
  95014. TransformNode.prototype._getEffectiveParent = function () {
  95015. return this.parent;
  95016. };
  95017. /**
  95018. * Computes the world matrix of the node
  95019. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95020. * @returns the world matrix
  95021. */
  95022. TransformNode.prototype.computeWorldMatrix = function (force) {
  95023. var currentRenderId = this.getScene().getRenderId();
  95024. if (this._isWorldMatrixFrozen) {
  95025. return this._worldMatrix;
  95026. }
  95027. if (!this._isDirty && !force && this.isSynchronized()) {
  95028. this._currentRenderId = currentRenderId;
  95029. return this._worldMatrix;
  95030. }
  95031. this._updateCache();
  95032. this._cache.pivotMatrixUpdated = false;
  95033. this._cache.billboardMode = this.billboardMode;
  95034. this._cache.infiniteDistance = this.infiniteDistance;
  95035. this._currentRenderId = currentRenderId;
  95036. this._childUpdateId++;
  95037. this._isDirty = false;
  95038. var parent = this._getEffectiveParent();
  95039. // Scaling
  95040. var scaling = this._cache.scaling;
  95041. var translation = this._cache.position;
  95042. // Translation
  95043. var camera = this.getScene().activeCamera;
  95044. if (this.infiniteDistance && !this.parent && camera) {
  95045. var cameraWorldMatrix = camera.getWorldMatrix();
  95046. var cameraGlobalPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  95047. translation.copyFromFloats(this._position.x + cameraGlobalPosition.x, this._position.y + cameraGlobalPosition.y, this._position.z + cameraGlobalPosition.z);
  95048. }
  95049. else {
  95050. translation.copyFrom(this._position);
  95051. }
  95052. // Scaling
  95053. scaling.copyFromFloats(this._scaling.x * this.scalingDeterminant, this._scaling.y * this.scalingDeterminant, this._scaling.z * this.scalingDeterminant);
  95054. // Rotation
  95055. var rotation = this._cache.rotationQuaternion;
  95056. if (this._rotationQuaternion) {
  95057. if (this.reIntegrateRotationIntoRotationQuaternion) {
  95058. var len = this.rotation.lengthSquared();
  95059. if (len) {
  95060. this._rotationQuaternion.multiplyInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._rotation.y, this._rotation.x, this._rotation.z));
  95061. this._rotation.copyFromFloats(0, 0, 0);
  95062. }
  95063. }
  95064. rotation.copyFrom(this._rotationQuaternion);
  95065. }
  95066. else {
  95067. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this._rotation.y, this._rotation.x, this._rotation.z, rotation);
  95068. this._cache.rotation.copyFrom(this._rotation);
  95069. }
  95070. // Compose
  95071. this._activeCompositionProcess(scaling, rotation, translation);
  95072. // Parent
  95073. if (parent && parent.getWorldMatrix) {
  95074. this._activeParentProcessor(parent);
  95075. this._markSyncedWithParent();
  95076. }
  95077. else {
  95078. this._worldMatrix.copyFrom(this._localMatrix);
  95079. }
  95080. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  95081. this._activeBillboardPostProcessor();
  95082. // Normal matrix
  95083. if (!this.ignoreNonUniformScaling) {
  95084. if (this._scaling.isNonUniform) {
  95085. this._updateNonUniformScalingState(true);
  95086. }
  95087. else if (parent && parent._nonUniformScaling) {
  95088. this._updateNonUniformScalingState(parent._nonUniformScaling);
  95089. }
  95090. else {
  95091. this._updateNonUniformScalingState(false);
  95092. }
  95093. }
  95094. else {
  95095. this._updateNonUniformScalingState(false);
  95096. }
  95097. this._afterComputeWorldMatrix();
  95098. // Absolute position
  95099. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  95100. // Callbacks
  95101. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  95102. if (!this._poseMatrix) {
  95103. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._worldMatrix);
  95104. }
  95105. // Cache the determinant
  95106. this._worldMatrixDeterminantIsDirty = true;
  95107. return this._worldMatrix;
  95108. };
  95109. TransformNode.prototype._afterComputeWorldMatrix = function () {
  95110. };
  95111. /**
  95112. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95113. * @param func callback function to add
  95114. *
  95115. * @returns the TransformNode.
  95116. */
  95117. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  95118. this.onAfterWorldMatrixUpdateObservable.add(func);
  95119. return this;
  95120. };
  95121. /**
  95122. * Removes a registered callback function.
  95123. * @param func callback function to remove
  95124. * @returns the TransformNode.
  95125. */
  95126. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  95127. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  95128. return this;
  95129. };
  95130. /**
  95131. * Gets the position of the current mesh in camera space
  95132. * @param camera defines the camera to use
  95133. * @returns a position
  95134. */
  95135. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  95136. if (camera === void 0) { camera = null; }
  95137. if (!camera) {
  95138. camera = this.getScene().activeCamera;
  95139. }
  95140. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  95141. };
  95142. /**
  95143. * Returns the distance from the mesh to the active camera
  95144. * @param camera defines the camera to use
  95145. * @returns the distance
  95146. */
  95147. TransformNode.prototype.getDistanceToCamera = function (camera) {
  95148. if (camera === void 0) { camera = null; }
  95149. if (!camera) {
  95150. camera = this.getScene().activeCamera;
  95151. }
  95152. return this.absolutePosition.subtract(camera.globalPosition).length();
  95153. };
  95154. /**
  95155. * Clone the current transform node
  95156. * @param name Name of the new clone
  95157. * @param newParent New parent for the clone
  95158. * @param doNotCloneChildren Do not clone children hierarchy
  95159. * @returns the new transform node
  95160. */
  95161. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  95162. var _this = this;
  95163. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  95164. result.name = name;
  95165. result.id = name;
  95166. if (newParent) {
  95167. result.parent = newParent;
  95168. }
  95169. if (!doNotCloneChildren) {
  95170. // Children
  95171. var directDescendants = this.getDescendants(true);
  95172. for (var index = 0; index < directDescendants.length; index++) {
  95173. var child = directDescendants[index];
  95174. if (child.clone) {
  95175. child.clone(name + "." + child.name, result);
  95176. }
  95177. }
  95178. }
  95179. return result;
  95180. };
  95181. /**
  95182. * Serializes the objects information.
  95183. * @param currentSerializationObject defines the object to serialize in
  95184. * @returns the serialized object
  95185. */
  95186. TransformNode.prototype.serialize = function (currentSerializationObject) {
  95187. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  95188. serializationObject.type = this.getClassName();
  95189. // Parent
  95190. if (this.parent) {
  95191. serializationObject.parentId = this.parent.id;
  95192. }
  95193. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  95194. serializationObject.isEnabled = this.isEnabled();
  95195. // Parent
  95196. if (this.parent) {
  95197. serializationObject.parentId = this.parent.id;
  95198. }
  95199. return serializationObject;
  95200. };
  95201. // Statics
  95202. /**
  95203. * Returns a new TransformNode object parsed from the source provided.
  95204. * @param parsedTransformNode is the source.
  95205. * @param scene the scne the object belongs to
  95206. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95207. * @returns a new TransformNode object parsed from the source provided.
  95208. */
  95209. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  95210. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  95211. if (parsedTransformNode.localMatrix) {
  95212. transformNode.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  95213. }
  95214. else if (parsedTransformNode.pivotMatrix) {
  95215. transformNode.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  95216. }
  95217. transformNode.setEnabled(parsedTransformNode.isEnabled);
  95218. // Parent
  95219. if (parsedTransformNode.parentId) {
  95220. transformNode._waitingParentId = parsedTransformNode.parentId;
  95221. }
  95222. return transformNode;
  95223. };
  95224. /**
  95225. * Get all child-transformNodes of this node
  95226. * @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
  95227. * @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
  95228. * @returns an array of TransformNode
  95229. */
  95230. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  95231. var results = [];
  95232. this._getDescendants(results, directDescendantsOnly, function (node) {
  95233. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  95234. });
  95235. return results;
  95236. };
  95237. /**
  95238. * Releases resources associated with this transform node.
  95239. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95240. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95241. */
  95242. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  95243. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  95244. // Animations
  95245. this.getScene().stopAnimation(this);
  95246. // Remove from scene
  95247. this.getScene().removeTransformNode(this);
  95248. this.onAfterWorldMatrixUpdateObservable.clear();
  95249. if (doNotRecurse) {
  95250. var transformNodes = this.getChildTransformNodes(true);
  95251. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  95252. var transformNode = transformNodes_1[_i];
  95253. transformNode.parent = null;
  95254. transformNode.computeWorldMatrix(true);
  95255. }
  95256. }
  95257. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  95258. };
  95259. // Statics
  95260. /**
  95261. * Object will not rotate to face the camera
  95262. */
  95263. TransformNode.BILLBOARDMODE_NONE = 0;
  95264. /**
  95265. * Object will rotate to face the camera but only on the x axis
  95266. */
  95267. TransformNode.BILLBOARDMODE_X = 1;
  95268. /**
  95269. * Object will rotate to face the camera but only on the y axis
  95270. */
  95271. TransformNode.BILLBOARDMODE_Y = 2;
  95272. /**
  95273. * Object will rotate to face the camera but only on the z axis
  95274. */
  95275. TransformNode.BILLBOARDMODE_Z = 4;
  95276. /**
  95277. * Object will rotate to face the camera
  95278. */
  95279. TransformNode.BILLBOARDMODE_ALL = 7;
  95280. TransformNode._lookAtVectorCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  95281. TransformNode._rotationAxisCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  95282. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95283. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  95284. ], TransformNode.prototype, "_position", void 0);
  95285. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95286. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  95287. ], TransformNode.prototype, "_rotation", void 0);
  95288. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95289. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  95290. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  95291. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95292. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  95293. ], TransformNode.prototype, "_scaling", void 0);
  95294. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95295. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("billboardMode")
  95296. ], TransformNode.prototype, "_billboardMode", void 0);
  95297. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95298. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  95299. ], TransformNode.prototype, "scalingDeterminant", void 0);
  95300. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95301. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  95302. ], TransformNode.prototype, "infiniteDistance", void 0);
  95303. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95304. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  95305. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  95306. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  95307. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  95308. ], TransformNode.prototype, "reIntegrateRotationIntoRotationQuaternion", void 0);
  95309. return TransformNode;
  95310. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  95311. /***/ }),
  95312. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  95313. /*!***************************************************************!*\
  95314. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  95315. \***************************************************************/
  95316. /*! exports provided: CubeMapToSphericalPolynomialTools */
  95317. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95318. "use strict";
  95319. __webpack_require__.r(__webpack_exports__);
  95320. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  95321. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  95322. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  95323. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  95324. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  95325. var FileFaceOrientation = /** @class */ (function () {
  95326. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  95327. this.name = name;
  95328. this.worldAxisForNormal = worldAxisForNormal;
  95329. this.worldAxisForFileX = worldAxisForFileX;
  95330. this.worldAxisForFileY = worldAxisForFileY;
  95331. }
  95332. return FileFaceOrientation;
  95333. }());
  95334. /**
  95335. * Helper class dealing with the extraction of spherical polynomial dataArray
  95336. * from a cube map.
  95337. */
  95338. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  95339. function CubeMapToSphericalPolynomialTools() {
  95340. }
  95341. /**
  95342. * Converts a texture to the according Spherical Polynomial data.
  95343. * This extracts the first 3 orders only as they are the only one used in the lighting.
  95344. *
  95345. * @param texture The texture to extract the information from.
  95346. * @return The Spherical Polynomial data.
  95347. */
  95348. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  95349. if (!texture.isCube) {
  95350. // Only supports cube Textures currently.
  95351. return null;
  95352. }
  95353. var size = texture.getSize().width;
  95354. var right = texture.readPixels(0);
  95355. var left = texture.readPixels(1);
  95356. var up;
  95357. var down;
  95358. if (texture.isRenderTarget) {
  95359. up = texture.readPixels(3);
  95360. down = texture.readPixels(2);
  95361. }
  95362. else {
  95363. up = texture.readPixels(2);
  95364. down = texture.readPixels(3);
  95365. }
  95366. var front = texture.readPixels(4);
  95367. var back = texture.readPixels(5);
  95368. var gammaSpace = texture.gammaSpace;
  95369. // Always read as RGBA.
  95370. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  95371. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  95372. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  95373. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  95374. }
  95375. var cubeInfo = {
  95376. size: size,
  95377. right: right,
  95378. left: left,
  95379. up: up,
  95380. down: down,
  95381. front: front,
  95382. back: back,
  95383. format: format,
  95384. type: type,
  95385. gammaSpace: gammaSpace,
  95386. };
  95387. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  95388. };
  95389. /**
  95390. * Converts a cubemap to the according Spherical Polynomial data.
  95391. * This extracts the first 3 orders only as they are the only one used in the lighting.
  95392. *
  95393. * @param cubeInfo The Cube map to extract the information from.
  95394. * @return The Spherical Polynomial data.
  95395. */
  95396. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  95397. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  95398. var totalSolidAngle = 0.0;
  95399. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  95400. var du = 2.0 / cubeInfo.size;
  95401. var dv = du;
  95402. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  95403. var minUV = du * 0.5 - 1.0;
  95404. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  95405. var fileFace = this.FileFaces[faceIndex];
  95406. var dataArray = cubeInfo[fileFace.name];
  95407. var v = minUV;
  95408. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  95409. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  95410. // Because SP is still linear, so summation is fine in that basis.
  95411. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  95412. for (var y = 0; y < cubeInfo.size; y++) {
  95413. var u = minUV;
  95414. for (var x = 0; x < cubeInfo.size; x++) {
  95415. // World direction (not normalised)
  95416. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  95417. worldDirection.normalize();
  95418. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  95419. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  95420. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  95421. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  95422. // Handle Integer types.
  95423. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  95424. r /= 255;
  95425. g /= 255;
  95426. b /= 255;
  95427. }
  95428. // Handle Gamma space textures.
  95429. if (cubeInfo.gammaSpace) {
  95430. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  95431. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  95432. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  95433. }
  95434. var color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](r, g, b);
  95435. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  95436. totalSolidAngle += deltaSolidAngle;
  95437. u += du;
  95438. }
  95439. v += dv;
  95440. }
  95441. }
  95442. // Solid angle for entire sphere is 4*pi
  95443. var sphereSolidAngle = 4.0 * Math.PI;
  95444. // Adjust the solid angle to allow for how many faces we processed.
  95445. var facesProcessed = 6.0;
  95446. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  95447. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  95448. // This is needed because the numerical integration over the cube uses a
  95449. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  95450. // and also to compensate for accumulative error due to float precision in the summation.
  95451. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  95452. sphericalHarmonics.scale(correctionFactor);
  95453. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  95454. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  95455. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  95456. };
  95457. CubeMapToSphericalPolynomialTools.FileFaces = [
  95458. 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)),
  95459. 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)),
  95460. 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)),
  95461. 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)),
  95462. 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)),
  95463. 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
  95464. ];
  95465. return CubeMapToSphericalPolynomialTools;
  95466. }());
  95467. /***/ }),
  95468. /***/ "./Misc/HighDynamicRange/hdr.ts":
  95469. /*!**************************************!*\
  95470. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  95471. \**************************************/
  95472. /*! exports provided: HDRTools */
  95473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95474. "use strict";
  95475. __webpack_require__.r(__webpack_exports__);
  95476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  95477. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  95478. /**
  95479. * This groups tools to convert HDR texture to native colors array.
  95480. */
  95481. var HDRTools = /** @class */ (function () {
  95482. function HDRTools() {
  95483. }
  95484. HDRTools.Ldexp = function (mantissa, exponent) {
  95485. if (exponent > 1023) {
  95486. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  95487. }
  95488. if (exponent < -1074) {
  95489. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  95490. }
  95491. return mantissa * Math.pow(2, exponent);
  95492. };
  95493. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  95494. if (exponent > 0) { /*nonzero pixel*/
  95495. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  95496. float32array[index + 0] = red * exponent;
  95497. float32array[index + 1] = green * exponent;
  95498. float32array[index + 2] = blue * exponent;
  95499. }
  95500. else {
  95501. float32array[index + 0] = 0;
  95502. float32array[index + 1] = 0;
  95503. float32array[index + 2] = 0;
  95504. }
  95505. };
  95506. HDRTools.readStringLine = function (uint8array, startIndex) {
  95507. var line = "";
  95508. var character = "";
  95509. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  95510. character = String.fromCharCode(uint8array[i]);
  95511. if (character == "\n") {
  95512. break;
  95513. }
  95514. line += character;
  95515. }
  95516. return line;
  95517. };
  95518. /**
  95519. * Reads header information from an RGBE texture stored in a native array.
  95520. * More information on this format are available here:
  95521. * https://en.wikipedia.org/wiki/RGBE_image_format
  95522. *
  95523. * @param uint8array The binary file stored in native array.
  95524. * @return The header information.
  95525. */
  95526. HDRTools.RGBE_ReadHeader = function (uint8array) {
  95527. var height = 0;
  95528. var width = 0;
  95529. var line = this.readStringLine(uint8array, 0);
  95530. if (line[0] != '#' || line[1] != '?') {
  95531. throw "Bad HDR Format.";
  95532. }
  95533. var endOfHeader = false;
  95534. var findFormat = false;
  95535. var lineIndex = 0;
  95536. do {
  95537. lineIndex += (line.length + 1);
  95538. line = this.readStringLine(uint8array, lineIndex);
  95539. if (line == "FORMAT=32-bit_rle_rgbe") {
  95540. findFormat = true;
  95541. }
  95542. else if (line.length == 0) {
  95543. endOfHeader = true;
  95544. }
  95545. } while (!endOfHeader);
  95546. if (!findFormat) {
  95547. throw "HDR Bad header format, unsupported FORMAT";
  95548. }
  95549. lineIndex += (line.length + 1);
  95550. line = this.readStringLine(uint8array, lineIndex);
  95551. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  95552. var match = sizeRegexp.exec(line);
  95553. // TODO. Support +Y and -X if needed.
  95554. if (!match || match.length < 3) {
  95555. throw "HDR Bad header format, no size";
  95556. }
  95557. width = parseInt(match[2]);
  95558. height = parseInt(match[1]);
  95559. if (width < 8 || width > 0x7fff) {
  95560. throw "HDR Bad header format, unsupported size";
  95561. }
  95562. lineIndex += (line.length + 1);
  95563. return {
  95564. height: height,
  95565. width: width,
  95566. dataPosition: lineIndex
  95567. };
  95568. };
  95569. /**
  95570. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  95571. * This RGBE texture needs to store the information as a panorama.
  95572. *
  95573. * More information on this format are available here:
  95574. * https://en.wikipedia.org/wiki/RGBE_image_format
  95575. *
  95576. * @param buffer The binary file stored in an array buffer.
  95577. * @param size The expected size of the extracted cubemap.
  95578. * @return The Cube Map information.
  95579. */
  95580. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  95581. var uint8array = new Uint8Array(buffer);
  95582. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  95583. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  95584. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  95585. return cubeMapData;
  95586. };
  95587. /**
  95588. * Returns the pixels data extracted from an RGBE texture.
  95589. * This pixels will be stored left to right up to down in the R G B order in one array.
  95590. *
  95591. * More information on this format are available here:
  95592. * https://en.wikipedia.org/wiki/RGBE_image_format
  95593. *
  95594. * @param uint8array The binary file stored in an array buffer.
  95595. * @param hdrInfo The header information of the file.
  95596. * @return The pixels data in RGB right to left up to down order.
  95597. */
  95598. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  95599. // Keep for multi format supports.
  95600. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  95601. };
  95602. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  95603. var num_scanlines = hdrInfo.height;
  95604. var scanline_width = hdrInfo.width;
  95605. var a, b, c, d, count;
  95606. var dataIndex = hdrInfo.dataPosition;
  95607. var index = 0, endIndex = 0, i = 0;
  95608. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  95609. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  95610. // 3 channels of 4 bytes per pixel in float.
  95611. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  95612. var resultArray = new Float32Array(resultBuffer);
  95613. // read in each successive scanline
  95614. while (num_scanlines > 0) {
  95615. a = uint8array[dataIndex++];
  95616. b = uint8array[dataIndex++];
  95617. c = uint8array[dataIndex++];
  95618. d = uint8array[dataIndex++];
  95619. if (a != 2 || b != 2 || (c & 0x80)) {
  95620. // this file is not run length encoded
  95621. throw "HDR Bad header format, not RLE";
  95622. }
  95623. if (((c << 8) | d) != scanline_width) {
  95624. throw "HDR Bad header format, wrong scan line width";
  95625. }
  95626. index = 0;
  95627. // read each of the four channels for the scanline into the buffer
  95628. for (i = 0; i < 4; i++) {
  95629. endIndex = (i + 1) * scanline_width;
  95630. while (index < endIndex) {
  95631. a = uint8array[dataIndex++];
  95632. b = uint8array[dataIndex++];
  95633. if (a > 128) {
  95634. // a run of the same value
  95635. count = a - 128;
  95636. if ((count == 0) || (count > endIndex - index)) {
  95637. throw "HDR Bad Format, bad scanline data (run)";
  95638. }
  95639. while (count-- > 0) {
  95640. scanLineArray[index++] = b;
  95641. }
  95642. }
  95643. else {
  95644. // a non-run
  95645. count = a;
  95646. if ((count == 0) || (count > endIndex - index)) {
  95647. throw "HDR Bad Format, bad scanline data (non-run)";
  95648. }
  95649. scanLineArray[index++] = b;
  95650. if (--count > 0) {
  95651. for (var j = 0; j < count; j++) {
  95652. scanLineArray[index++] = uint8array[dataIndex++];
  95653. }
  95654. }
  95655. }
  95656. }
  95657. }
  95658. // now convert data from buffer into floats
  95659. for (i = 0; i < scanline_width; i++) {
  95660. a = scanLineArray[i];
  95661. b = scanLineArray[i + scanline_width];
  95662. c = scanLineArray[i + 2 * scanline_width];
  95663. d = scanLineArray[i + 3 * scanline_width];
  95664. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  95665. }
  95666. num_scanlines--;
  95667. }
  95668. return resultArray;
  95669. };
  95670. return HDRTools;
  95671. }());
  95672. /***/ }),
  95673. /***/ "./Misc/HighDynamicRange/index.ts":
  95674. /*!****************************************!*\
  95675. !*** ./Misc/HighDynamicRange/index.ts ***!
  95676. \****************************************/
  95677. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  95678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95679. "use strict";
  95680. __webpack_require__.r(__webpack_exports__);
  95681. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  95682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  95683. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  95684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  95685. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  95686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  95687. /***/ }),
  95688. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  95689. /*!****************************************************!*\
  95690. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  95691. \****************************************************/
  95692. /*! exports provided: PanoramaToCubeMapTools */
  95693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95694. "use strict";
  95695. __webpack_require__.r(__webpack_exports__);
  95696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  95697. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  95698. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  95699. /**
  95700. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  95701. */
  95702. var PanoramaToCubeMapTools = /** @class */ (function () {
  95703. function PanoramaToCubeMapTools() {
  95704. }
  95705. /**
  95706. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  95707. *
  95708. * @param float32Array The source data.
  95709. * @param inputWidth The width of the input panorama.
  95710. * @param inputHeight The height of the input panorama.
  95711. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  95712. * @return The cubemap data
  95713. */
  95714. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  95715. if (!float32Array) {
  95716. throw "ConvertPanoramaToCubemap: input cannot be null";
  95717. }
  95718. if (float32Array.length != inputWidth * inputHeight * 3) {
  95719. throw "ConvertPanoramaToCubemap: input size is wrong";
  95720. }
  95721. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  95722. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  95723. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  95724. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  95725. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  95726. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  95727. return {
  95728. front: textureFront,
  95729. back: textureBack,
  95730. left: textureLeft,
  95731. right: textureRight,
  95732. up: textureUp,
  95733. down: textureDown,
  95734. size: size,
  95735. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  95736. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  95737. gammaSpace: false,
  95738. };
  95739. };
  95740. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  95741. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  95742. var textureArray = new Float32Array(buffer);
  95743. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  95744. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  95745. var dy = 1 / texSize;
  95746. var fy = 0;
  95747. for (var y = 0; y < texSize; y++) {
  95748. var xv1 = faceData[0];
  95749. var xv2 = faceData[2];
  95750. for (var x = 0; x < texSize; x++) {
  95751. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  95752. v.normalize();
  95753. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  95754. // 3 channels per pixels
  95755. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  95756. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  95757. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  95758. xv1 = xv1.add(rotDX1);
  95759. xv2 = xv2.add(rotDX2);
  95760. }
  95761. fy += dy;
  95762. }
  95763. return textureArray;
  95764. };
  95765. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  95766. var theta = Math.atan2(vDir.z, vDir.x);
  95767. var phi = Math.acos(vDir.y);
  95768. while (theta < -Math.PI) {
  95769. theta += 2 * Math.PI;
  95770. }
  95771. while (theta > Math.PI) {
  95772. theta -= 2 * Math.PI;
  95773. }
  95774. var dx = theta / Math.PI;
  95775. var dy = phi / Math.PI;
  95776. // recenter.
  95777. dx = dx * 0.5 + 0.5;
  95778. var px = Math.round(dx * inputWidth);
  95779. if (px < 0) {
  95780. px = 0;
  95781. }
  95782. else if (px >= inputWidth) {
  95783. px = inputWidth - 1;
  95784. }
  95785. var py = Math.round(dy * inputHeight);
  95786. if (py < 0) {
  95787. py = 0;
  95788. }
  95789. else if (py >= inputHeight) {
  95790. py = inputHeight - 1;
  95791. }
  95792. var inputY = (inputHeight - py - 1);
  95793. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  95794. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  95795. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  95796. return {
  95797. r: r,
  95798. g: g,
  95799. b: b
  95800. };
  95801. };
  95802. PanoramaToCubeMapTools.FACE_FRONT = [
  95803. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  95804. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  95805. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  95806. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  95807. ];
  95808. PanoramaToCubeMapTools.FACE_BACK = [
  95809. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  95810. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  95811. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  95812. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  95813. ];
  95814. PanoramaToCubeMapTools.FACE_RIGHT = [
  95815. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  95816. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  95817. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  95818. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  95819. ];
  95820. PanoramaToCubeMapTools.FACE_LEFT = [
  95821. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  95822. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  95823. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  95824. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  95825. ];
  95826. PanoramaToCubeMapTools.FACE_DOWN = [
  95827. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  95828. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  95829. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  95830. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  95831. ];
  95832. PanoramaToCubeMapTools.FACE_UP = [
  95833. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  95834. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  95835. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  95836. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  95837. ];
  95838. return PanoramaToCubeMapTools;
  95839. }());
  95840. /***/ }),
  95841. /***/ "./Misc/andOrNotEvaluator.ts":
  95842. /*!***********************************!*\
  95843. !*** ./Misc/andOrNotEvaluator.ts ***!
  95844. \***********************************/
  95845. /*! exports provided: AndOrNotEvaluator */
  95846. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95847. "use strict";
  95848. __webpack_require__.r(__webpack_exports__);
  95849. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  95850. /**
  95851. * Class used to evalaute queries containing `and` and `or` operators
  95852. */
  95853. var AndOrNotEvaluator = /** @class */ (function () {
  95854. function AndOrNotEvaluator() {
  95855. }
  95856. /**
  95857. * Evaluate a query
  95858. * @param query defines the query to evaluate
  95859. * @param evaluateCallback defines the callback used to filter result
  95860. * @returns true if the query matches
  95861. */
  95862. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  95863. if (!query.match(/\([^\(\)]*\)/g)) {
  95864. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  95865. }
  95866. else {
  95867. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  95868. // remove parenthesis
  95869. r = r.slice(1, r.length - 1);
  95870. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  95871. });
  95872. }
  95873. if (query === "true") {
  95874. return true;
  95875. }
  95876. if (query === "false") {
  95877. return false;
  95878. }
  95879. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  95880. };
  95881. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  95882. evaluateCallback = evaluateCallback || (function (r) {
  95883. return r === "true" ? true : false;
  95884. });
  95885. var result;
  95886. var or = parenthesisContent.split("||");
  95887. for (var i in or) {
  95888. if (or.hasOwnProperty(i)) {
  95889. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  95890. var and = ori.split("&&");
  95891. if (and.length > 1) {
  95892. for (var j = 0; j < and.length; ++j) {
  95893. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  95894. if (andj !== "true" && andj !== "false") {
  95895. if (andj[0] === "!") {
  95896. result = !evaluateCallback(andj.substring(1));
  95897. }
  95898. else {
  95899. result = evaluateCallback(andj);
  95900. }
  95901. }
  95902. else {
  95903. result = andj === "true" ? true : false;
  95904. }
  95905. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  95906. ori = "false";
  95907. break;
  95908. }
  95909. }
  95910. }
  95911. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  95912. result = true;
  95913. break;
  95914. }
  95915. // result equals false (or undefined)
  95916. if (ori !== "true" && ori !== "false") {
  95917. if (ori[0] === "!") {
  95918. result = !evaluateCallback(ori.substring(1));
  95919. }
  95920. else {
  95921. result = evaluateCallback(ori);
  95922. }
  95923. }
  95924. else {
  95925. result = ori === "true" ? true : false;
  95926. }
  95927. }
  95928. }
  95929. // the whole parenthesis scope is replaced by 'true' or 'false'
  95930. return result ? "true" : "false";
  95931. };
  95932. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  95933. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  95934. // remove whitespaces
  95935. r = r.replace(/[\s]/g, function () { return ""; });
  95936. return r.length % 2 ? "!" : "";
  95937. });
  95938. booleanString = booleanString.trim();
  95939. if (booleanString === "!true") {
  95940. booleanString = "false";
  95941. }
  95942. else if (booleanString === "!false") {
  95943. booleanString = "true";
  95944. }
  95945. return booleanString;
  95946. };
  95947. return AndOrNotEvaluator;
  95948. }());
  95949. /***/ }),
  95950. /***/ "./Misc/arrayTools.ts":
  95951. /*!****************************!*\
  95952. !*** ./Misc/arrayTools.ts ***!
  95953. \****************************/
  95954. /*! exports provided: ArrayTools */
  95955. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95956. "use strict";
  95957. __webpack_require__.r(__webpack_exports__);
  95958. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  95959. /**
  95960. * Class containing a set of static utilities functions for arrays.
  95961. */
  95962. var ArrayTools = /** @class */ (function () {
  95963. function ArrayTools() {
  95964. }
  95965. /**
  95966. * Returns an array of the given size filled with element built from the given constructor and the paramters
  95967. * @param size the number of element to construct and put in the array
  95968. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  95969. * @returns a new array filled with new objects
  95970. */
  95971. ArrayTools.BuildArray = function (size, itemBuilder) {
  95972. var a = [];
  95973. for (var i = 0; i < size; ++i) {
  95974. a.push(itemBuilder());
  95975. }
  95976. return a;
  95977. };
  95978. return ArrayTools;
  95979. }());
  95980. /***/ }),
  95981. /***/ "./Misc/assetsManager.ts":
  95982. /*!*******************************!*\
  95983. !*** ./Misc/assetsManager.ts ***!
  95984. \*******************************/
  95985. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, EquiRectangularCubeTextureAssetTask, AssetsManager */
  95986. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95987. "use strict";
  95988. __webpack_require__.r(__webpack_exports__);
  95989. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  95990. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  95991. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  95992. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  95993. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  95994. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  95995. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  95996. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  95997. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  95998. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  95999. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return EquiRectangularCubeTextureAssetTask; });
  96000. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  96001. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  96002. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  96003. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  96004. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  96005. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  96006. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  96007. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  96008. /* harmony import */ var _Materials_Textures_equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/equiRectangularCubeTexture */ "./Materials/Textures/equiRectangularCubeTexture.ts");
  96009. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  96010. /**
  96011. * Defines the list of states available for a task inside a AssetsManager
  96012. */
  96013. var AssetTaskState;
  96014. (function (AssetTaskState) {
  96015. /**
  96016. * Initialization
  96017. */
  96018. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  96019. /**
  96020. * Running
  96021. */
  96022. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  96023. /**
  96024. * Done
  96025. */
  96026. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  96027. /**
  96028. * Error
  96029. */
  96030. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  96031. })(AssetTaskState || (AssetTaskState = {}));
  96032. /**
  96033. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  96034. */
  96035. var AbstractAssetTask = /** @class */ (function () {
  96036. /**
  96037. * Creates a new AssetsManager
  96038. * @param name defines the name of the task
  96039. */
  96040. function AbstractAssetTask(
  96041. /**
  96042. * Task name
  96043. */ name) {
  96044. this.name = name;
  96045. this._isCompleted = false;
  96046. this._taskState = AssetTaskState.INIT;
  96047. }
  96048. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  96049. /**
  96050. * Get if the task is completed
  96051. */
  96052. get: function () {
  96053. return this._isCompleted;
  96054. },
  96055. enumerable: true,
  96056. configurable: true
  96057. });
  96058. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  96059. /**
  96060. * Gets the current state of the task
  96061. */
  96062. get: function () {
  96063. return this._taskState;
  96064. },
  96065. enumerable: true,
  96066. configurable: true
  96067. });
  96068. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  96069. /**
  96070. * Gets the current error object (if task is in error)
  96071. */
  96072. get: function () {
  96073. return this._errorObject;
  96074. },
  96075. enumerable: true,
  96076. configurable: true
  96077. });
  96078. /**
  96079. * Internal only
  96080. * @hidden
  96081. */
  96082. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  96083. if (this._errorObject) {
  96084. return;
  96085. }
  96086. this._errorObject = {
  96087. message: message,
  96088. exception: exception
  96089. };
  96090. };
  96091. /**
  96092. * Execute the current task
  96093. * @param scene defines the scene where you want your assets to be loaded
  96094. * @param onSuccess is a callback called when the task is successfully executed
  96095. * @param onError is a callback called if an error occurs
  96096. */
  96097. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  96098. var _this = this;
  96099. this._taskState = AssetTaskState.RUNNING;
  96100. this.runTask(scene, function () {
  96101. _this.onDoneCallback(onSuccess, onError);
  96102. }, function (msg, exception) {
  96103. _this.onErrorCallback(onError, msg, exception);
  96104. });
  96105. };
  96106. /**
  96107. * Execute the current task
  96108. * @param scene defines the scene where you want your assets to be loaded
  96109. * @param onSuccess is a callback called when the task is successfully executed
  96110. * @param onError is a callback called if an error occurs
  96111. */
  96112. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96113. throw new Error("runTask is not implemented");
  96114. };
  96115. /**
  96116. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  96117. * This can be used with failed tasks that have the reason for failure fixed.
  96118. */
  96119. AbstractAssetTask.prototype.reset = function () {
  96120. this._taskState = AssetTaskState.INIT;
  96121. };
  96122. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  96123. this._taskState = AssetTaskState.ERROR;
  96124. this._errorObject = {
  96125. message: message,
  96126. exception: exception
  96127. };
  96128. if (this.onError) {
  96129. this.onError(this, message, exception);
  96130. }
  96131. onError();
  96132. };
  96133. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  96134. try {
  96135. this._taskState = AssetTaskState.DONE;
  96136. this._isCompleted = true;
  96137. if (this.onSuccess) {
  96138. this.onSuccess(this);
  96139. }
  96140. onSuccess();
  96141. }
  96142. catch (e) {
  96143. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  96144. }
  96145. };
  96146. return AbstractAssetTask;
  96147. }());
  96148. /**
  96149. * Class used to share progress information about assets loading
  96150. */
  96151. var AssetsProgressEvent = /** @class */ (function () {
  96152. /**
  96153. * Creates a AssetsProgressEvent
  96154. * @param remainingCount defines the number of remaining tasks to process
  96155. * @param totalCount defines the total number of tasks
  96156. * @param task defines the task that was just processed
  96157. */
  96158. function AssetsProgressEvent(remainingCount, totalCount, task) {
  96159. this.remainingCount = remainingCount;
  96160. this.totalCount = totalCount;
  96161. this.task = task;
  96162. }
  96163. return AssetsProgressEvent;
  96164. }());
  96165. /**
  96166. * Define a task used by AssetsManager to load meshes
  96167. */
  96168. var MeshAssetTask = /** @class */ (function (_super) {
  96169. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  96170. /**
  96171. * Creates a new MeshAssetTask
  96172. * @param name defines the name of the task
  96173. * @param meshesNames defines the list of mesh's names you want to load
  96174. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  96175. * @param sceneFilename defines the filename of the scene to load from
  96176. */
  96177. function MeshAssetTask(
  96178. /**
  96179. * Defines the name of the task
  96180. */
  96181. name,
  96182. /**
  96183. * Defines the list of mesh's names you want to load
  96184. */
  96185. meshesNames,
  96186. /**
  96187. * Defines the root url to use as a base to load your meshes and associated resources
  96188. */
  96189. rootUrl,
  96190. /**
  96191. * Defines the filename of the scene to load from
  96192. */
  96193. sceneFilename) {
  96194. var _this = _super.call(this, name) || this;
  96195. _this.name = name;
  96196. _this.meshesNames = meshesNames;
  96197. _this.rootUrl = rootUrl;
  96198. _this.sceneFilename = sceneFilename;
  96199. return _this;
  96200. }
  96201. /**
  96202. * Execute the current task
  96203. * @param scene defines the scene where you want your assets to be loaded
  96204. * @param onSuccess is a callback called when the task is successfully executed
  96205. * @param onError is a callback called if an error occurs
  96206. */
  96207. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96208. var _this = this;
  96209. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  96210. _this.loadedMeshes = meshes;
  96211. _this.loadedParticleSystems = particleSystems;
  96212. _this.loadedSkeletons = skeletons;
  96213. _this.loadedAnimationGroups = animationGroups;
  96214. onSuccess();
  96215. }, null, function (scene, message, exception) {
  96216. onError(message, exception);
  96217. });
  96218. };
  96219. return MeshAssetTask;
  96220. }(AbstractAssetTask));
  96221. /**
  96222. * Define a task used by AssetsManager to load text content
  96223. */
  96224. var TextFileAssetTask = /** @class */ (function (_super) {
  96225. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  96226. /**
  96227. * Creates a new TextFileAssetTask object
  96228. * @param name defines the name of the task
  96229. * @param url defines the location of the file to load
  96230. */
  96231. function TextFileAssetTask(
  96232. /**
  96233. * Defines the name of the task
  96234. */
  96235. name,
  96236. /**
  96237. * Defines the location of the file to load
  96238. */
  96239. url) {
  96240. var _this = _super.call(this, name) || this;
  96241. _this.name = name;
  96242. _this.url = url;
  96243. return _this;
  96244. }
  96245. /**
  96246. * Execute the current task
  96247. * @param scene defines the scene where you want your assets to be loaded
  96248. * @param onSuccess is a callback called when the task is successfully executed
  96249. * @param onError is a callback called if an error occurs
  96250. */
  96251. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96252. var _this = this;
  96253. scene._loadFile(this.url, function (data) {
  96254. _this.text = data;
  96255. onSuccess();
  96256. }, undefined, false, false, function (request, exception) {
  96257. if (request) {
  96258. onError(request.status + " " + request.statusText, exception);
  96259. }
  96260. });
  96261. };
  96262. return TextFileAssetTask;
  96263. }(AbstractAssetTask));
  96264. /**
  96265. * Define a task used by AssetsManager to load binary data
  96266. */
  96267. var BinaryFileAssetTask = /** @class */ (function (_super) {
  96268. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  96269. /**
  96270. * Creates a new BinaryFileAssetTask object
  96271. * @param name defines the name of the new task
  96272. * @param url defines the location of the file to load
  96273. */
  96274. function BinaryFileAssetTask(
  96275. /**
  96276. * Defines the name of the task
  96277. */
  96278. name,
  96279. /**
  96280. * Defines the location of the file to load
  96281. */
  96282. url) {
  96283. var _this = _super.call(this, name) || this;
  96284. _this.name = name;
  96285. _this.url = url;
  96286. return _this;
  96287. }
  96288. /**
  96289. * Execute the current task
  96290. * @param scene defines the scene where you want your assets to be loaded
  96291. * @param onSuccess is a callback called when the task is successfully executed
  96292. * @param onError is a callback called if an error occurs
  96293. */
  96294. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96295. var _this = this;
  96296. scene._loadFile(this.url, function (data) {
  96297. _this.data = data;
  96298. onSuccess();
  96299. }, undefined, true, true, function (request, exception) {
  96300. if (request) {
  96301. onError(request.status + " " + request.statusText, exception);
  96302. }
  96303. });
  96304. };
  96305. return BinaryFileAssetTask;
  96306. }(AbstractAssetTask));
  96307. /**
  96308. * Define a task used by AssetsManager to load images
  96309. */
  96310. var ImageAssetTask = /** @class */ (function (_super) {
  96311. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  96312. /**
  96313. * Creates a new ImageAssetTask
  96314. * @param name defines the name of the task
  96315. * @param url defines the location of the image to load
  96316. */
  96317. function ImageAssetTask(
  96318. /**
  96319. * Defines the name of the task
  96320. */
  96321. name,
  96322. /**
  96323. * Defines the location of the image to load
  96324. */
  96325. url) {
  96326. var _this = _super.call(this, name) || this;
  96327. _this.name = name;
  96328. _this.url = url;
  96329. return _this;
  96330. }
  96331. /**
  96332. * Execute the current task
  96333. * @param scene defines the scene where you want your assets to be loaded
  96334. * @param onSuccess is a callback called when the task is successfully executed
  96335. * @param onError is a callback called if an error occurs
  96336. */
  96337. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96338. var _this = this;
  96339. var img = new Image();
  96340. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  96341. img.onload = function () {
  96342. _this.image = img;
  96343. onSuccess();
  96344. };
  96345. img.onerror = function (err) {
  96346. onError("Error loading image", err);
  96347. };
  96348. img.src = this.url;
  96349. };
  96350. return ImageAssetTask;
  96351. }(AbstractAssetTask));
  96352. /**
  96353. * Define a task used by AssetsManager to load 2D textures
  96354. */
  96355. var TextureAssetTask = /** @class */ (function (_super) {
  96356. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  96357. /**
  96358. * Creates a new TextureAssetTask object
  96359. * @param name defines the name of the task
  96360. * @param url defines the location of the file to load
  96361. * @param noMipmap defines if mipmap should not be generated (default is false)
  96362. * @param invertY defines if texture must be inverted on Y axis (default is false)
  96363. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  96364. */
  96365. function TextureAssetTask(
  96366. /**
  96367. * Defines the name of the task
  96368. */
  96369. name,
  96370. /**
  96371. * Defines the location of the file to load
  96372. */
  96373. url,
  96374. /**
  96375. * Defines if mipmap should not be generated (default is false)
  96376. */
  96377. noMipmap,
  96378. /**
  96379. * Defines if texture must be inverted on Y axis (default is false)
  96380. */
  96381. invertY,
  96382. /**
  96383. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  96384. */
  96385. samplingMode) {
  96386. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  96387. var _this = _super.call(this, name) || this;
  96388. _this.name = name;
  96389. _this.url = url;
  96390. _this.noMipmap = noMipmap;
  96391. _this.invertY = invertY;
  96392. _this.samplingMode = samplingMode;
  96393. return _this;
  96394. }
  96395. /**
  96396. * Execute the current task
  96397. * @param scene defines the scene where you want your assets to be loaded
  96398. * @param onSuccess is a callback called when the task is successfully executed
  96399. * @param onError is a callback called if an error occurs
  96400. */
  96401. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96402. var onload = function () {
  96403. onSuccess();
  96404. };
  96405. var onerror = function (message, exception) {
  96406. onError(message, exception);
  96407. };
  96408. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  96409. };
  96410. return TextureAssetTask;
  96411. }(AbstractAssetTask));
  96412. /**
  96413. * Define a task used by AssetsManager to load cube textures
  96414. */
  96415. var CubeTextureAssetTask = /** @class */ (function (_super) {
  96416. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  96417. /**
  96418. * Creates a new CubeTextureAssetTask
  96419. * @param name defines the name of the task
  96420. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  96421. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  96422. * @param noMipmap defines if mipmaps should not be generated (default is false)
  96423. * @param files defines the explicit list of files (undefined by default)
  96424. */
  96425. function CubeTextureAssetTask(
  96426. /**
  96427. * Defines the name of the task
  96428. */
  96429. name,
  96430. /**
  96431. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  96432. */
  96433. url,
  96434. /**
  96435. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  96436. */
  96437. extensions,
  96438. /**
  96439. * Defines if mipmaps should not be generated (default is false)
  96440. */
  96441. noMipmap,
  96442. /**
  96443. * Defines the explicit list of files (undefined by default)
  96444. */
  96445. files) {
  96446. var _this = _super.call(this, name) || this;
  96447. _this.name = name;
  96448. _this.url = url;
  96449. _this.extensions = extensions;
  96450. _this.noMipmap = noMipmap;
  96451. _this.files = files;
  96452. return _this;
  96453. }
  96454. /**
  96455. * Execute the current task
  96456. * @param scene defines the scene where you want your assets to be loaded
  96457. * @param onSuccess is a callback called when the task is successfully executed
  96458. * @param onError is a callback called if an error occurs
  96459. */
  96460. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96461. var onload = function () {
  96462. onSuccess();
  96463. };
  96464. var onerror = function (message, exception) {
  96465. onError(message, exception);
  96466. };
  96467. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  96468. };
  96469. return CubeTextureAssetTask;
  96470. }(AbstractAssetTask));
  96471. /**
  96472. * Define a task used by AssetsManager to load HDR cube textures
  96473. */
  96474. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  96475. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  96476. /**
  96477. * Creates a new HDRCubeTextureAssetTask object
  96478. * @param name defines the name of the task
  96479. * @param url defines the location of the file to load
  96480. * @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.
  96481. * @param noMipmap defines if mipmaps should not be generated (default is false)
  96482. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  96483. * @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)
  96484. * @param reserved Internal use only
  96485. */
  96486. function HDRCubeTextureAssetTask(
  96487. /**
  96488. * Defines the name of the task
  96489. */
  96490. name,
  96491. /**
  96492. * Defines the location of the file to load
  96493. */
  96494. url,
  96495. /**
  96496. * Defines the desired size (the more it increases the longer the generation will be)
  96497. */
  96498. size,
  96499. /**
  96500. * Defines if mipmaps should not be generated (default is false)
  96501. */
  96502. noMipmap,
  96503. /**
  96504. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  96505. */
  96506. generateHarmonics,
  96507. /**
  96508. * 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)
  96509. */
  96510. gammaSpace,
  96511. /**
  96512. * Internal Use Only
  96513. */
  96514. reserved) {
  96515. if (noMipmap === void 0) { noMipmap = false; }
  96516. if (generateHarmonics === void 0) { generateHarmonics = true; }
  96517. if (gammaSpace === void 0) { gammaSpace = false; }
  96518. if (reserved === void 0) { reserved = false; }
  96519. var _this = _super.call(this, name) || this;
  96520. _this.name = name;
  96521. _this.url = url;
  96522. _this.size = size;
  96523. _this.noMipmap = noMipmap;
  96524. _this.generateHarmonics = generateHarmonics;
  96525. _this.gammaSpace = gammaSpace;
  96526. _this.reserved = reserved;
  96527. return _this;
  96528. }
  96529. /**
  96530. * Execute the current task
  96531. * @param scene defines the scene where you want your assets to be loaded
  96532. * @param onSuccess is a callback called when the task is successfully executed
  96533. * @param onError is a callback called if an error occurs
  96534. */
  96535. HDRCubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96536. var onload = function () {
  96537. onSuccess();
  96538. };
  96539. var onerror = function (message, exception) {
  96540. onError(message, exception);
  96541. };
  96542. 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);
  96543. };
  96544. return HDRCubeTextureAssetTask;
  96545. }(AbstractAssetTask));
  96546. /**
  96547. * Define a task used by AssetsManager to load Equirectangular cube textures
  96548. */
  96549. var EquiRectangularCubeTextureAssetTask = /** @class */ (function (_super) {
  96550. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](EquiRectangularCubeTextureAssetTask, _super);
  96551. /**
  96552. * Creates a new EquiRectangularCubeTextureAssetTask object
  96553. * @param name defines the name of the task
  96554. * @param url defines the location of the file to load
  96555. * @param size defines the desired size (the more it increases the longer the generation will be)
  96556. * If the size is omitted this implies you are using a preprocessed cubemap.
  96557. * @param noMipmap defines if mipmaps should not be generated (default is false)
  96558. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  96559. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  96560. * (default is true)
  96561. */
  96562. function EquiRectangularCubeTextureAssetTask(
  96563. /**
  96564. * Defines the name of the task
  96565. */
  96566. name,
  96567. /**
  96568. * Defines the location of the file to load
  96569. */
  96570. url,
  96571. /**
  96572. * Defines the desired size (the more it increases the longer the generation will be)
  96573. */
  96574. size,
  96575. /**
  96576. * Defines if mipmaps should not be generated (default is false)
  96577. */
  96578. noMipmap,
  96579. /**
  96580. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  96581. * but the standard material would require them in Gamma space) (default is true)
  96582. */
  96583. gammaSpace) {
  96584. if (noMipmap === void 0) { noMipmap = false; }
  96585. if (gammaSpace === void 0) { gammaSpace = true; }
  96586. var _this = _super.call(this, name) || this;
  96587. _this.name = name;
  96588. _this.url = url;
  96589. _this.size = size;
  96590. _this.noMipmap = noMipmap;
  96591. _this.gammaSpace = gammaSpace;
  96592. return _this;
  96593. }
  96594. /**
  96595. * Execute the current task
  96596. * @param scene defines the scene where you want your assets to be loaded
  96597. * @param onSuccess is a callback called when the task is successfully executed
  96598. * @param onError is a callback called if an error occurs
  96599. */
  96600. EquiRectangularCubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  96601. var onload = function () {
  96602. onSuccess();
  96603. };
  96604. var onerror = function (message, exception) {
  96605. onError(message, exception);
  96606. };
  96607. this.texture = new _Materials_Textures_equiRectangularCubeTexture__WEBPACK_IMPORTED_MODULE_7__["EquiRectangularCubeTexture"](this.url, scene, this.size, this.noMipmap, this.gammaSpace, onload, onerror);
  96608. };
  96609. return EquiRectangularCubeTextureAssetTask;
  96610. }(AbstractAssetTask));
  96611. /**
  96612. * This class can be used to easily import assets into a scene
  96613. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  96614. */
  96615. var AssetsManager = /** @class */ (function () {
  96616. /**
  96617. * Creates a new AssetsManager
  96618. * @param scene defines the scene to work on
  96619. */
  96620. function AssetsManager(scene) {
  96621. this._isLoading = false;
  96622. this._tasks = new Array();
  96623. this._waitingTasksCount = 0;
  96624. this._totalTasksCount = 0;
  96625. /**
  96626. * Observable called when all tasks are processed
  96627. */
  96628. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96629. /**
  96630. * Observable called when a task had an error
  96631. */
  96632. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96633. /**
  96634. * Observable called when all tasks were executed
  96635. */
  96636. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96637. /**
  96638. * Observable called when a task is done (whatever the result is)
  96639. */
  96640. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  96641. /**
  96642. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  96643. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  96644. */
  96645. this.useDefaultLoadingScreen = true;
  96646. this._scene = scene;
  96647. }
  96648. /**
  96649. * Add a MeshAssetTask to the list of active tasks
  96650. * @param taskName defines the name of the new task
  96651. * @param meshesNames defines the name of meshes to load
  96652. * @param rootUrl defines the root url to use to locate files
  96653. * @param sceneFilename defines the filename of the scene file
  96654. * @returns a new MeshAssetTask object
  96655. */
  96656. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  96657. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  96658. this._tasks.push(task);
  96659. return task;
  96660. };
  96661. /**
  96662. * Add a TextFileAssetTask to the list of active tasks
  96663. * @param taskName defines the name of the new task
  96664. * @param url defines the url of the file to load
  96665. * @returns a new TextFileAssetTask object
  96666. */
  96667. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  96668. var task = new TextFileAssetTask(taskName, url);
  96669. this._tasks.push(task);
  96670. return task;
  96671. };
  96672. /**
  96673. * Add a BinaryFileAssetTask to the list of active tasks
  96674. * @param taskName defines the name of the new task
  96675. * @param url defines the url of the file to load
  96676. * @returns a new BinaryFileAssetTask object
  96677. */
  96678. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  96679. var task = new BinaryFileAssetTask(taskName, url);
  96680. this._tasks.push(task);
  96681. return task;
  96682. };
  96683. /**
  96684. * Add a ImageAssetTask to the list of active tasks
  96685. * @param taskName defines the name of the new task
  96686. * @param url defines the url of the file to load
  96687. * @returns a new ImageAssetTask object
  96688. */
  96689. AssetsManager.prototype.addImageTask = function (taskName, url) {
  96690. var task = new ImageAssetTask(taskName, url);
  96691. this._tasks.push(task);
  96692. return task;
  96693. };
  96694. /**
  96695. * Add a TextureAssetTask to the list of active tasks
  96696. * @param taskName defines the name of the new task
  96697. * @param url defines the url of the file to load
  96698. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  96699. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  96700. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  96701. * @returns a new TextureAssetTask object
  96702. */
  96703. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  96704. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  96705. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  96706. this._tasks.push(task);
  96707. return task;
  96708. };
  96709. /**
  96710. * Add a CubeTextureAssetTask to the list of active tasks
  96711. * @param taskName defines the name of the new task
  96712. * @param url defines the url of the file to load
  96713. * @param extensions defines the extension to use to load the cube map (can be null)
  96714. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  96715. * @param files defines the list of files to load (can be null)
  96716. * @returns a new CubeTextureAssetTask object
  96717. */
  96718. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  96719. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  96720. this._tasks.push(task);
  96721. return task;
  96722. };
  96723. /**
  96724. *
  96725. * Add a HDRCubeTextureAssetTask to the list of active tasks
  96726. * @param taskName defines the name of the new task
  96727. * @param url defines the url of the file to load
  96728. * @param size defines the size you want for the cubemap (can be null)
  96729. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  96730. * @param generateHarmonics defines if you want to automatically generate (true by default)
  96731. * @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)
  96732. * @param reserved Internal use only
  96733. * @returns a new HDRCubeTextureAssetTask object
  96734. */
  96735. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  96736. if (noMipmap === void 0) { noMipmap = false; }
  96737. if (generateHarmonics === void 0) { generateHarmonics = true; }
  96738. if (gammaSpace === void 0) { gammaSpace = false; }
  96739. if (reserved === void 0) { reserved = false; }
  96740. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  96741. this._tasks.push(task);
  96742. return task;
  96743. };
  96744. /**
  96745. *
  96746. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  96747. * @param taskName defines the name of the new task
  96748. * @param url defines the url of the file to load
  96749. * @param size defines the size you want for the cubemap (can be null)
  96750. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  96751. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  96752. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  96753. * @returns a new EquiRectangularCubeTextureAssetTask object
  96754. */
  96755. AssetsManager.prototype.addEquiRectangularCubeTextureAssetTask = function (taskName, url, size, noMipmap, gammaSpace) {
  96756. if (noMipmap === void 0) { noMipmap = false; }
  96757. if (gammaSpace === void 0) { gammaSpace = true; }
  96758. var task = new EquiRectangularCubeTextureAssetTask(taskName, url, size, noMipmap, gammaSpace);
  96759. this._tasks.push(task);
  96760. return task;
  96761. };
  96762. /**
  96763. * Remove a task from the assets manager.
  96764. * @param task the task to remove
  96765. */
  96766. AssetsManager.prototype.removeTask = function (task) {
  96767. var index = this._tasks.indexOf(task);
  96768. if (index > -1) {
  96769. this._tasks.splice(index, 1);
  96770. }
  96771. };
  96772. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  96773. this._waitingTasksCount--;
  96774. try {
  96775. if (this.onProgress) {
  96776. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  96777. }
  96778. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  96779. }
  96780. catch (e) {
  96781. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Error("Error running progress callbacks.");
  96782. console.log(e);
  96783. }
  96784. if (this._waitingTasksCount === 0) {
  96785. try {
  96786. if (this.onFinish) {
  96787. this.onFinish(this._tasks);
  96788. }
  96789. // Let's remove successfull tasks
  96790. var currentTasks = this._tasks.slice();
  96791. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  96792. var task = currentTasks_1[_i];
  96793. if (task.taskState === AssetTaskState.DONE) {
  96794. var index = this._tasks.indexOf(task);
  96795. if (index > -1) {
  96796. this._tasks.splice(index, 1);
  96797. }
  96798. }
  96799. }
  96800. this.onTasksDoneObservable.notifyObservers(this._tasks);
  96801. }
  96802. catch (e) {
  96803. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Error("Error running tasks-done callbacks.");
  96804. console.log(e);
  96805. }
  96806. this._isLoading = false;
  96807. this._scene.getEngine().hideLoadingUI();
  96808. }
  96809. };
  96810. AssetsManager.prototype._runTask = function (task) {
  96811. var _this = this;
  96812. var done = function () {
  96813. try {
  96814. if (_this.onTaskSuccess) {
  96815. _this.onTaskSuccess(task);
  96816. }
  96817. _this.onTaskSuccessObservable.notifyObservers(task);
  96818. _this._decreaseWaitingTasksCount(task);
  96819. }
  96820. catch (e) {
  96821. error("Error executing task success callbacks", e);
  96822. }
  96823. };
  96824. var error = function (message, exception) {
  96825. task._setErrorObject(message, exception);
  96826. if (_this.onTaskError) {
  96827. _this.onTaskError(task);
  96828. }
  96829. _this.onTaskErrorObservable.notifyObservers(task);
  96830. _this._decreaseWaitingTasksCount(task);
  96831. };
  96832. task.run(this._scene, done, error);
  96833. };
  96834. /**
  96835. * Reset the AssetsManager and remove all tasks
  96836. * @return the current instance of the AssetsManager
  96837. */
  96838. AssetsManager.prototype.reset = function () {
  96839. this._isLoading = false;
  96840. this._tasks = new Array();
  96841. return this;
  96842. };
  96843. /**
  96844. * Start the loading process
  96845. * @return the current instance of the AssetsManager
  96846. */
  96847. AssetsManager.prototype.load = function () {
  96848. if (this._isLoading) {
  96849. return this;
  96850. }
  96851. this._isLoading = true;
  96852. this._waitingTasksCount = this._tasks.length;
  96853. this._totalTasksCount = this._tasks.length;
  96854. if (this._waitingTasksCount === 0) {
  96855. this._isLoading = false;
  96856. if (this.onFinish) {
  96857. this.onFinish(this._tasks);
  96858. }
  96859. this.onTasksDoneObservable.notifyObservers(this._tasks);
  96860. return this;
  96861. }
  96862. if (this.useDefaultLoadingScreen) {
  96863. this._scene.getEngine().displayLoadingUI();
  96864. }
  96865. for (var index = 0; index < this._tasks.length; index++) {
  96866. var task = this._tasks[index];
  96867. if (task.taskState === AssetTaskState.INIT) {
  96868. this._runTask(task);
  96869. }
  96870. }
  96871. return this;
  96872. };
  96873. /**
  96874. * Start the loading process as an async operation
  96875. * @return a promise returning the list of failed tasks
  96876. */
  96877. AssetsManager.prototype.loadAsync = function () {
  96878. var _this = this;
  96879. return new Promise(function (resolve, reject) {
  96880. _this.onTasksDoneObservable.addOnce(function (remainingTasks) {
  96881. if (remainingTasks && remainingTasks.length) {
  96882. reject(remainingTasks);
  96883. }
  96884. else {
  96885. resolve();
  96886. }
  96887. });
  96888. });
  96889. };
  96890. return AssetsManager;
  96891. }());
  96892. /***/ }),
  96893. /***/ "./Misc/brdfTextureTools.ts":
  96894. /*!**********************************!*\
  96895. !*** ./Misc/brdfTextureTools.ts ***!
  96896. \**********************************/
  96897. /*! exports provided: BRDFTextureTools */
  96898. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96899. "use strict";
  96900. __webpack_require__.r(__webpack_exports__);
  96901. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BRDFTextureTools", function() { return BRDFTextureTools; });
  96902. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  96903. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  96904. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  96905. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  96906. /**
  96907. * Class used to host texture specific utilities
  96908. */
  96909. var BRDFTextureTools = /** @class */ (function () {
  96910. function BRDFTextureTools() {
  96911. }
  96912. /**
  96913. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  96914. * @param texture the texture to expand.
  96915. */
  96916. BRDFTextureTools._ExpandDefaultBRDFTexture = function (texture) {
  96917. // Gets everything ready.
  96918. var engine = texture.getEngine();
  96919. var caps = engine.getCaps();
  96920. var expandTexture = false;
  96921. // If half float available we can uncompress the texture
  96922. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  96923. expandTexture = true;
  96924. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_HALF_FLOAT;
  96925. }
  96926. // If full float available we can uncompress the texture
  96927. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  96928. expandTexture = true;
  96929. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT;
  96930. }
  96931. // Expand the texture if possible
  96932. if (expandTexture) {
  96933. // Do not use during decode.
  96934. texture.isReady = false;
  96935. // Simply run through the decode PP.
  96936. var rgbdPostProcess_1 = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]("rgbdDecode", "rgbdDecode", null, null, 1, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, engine, false, undefined, texture.type, undefined, null, false);
  96937. texture._isRGBD = false;
  96938. texture.invertY = false;
  96939. // Hold the output of the decoding.
  96940. var expandedTexture_1 = engine.createRenderTargetTexture(texture.width, {
  96941. generateDepthBuffer: false,
  96942. generateMipMaps: false,
  96943. generateStencilBuffer: false,
  96944. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  96945. type: texture.type,
  96946. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA
  96947. });
  96948. rgbdPostProcess_1.getEffect().executeWhenCompiled(function () {
  96949. // PP Render Pass
  96950. rgbdPostProcess_1.onApply = function (effect) {
  96951. effect._bindTexture("textureSampler", texture);
  96952. effect.setFloat2("scale", 1, 1);
  96953. };
  96954. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess_1], expandedTexture_1, true);
  96955. // Cleanup
  96956. engine.restoreDefaultFramebuffer();
  96957. engine._releaseTexture(texture);
  96958. engine._releaseFramebufferObjects(expandedTexture_1);
  96959. if (rgbdPostProcess_1) {
  96960. rgbdPostProcess_1.dispose();
  96961. }
  96962. // Internal Swap
  96963. expandedTexture_1._swapAndDie(texture);
  96964. // Ready to get rolling again.
  96965. texture.isReady = true;
  96966. });
  96967. }
  96968. };
  96969. /**
  96970. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  96971. * @param scene defines the hosting scene
  96972. * @returns the environment BRDF texture
  96973. */
  96974. BRDFTextureTools.GetEnvironmentBRDFTexture = function (scene) {
  96975. var _this = this;
  96976. if (!scene.environmentBRDFTexture) {
  96977. // Forces Delayed Texture Loading to prevent undefined error whilst setting RGBD values.
  96978. var useDelayedTextureLoading = scene.useDelayedTextureLoading;
  96979. scene.useDelayedTextureLoading = false;
  96980. 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);
  96981. texture._texture._isRGBD = true;
  96982. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  96983. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  96984. scene.environmentBRDFTexture = texture;
  96985. scene.useDelayedTextureLoading = useDelayedTextureLoading;
  96986. texture.onLoadObservable.addOnce(function () {
  96987. _this._ExpandDefaultBRDFTexture(texture._texture);
  96988. });
  96989. }
  96990. return scene.environmentBRDFTexture;
  96991. };
  96992. BRDFTextureTools._environmentBRDFBase64Texture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR4Xuy9Ccx261oW9q5v/r7/33ufgalSbWtiTJsmTZOmSdOkpVKsWhxAxIJFQaCKUkpFiiBFKjKPh3PO7hjb2LmNnYxtjbGtbY21rQGkgCgiIKPMM5x99ruatZ7puq/7up/nWd/3bzzABjb/9675Xeu5hnt41rv8s+evW9fz+ZT+W9N/63o6re3v+nlfvq2CbdZT2hbW7dukDbf/a/9uS3G7E69Ln9PifK50sHSMvD2ur3+XY/E2++dyPelDPoU7Jm9XTm2uab86vJ56gvSd80dzXflA+Zul74PHwGuGv/MXLv+kL4Lfp56r3DM8ef6utE10Xnu97fra7uWi2/etZ8BV/F3F+fdni/8Dn9O4KSvt/cxPMa+HY5Qx024OHF3cM7zHdcsy3uAeuu3wPve3S2OVthHH09v5e9BuCT0HHgPlHsjz+3uxNALYAJ9JgAigALyBmQGPQEcAxwRQgVhIogwcIoAG2HYsM1gR3IokEDD5biMBhMeSoLXkweCoAxsGcDoX3Xi3nkCFACnfiQaPARECgPaVAMZjEuAsNttAjIBZSY8HXHkuFctt4Npj2e8+B/ImFOnwEcg9SPEqcNdyDBSZemwipBkwmvMwocG9Gm6nCDUisHpb+iSRTp+2kQTQAJ9cACt8cwRN/Ss5IJBJ7a2qC0AHYK4gUkpuQE2uoTiJfMPw4epjeqdRXYE5Rhu0me7aGCwIKtfFD0sAmklCgWBmG3utbfCrfdtlBUpK6qUIpwCkkUYDIg4yp4QhAeW9GDBwLR6glgysC8PvZq6o2MJMT3jdhtKqI0WiMfeTCMhs54BqzwNPyLueclxzS/3+XQI0jtSSQrmly4ecv249Z+U/gQOoNj+HBKj+yhGEtn9/2C10qLaWLH5Tz6KykeI3FTb7wM0uRJMWlZtmQwgXFgAr23VwDGRjADoPOgMIQ1pigNdnCrbviaqvFMopuDpvHjB8/RXoeI8ydGp4RAM2x13NzQtr74BkQoFZlceBDQTugIlaixa7kbn5nl3wNgVNpxGKi2OvQxJmjOJ24riNB/sKX0VJPS/zjNfTTgAp9s95AIj9K9DPqPQc22+nS6C0eYAGZJMLyF+sPPwGVggXypcH8HggA5gwbCjHhy9v1Z7yDIY4Gie3nIMGrQHUUNVBVeq14rnyOeiBvWjVl8QgQoZ6NajErESk0n0wx4CLFLuXJ5gOE4J8gtV4cW2RlYbvrO5lVWMk10KU6lpwrHbBr8cHn8+EMdH5YPl2H4gANhCmPEABLTsBp/5k+Y1TwGReWlGTgqiy6WFrxXcEQQTilLw8mUP5AIh1pbJnTgUrOiYIVBZKMAXqW7GISigAyjbYgkWfyyqyTTI5ZckLokEehQNxAs8TYMHF8X3w+3kSrcc1qozPAsAUqbfLX8B5AKgyFGBidOcIiB8JAMdZWV4fGak/nU+Sd0BC266CANbTqdp+zPZHmX9Uf1Txju1HxS6DbeeAZtOtavtKAILAhw9B1aCNjhyJELDZrldlFwRB1YT2nJtUNnVTBPJ41Y+dAQwOE2eD6+EBWZ4FDDRUFmUn7ZiLzjkgGbgOTTTintG1y2QiuKh2ZSKrLoDDVt4RI90jc28CMunnC/AK27iBhEB+FHgme78rtk2w5b+vcguSAKLyH5YCfT6ghAgFeAh+H9PXBxcBPiKICjo4fnEE+ODLk1NJQ7M9PACXK2iqgTa1DTpPHo59FYGgNZuM9T1AoBphFMIPIhXPMzG1Q/jBVYceAobVqCElHYo+uzwBPKvGyXBuY1O9YjZBQzOP312TK4PAVjDw/Hn/p5CEJKI2puq15C/jXFz7kiZB2CPLckzzzIPjlMtbPuT89WtK/rUSoOkFMDV/KvflEp6pCnCtH614yRPU0AAScxjvlwGABFFGlgQ12MJD+QCt7HX88bEE2aRFFnhGOdBO5hWsLDOx/mzZT6meSgAa9cLrYnA6O0yqxSDpbG/uFRAXwDWPYUsG1s2Le91Yp8CJsK5VM6wYUJyMGLLqjESsCcykC80XsddknltlRSC/fL+GBFAdXXw97fDrafnnzl+fG4FyIrAAPggD9nsTNQIhsLfziwqAVX+r5IcqAQKMxZlYUBaSQVUog4jWgXJhCGKah1QlQIUDZlDSQCm804n1+6rfQOAqEALA0SCMcwdeqZyqONKIQBsAVoBWKlcvRKnq6YHSKmAa/LJKUZFBJMf3tEdeJvmGY05cIx1XkXIlH8re8/J0SeK6I3LMvQCSAHQYULL8OhfApT6X2BN2v4YSRxW/Hivf4ALcScuPAx9JxxIHwKY6AXiIfC5+mHBNj63rW2cAwyMiDiQnygJ3AQzEZ+6BG+iCGBQ4BqD1cTHlKFTJUA3kyi0RyHF8EAAVWOg+vBCSqLeMFFnct64jOXAcW6SM8wHbLcgEUNT/3BKA2BJsWnoFAahKgGv79V2Bs5WAWkbkHAAMirgnoA1ajN8REKHay/IesCzkDdrzfMR6/B5moHuLORMu1PtKipbG9wGldsSgQVSpqdkWECRtRcPyn1DQGTVvl+rPh7pYOA2tvKxE8DOBJJuq+4/i7rj0SKpN9zA9QpFQbV9EtBxbZ1uPUcYDuAlDAEn5z83i7yRgld91AXZiftMXkG9oAartCqQKQOgIhOKHMX8elsbWF8mgdRSnm0QfJry4SoCEhAwND9EMjFE+wCXXJlS/o7ZK9RXwDhNDl0jsgJ2r81cpz8a0MpfrkJNA53sQqWsHXI8mCXZdCDImRAHmuvljjiO+Z+0FUG5GCMLy6/YcAAB/B30igdOZ4/2dDRJBIKCNQyggxfheNfn4kh8qsSGKei6v5l7VDyQEcSBzWIEKgDeTtkubWQvKg5StfBsXI4DDd2ky2EBirkt3pw3BXbFnQdjGVqSoj9weBi3fB1QqHyaIe0FEZMmmnigfNqoYwDOge4zg1AovQhcCmflOgjgbX4jrCLavWzpCa8/EOQ5xXds2y687f0ObDchdgC4M2E4wqAQYYsiDcrcRDSjVRRiQlQds/5WzAE3mHSoJlJGfIoeW8jezBDON+R7/URIQE4IyJvcJQT5XSzqCLhHJtOFN9pBVh0iil5U+5BhUnM6qw3G2UOCo4w/hkNUGtDWIa3mOgVC8CsjhtVhSN/c7ALl0J0Aqs6BkUkASUWMFiapFKoLwRCgBBJCUf9wE1MCswoEKdOcSChlQf76y8PlOGkeAeYZCMkwg+SlJ4PfIQal9uQZULKW4sAxVi2N1rr2zMusyXx/cKtZXqtrtFJxQ5C4xKBWeARc7D6F2GlAQLu4j3zoRoEwXPqRTkKMBMJt9pWLWAZbX2mON8gDTyTl4Jgbc7lrFd8HxiPdH3N9tkSGAU24DtmU+7gYsTT8lHGjlPhPz13gZFV01BWUbpWr+tazYyMOoI8TkCKg4ISgUtRIQcDwk9xhQ0u4jIQHL6m0bqDn5xANopvZ/vMZfvpGoYbscRNWbLEITA55VGMhAkZMrsfYAqQa3JBsgBiKJUTKuOg9x3PBa8ZljsjCqZojlqPIy/CFCMg6pfEe6ZvNdA+JbPrSGAG0egO36C8p+KTtYe/ttGZBzBKz+uv5fzotMPQLz/r3YRbhqAYDOgdvnDDzJIPNb4BxK8kX5AnQghqk74cJAubXqB7aWBodSMnU8Qw8MdHPMdv/cwOUEnhvEvnLRxnusgD0n0AM5CgmCMp1T2epj9ffu8XuJQFLwEZH5Z9OIH11FJoACfnohSNDwo63/DBnkyyo5gTDbv329AtpokhAOKtq23shiD21ZxIUW9VBwHACYsdomk5+HEiiTGSQ4uCsggqYg/L547mJyMZ5mNqdKRc0Eq0HDAMNrZyJS5SfaXlpqvEfRwOXjRKrIcxoitWUSI8WcUth8TYY81LPoJQs75+2SSM9F0DUYcHfcRLvFgijzdyAC2DL/rQyIQEdXYGYE1jKgz/Tbkh/Z/5QsqH3jBpQqL4AM3Fmv3QOFEDgoe9l/tZ1RAuEsROLPKo6v0VpVoGx34bBDYBxUD14EMQwciGp+CgGggMeOgq45Lnd13MZR8gjAFfYNDBUcoYturN7MmtMwTolJOoN35Ca6oUS+1uVDz38tVQFKAhBagBvQC1gpHJDgB3vPiUAX00MG38TzXtGl1e/lDdJoM5l9vGH4EF03IA+UMkBRPY0TgAcrcgpISra7TOUDhKswpBN1zen9npIAVANdDjrOHQycROMOr0xy0KrjT4C5FwO3R6nU8RHJwgN5AKPgh8EN/iRKaIJDafeAvmf+uBNAUn07GagP/jLYIkIoNzB2BVb9i8x5R+DsugFj277adAYrzcjzFQIkCkhYssIpYKtOQUkedI4qUlXeoQFmPkloQhPhPIrtVVZQgpsHY5DQi4A1TRiVw/ygNMqnnErPDgsw9TLz7lwHbPhIofsE411geVYtgtDEhFUPXVZUY8o7jMQR62n556sDaM1AUSlw2ASkbH3JI1T1hwRhecBQMTAqraw+EYCNz2dife4baDfHJRyNks3affEAYGCyIk8lEVlRZdKunVcBVA1YNUiniIE7INmhUIwMmmVKcxFIFGGNMvDTYMZcSrnO7BbbRzxae+6ufViQUZR/wX2738WFVoIICgYKW8jvQd8Bt4Xx6Aggeh9AHPejamN23ycF7Qs/mouoFrmC264z+yEYOKPP5ABZ9y64VYJOOYfIFaBSSVeAmWKRA0DlEqpbH2XFePkjHqj9TH65v6gMKfw0lpHPpxS5objAaP5FmjOhQ5PEdnyRhFMEV3cdJe3w/uNZguVpk6AiIPMABGJ1X0ffyZDUCNwgavB9SviJbiMTQGkCyglA1QFI8bypBHAuAOcHRK6g2K1uHK8tvrTx0/kAn2TD47Ux7sOB+shrdn8yhqfKASufBbi2h2FPQX7WXdUPiCPt6hUujXs7aB9VGmTnMhrkADgmPaO+Qez72CafOfdQb6JO1Kl7xgpNhDIq5Y3W1+cXOJiZ9cuH7SEA9gCUeQC5538v2aVLUZWApt4JrOkhROqPDoG2LczZrQBwchCYeBjrk+pB0rFlrGEosLswrD/OFdT7AgqGg5oVy5NLRXZ+vAKoA5C6hBreI3YzNIja9Qg1AdVvY7oRRpQl1wAVDUk9hVXKq4gDvh9/g6LgziGMQExuxwBMuIUeifVast11dZJ9LCYu1IDxh8pf/l4+7PyNtQpgfxUoE0EH/GWAaTdQ1EWECFV1RO8ArwubeoISotjfgFGp8UDRe3G6BK4KKYq5xhgUH6wAJ6s6D6gQpBznsvLwgAqsOEK68YO3s5bMhD09AlACWQQi5VIM0COwiuWjmDx0FjzvgxW/13pcSnnm2dC9jZKl5WGIHhFNACqPkc7lCGCU/TcuwLmCMeiNQzDg7gPa234RHqBysJPAhxG6hbhfwKgpxfkxMAHCgmTUwJtOEiqVrC61/EFg7Ci3AppXF9Atdh+kuFUdFaCFojm3IgECEBeK60kKAHUoZhfuS4B7lAcwKh8kHHUmH0u9nhSqkjviFgRiXI1fXwmA3wWgG39aP0BR1aPqnwY9WGhX/89DsRsKiPZfyAHg4EOlaOAC8jDEAKZOuQJUdraYUtl9vkFZP6tmgyShUB0GD37PSLldTG8SgA0AQ3VXRAT3xrgIJiiy3CoB6UDEJNa+YIYoJeciRxERlrPMMCaCZKLKvxSQmu/vzhkkEtnBgeIj+PHK6nLcNpOkeYZ0rOXX1xCAXgZi2oCx3s+WPq8zbiBfmgE6lP/KhWGcXZfBvji4iBAkmA2ZEIvS8QuBpfthldqqIZUWYdA64OLgRIUS2fUjrgEJLSozuUQmgUu6jXAbqxSOLAJra++HJ1McpC9K8Q8fRyQ9DVgDZ6G+W+WKSgxarVWoJglCnHtEIJVTpkuB9hozAeQkYGc6sCkD7oABN5AHeHUDBVTlC5mWX6X+jRwQmCVcqOUpTtzV4zfrjsAyYQMCV8XonbLfbPa/PT/rYurDDkkBO8/INeQnzOpolZlUipXWKEE9IDQf2az/oQSgIRGtvt0KRUURfiMYpNWJtaGO5SyrblSVKcfu9SWMzl9DEQ3uci09lY2Sn4ZAQDzqZZdzd8qY+OQrwdKxdJiR7tXy68//X2sF3kCArwTLLiCe/PMY9S+jEx2BBYyr2e+DQOQITJ2/Dex54Jfz0r4DV8AAQXWwyq7sPHK6Tc6MrHy8Pg8DVhAR9w5bgyN1V+oULkOw4rXZ5bpa4O/ZSKGZeJ26qnzFvlGrKjk1N+sZZoqgAoLo5R4UuTNpmVKtPgcLVCWC/B2ciwDS3gmgtgLvBJB7Ajrgt/kBTPwBkKlvIJ0zWF8v6A1KBIaVgTYgfaNQ0C8gyMEMD6oy1DME+QPnGsiiIrnU8wDDj9aPzh+pUDsFERYMHv7eJjwZqa5UdgzbiEQiIA2TewFoRCIyJhrhToj8nMqO1rcHA+a9XKslGA9g+508AYr1GCLAd1/+BXAAGwjw58AR6M3ed6x/vhKb5KOcQQXQRE9A7ari+j8QyUR2P3QEMJhVlaGJQL6hLkywKoKgsU7AZs8ZXHbboHKgBgwmKqMBxZliBbyZBKDscAs64jjnkVlGWWG+T45EgOwiwmF9xiYmDUzqeETVVSVRhKgkDiCIgFh0olCQaxl0ZmwSGdbrKTgYrBfHLGQHBFC6AakBCJOBEPcnV065AEwEFqA/QvVVCIBKZ5xE/nLVHnNVARUbB7/L8nMeQrgDAQKfjGykYHQDHEAT+UIsvgUX93XlJgFqoxKiPDSTyFMJNbmfcikiuabAzddpwTtSvn4LrrpWbvIqAx+eLiwSSt9UwOZMRNLNPDNa71UaQatzJ6b7kUBfL1qRNwIer9q4knS1mQC2o9gZgbIfQCT+ynYtUUd5AdMViKQRdAIa1dfJQZkPeArw4cZgXBqWDYGd8VraYhjmLuGo1mUYmAdkE4M8gJAQq2ry/hTj2n3QlSAcGilFaqxUVS/zyuSB0FfPIYmMlLKj6JbwgHxgRgS3RHviCPaTBGG3rcajNolZUnDrAxvfnqQ6vsqptO2W33D+pjVNBW4EMAX+mpgTicCB+isAO1U3vf0+BHCKT0qPA8e4B8wH4OCJYvSIHBhcYP10M0+5IpX4U27DNiXVLfA8Nc4m5arPt8AyyI5z9yHeQ1CR2BmIwa9IyBCmrezX17mRarXsugaNTiBqUnMuw90fIiqZVwDiFm6nKLJ1AUF1xXzXvAfdt6b+9GzpXsq8C7uPzrGJAHJ8nysBhgjodeCqDFjdgAoFirJHGf2q4FAdEACtpcEg9m84toM/zgMwucBwCcOE3ja4DocenKehOQ8FAdD80FgBR+VAsz5oJXXVBGnpo9IgAaHIlEzqiZJm+cYAQgsee96oEUiXtqicWiV0UFkogIzICwEb5DdGuQv3Pei+heszmKOKST2MChGUWBA5VAIwrwI7l5Bgu6HnWoKzbcDQHASKb+P3fqJPdwQWRmTF7FQIuurPwLPHxRIK21NPGn3gcznGOQ8kNBp0DQ8+HuQEEqtMz3HUKzZOJjOQUsIjQBYOQg1Uc71MbF0CadfplLXadOuompaDc+BkKbkNXaf3eZlCVPIc7CzpHI0g8nUJVVbfsQ2T8n2UI6IxI1xCdOzlN9YQoDQDbe8FhERgbt1V4J9OBAbqb/IGBGIdJsCtL+xmQgUcMAeB784/ytzT8XF/UFRHMNW22wHGCSwNavH9m4fQvw6rADeZ9T+UAKyXpgajzrp3yWKkxhVHHhBIvDqRZgmQXZMBemCfdVYfBIJzAJnoXJs2EIUF6YjY7Pdmp9gNIeDaMgHAj4PWXoDtkEFFQM73L3YvhxGh5QeFB9uf8EPqn8MFta5lxicnBWFyUYAVb6AELSaTEECsmAQu88B761JbCoDY21a53rgKqy5tiMCzKYqr5hQAOcnYUtnfIAutEmxqkJprNM+lkV0BZEhITSYLzGCIE1BCQNP5Bq6Bk7+Pdwd4B5Q7EOsFuTwqRNheCZYcQHkbcHshSCnxuV4A/jFQfBlIeYBmYk405dfH+sZyF+UqD2yg9N7Kl+FGg79Ty4+B3x7MlKJTEonBgAPZgjpI/HUdxcgV4MAOSKVnXwXo+ZpN/MrJVACnsqHqWPCNAFeQ0wESa7dGOQEPKHUNVbfrIQJ1LeeVYZK4z4bQ8Vv5a023KfiO+R46sgzcZL09kBeI9l1+4/mbN/mHFuD9F0HbLwTz36jsuQ/AN/6gkkfvA9BqX8Dis/xC6UmJnYpPrEfTZh6A3Nc/JLTqbO8Q+EhubVwASdXxYZOX5vqGMwEVwPuuQCWfZJKQBvMoL1GPaxQX9pIJqpjMKvakSxGACpxJlFTUSTigC7heF88XkgOCiIiGn2fbFfco32eOiKYqAeIat0XLbzp/M5QBs33fQR8QAai8aQTC5aYKgKFBUThUf87Ccx8BgM6oNzkItPjFPTCrKhuP24ZhAgGfVLGr6KyIImRQg9JE0nCMxhNtkDThEoNoYj5AwyjqBAxCvG+gvjFRdNQuOpZQS6da/KzwWkid00ehqJ0SnwPtTBhQgEXuISYARYLBfYfvh3c0x4p57ey+QCYwnoAASuafp/4CKewAwex/+Zxv9nZgUb8vpbum7pFDyF8TcgNVI8sorevK47UEg8ozCgvatqzEVoWdsyiDC9RNq71NJFq34bPMdtAUxwN7KdVUdlTZ9oESm3MH/fXOxaCq9MDZBUd5fm2IF/AmTrAqaIBAoDeupJbP2pgyxz2YpHNkVMVCX3ev7DdFDkFZ77H78rMrrmEngPYyEHgNGAK9/G1e/rkdEsGnGoJoPbkESRZGhZV7sIBI4w4AjAPRxfvgNsR+mA02gEbwUJwW2XxUZSQQHhhORTtq37Xdw1jdKw8PJhfCCHWzRDGX3VfgmU3oKVDX6hESEDXq7gPckJIFKj7rxgXGdxmFtc8Qj6X2IfdBBBiSQyUtrdae/Cw5soBUA6Fe457PtfyL529JIUDOA4zj/5wfcFl+Uv8Cyv1fPyGIXUF9qJzsK/sX8kDgvmjg98Dds/ITNp8HHD4sV/Iz5ASDbdrOm6Nn4dMDdQR6c91RYxERhVbi6v1LvcNodK8jEMm0qLgnlQw643SM56rnLeQQqam7/nwyvhfhtcgkYQ+s+Iw1qfq8g3JGR4ljPVUCaD8NHrgAUv9qz8yEoPIQAPR1fRz/s5NA6yfXdeL9+sghVJBWf+QUCv8juGFwNUs1b/OtW4hLfiOVta7BJv6G+wK5WHgoK56PRqDqkZkFhQU9g3Zs7wfhwahsicXAA0k8b5c7RIJ0NqX0mpyNWpOzKeDvJSoRM7h9OW5EXjsB+IlA7QdCqyPA+B+TfEgARaWd+peBVKgUwoVyXKfwvvMvjUNyFEYto3xAuek+BEBr13IGloVtOFCecgA8zj47V4EwaPfD2Ds+hrBwOEhZyXqOYgz6QtRsOK26uHNWMIrvlwd0e35+WNZB28s/IDDEPZKKPKveKvSiONw5BnZ+AriRy9AvFBXkQLmK8TV4Z9AjjuXDawiQmoF8CHDOoZRN/tX+gEoMj1P/FB5YgnDhgWgSUvuZUEMQAzqBpwMfHoXLFtsEHrNzE1TKUsvqAgEK1NgMF1I4BttItbsJPpOMixVMkgJcL+totbXDRF/sBBQg8I4VUmA6a+cG+w0AlrkHcR+c46lSHt+n0T49wKLzZKW398ITgXcB62n58PNf33MAthcAMv9VcYNqAMf3rgowjv+bwgrVL4MDlLRsL/cbAL8OQgSb+duCMp4S3Oxtcw68Lw675j56au9jcmWjtV1HYnFgm+jbj52EGsyjBKBSsyISFnSPyhlIex+7D3zuSArOEWUAPzpJSC6l3aUeIPF+BC6g7k6iYVzH8XXLb84E0H4dWLgAsP9NnSnpp0KEieRf2P4ryn3KiiuAovo5q6wqA5k0pCsg++1i/4w6va+107gNDzzMitvtKHlH1rer3NyRWAZLHkyjBJ9TjKjSMJNxD5yLUUPlYtQAN66C7g8DePaYBrgBCB05WOAyAbfEnQd4RDwtQekJwycCJ4jDuBrafnspKBIA/zYAv/EnBH+YB4jVv5f1d4pq1L+M3sZ2lRhggCrga/UH1uxYcEM09T6O9oXH7MIEP3XVkQsA1g7J2BU4YglBP1JjbbuVMjoiyYRqwG2A7PMMChBMmH01zQ8lJJrYkdiyYgOJDgM8Idvv+QSlB7JSdj3zD7yuZMbmw/ehPMd2PysBpNh/awkusX6uBvCEIIj504AtMTyDfWYOACblbAKvHtuAAFwHVQKUDe8n7wLwhkk7aEWmiTvTIYBxGp4cTOynLLtLOlUpd4PCVhzsQEG3YYGn+9Hx+yE8HMA7A5hdzWOPo67XLVP19OmQge4VEddjkncezNS7wudQHYyQkORQbVglMC7VuoDlt+whQJkKfLZTgWuv/xYW4Cu8EPTb0Rns21dGQOdbMFEStIm8OKtvjm+ARUAVZTwXItD+VhGA2CoF21jLuwOKRTlMoHp6D2BmrgFl2lmhXJkRtscrMoAR12bXazvMdtcOSriyTqZ8hhQcUYgwpKfATHZRgo3vT7PiFjBehe36CJz6nQMqfKGxY8ihF5rkdRQelXujCHdbtvyW87fWRqBUDoQ3A7vaP0wSUrMAwzxAuTj8t5MczIBM/2SCQZCinQ5i+sO5ASQsJhS8HnYk+bNT3CrO5YECmeVR5MKUolz0EC1h0YCr46UMjo4rgO+hgBCGIK7WPUsKSk1F/wMMcme7a7QD95FaiUys3S3nIQzstT0pDDDXb7+fJwx1T+haypgSzkCRswW5vU/9dWsigNoHkJ1AfSFIN/lX7H++pAN5gJpbQIAXJar/ti/Ssv4wyFG5wFnIUh+WETlhxbF5RCiGBArIyAmoZBiHFHUbfJR9cjAPvVeSU/0DHdAjafE58D5GgxiJqausQGgqrjbLZB+AVso5dRfVisBFSKse2DVzzl4AACAASURBVHG+d6MEnXQYBuiW2I1iK0Ew5ABYKQ+Lehii/MnyW8EBtLn/KRdQau2+5l/WlWQOhwQ2XDBKzgB3YUG5VF8StOEBxFHkCOpgDpJ6VlExD5Fvu0wmwkDq5QmUWyDQtudJqk3TfavOItnhoAnsdQxs0Z+AjSZRqRAVbjAY0UVEg85+L0sdEZAs2RB5wqBHb5IuOyCPACh2//yJvvNjVT0kGHN85VK8Q5gjq57bSOsyAWwjPs8HKEm9Eg5so8kk+loizlcFOO4/lgdw6l3IAQEkljkrLVW8PMzYRbC9MrxqQMiKzQnC4hCs+sgYPSqtuapByaPoARIm9vi62T4LgLSchAKaB5QlHLG+5iLmgcv9ENahoJ62p1R4augyOknCI7F6pOrq/E28OkpPqv441+DJwpNqu2fLbzv/jTYZKHoHwP6EN4IojCqmBHPSrwzgEsO7z+WR6ux/U3FMILJCU4LOOAGt2D5WR863wI6Se2HWP6iHz+QHQhC5EKLdA1ZY7Rj89xvF/3PHVUQEy6AioJyAUbDJON8AonIsEYCZFdghiumuPrp/oduAc1EeIu1iw8WyLCI2v/1YzfWxjIzBhKi0tSGAWgoE1Vf2Pylu3/bXLH0lgDI4JjoDEUhVwRQ4SdXREncU+wiw02EC11CTdnST6/YKEDZDbodXGdWBiprvBI8bwMbWUFYReslGHqwB0PouwcfdTE5IHxYgvKaFaGqf4bJ8z4bbgfriMzEJRoyrxbOIvscbkx8YKD187/A7bCHA5gCO2H9j++nloHZdnAdwTUC9+QAVgOQEjM1v7GrUtpPg06oMLC3zAHo95ibMQOMchCGTHjkUYmvbGEUgxeyp6UhpjUaaQROAOMg7WPUZ9BNUC26/X8uPsmqp+yAciAG7B4iKm8NldC+G+QxwBvOqLr4D5mTYNXTufQG5cnfdEOAj9hAg9QHUMmD9bFXeuYFi+00F4EAeAKoAM6RQkpL1BiPAVL4AW5FZyWViDpR+Yj2/xBETYDiwHNnk5262EdeH3zO00ex08kB0eRFshJnpDyhOgJQECcMM9N51sLrOkoiK1UWi8gg4jboLp9ZTyylnYBwUEVxQTj0GWrzrjSgr/7hQIwoB0vLlI85/s00Gyom/NiMwzwswNf9W/quhANf/XYiQL9pYaVR0tPciJyCBPJcbSLiKLfzICYzW4/HNgxxVCgTAYtLQbsG4jV55sESgFb02HmV7bgc6JTLrSS1ZpgHIce6g6jAJ8BnlDsFJ8fiTEoSkzvI7B0QYq3AP0D4UHIUT2n3g3bGksRMAhgDoAvS7AEQzkLPwg/ZgtX1WwHT/tv9PBIFAzuvH4A6AT6HBKCfg1nPTkJswVAgPIZpvfJR1FwMndBRFUUXyDMHMoIjtfpBzEE7FDjD41MtDRLa23BKqWc8obTsdK5xV3dCxKEcULQuIs+cWIiDy9TyOGHx45kOAdqZuCPCR2QHYtwDTjEByAHPlP1b4WPGLylqlbtvXmwmq2pTZVwIsCJAELCF0bToBshET3PygycfyregzMGpNCpvPa9WlQyiVKAXZwAwBk8jMfvFQwrCQDhJ1B0QGxL1SY+Qc8jWq645UkJ1LlEnnigs7qX4Y0AOWIh+7vSK3uRDAHvuo0kf3YvnI87eBA8DXgQEJgKV3th/yAC1Gty/5aPsE6l5jefE+AFNa65TpyOa3LDUkCKW7gMfvYlNR31dKzfup5J9yDfXUbMkHbkGA0JCOs73aiaiBb1xCvV+s+0CkSCZAXmy1GZyj5GR8be4KTWkLcx+VQ5zDmAPxTOhhibq5EXP9ktRniGFG6Y8Qg72+7ejLbz9/m58LUMuA29uAfMlPZvupFdgTReshwISfU3eXzFOTe1T874EunYABq2jogUFfj+gAzgBosW7XVRS1M0DpE1C6nHiwzIQJrDASjILYlMpE5xsCNmp4AnAitJlyMCQsoBsRmAYnHnkMQnYysVvokcr4PHMu4MhxPNj5/hoCaLG/sv+cDMyXS9n/Rgz5JpdYvgwu+bkdS5MBHkttC+Ymyg2QYvrEnlBgAoTO5ItkWtj7H51DJdkEwVQ5E4m2TCyNu/z+zWx01nFSTrmdXpmKWpm9b2CFFAO6Q3YKJP2kHsIXzh02Hr1IZzCTwDsC6Mcovd3HEn/6tHwUOIBU5qMXgir7X4G8HSQnBct2FWylZbjTDgxlQB3Ti31Nwo2n6qJb8Ouq8whKfO0GCYeh9qm23qvKVOKwALdT17fEg/qjcwus2tH+JibsJRO5dZgSnu58QEbSQYD78XGpt7w8aNm9pPGHA13bZqV+0gkNrj9SanVd6vu/cUpPY8N8D036uwP4qPPfCsqA4oUgNXtvW4Fr8k4QQ+KDTBQYBxelFJbf7IMq1N22uANOqtGXl4lEdhHl0c2FCO1644TeODRo18/AwLgWB7LVNyYEPSA4e26uq7iMKF+BTiOy7k+y+qTYxoHEA1wp2ygHESYIu8DxRL8nDPND8TkD7QLU9U4Rw3LEMVi3FX3fnQBaGZDtP/1GQFX5pu7JNeiQwAI5f20OA5RzYLU1CT6I9SvzdyoBhoCorTdQ9XGIQMnMPGjS5YzDiTqMxACvgyNKJPYqCAjQUd4gg50n3dghawdRS6wqpY4HpwQjXB8Dpw/eHqg6KiiJyV6zVuzHO4oIdMr5jLdFlxMreuQ6zPJKJOtp+R3GAaSOQN//r5KBAejrHAFeT5+F/S9K1xKI+UsL1TbbFgBGlQDTSOStcwGu4feZikAH8F5ZAzdR4u4AEOraWC1kfgJLgNBTkXCvYN7Abs85r7zRfi/C6jfy4cGvVXnG8s9c1xGw9p3IWL29gwgch3mGkdLPEcbyO87fLhyABbyu+2+XyxOCbPkvxWfZ/le16+UEUMlVyY9cBAMQiUKBs4YiwgmYcmO+8dVhRCFCISgcJgAksX+6JxpUbTG4HLbdxjXgMB+dN1DtvJskrIgsHDnOgdCdI7gPeHcUYc0q9VyCsOcCYgDOHLvEBnPEgFsFzmuinDl2EvbYy0efv92XAXcwxMnAAuym1CUkwFJfIgi0xLpKgM6gAC8CehmtCBBSVswTqFhWEREO9GELbz43uo3qQPyA8fE7KRiTVs3Ee5JyuYEpG23bce0w44HmCW2kknZwl2epCO5Y2KBiYh8qtOsdXedTiOTFuwAdxmhio22X2JE1wvGuIDr2TgCuFbh2/gEJkNrLWYHG1mflr0osSAKteRjnA2CgYahl9J9QCSCCqjdJxd8E+C6wjzQCkT2PYvC+zS+E2bPr5BaEk+jF3gZ8naoFq3cIWraxg0qEGsCjXIHdp6fm1i4zqUWqOusCZo93hGimlR7ifeVElt95/tvZAbye1Vr9OCiEBJAI7CYATdyeyQAAzJWDxBOKNMpXpfCALD5P+EkPB50EaIpRXbtN3WoimVdvaAD4ELTC+hp7bNYLUKtrG9h1b/GDMCQ4t3MfnX6AFq8HjijJsZ48BOseA3qkOa16PSdCJJmvcfY4RwDs4/04BBgT0NGQoW2/E4CpAuyqHGT/tynDGaje/mPdv9lkkyfougEIHyIywAlBmYjaw+lVAgY9AZksfPbfDpbqRQSAo9h+FALIfgFM01EfvbTwISHo68d+CAXEkCx6lQkAyxGyGFn9XtmS3UYMlL7CKzDOqLZSVL1MWPLFZggeY9+Z7I4dI+29/EvVAWzgxrhf2P8cX2v7rxOAwzyAidPbMfybg0WugBN3w/gfwgl2EC4bD3kGpdiiStBczAzwMI8xEe/n62U1miOEQO2NwrVr6AHYW/o2uM2A7JBF7zv0VV+rJIO1d42KNOw5tTOZdQFHlH1MPLEjOS1t/BQSj1xVb/lOANUBqOTf5gagGzAp3a7rOWTAfxGkUAFQyj+qEDhiKI+gUx3gpCOBHFVa2fcSNijrrpQ68QKRipnGHAAvE4oE76hKcCRJCDZ96DQOlQbnrHLPjo+sepQLMUCs9/7pCu/A6ADmQ4exNdfPvwdI5SDG5xEhACQLe85g+Zjzd7QqQHUAnYYgWfrLj0V0AjbbvP0FLkFWCHzXYPry+SiDRKGN3wGYrEYMWpGJnwX8Uy3+FDCVA0Fwl7+HuYFAQaOQJo3UTqzuj+fUd7ZSAefqu4Dx9TzdRcw4DSb+Adi7gOzvq92HF57DDmA5nXYCaA4AgS+mA1eHYJXe/IhojadtHkD/GAiCFC23XV5vgEss+gSh3HbGCXB+IcjOK8ArN4Gs/dT1ZshHoUcGKg+WrkuZArdudWWlUlSggRgPdm/dZ7Z9MYQwQxqjfMVRZZ8KATJxvDBnAONk+z7LxxoHwAlAOx/A2X9WfBMWZO2umX3RMhx2A3oyqE4A1FxWDcqgrjb7gBMwHYNlSASdg9RjYBJnXcXWjUAu8abKjgKwsQPR4DFA7XUf1lCD7eX4uAYoHVeCR5oBYJ90WlChLLPdd4Y0bBCy33oRdytg6mX2Pka2fjaRWckmdBZz51s+9vyd5AC4AUi0BocdgPhCD8oTjHoEhpl/DAPIXRSTKpt4fDKvPSBRHTjiBMhZWBXsEAea6lDR2wMsOQl3/IgQzHX5we7IxoEdIPxIAGuw9q+FCSFORs5ZdAb905KDkeX2uQFzno6CI8WUOP1R8T6puiOg3AugHMfyu87f2c0BVNXfS4DzCcBi+f1rvrbLs0RhbXsf6N08Qh34Cjx4XPvQzDU6BwFOoAf4KBk4kdSbDhEq0R0H9egcfQWm+wUDzpNJxyG4ezRDCLGyx4Cm40oQziX1RiQyC1gFdgXI014enFPv2XPbJKA99k4AugrQeSNw+ZWgrhPIQDfKfqAbsJMwNO3FBPpWnYCBaAaeUn3RTVgGOTYvuWUCGIFi1oc6Wt/LPUwpfnM8DOoGpcE2gsx6dr3vTMYhA4PjxVl9/p7tWiwo1DXqMKEuHbTk4r2udp2UWpHuNKg7qq5CEH3c9bT8y+fvSg7gVH4XAC1/8HLQrhPI1p8sf3oUrPzCyqucgVHR3j75lu53oF2HOW/UHciE45pxvAXsWfOwioB2m65TWfM6kCYy/BKIw/2OuwlvzS2wuoSQv7MmJ22z6/GEkvcShzO5gHFYMFLjScU+oOwvxAHMlgE3AtgdwK7qBfD8MpBm/znj75qCMDnGrwwzai0ah0I1t2FBHTzRNGHOJ0jQvwAnAJY8Bi/1LYC9g+xEFiStzDJmh975vgIL4lIW3hHFEeWOlbYHMHvdcyRiieNpIURIENA/z85nTCqaxKaTe9NEcew88vxbGfDjzn9nXdfXoQsQSAAagJK17lQFVJJPqLl8O5DJvqsZhPnyzSD1cwNMVYCPWewzq65JwsFNxWoDgvZgrG9BHoPRgEEkBkcg1/uPY3dJLuh+ZhqERMUgAvc8ITQTPU4GWpWeCyHaPnb7QVKP7k2196S4fMxpa9+6XtKhg2rMvrySBX9/71qicGMnAOsAsAXYVgBUC3CLuVVnIAx/IAP3CrFu1x9CCDPr1hUkXEP4YVTfAs8RRd633SQMM1hl/Dq7BU1PxkYmQyT+4YYuokc6wSBRhFGXdXv6NTDGRBGTTQzgx+zDJHocsGsXrNbNzCt+7GAkiKeqAxFJ9Zbn6ycXExHQ8rt3B1DmARTAp/ZffEloiqMzwNjaiw7AekLeJytzywmg6or8QRAW2ONDzC+Sdq21FwnJ5gkSkellRsUphu9Zf3negf3WwA1A2SEGR0rFAUnCKHdT6fYkIYTXQgQqLG5MLo8JCxjAjyAIysKzo1CZ+lEu4VEO4JFz/1UOwTmAfOzl95y/ew8BUhIQGoHMxKDtkFQVoAqAcQIq2VcdACp1IZV8ea7VV6g8txCze5CEwQNcH7e4CHxYlZ6IHMw2eZ0CXSG6dJmsXrwEr0sfbRrYT1D5GUCOHUH8XTmujo41tv6xRXaADOfFjwlixgU4ktiGucsleGsu95stAwYTguqYA7IPHUAiAHQADejmrUDGAaj3A3AfP7kFGeejXe6QAWTo0xeh/Qag5/DAgpfCg8gJiAYhCUY1r8Ak/goBHggBqOtQEdQ0MZATcI6jEp0Gl3IoCKEeaKN99zM5gHLo5T/3VLdALYqhR4q9r+8o8Gh/vidOgctzmOzkm1J1fLaGfDwZ75turcAfnwmglQGTC6iWv1QGqvLie/62A9vP1tqryT+4T75NGLsPyoBVM9FRuBKeSBASaZjhxMcqzCnBbHMN0i1kQmrnsLbUOYHwtWBKRWlZ2FdQANyGzog4HgPePiHw9Vu1ndl3fE0BUb3QOH/gEiYz949S+x3IHNbosEyTXWfbrQrw8efvyUnA103M30ICSwiVGIAQWvJN5AlkC7BX/gqWiAxEac928E1UBSowvfXmbsCedW8kF6u4sbUHk3i2h2AybBhm4uPwgtWJPZFdfxzEw3DBNbXMnSO67qJuXcfB9viJhKEU3qh2kPQ7Tgo2jGCnosmi4wA+4fw9YQhQ+wJqQnCQCzCkUMy6qA5E3YFSyeHijVJSuZCy/nWvamnxOOVx4Y1R3YDAnmSNDYW4dWxXYeu8bWzZGX75GgYuYaTuQxC6DEVMPD3gKb8xVvH5c3VBX2Pip4UPXTAf6MCbAbez9t24vrk6RXJRuLNNYgpzAJ9w/t71lJOADfA0LbjE/y7bn3MBocqneF3P2ustB4CarP5M7I/QRNUj1Q9sf+gEoklCZM9kiZHUWZPH05W+VR20gipFPEIMx5yCDnscGUwm554aLjhQD6oRI3fRV/y8dqIUN0MS5p5VpxKruj9mxwH83vP3ZgeQQoAW/4uWYOMEMqtEbwdyuYF8U0yMj8oILFXDgLy+FxbMVAWiNl855RbPaZ1CfRCq34A7/Caz/u1h+fPGLsErXA1LkjSYVmh3joCQIqU+ThI+NHrDXAApJitqPwwQdhpCA7bw/tgH9q/PBFR8MnegyCapPeUGOu4kCg2WT8wEYJKAriRY1Do3Can4P4PCdvpZAO+fENxoz3v2fpjwIyu/37HkPurNU/0BJuPPoBFuwwCnM4GI7XTXvmulVKDzcw/I1bxgYB8H/ryVr8AkEPQBOyaWHtHUsTAZj7OSDj8P8gixawiIZPBK7xJkF8KPwwJ4LnSNyyeev0+GAKkJKMX87e8GYKwU+EpApPYtbq+KNZP1f0zsP1MqrByqwV5vm0ziKXIpw88CwcE0aj+WLbhIEMcBnzhWX8+U4otS2GOJ4UW6gIhARtb9kCMY1PGPOoK5F4qQqovkLgI+lU97TqStU6HB8knn7/NJwN0yY9//4M1ATtmz+hq1Dyz+TAmwC2YRJhR7hA6jTtxRIIqO0QBdgOQHEB0Pvo9KzDUo0oN5gkuQbkFYWQ3c46TSAxkfbRr0gdpFZOOPq92BudbBG30soD0QnQM4WDmIHUC79kQSFtBzZcAA6EAQ/P22sy6fdP7+9XTa4n+YDYghQAF3dgNzswHTl4gn/hQyUBN/qjewNh6dggTzZFVAhQczoQJGXEMFR0LxAxO+oZvsYQHUcxk4nOxgnTn+U6sGDpgi/ozU9oUtDxp1elZ9qNod2z0MASrpEhgPHLM91Y6quxBm7AAUqWxjYPnk8/evKf73SUAVAiRQ92YFauD73EAmAaPSqnEIVNhYWdq28KZL0EVNQX1rHVUDjJmOKglRLN5JHlpAWcvecxL9dX7t44DfdwlToUSQXIus/FNIYr7SMKHyT0gKqhg9VHdJEj37bis9NQwwLqdv/3cH8K+cf2BdswOwbwYSFYGw/790DuaLktYf8wc4wDtOga0/5wK4n0A1C0X9AWa5SACa1mW1HuJ9l/H3gGkDWoUM9vhzoD5u3Xvhi/ITI7II1x+w848G+uDlINFxu0nCAxOVlC1nh+AnDXnCGYcFOO0XQgVTATjoAOD57ASQFD2FAV718fXgOE9A2fx4WUsUZl505cB8+9jqT3xm2+w6BDOLy3f/qfxCmW9QQw3KBZgsv4rlrYK76wvj8w6ooYqhzb9ne76KEaD3sxOwFJBKiPFCcwFvVAhx4LjKfjvbf2B+gCYJAOuwGnHAAUw7CEsWy+/bHQC8DkyWAHkmIIQA5Aoa0OfzAL6lF4ZuryegJvvIUQRx/h50ZELBh52ikJZ84Ri6Hr3XN0CM3PbpuYf+ul5Y4GLwHikNuvz0sWJCiYDvyKKj0uqcDMDuNgccQFf1C8kPwehdmlTvQ5UDH+q5Y051HioHIJZRE9GeA/j9579rQ4BcAeg7Aazni94AbLwZhAP14ZQ+AtnYg8ookn0qNFDHiZKHUA7kWrtU7+h8WFY0bRo79bTMQGIcyBT01NsPEu8vZtSf9b/nUoTH6ChpA761uOxnekCsVzOR2IuIwR4frqXTazBFDsWxhSFCrNTOQeyBdxoPikCUa9DLIAQNqxHqusgBbATQQoBtZaoGtLf/2L/r6757zUCiLFicQVVXmdArrgHZlpN44rNRcCYLZd+jun9+KHxt9VEJ0AzJoJ8/iGCoHUqLAUOXguGFAe08OJ2Sc7uzGLz8PZxLCBU7JrhhiHHABWjSyOfuqLYEMJTp3PqDDoD3r9/5UMvvGOiqX2B3AJ9y/sHdAfifB8MfBcXpwZkkAOTqxaBx1r89cL2NTSTWrcNcAADMgTGoAIQVAyKLmbDgsd2BnGcQjiGO9ftgZtcynzOInYQ6Bja2PNUFOIBKx6GV9miooFV/cOzAiuO5p3II1QHokOKwA5CEY1U+Z912aSjOI/27npY/sBNASgKmdwPm7L/rAlRvBAp+LIR6AHqTgcaOIN8o19orYvZIuXuKHrUIy7BA6bW38i5s2HdToGWTzN+p7YUPUe1VHm60zoIkUF0oIb0hLiAP/n78r+lKuoEDJNENPzoW+pADECU4TRAFiHZMmLBgygEooLdjV8DLGYZp3+UPnH/INgLhLwQbMpidD7CRCCbV4B0BrjnIDng5j6Ao5UDd661UDUOmpIeDH+AyY/tFt54Dew0X5qx/ulXBNdVjxTbZAV5kg8FzmatTVQEFTk8GTEz5u3bOHdl5RTT7toNS4gyJtOPMhxn+OjPIDjmAGOD+haQ9EA+IImwDHjmAdj+WP3j+IWgEKra/JPbaewJNDJ+dgv35rwzmcFJQshz1xaIOlLYfwJEIk4or33FogXY+r3ONOwS8qtQRIGH50Dmo3EOfFLT25fsWEIsGsT3PU7fB109PkwHYTc5XcH2cfVUIQpVkPZwHiN1Pc1EFeOzcvGIbhyBbjS0YRyFDPeOjHYAHv52D0NZvfy2fev5hqgLYNwPX9wLugIO3BRd34EDdgF5sa6jspsSHlQXOAzCAEYg6FLCq9xSln1TnQ12BY+s/tvz+GG249gIBGADDmn/vHJ3wZHhcva+06cPZghPqPkhA9sIDQ0YvwOK/OAewnvhYUf4Ax0UNCzKZ7gRgGoGq7Uewi98KQOBXIENJ0PQHgBoai06qbxSYXhiSQwH3wg2p6jb558hgVum7jiGoLqjynzzfUYfQcw/FMj+OFHrE4VxJMP9ehw5WbRzQuk06KmeiQw/vKPx5oxCkqv5kv75VcOEIXD6h5wAemwPwpGfyB9V9ebLHJOB29uVfPf+IqQLYMiDW+LneL5KCWBmISoFH8gBBmNAHNKs9gsL+naKIYrE7tl/afQXIkbKP1h8lBTbP6vMBUiCFi47uQxW95f5tOuo7G07wL+DwN+om+ErJbmomoAIWkM6LcADbzTNk4y17uy+KyGgZ5QFm9y3favm0nQDKZCDMAcDfBbQy9uewAADlmntUeIBAGuUBuH5f8g4dIHeSe0mYRQjBpb0af+P5Rw5gBPbR+qNkwLAkUOaBwlBVYI63EWQCFt2u7ZAC5wcOuAq2s1WRBxUMFd8710L3aLSPstwjiz9yEOb7Bd2Jj7H6qPyFgHYH8K+df1TkAGhOAP5ISDf2D0IA5wx0SLDfnKDcZwYXtwebPEQv+RerfOsALAR2QOEflRCcU2sdzcPSOkh6bqC/rgv4YTw/mSeAee46XCiJt471f2ozEc21Vw7Egss7gmMAb2PRkQk9N2vN273g0GVs9ZWjwGXoIDIB2BxAifdLjd9WBvavxO8GkPmAuPwXNgkpyy9aev2LN9FZlPQZAdk5AU8GjYDIlaADwP6AunxEFu1c6i8cdHq9dwNHEn6szGbgB92CR1xAPR78WKUClwW+AFe2x37fY26iF++XkC/cRsy1j4iC3YghjwDghxwAjS8bOliSsMRgAd+u35LDVmpdPv38Y6IT0DcEpZ8N2y5fTAxSXYGz+YCw979Yc9X6q94F4MODBstCEPPADknmEWQQAXAW7EMXwAMF5xlMOoRpwB/OEwhFd2FDQAZB8xQm/ZSb6OcEWi/+GNiW2F8EwBmMGMIoQnn0snC+ATmAf30nAOwE5CnBQAZF6eGXg6re8otCgmSftfn562OugPfLjTKFueu/+/dIJNHWUQOSAWveKqoaCGDXoRs1F02Qgbm2eq2s+QhxpXad9UMF18dDBXQEFdp+TUXlORibK2PymXAhX+9khSAC8aiRSF4z9vhDHX5MFAiqosxEHvScXEhAY4mz9WX7/d/wtWFW+f05vDNY/tD5x3UOIMf6+AYg/LWgFAqU3wUAu29m/+WuwB4ZOMBj6BDlCvLNFcCMbTzo7UQ4gIFEGyyWsLQNVyDx4QYOQOkQRMzsyUSFHpPJQ2HXvQsYAD6o0fNeKsTZlw2nCw+s/zCxGTuL/c51ZuVZZ3EU4M2eI3mM8gt4TxrgrYNKxDBa5q0+EgqGCzsByBxAfUfAdjJ6EYgDvnhRiCgDGhWnacJ2HcfxPjlonQQO+uwIuiW+/FgmKwDWfSiAeYDPgfWY8ns4DNyCULH5sAM8wjCB1wFqdxrxhPXvZvdji74fWWT1LbDngNqO1aAXxdxo8SX4B2U7vD57Dhvz1+0ciVnws9Ph614+4/wTYQ7AvSLMvAtQ/UKwfVGInDrsGnrgVWFovdC3NQAAIABJREFUg6hL0PfLZyZUcwT2e1WCA8uYypLPVAD6Vt4CWYNsDuyHiaMb44/cCJCZs/1e9brkMcg1xI7HWloFUAUqY8uFks8ouNsmfBfBhAMopeNOjb88W7TzDHj8rvx2JhsWWELwQFfkBt8jX+fyh3cCiHIAXA4E218Ayu3BJiGYKwkl9pUvB6GfFVcEUSyPA3XQF2Be/MHA058r8Lp9AzNWHiEcgV4vlwAzCjhQfJmTIMfy1OMNEniWcqxVLZbbgJfeLYAgMccKCIZtdXzsvKY7yUgBXX2HA85BvjvAX8tY7fW1yVBB5i/QGbTvtHzm+SeDHIAvB6a4f9tZTw22IKIyYK8qwOsoL1CHPcT8ZnBQX0CDoH97kB+gDGrYQuQKZtR9ZptqsDMg+w5Dx/Xdfbox/gSRBDVz5SlcjD9dKfBHm5t41Ak5trF0sPvQqafLbcw5AKPeNKMR80W95Jw7Ro75K9DhuSL4IWDLc/7tuNbbrqflM88/lacD55eClqYfyAGU14DLEmB1AtvD3E4avCLsQCJwP46c/lvOYRU03B6z7oY8MHYcOAKjqvPq3gf0/HHYOjtyCRJhkRLr/ScThzzPYTLTzzC3CUALZksmcRjSTyKqY9Iy2X044QBA0fmXftC9qERduQ9R/oATk5Gtt8fx39WGCqD8IjxZ/o1KAPmHQcorwdyPg/jJQdIRmORf3BlomoGqsyBg8mzB3ChkFN6EFzYZaId1MLlIALylIL07aFfYW9cjGExwjhKKsK1U9FjJPQHpWFtup8qVYUJNeQK4rkBNmaBQwcw6SiLi4Ld/BwlBUX6ThITABqLjkptWaH9upcj7vodyBO1KpdUPypajbZGcls86/3ROAuZfB6r23v5SkP9BEJsErL8VOGgAqgMumApswM2JQEjuWZDmG6VyBKZzz27nCMLNAdDuwEN4e7TsSuygUI5AhgqPCAnmwD4Aarn+x+YIDs0JsAN7/9TtIhTb47sBDjQWuXCFzq3seQN9GzF+u7xO5hi0SuNxvdpbEk2qHtl6f13xtvYYyx/ZCcAmAfEnws1rwrD2X1/80V4Lli4jeGX4IAfgHIFqCFI9AwQ8m/2fcQR2GwtKtupe9RWIY/ud17iy2hPIQyokE1dAT1Phg3Apg8qDV3MinzC/EKh4cSQHKhVswRPJKMfUU+8gPAn6B0YWP3QPzl3pUKSRDth6SvwiUaQwCbfF4yZCWT77/DM5CUjvBDRvB6Y3BO1gFu8LKE0KNd6eJAOX9MuKCkk45Qw80LYlUeIvr4P+QYZFyTuYc3W2l0DPg1uqe6lw0ENjmnHXlRNKSsPlthMWfvpYj+w0LHaX70N0vSZJdtBNGMIJwZm2ksQgGmvapB/lPjRAu4oukneaECy4y9iQtv5Atr84gnYP0nmWzz7/rEgC4lTg9lqwBK4A+KU6UOP5BuI6wCNiMHkDNNg8PRiJQalzAnm6TlZ2pd5+mY3xWZmPOACtwkN3AKw9RQwO7L7DTp0Tj11BMdV9qFR0dE5rUc31TCYSnXUPKg1IJAhIBFJVahHuKOuMym7/bqQy8zNgY4dAyu5afi0Z9cMC3Na6ALyO5XMqAagkYPCWYJfph7IgkkSvG5BLejJ+F6XEzNYyZCCGN+8fhPjp8QrPoFYkhARm7bM6b8kke0CidjLxAE0FtrgSoZy9aH9vrn9uymUcDBsqICfKkpHzYeurANlddpAsyhN0cf6BygEnASX4yZ53HQT1Szirb5KYMF5cCGCJYfmj558TSUCcAGTfEdjyA9uBsB+gNf3YDsB8rB4ZhLE9tgDTkHY9ATzk2YE8zhFYCzsCPDsGBE9SSQW2OFygHEbef257OPfwvJ2E5aGkYL6yg2FDBZxI5ikVD5cF5zXhBWb4RagUtw9b58MkIc8RTCjy+/pj21BFhxyt38EqvM4VJDzwdS6fe/75gABK/I6/FORzAUgI6aJ7cb8nA6OKwgVYpR+FBwrkmRj2757+9hrdW0YgFDkB8x0qSMsxbVCBD79RFjuLNFEFlyovIY81BHtg4feA0PsGPoe24pFDUcSiJ+F4YvQxe70fopQ2dgV0vPDlIH2gN/LJZwzKergduwEFbusQkEhtWFDuk8wJkAuw14Ak0v5e/s1MAOmXgV8HAGNIQD8V7nIBfmbg3hDEyT2cvWfAXrZFsDRQ+r5+VnelzGUw8+C0/QAGvEafLQANcZgsOJ+bv0McBhglJ+Da6+qEFc6S41E7wBwmK01qLT3L6XkHcN7J8p4lu3zPBhWOUby/X8WwD2CsvvgWIAQgg1Y5ExdGoAp3SoazLoEVvYUG7Y7uy4KE4fJ55/dQFYCAL2cF0u8F1sQf/VIQlg1Vpr/zHgADOH6TMCq5nAw0o/QMlAjwipR6roBcSjVdcHwA7TTQcxlLw1t9FwDwNNgBho8oL9qfCnucK1AgMkQZWfhJV6DyDHWZKMfh9YS5AVVFKGosGqgUuPk8cQhgHcG+HVQ+GgG0MYpuwRLGelr+2Pm1DgFsyhxVARDsOgm4X4J7PwDYbfGKcGvRm9I3WMH+BVxhPkCoPyQK5bkUYE3YoMEWA7kX+3uQmOOYcCJyEiLEAPCqMEKGQMPQgex8x3koZWb7Hln+npXf1z3KFYAaDhwJ2/UplXe/GkzqS6Q1EwIY+y5fL6YtfSKAGPwYBu8GaSOA02nrAsS5ALYMmMKD7UthXmA7kX9V+P7Vq7IzMYAyY9mwlu7QtvO2AvjkBDxJsFLj8VmpESp4rp66otNottXuMSIMALBLYtlrUkqYQDEmB0MTQ7AL9Z7qUCQj3214UvmBfuhgyUHnF+oA707o8bZfHdsAlSoAPTfAAIxJJIOYqhQRgA0pgFCxwkfhA4N/I9Pl88/vDQhgAy+WAfnVYNgKjIk/9U4AahvmrsBKAOkNQumGlb+L0+iBOQM7mi1YuwMGJOLUvxBGENdXaz0CuSIX+2Meo1DAQKtj6ZXi8zTcQls4UIwiT4cMlniwb36k8Hy+rmsQquavNx3BWny/rLs+zBd4wrAq7hXXEYprUEIrj47BEtvI0itSSGFB++7FFShiWP6t8+umClB/GKTG/uwGUPlFGbBafpoIlPMB9SIGGX8LCN8PgOvd37IJiN2FJRSvtZG6M3zaoItBnNdU28xn64cCKvnmgQ5LgtKdIgef+e9dCwzOQV1fuRU7MIk8REnOkYhImvF3Qgtf9ne2vpMY9MqOVlsRir0nHmR9cmAiYRKT4B2QCcf56BAsYayn5Y+fz+t6em9S+1wFSMqP9f+SGMQXgkQdgfyeQHgpSK8TUCUJUbkVYbjYXABL7seKDkpvVD0CuwIwDtd8PIjduoClwV/6t9tVeXrCAKYpL1/D8fyAV+5jIYZRWFk1sN9FAXYfpJ3wQbsF4QA6hNGz8AiS9nf+ZoI8LIhRzUfOIYjXZduwdQwF1Og0PFn4fRoppnXLF+wEsM0DwNmAhQAoDDDvCtgOZasB+8FLrsDZ/M7U4GL53ew/tOyYW2jLGxCUDUcVF4ruQgPlCgSwndXMxxY9AOgKujB2MXYnrOjE4+4cE/kBp9aySuFjbkdqjwX8cD9l73W+QJGDXoZAtSodvSwUwWaBR/vn8dFAinbcEomy5Ug6PUfAxFMIAJ0PhhD1XECMy584r+f19PpiCWDrB8i1f3QD9V0BOCdgXA2oIIjmC8gkIDiJMEkYATYCfk/RRwQShAxVqSKiQK2GbUSc3XUJZOsjMkk2O6Ya4QlEA9BEGDBVafCk8fhSYb6mQSsyAkoBFsFhXx2OVn9k+2PyaCDT4YICJ8fxM9so4kiS3sY4g1/ts/yJ19fXT8v5YrP/rRFoAzV3APZyAWKSULX04tXh3B/QqQI4BZ0OBY6qP4OG3EfpAOzG8R0S6BIFhyTYCcjHZCLCh97bFvYbgBePUghFEgfUv5la9+0fWyoUPQ+spp4slUvIy4JJP9rqd5wBKPu+FZUklVprcCty0ATkVP0FzABsxLCeli987/ra6eJ8lQgArH8lgEIG21fmkIBfEhpXA8y8ARUedHIAxuYfJAAkEA+dNGw1bPLyUKnbnjYMgTMGDT9en7lXQJEROIlBqOHASvG0AzgBuZQVI5DNgj1MBO5ohqNMEoWO/W0o4B2AdzPKKhtnEHbrHXMJeL06Zrehw35doiQYqb1yCvacNgfACcDdMHzha+vPL5frjSWA11uNf/8VoOwGaguw7QfYL4SnCZMDaD39oiRYYFh+cciAUij5QRJAE+7BiiTAysvntkqtgRw5CR9CYHZfHgtn8k2GAEWZOKCx35vuyCDmd0RgkpvC5vecwcSsQEVQBkCdY5S7zKDh79CAkvc4UBnAc9i/PaDLeas7gFePK2CzYwitPhAoKroiHU94jRiWL3pt/dnl8nQXhwD4I6FRI5BtFEpfGpN+/ZJgfeBYJaAMPyp5IhxWb0EUJsmHgx72hay/BiEeNzqGWh6QhQkFPFlU4HZU296LfJ4hQcC5ujkChF/eZ6IvQIJ2IgE5VvV23RbcmnhGCT/1k2EIUvu3tuq9mD0RcGzxWbUdQWR3VAiPyUa5l0YAREC1XGhdEB57+aL3rD+zXJ5uT6fzhc4BQDtwdgL7acqvA2GzEMf26heEqtqXGDvIERgXIBKCQYnQEQUafFHi4+2tcto8gIGryQXwXmW/pi5IV96F8HbsFo7kCDyN7UcLymoRmcQxvz2+2W744lJBLtOhAA5ivD+WCKpiypZfJBN/jFllTyDXoLKAtoBk8HtwewehtsHviODXboHDFhsWLF/88+tP7QSwbHkATP6h9S+xP1t/3SKcvmjPAdCUYdoeByWCpS0fEAKAXhOCdwt+aCJkG4A81AnshZjIVkugCWDyddTPZkCX60fnQS7Eba8gnY9zcCZiUTml+jbufzpZRKDEI3PcHOUetDuIQeqBHpBNVW0kGPs3hhwFtF27P905yHG+/WxzD7xuPS1f/HPrT1xcnu5OF+t1IoDcD2BifwQ6hgSqHEgtwjXDD+8CiKoAveWDvMBxoEckAEBy4UEhBVboTAIuOeeBWgaVpY12XOMO4HgxQWEIwJG/3kt1/yngmr3B8cTuQJOMeuOvpYZ2N6zNJ5WddBgMMFRlQxwZuHPlQFTS46GBU+fJZh/lGiJX0F/uwb8nAb/kZ9cf23IAmwvoE4B/S1DL7HtnoJN+yu4zMRTQ0HITz5M6C3LoEcJwXQBkVvEGZrweUuLqCFROQOj9QOnrAB6UFflaG+iZJIJwYxgyRGD3pIODX7kGSShh6c6SwiG1f3Q5MFb2puLevvMbeXu5A23f50MCD352Bo20EkGmzxsB/OjFxel2J4AtD+DKfyUHoNqDtxsTOYIcBuwAoFmBJjwo4ImqA327PwRzQBxuP6P2EVjztXbtPWiMSPjxeROJ2EDHAqK5g1ZXLyTJZMPuJQC3y9Lba2AV5rDHWOlQlSeJ4EBFoecODBEEnYU6BEBw4/2aVPmOVUfAd+0+dZYiQNG9lOXaFSBZ2EQkfm889k4AX/oz6w8vmQBOy3rVCKCUAqEBKOoK7LUI5zcDmRZhsPoWEEwUTVkr0TwhFHDgo0SeU00gDwaf0O5UtAv6Bpx7cOdWpNPKkh5OjRjseZ8SBoz31ZOHYrC70GLY9gsEOjULUDuCbihB8+XZlVg1Va8wo9CkhBKgrAxcrf6oysJBwPFKWFPBDO28fWLga7XOYPnSn15/cFP/zQWcLk43iQD43QA5CVjfCcDNQUnl9y/NVYEM9qZNrPTqF4S1/U/H8I7giAuIgdzIxuhqlySyEstYnQBqEn6ODmzBslOaNPCgrsQ+gVmC8S4jDgX62+rjJlLyispgw+9jtyYioJh55jgFNBwmoN2uahoc36qnBWkP5Eftvtn+ES8Aad+JY31yBpCw3B3Al/3U+gN7DuDidLP9l9qCg1eEj+YFmJ8Vy+BAd1CHuQgJXFlvZP0tcXRJYAbEodozMDKwpxS87wgYzKGrCEuZjarkvmKCUWTn6/7d6oFXW3NekSj0oB7E8J1ZgAg4RRwS2CbcKe8I9C4D933q30wafLxCjk7VSfFnwoa++jdyZutfPi9f9pPr919cphzAaTldLxfrXg7slQTxp8NMIpAcQB0ctR8AlB1mDbZBpPIAbR8P8njdvm2YxS/k1FRfba90mo/J17Q/tEH1oIGtnZ8DAEM7gwlHFVKmz8H4GNNWZUAZtjrr/cu+KqnYA7sHbL5q0QYcJfZiJfeA9jP67BU0d9AUM4rZjy7HqscMGaht6n12Mwu9wiuCQcCzU0HiWb78J9fvLTmAZSOAy9NNIgDIAVA7cCOH7dBifgCrPr/+y7T8stJbd5AufqYikI/zQkEPRAFq6kGftwMw9bdhcBUiAAgFYHZK3w0DWO91so+JDn1FJaZwXgOqjCcNXMLvLVCKvV0xfke9DbgIasiJyGOcAHyEK4C23nLNM4AfhQcR+PvLNTGE5JCvffnyn1i/u1QBdgdwuecB9jAgqgi0Xwr2MwRdVYAbgvacQCYODAnQgqOTMNoVxP8VLOP8gFJfBdZk08gh1GuEYU3bKEcwk0C0DiQmCL6urnMwLshvKYFe7nenXdhCpUG2B3YNan+kLuCDSUMRkfDgZxcSxfdG8YO23h6IkQwUAI8RAFYjJtSfkoNa/dsxl6/48fW7qgNIeYDrrRqQXgQqZge6dmDbJFQV2839L+CkDsGa1Rd2viQUiQQ8CBCoPjdgQOlKc2jD899By7DR6Qm1t8BHZYPrFSVFVuR964HSGyhRHC38Bfy8Sd5zInwwAK/PLS8NHIJNINp7wKpsSILCnmMgt1Bnu+/UGsiOVXZs/9t32vNrcF/aeY9m+/0x05i3x9HHtyRhyYYJZD0tX/Fj63dsnYA1CXhxut5CgfV0XhoBbOFA6f/nBKHN/PccgF+XnIAdoD4k8KraTwByydADSIDeZekD9Q/JgYHQcQ9dEgJdFrG/vVcAmWEfA+q9CgVYjW34gNDVnYR6e00a9lx2+jGtOxASDElioj9gnPW3ScyR5WcF7ib2yOEUQomIZLScySxtjySyEcCPrt+OBJAcwO4CLuPJQQX0pUkoA7mqPvyEmKv50zpZ2hN5AQoRFMjtEM8kMcgJ7A9I2HjlGjwRAZEQAB1QJXEQKKmPIDofxuXKLfBRrWPiUEABl8gA4mxUaT43A1Bu24nZrW73iMCC0MT9gz4DBAWC07kCqB5YIHmV98dB2w6Ae0L7ryKOEcBH6r+tX77yR9ZvUw7gtBFB/akwGw7YFuCcKwCHYJt+GuDrgBBVAQ9oVnml+p0qwKLzARGwJdg6Sj1PHKiB1hXUc1KC0V9LftQy3yBIJHh7kTqu3TsPmW7VwRKItfgxcWgngL7iEYDvJgA7JCGsOpPPY5xAIVpU2VG8zw5BOQoP9IBgSN0j0ihOYDv38lU/vP7NrQRYQoDiAPaegNN5SS/+VAQArcG7jQdlr7G7bRNuIUB2DC7Dz4Duf5YuwIAkIIEXAmxQf3Yn3RxCDGZWzP0M7lpjQtmHhXM8HYIIE36iemBy883f1KM7MDKgvR9ojsF/c84P6LcEz4Mcz6Cs8zQBdBqGGKgj8CtgoxMp1xmRgl3uE4T6WG27RAA/tH7r3glY+wC2XoDTzZYH2MKARgDtRaGt9MevC6eqgJnm65OADcAIVJ0TaEMuIAUJOjrWKGO/r49Ljggu1i6/zqu9qga0HDps3ykBWhXXbzCSx4S2WksqilBilW+uxd4B5QTwWu36jvJT9cESQR/w6nyodhFAUYWTs5u3+W5fUOERATxV/XvEgOTKcX/5nAjgB9dvKY1Aex9AqQSUZOCu5vZ9gb72314ZZhuDIgeAICt/RySgbD4s25XHbtMGQl4+yOonYPpjaAUmYIsuQ+MNOuuNNlMYwNbcaG6Y14jcgW9OYo33kIQzdisEVun5E8fcRmnhO7cBq4mFj+M/434xgBuBWSVEUPDfqKSsqk8jAEzI+Wtm8mIgxxa/3QuzjygRLl/9d9dvIgewlwJrMnDrCajNPr5F2PYE0OvDTD2fHYACPMb5A1fgQC1IgBS9Den8Vz2GIJkDiUHW+hILCg9gGlPZrlt1h6vtkoinivr4O4lH3otTgz4zr4DerhipB49djytr+Lw/gsCebx7wvJ+ezIPgsX+jy5hxAkgkcWzOxPFC7b8oD6rz2dxEuu7lq39g/caeA7AzBEvWv8T8+bPp/MOkH/QI5Gx/+uJcCVCOIG3XBlNT83oMnD+ACm4GvlB2E1fT+l7VYBRCiOahmHSMT/BvQAxdS6TyrU4sCQnupAV/HoqdsMNqq/EiVMLlY+lQgtUeaSByAibTb0qDGYD1mUZOQIcPiljwGmb/ZkC/MPs/VfufcRI2R1Cub/ma71+/YZsMdLF1AEIIAMnA6z0ZmOcHsBtIIBVvDS6Ah4RgetAZcK4SoBW/kgCouSKAemwHUjhusG7fN1D8fbhLwtiuwocYVsUBao8gD2uGmTDaD4A4kjHEGDgE+dITdUYGMak2Ac9ruicMBh1q9pAcnpD5b6roXcIs0Mueve1n1D2NuQLco/a/PScbFlgHpdZte+L1LV/zfevX7WXAy5T44xzATgSnkgzcEoHcIQgNQjgvIFcGsCRokn6mHbjlAbziCxdQv4TNBcgGoO06egnCHjCDEKJCsRv/91qJUaPVnH/WcAA/5Qo0+AWQBVDtvspZcGDwxAai2iXHNCHUWTgSr9YM5PZZKTvaYiTqNyT+ly3Ex0KEXpIPv0sBtfoeaR06BHuvl6/53vWvKgJAB5A6A/07Asx8AaP4AGjpAJoLYMBXh5Dr+MY1uKYhC275rgA4ToORbhJCYGM1wKh6zykU5R0RA4UKXqM9QfS2kU5BTFe27iSdw0Pc1hCsMxq4AXFEa8j9Of1PhU2QAxFJFDYwIPDIrIT9UMCCZr8L+f72yKOAj8GKLiLaRrkIdc0N3EguviSIJIFOaHnH96z/TyOA9Xq5WNJ8gFwFyAnBm6012AJeJATxfQDmBSGo8JT1VwRByTmboYd8gVTofq5gH4JEChVcPcUfWXhJNKTkzol0YG3CDuUICPYyd2GPrz7xFfjXk0U+wZIH+gc8JlIGg50BydAfK769B6iYNmfwhPgfMucI3OhvBdzHEUD7bmzlX5T670nAd3z3+leGDmB/Uch6KRuCavyPCcLtEoPPoOLcB+A/l+NQmS50Bx7cJiyIAC6qAZYUCgjihKKCaB3QM65hMBeh6LKBozyu0vSivN4D9BTeazFexYQbCFqIFUEoAvkFIYAXUPNnRY8qDJFFb9vbZF4E9McTgM81LO/4O+tf3gjgYgP5xem6/Lsrf8oJ7HMDttxAi//FT4nnVuCk1qU6gPmBAmKO98v2ZZBah9BsPdp9BCLkCCJHEGX9DYB61YBRJUHAP0w4kuYOld67CO8bED6aioptxbVqL+cIZPXABx1zZUN/RqvaBUqWsHoWHyktdAA5b8IWeqToCLTob7w2/nvGDURxflTjj8iiHx5wBaB9Xr72u9a/BHMBahKQcwDpdWHr/ivCtTtwSv079r+ShVJ6ArkDNxCFiXftfrbWzknDomh+eRqC/RJhA5OuBoSuYNYRhDkFHTrIpeatu/aKPIytz2AvYeBLOQZj9aE4GIYDlC/QDkBbfHQmFXTTLwZhkrGqOAP6WTKICSBOBvaBHIcFinw4dFDbLF/7nev/ERFAcQAJ/LsL2H9FuE8ATdHrdOL6Ik9Ue5hEVIFW1JxcgJnYw+ssUFsSUQCYKgIG5NNuwB+3W0IEEFv4CVcB/fZ+DkBEJ6iW9h2EZQ9FDHHyr+3FYRAThgItghPV2cLOlqL4jKz4BvDGMSF454CtVP8poMd9+27A229FEB6ko7BgTCaVCMgJbedavvY71r9YQoCS8MNOwLpsOV3ltwa3ZCA6gPIGIQwBTIKPAa/ATstMYq2/rsJDkkUBBoOOqwgE7h4pyKaf4zkCA+uZ6gFPPKo9DAdcgcz9Z1BCmbEXDlhwT+QDqOKAgz8kAPEz6A0gDHhPAArYjyGAXlPPvBvQ6q2s/iH7P3iDcHIUMUks7/zb6/8qHUCO/wsBZAeQJgjV14VlN4C9AbXjrzQHgSMAckg3DtU8/b0vM3Zf5AyicEAtFwm+qvwZcNsZ0uOxVj4tP/tZAuEx81AOLX4jCFbXvr7TWvHrQWp/TwnGxCcq6VQm5ghABRK6QuDDBFgyOZvwRRHASPWjRF4vwddzAyrWRzJCoOo3/4zsv3UKJZTogX93AO/89vUvcBLQxP9pXsDWJHS1hwIXJ/sbgibbjwlAagl28T4qegGeDgssYCnGd2U9jOfFtqIMiMdvQIri/8i6Ry5DQPNoDuBQ30A6nwUvfDowr4CP4Qmhnam3LVIEvxgUr9UnBHX5Ds8aE4IlJs7Aa3eglXKGDBjgngwAoFK1VYgwsvfz66Nk4/LOv7X++cv2SrCWBPQOYCOAXA1YL+qPiJpWYCYA/FwUNi1riouKH+QAyBUY5zCt+lEVQZcOK2xB7SX0Z+r/IekMdN+p87xPaA6j5wPweD4rcIQAmHRGVQFDCrWxxzsUJgX7uZ8DiMhFHQNDkkYqHpRdMoDmoC4BQAjWFHqWALzSWycROwHlOJZ3fdv65zAEqGVAJID29+4AlvzSUFvrL2Cn9wcWglD2v4JHhQmZMIJwwE7hRetOScKOQ9hed+Iy/a6/P1D8EPht+/2vrtprl+EhOw/8/SHTLxVZmOtgQZ2T4Rg6AFHK9Ha/DD90KKzS3lFEBKBdANpkPp+10EwOCHrlDup1POItwUwuWo2Vxe+TQnM1CvRzRLG862+s/9PFVeoDSLX/9Xq5XMq8gNIDsPcD1HkC28tCytuC9vi/5QLs5KCi9hTrLz4hmIYFLBfk0GJ0BrlS97hvoIGylxT0wN+zARLQUbigCEYAMDzmNig6IUcx+wecQuQHpglgMmesYnE4AAAgAElEQVQwRwAWpPiJATln+z3oFbBRCc3flIfo2XpW03FuwAKSHUI7lwJuDPCx+isSgT6Ad33r+mcvLtfbi8tley1YIoDcDmyagbBJCN4WJMHP/QGo/jv4CzCa8pvmoR38CuQR8CfzAlRVaFBMwCbthnx7v1rQlH4EViCEx+QBwpIiqmrfLRwigHqNVqnLGXgpHntEAArQPZCzYs8RgnAE1a1YYHRVHyoY2xE1McTxeEwWihReBAHMHmM9Le/66+uf2QlgdwBpHkBxAzQfwDiAbTvzpqDa/beBYOsU3L52Dgd25aT8gKsAJJC1TkIgCRcGFMvfs/u0jux+ze2HDUY2NxCSwyAUMJTgQD9DGBluA8KYCRv0NgBjOsdcCIBQbOSjYnzW+xmV77kCre7t7Uc+ro9A384ykx/oOYPY7iuC6C/zrmAW2GW7cQixvPtb1v9+I4AN/DUMKOEAtgOXv9u04ev6Q6JV4fPPiYEDSGW9Bn6XACz7ZiA6AqgABUB3l5VBaEnCFvM64cHmPXq5garCojyo7Lo4loa9WDrhEmaAbxWbCUWrOypu8Rc6BzAmAKXe9vg4UNvVNoBb6vAzCDmXYOkHjzMCOKp1/Hds52fUXrXz+mVj8NpzWdAXp2IJyRPI8u5vXv/b/Y1AFycggBwG2EpAmhvQXhySkoEK/MYNMPjt5/1xZ4Iw4HdhgOoPiJzAWYCYty0Oo1j/mBQqNAfE0LaLlD1W/P45WFnb59m/+t2KaNijc4228etHLkCFDHWZKZURAcg2Yq3u7CBeDAG0GFo3CcXKrkAbAbmQ5B5zmIYe9Aap5Bttw26Ft13e/U3rn94IIKt/TQRe5ETgHgbYqcHmpSEpGQjKf4gQGvh9ApDyAFL1rc1vtr6fK0hrAYwm4QiEYGJuDgIYzDZP4M5hOvjw3D0IHwgRuEMwtPP6fAreKl8QuwDb/BMpPPoF+wvD3klYsKrmInYOXjWZAJSqI9D83/ExMQRRuQGlvscJwKv2TGhQCCFyFuV6l3d/4/m/urhachVgvb7Y8gDpZ8JdMrCSAYQI6dXhSAD5rUGm7JfAjDMFfViACg3g7zqBArPYCZSuQgvIsj26AASbdQMWhna7FC6U/43MPS2H3oKxgk+SwBNyBFEQoMIL3tYTAmcOyu8aiuVZ2SKyQACV+xSRAm87H/+3bzRyB0pNLaGo0MCqtyaA4yDv2/92TruddwrLu//a+b+4vFzqK8G2dwPCJKCwMajOF9hfGVbKgBH4ySGYnEAC4YnyBPsD5+2IDLTiN/W3sbxX/BbF23Ws9WnwAYW4xB/rvQBt3sevmQF4sM1EjsCCK1J/XK6A2tbzWukIRKvyk8IBRxRzdh89Ayu0KttFYNYlPkscTDhepZsXQbseATRW7nYmbf1VeKJDiG3p8u5vWP+z1AmY1Z8SgIUQQP3NlOE0UzD/glAmgqT0ojdAJAQl+I3dz25gL9OBM6jHauCs+Yi6La2LlrvEH1KAJ450VBECZCdg6KDjEDTRKJCiYxl7Bt5CKbmGvN1zJiyI3yCk5wNwoKCIQS+z3kOpdSM7TRDxPvM2PyIDDgdmE30vngAi9dcksLz69et/kjoBKwHUMqAMBUpOoBDFnhRMYUCz+Qr8eRlXBEKVL2AvNXr7uSUfM8irwjYHgI1DKgSwjT3gHNzEINybQgCO7QHwqk6gGnv0dthFOOMSZtQ9Jo/Y7mdYiW4/BFyz6DGJNJDoPe36ppga2Lx+liDG5IDqXc7tY2qr6PF2nlxG8bklBQ/c0frR8dGBLK9+3fqnLi72RqAtAdj6AEwFgPIB0BW4v0249ARI5Qcy6ILflwtLCNDgV7Ypys7uAJenEMLsWxXaVxQcQdTGICQUkSDM3YGxmjO8IzDn7WY6DTnh1/k8Un8J3ADsFnIN6HgOdg0YMtjt/NGOKP/j1R4beR4f/7Nys+L3qwOWYhCQNpR4DPjt9/Nhgj3m8upfXf+jWgW4PN1cqARg7hDMJGHbgrfGocvTzbqcL6z157jfuoINnL2koAO/yBskgJPi5/DBx/cFYAxo+kwVAWv3AeZBV6ElkkJICSx+XQZRt1fgMeqf9pkFf5l+yv4g2t9qrT9PHO8r5ecZf33lx7VouyNC6G2DYENA279bgg5B/kYRQE/de3mBBvRRjiDRTdl+efX/Xf9kKwO2MABDgpoUzGpvXhxSl209AQjyQgCvu0agdeklBZsTqIDhBKEBOQBYKv7WE2BB3iJ4sP3UbahDBp45iOqOHoBBaz+360HIaaCH4UFUVoTlEsBB4lCDXWUBFODt3pEjeIwbUMfywO2FAx7ACuwxAeikGlp+Bu0oHPAJwrm43RJAnNhr1xNvU0hgefX/Pv/7rQzY2oA30LuKABBA7RosyzYXANWA6gYMeBMZaOXHHEGGqKsMCHKAZCAnCS3wMRzIeiwSi2zlW55AATzODRjtF1UDooTAxIeewaQbWbmN+j+xUqCgzWTB23ir75U/dgneXzQV7wGdnUSc2GO3gMlBlSj0gG3XocD8YglgjhyKrvsQokMCy+m0vPpXzv9ucQCp+SfF+xd7nO9j/50URA4gdQjmHxItRLBQebACWiQEAewJdDm+r63C6XMDuX2PgLH8wgnU/VwlwBNDcx42AMAJSirmN2ptyn7aEcR5Axs6FID3t1dv91HUoJf17b7dB5XckE2d11+2ZzDrygD6DFb3Y5b/qBMYuQMGn46v58OBPph7Ci/tP/20GB7d5hUUCaRly6v/1/pvp8lAbS4AzAnYSWBvDirZ/0wAygGcLtar2hMgwc8JQV0ZSMoN/+XPFvwFpna7ppmFMJraNwIpwLahAfcVcB6B5xM4fa7EYwHM+1njr6x/FPfTGYOE4XTsPwoXur8cxKTAtNDWe4AzUBthxJY/VngmCaXidhvrDlCxEcz9+r93GLEbsADUYG5nbvE8hx8xkAvgyx7+GLhv+3t59S+v764OAN4JUBN+OSnYEoDrdf07kcHNcpneFbAnA43659LgDmAEf/D3pu8j8LNTyFl46w4A4KY8yKSRt4O+A4799ecGcBvPxyFBrN4zVQL9HoIoQHixBBA5hjjut/DGnAFSQVluXYIKDRjQ6Dp6YG+hgz1qAUc7zljpfQIwcAPwS0KKELxFt0e2yt1b58kgdhAa/NvS5dW/tL5zJ4C9AuDtfwoF0iSgPFW4/r0t253ARgCZDPYwIKu/dAMYBiDY8z7NqlsXwGEBbseVgLatbx6KQoFY7YMQARKLHtzHk4MGzBPtxZ2aAmX/Izfhge2Jw1t4a+61ytuwQIGeKUJVArzizwLfA5v1P123Vc1GSAxS5xDAelv73/a0JNOz/kgT7ZryxZlf8sVl/m/lIGLgl+++vPp/nr/m4nKbC9A6AQvoMRSA2H8H+77NBnpIAu4/MX5RqgE504+hADoB9/cGmrmQAMnAhAW7gyjqjPkCIAKT+LPgdklEU7yzvQOeMND2H3QCtaphgwMP0RjMeMbHOAALWntmdTwLa64MzIIeodqoJUr6WRhbEjnmBBqxWfi1n+zWBNEHOFt7ZfURphFJoAtQ21uXYH1Gs/498LdAYXn1f1+/quYA9nkA2eLnRqCNGPZXhOV6P/67EwEQQCGENDloy/hDEtAAXocACdi2X4BDAvyM4Hfb1ap7dhKUGEQAa/XHDsQcKphZhFHyEMID0y6MPkH/qnEvTNBGfFbd57bTxMFQL+rJVxSBXqm9Bz7uPU4Etq17wPdOIB95J1xW3raMrXtU/x8BXhOAsu4NkBy7z9j6mW20e9hCgL+4fgX3Aeygh0qAj/8TKezgL6HB1f5Ogevl6nS7TxHegZz/k+DH/oDXIfZvLsCqO24D6l6bgXxSUIcCZd8gPDBqTIlEMwcAzxeDviozzQDU8ftkPiDs/JsDuiYTVvG2lXYA3jNwVsAm9LzCe0VXZOHjdwZ2epOUpQ0mEQ9qH8PPxPkRGaDJ96FFpNL9GP9p6s8OQH3eCOB/W78M3gewzwPY7X1xAqD8Tf2zSygOIOUA9jzCXg68OF+mGLW4gALq2BE0sCdiMOBfXjefffxfgNryBiU5Z1wCTCay7oEVHtXdA72XKDRuIoOeHQaercGMHMJEo4+aV2DBfYwQeqGDygbw9r2wQCm8pRBUdeEQzAxDezSV7POE0LH9zg+o/MAR+++3xSVo0zHUYJWeVXZLFHPALyS1vPt/OX/xNh24qT5MCqLEX4n767/FATQiSI7gct3fF2hDAAX+5gJs/A+A38mghQUq/o9CgbIcY3u/bYGjrxD4/YrSi9wBdBIyQXjAxzmC5iXsX4oongL2tK8nCG34tTtoBKCThR706axuOU0fVvD2YcEoDChA8HYfQedDAQvex9l/RQCjZRa4x9X/GPAL2Szv/gvrF17CZKCdCPYuwNwMlBN+JdY3/17lHEAmghoSXJ5ubQiA4PdEwLH/Dvha+wfwQwXBgZtcA69vVty6iwb7AgZcj9N+W+iwLx20DmuXgKCL7T6v0Uofqfsx1edwIHIBfrmmCmPY3VuJmCjsMWLgM2mosEARgl5mCWAmFLB+Ymz3lVtggPJ5ewQQ7VtgjDmE3jJPEsu7//z6Ba0PwKp/6QYsOYC9VHjZ4n8AfM0HXGy5gDo5KLmApOAF1P7vZNcT0JEMjPLzNnVbtP8cKoC6S4LAPAABHCYZVUC6RGIDNNt8b/sR1n0HoEOEo44g2p4hbz/3CQDWyhmDDOhy7Dngo6NgW2913PoIb/e96nOGAD/j/seXj8jBry/2u8HWJwF76xrEHw/86gDe9efOn3+5vRIsx/yl9FfLgpdpTgDY/jRHAGx//Xy1L98JYLk4XzUXsCkmJgWbC2jgx9i/kIFalgEP1QKv9pwLaKpucwJo/znhV8godgE8qWhEAjo0YKBiLkCBWCn8jOrPbFMsOpCC+4XeiDBmw4CYDKyu+2DBx/rKCaiEIFPEnOr3E34I0ZYz8O7A0ouO/4+ovz4DHreAu/2riCKtXd71P58/73J/KWhpBU4u4GLv7kvJvp0M9lLgen1xlbL/hgQgFNjfMLy7gJwHgERgIgGbHEygKUAvJJHj/qra1h342L4pf10nOgY1UQgSEFOKo3wAgr6XHLTvEMJwowAKAWqP5EOAx5IAgpeOUe26tvYJjt498Na9vIC1+O2IHviPt/x4VKX63i2oJRFBIPgUAWi1j+J5u1wBm4GrfEEM7j4ppLXLu/7H9XN3AoAeAGgKSuqPLiCDvZIAgj/b/0ICpgpgQoEE9Jb4KwDOy43dj8BPicE9LodtYeKQJwx0BFllIUSwoFbOoCizTQaOHIGfhmxpwQLdhwwWfk/IATzyBaIzeQCv7wz04jKU4S8kY6nCAlkpvLf8SCHHQK9AjlBt59JW3G57xBH40KCdAVXdVwdY83ukYH3B8q4/u35OygFk5S9lwKL+l+ACWP0t+Hf7X3IAez/A8voFkkBK7rVQAO1/IQN0CW1ZcgnFLVhAc3/AHAlURYeXitjwgKsCCPbob9VbYG38TG4gQYRTgQz4SQKYnA7M2j6bC7Db+TDAq35s7RVoLbTVpxj8WtubXe9XAGwiz+v9yAEw9C0oj6u/phsL/TngY8CxvPPPnD+LQ4BL6PzbYv+LDejl31zm2x3A1ZLmEOTYH/7dw4DTcr5sgH8v5AFsTqARQ7b+Bey1/s/gz58hRHCkALMJnfWn2YWzwPdhAJOEzRdYGOO2ESnY5TpsUCFDXpbbnCPwegMfL5klABsa9JN9EfRV7O+tfE/TZ+J+b8+tlvdtf0QArMYM7Nj+27i/D28mD+8H2AOMPpcjLu/8H9bPvLg43V5yCACx/5b533MBu+LveYDkGK6WDegpJ1Dsf/p3dwKnPQ/w3toQ1KoBrTKArqApfKkeKOUvio9xP6u+cAHO4rcwAGcSHksS6lAgyhcoQvBaD8oeTC8uDkHBdzv3G0sAKhBQNIAQLleqrL2lhb7510D3ZNEDu03t4ZY6VEAnEG0dq72y62P119bfUsa82isyqATwtf/d+hnJAUAIsMX8HALkEmAigaT6xQHsFYGrbP+3f1siME0PXt4LpUAsCxIRbMqf4/9CFsb2jxxBjfuBHKifQCcCmQwKLLHEGKn9yAX08wSVANyPhRxPBJY9tiFbaOSxZKD3Q3g2+uGl4zxArPk+M9CjBIasNvX9UMCnCvswR+AhlL0XiAAbxfCj2N4Tx0jn9Xr8Bss7/pvzp5cQ4HJ/H8B6vYUALfGHmX/4+2qFECD9vdn+Av6Lq9P2YyO3G/j3+H2P/fPfORfQQN5yAwh8QwI1iVjCBPVvBjK0Dtc8Qg4JIgJQLqDvBmy8H6t+QAD0UlGGu53uOxf/c9YAHcJRIogIwGp9OsOYAHRtYOQHGhBHGt9zBlbB8XoTPBqsLJx1jM+WPqIDPnaDooLxGPqWTB4HfHWM5R1/ev20y4v2PgAs+212fyeDZv139b/cY/715rKEADvwKwnc5XBgCwPu1uX1BR3AeSOBnAisAOfPuXFoW28dAeUIcq5AJwuRIFDJRckwIAd8g5DKE+j16B7y37MvHDVvOEajPyIATx8cHjQIquRhZOv1UcbVAEsJI6BHQUDbr6fhDOkZiD8e9Ec0nwMDa+x7cb2H6tMMf6EjTxzLO/7r9VMvLtb9xR4p+ZdBn2v+W24gx/07Eeyfd/ufbX+J/3MIkEOBXf2Xq9Pd6SJVAgrw939LCXBXavhcS4MW+Coc8O4A8wUJ/E3to8qAXm7dgA0HEPS4XbXy+SfNMNvf4IlAbb0AZl/q0beq3q//67pAWzrnAlitPQkcI4Aj8Lehgf7kLbungFnTr91BPwRQsJ6L9DmbgHCc8wAvTvnLkZav+S/Pn9KqACkPsCl8TvLt4C8uYF9ecwA5BChEUJJ/16e7vay4hQA7AZwvE/ghD3BKFQEJfugXSCAuPQMF4HkZTBJqYA+qBSo34FRfkYFqFS75AiCGmdeO8ctF5LsF0jEb5BD+fRdg10Ylwm2YMaDVZ47ibTBxlADQwHPIwFDVbmDGAfSIIYb0nO3XoD9a2Ovp+kjhR+tH1BDtv3z1f77+vpYETC6gZP0vU8a/qn4lgBQS7HH/5fXe9ZeTgEuy/1en7d9CAFc1D1DUvuQFQP1LjgDzAiZHsIO45BIQ6Br0NvZ/ihtoJGDCAAd6jPXt31bhdTlwPgcQ6XwM+jgc6JOBNfJlW7XUqjwDPgK9zR54kI/MfboiG20rQLfjMJBx6yhXYHW6F/Nj1kDF20xD3gFoGL9R4N/OtnzVf3r+pEQAGfw1CZjBX23/9nmL/5dN3W8urlIOoGT/M/B35c9/329/ny7Peykwlfu2f4vlb9b/XAmhdQgmABfXkPoGPDnYnEADPcwlyOofE0LJDwzCAflGIeEGahMPWvxRJSBS+p4DsG5hZP81CYz9wBwJHCEAFRJo9e4X/Y7bfF8AHIGeCcLCegR4Xh+TQl+/31gC+I/Pv/fyMjf0bBOCNsXfSGDr+tvBX4Cfkn+76m9JQEEAF9e76hcSuN+cwOYOdiDvIE8EUMGdKwPJwvtcQMsbtLZhGxY0oCP4PRH08gN2XZuR2EqDXDmwLb24XQHlUx1Ag7PP7D/dATSFHnsDHQwwLfiynrbyVtNHdl85gEjxLVlYrWUHoFRc5/yZIHpuYBzRR0DuAfyp4I9Ip+YAvvJPrR+/JQG3EuBWAUhJv9P1BvIN/JUIdvXPyn+9EcZ6c7H925J/dxdX6+3+K0OJCHYHsFyttwncRf0TGaDCa1fQHEAUFiRwJHLAvxNAo3wAVwG4q3AEfKwolL8R+E35dSIQAwLc1iq6LQPyOv95PgAoxrln/1UiEN3CDAGMlT4igHnlV87BG+1jBBCB3roB9gIMVAXcX2gCmCGP5Sv+w/PHpclAadbfRgAb6Av4S9y/EwISwN4HcLq9vC5xfwZ/jv8vrncCuC8EUElAOQF0AJAsbG6hgJxDBFxeQI/235JAI4lMHKYleFwe1B2DnCjULsDG+FFI4ElgnNzz2YMetHFdL9VX0oVRTcBSgHIADYjNcVjAItARpEr5C+AiMB8BOULZO4ftGjlXUPIMRTd7ZMDbNmdwhBTamfrhQbR2Bvx7DuDL/+T5d+0hwNLAv2f+r5abqwb668vrZP1r7H992j43B7Bl/wH8ORG4EcBdCQHQCdi/W7cguoGm/MkxDBOEUDFQpcPUkMT9AQr4Nh+gm4RY9TG5x87gMZOEElRnQgCv/rxEx/rj6j9TBNKBdQRWzeesvncA5ZjewjNQLeCRWHhfD2ZPALHVH5OBBvws2EdAHa1XBHBkn+XL/oP1Yy63PoBN+bcQIMf/l9c5BNj+zUSwkcCeF7hOwK8EUMDf/t3Vf3MBy+V6l+L/13L8j7mAMkGo5AZagjAGfysncpkwrhog6DFv0EsANmIYKX+rDkRuICKApvhRvd8TwNPtf3MBbOWbVuttojDAK7tWfQVw3DKpr1LzPgE0SPvtFAGoMAGVWqXvijOYA/yLIIAjQPYZiDnnsHzpv3f+6MuLZZ8MtIcAxf5fn26utr8LAVyXrP96k4ng9iK5gBT7b+C/Xva4v9j/i+vTQ3UAmQBqInB5rWb5k9UvxIAJwaL8UDHA0iF2DKL6Q2ehs/01b9CSf3YbjPHjsKCpc8sZ+OQgAzyO+Y8RgCWB+fg/0nxebj83mjhKAB7wiVgKiNjs4/aWCGLrrxW/ncPb9t46G9vHoB/F/KP1Mxb/MQRwdJ/lS/6d9aNKErCAf7f+1zkEqARQlD8TwfVa4/8M+rvLFPdvBPCQHcBOAOdTAftrOQFYwL65ggL45gJ8GNBCAKwWmJDAgF41D2G2nxOEHBaozyr5p2y/Ajluh8ZeZfs56u/BexT/a+tfQOj13tt6Ze0biO0RME7n+N5+5vxAi7uTA4hCALVOEQC7CAYyGnuv6J4g4m0iIP+iIYAvevf5I65yGXC3/0X5r9brqwz+q5sU/yfrvzmAlvzblf/qtIF/+3e3/fm/jQQeLjIBbCTAoUAjBgR/yf7bngEuFba+gig3gD0CbPuf0jGYiMCHBQXYZT2/G8Am/ljxkQqa/VY5AFxb8gR+WbzEqz3rPdr/eQLwYUDLIKh1s2rP2x0DPOcKUOERpBb0niBOp6U6l55LmCWEN8oB8LWNAoHli951/q0XS+rxb4m/BP6dAKoD2EgAwL+TQLL/l2j9r9f7y+vlYXcBWwhweb47Lyn+T3mAkgsoroCVH/MBLQTA3gFdHeBEoSaA8mahca8AOgZfGozmBDRN7vUCMDkUILPa6wwAg3scAign0JbZTIB3AQ3IqPhWxVm5vUvA7Xt/s/Wfs/gYViiQz4JdbZeOt/8iaP2faLsIgLM5gegcIyDPEIo6xvKFX7v+5hQCbHMA1uvN/l9t9j+DP7mAFPdf7nmA0+3lzVb6yyHA9a7+95vSZ+BvDmAH/+X16dnp6nzbgJ8IIOUBGhFwdcDmBHjeAPcQ2H4BmwhMSi+TgyIXUPoHxlODZ8KBkQOwcbzX+pG9n1H/PvBbwo2Dgaa62u57RVexPapv/DeTwQwBRKFAs/ps41vmwW8zcgW/WAjgaPy/fa/lC776/JtSG/CW9MvgL/Z/cwGb/U9uYLf/V1vdP6t/tv07AewkkP7bgP9wcXN6dnF9erZcvn6TwF7Ab11AcwboBF6rk4dUglA3EcVlQqv2SAqqOjCr/Dr5Z5t/Wj4AI38Ldjb/nAPo2/tY/b3Vt0eyII9UfkwAfJwEMEUIzWm0mNoSg1d7tuYe2O1YDcgN7iqeP7rs7wUBHAXz0e2LG1j++Feuv2F3AJdb0q9Z/+QCNsCfbi5vltuNAPbYf6v97wnATfmXDfBIAA+XN7v6P9vU//Lm9Hy9eO9VUv1GApYQwA3UUMGGBVwh0L0Ctp247wSwAuDnDbQXkPas/wwBoMpzDmDkAFDhEeYW2J4A5lS/ALQHcAtka/85qacdwMjqK7W36t4HfLkmb81HRMFWvUcK7+sE8Fjw7w7g87/s/GEbAWwlv80BXN8k+7//d7PlAHbVT+Df/0vWPxHAupf+LnPcv4F/A/6m/pkAXlqX1y4S4N9TXYAjhL37D/MEcV7gMRWC+XbhXva/vIY8mB0oJgFZE68IwJKASgRqhW8gt+t7qu9j+z7AOd73YYEigQKsFl4UR6Cs/hjsvdg+AnkvBxDnAqyT8ATRcgCjDP9svN8D7hFQH9mW8wDLH/uS84duIcBOADvw1+vrDP5EAgn81QEU9b9Z7i+v1ruLm9P91fWSlX99uLxeduXP/72UgF/An/7d3cCu9vY/mxtIpNAmENFEIpxUVLsEsVyIvz3gW4b5NeN2tmBMBOplIT4hiIafy4I2GIh0vtj1eQKYAb8CcTPhSAjNIbBKN9XluB4BaR0Bxt3Wntt9RiGAjd/fJIB2P2aThI4APvcLX/+Qq8uL2633//pmcwA5D7D/u+4EgODfcgCXN9n236TYf4v5i/pf3qzPLm+WlzYCuLhen51PP5+Bnohg3YFv3UDLDxQnwF2D+DlZfTOrsJJBATo2DuH8gWL92farvoCS6OMfIFEOwHb6aa2PC389sM8RgFJ3tuz9zz4HgGRh1RvJoSm+B7aP72fcwBzIE1mp+F8ve1zcj6HF4x1ApNBHlyuQP0X99xDgj37B+Z/ZZgJuan+9xf03hQh24G9hADiA9XYD/9Vm+wv4N9t/c3q4SjF/Uv/b00YALy2Xr9/toN8AvxQnYN2ATw5ymbCBn+cP6O7BXi4gKbt6bwB3A7b2Xp8HKOt0yQ/7ARG+jyWAfkxvXwLOCh+BfmTnrcqzSs8TQM/2Ixn0/44s/S93Angq+HcC+OzPf/2fvry8uN0SgDebA7jNZLA5gE39b5r9v0rKf3dVwb/eX93sln8jgedXxfrfnl66uj29clpeuzovmwNA8AchgUsS2vkDLUegmoZ8+3CL++EVUykAAAroSURBVDkUwLIgZ/zbJKAxAWjVj+DPZT6l7PGyWOHbPrG954SftfqYsUfgq2y+dQUjy+/t/Tzoe0m8Iwm+IyQRJQY5CXg0B3BU6WeBPbtdLzxYPuvzzv/U5gA2639zs+z/7mHAzbolBHcCKMm/jQCutth/j/vX7d+HTADPrm63uH99fnW7vHx1e9r+eyXZ//KfJ4HdGVTg49++aUj1CpQ3BtlwoCi8bwyypBCVAIvi4zyAErdj/d/W+THhZ0OAluizfqAY//ZvWm8V3y+zQI8dgFZ5TQYc51vwzzkAb917BKCAGW3PDuCXAgG8LyQAdwfwhz/n9X/y+uridkv+3dxuJHC6ubrdqwHbsj0EuLpZNtW/u7peGwHs4F835X92dbs8v9pU/2ZX/pev7k6vXFy/nuN/JADrBhIBaBJoCcG4cxAJoLx5WLYM0wtD5roA2fpz7K8IwCb4uJVHE0ADvFfz7RxK/Ru4LUGwQnMI4IFdYmmO171LaLF128cvs1UAuz5ah8vV30cJAMH1S9kBsGN5TCJw+Yw/cv4ntiagHfy3y04A1zc78HfwX+/gT7H/dVb/6xL3327gT9b/6nZ96fpueWVT/qvb01tOl++5bur/cxnojQwa+I/mBLhV2L9dKH5vQNQEZBN+HOPrz9zO44t43MiLYFXlO2XnRxY/EUSk9t6y2+x+ZPObVe+B3TuDPiG8SQAWokdDgzckCfjpn/n6P745gOub8/XtXQoBbm4365/UPxHAHvfvsf/VzXp/fbs829Q/Kf/6/Pou2f7ru9MrV3ent17drq+cTxvoy38YCvx8Sgru/xVHgJWBLWmI5cFSDrTJQPdCkVwJ4NmC/sUgUcZ/3vIfaemJQK+s/XiZBWzbPlJ2julVjK/jcgR++ZsBrAhg1va/kSHALwYH8CJCgBeSA/i0P3T+x7YGoNu7083t7XJzfbvF/nseYI//r28T+K9vlx38V7fLw/Vu+9dn13fLS9cp4ffy9d36yvX98tbru9PblqvX7hL4fzaDfPt7A74lAp8cTETguwYxIahLghgCqAQgZvltzV/N+ceY36f1UNl1lb/E9Sd6y7+N8dneKzvvFR7t/yzwtaIzyBXAjzqAxxDAiAx+KYYA7zME8Ac/7fV/9Ob24vbm9ny9EcDN3XK7hQBIAJv1v7o93V/fnh6ub9eH6xTzP7++O710fXd6+ebu9Jbr7b/709uu79e3J+AXAkguYN0/RwRAvQKibbg1BJWOQZwp2HthCJf+et1+JRTAWL7pfQ/sNr7nuD599m5AJfSsbbcqbxXcO4A5oCt1j9T8TQIoYc2L7QN4nyGAT/nU8z+yxf27A7jL1YDbXflvr2+T/b/ewL9Z/7vl2fXt6dn13en5zQ7+9eWbu2UD/ltv7k9vu3k4vd9y9Z77jQDWnQTKfxgKIBFgGJAbhUTbsJowZDsES6mPXxdWynyo8tFbfjDJx8k8m85TyTyM1ft/FzKYA3oP5M0dPA34PYv/JgH8EieAT/797/21m/Lf3adE4O3mAG53F7Db/5vbZVP+++u79eHmdrHgv1/ecvNweuvt/entG/hv7s9vP59+5tT+804guQAmgVYitKVBnEWIU4jt68PGrw23qt+SegXY0b/JynNZT8X1aOf93x70bZsE3gjoPZC/SQD9rr+ogagk0zj0+IXsA3ifcQCf+MnnX3N3d0oEcJcSgDe7+q+3O/jvNuu/3t/cnZ7d3C278t/cry/fFvA/rG+/fVje/+756YNOFz97fT79NBHARgg2HIhDgdw1OJwjYF8eqgmgB3rM67eIXgO9WHf+19p6SwocpyfrjqBn8EZgfpMAPMij0l4P0DPrflkSwO/5hPf+6vv75ADu7vdqwM3N3cXdzd2m/uvdzd3ycLOp/93p+e39ksD/sLzl9uH0trtnp7ffPjt9wN2z0wdd3b7n5fPpp06JAJgEOBTQYUBT/1IaxAlBJfmH7xDEST6+xIdKz5F8qfKrd/O0WL84gAJg/JeXqdq8An16tdSbBKB7BHp9ALPAf7MKMN8RsHzc7z7/g/cPp5v73QGsexLw9m7J4D/d394vz27u1me3D8tLt/fry3cPy1vunu3gf7+75+sH3L+0/Irbh9c/4Hz6yVMigB4JRKXBEv+rSUL0GnE38Qd7+5Xql7l6GMe3Rt+WnPMKX1Q9+jft6y08gtv//SYBqJzDTKb/KAEcJYJflg7gYz72vb/y4dmm/psLWG5v7k63t3enu9u7Dfynh9v707O7DfwPp5fvHk5vuX++vu3++fL+98/XD3x4efngh5dPv+p8+vFTIgAmAZUP4N6AKP7HdwTYdwNibb/9BFjSdGXum9pbkFulb3G4BbwHuQJ4H/SFJLZ/33cJYFQJeKP6AGbLgL8YCEDF9rPLODcx0vEX0gfw0b/z/MHPn59ubvcQYFP/9fb2frm/vV/v7+5Pz+6fLS/dPZxevn92esv9S6e3Pzw/vf/Dy6e/79nLp7//+VtO/9B68RNXiQCYBEoYsP0bhQB2fkD78RCeAdisPv/mXwx6m7zzoG5ttiU2t/82m95UHoFs/36TAHRD0Wxr8C8VBzAL9veZJOBH/vb3ftBGAPfPLm/v7k63dw+nu7v70/3tw/pw/3B6fv/s9PLDS8tbH146vf3ZS+sHPH/L8sHPX1l/1ctvW37N6fLHb86nHz2dTz8mCGALBdABYGMQTxDCl4Xa2X42wccqz026kcK3hhwEeQTs2eUYy79JAG8SQNSbP0sKf08cwG/7iPMHJAew3jw8XNzd3Z/v7p8tD/fPTs8fXjq9/Oyl5a3PXz693/NX1g986a3Lr3zlbadf/cr7nf7h08WPXJ9PP3w6n34ECOAnIAwoyUDVC8CTgLi5BxW/NOew1iewl/9KLI9Kj0BWoJ4F+psOIIH7zRDAViQUYGfB/j7jAD78w197+7Pny83Ds+X2/tly9/Cw3j97aXn+7KXl5ecvn976/JX1/V552/IrXnnb+g+89f2XX/u2D/z/2zuXnYSBMAqf0YhAW1pKuQVUVDRqCG5MUBN0oRt3bnwMX8c38EmMD+DGxBgX3qKocUc0mk5NkQk/ZWw1bozMgnBpWJ5zvv8yrbfM0QLHIzieiAH4FED7ACL9xS4APQlI7wxM7+4jOvm9pKejObng+1H9K9ErA/jeslDYOrAygH9oADs7PK3piCU1b1wzWEI3mKYZnmFazDZt5KwMypkcqtki6pbzuuTiFhz34HgIGIBIf5r8YtxHEz+I+PLmXb/YP0VOXwK/xW/0e9Rn2XUZzkcRgioBoqlA9QB69ESben+GALa231O67sV0YyRupJA00yMpy2a27aDg5FHJl7xaucKaca1V4LiEi5uuAfgEQPGf1vy0xqcNPXnCy0QcJvZgyn8n9RUBKAKQbQaGj/56kqVPBgqKVzZujBL7nzGAZrOtpczYuGmxhGUzw8myTK6IUmkSi5Uqa05Mt7c4TsFxAY4ruLjr4r8vfj/1hfBF2gu8F3W8OIwzmOJRqR5mDIoABpeJxHz9N++qBKCiHwIDaKy+JWx7LO5kPb1QhDM1g9mFGttYWfP2OY7BcQKOc3Bcd7Df7XT9/VpfHPWlgo8WeVD0UUkvS3tFAIPjyN+Inv5XGcCQGUC9/hwrlQ1tbn602FjH5u7eywHHIVwcgeOsi/v+jN9v6vn1O+AG6vEwUf/kWjDVFQGEpzwdPSoD6J9UfIX2wWWiYS8BPgCAPOYxoDrtqQAAAABJRU5ErkJggg==";
  96993. return BRDFTextureTools;
  96994. }());
  96995. /***/ }),
  96996. /***/ "./Misc/dds.ts":
  96997. /*!*********************!*\
  96998. !*** ./Misc/dds.ts ***!
  96999. \*********************/
  97000. /*! exports provided: DDSTools */
  97001. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97002. "use strict";
  97003. __webpack_require__.r(__webpack_exports__);
  97004. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  97005. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  97006. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  97007. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97008. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  97009. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  97010. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  97011. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  97012. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  97013. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  97014. // All values and structures referenced from:
  97015. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  97016. var DDS_MAGIC = 0x20534444;
  97017. var
  97018. //DDSD_CAPS = 0x1,
  97019. //DDSD_HEIGHT = 0x2,
  97020. //DDSD_WIDTH = 0x4,
  97021. //DDSD_PITCH = 0x8,
  97022. //DDSD_PIXELFORMAT = 0x1000,
  97023. DDSD_MIPMAPCOUNT = 0x20000;
  97024. //DDSD_LINEARSIZE = 0x80000,
  97025. //DDSD_DEPTH = 0x800000;
  97026. // var DDSCAPS_COMPLEX = 0x8,
  97027. // DDSCAPS_MIPMAP = 0x400000,
  97028. // DDSCAPS_TEXTURE = 0x1000;
  97029. var DDSCAPS2_CUBEMAP = 0x200;
  97030. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  97031. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  97032. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  97033. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  97034. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  97035. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  97036. // DDSCAPS2_VOLUME = 0x200000;
  97037. var
  97038. //DDPF_ALPHAPIXELS = 0x1,
  97039. //DDPF_ALPHA = 0x2,
  97040. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  97041. //DDPF_YUV = 0x200,
  97042. DDPF_LUMINANCE = 0x20000;
  97043. function FourCCToInt32(value) {
  97044. return value.charCodeAt(0) +
  97045. (value.charCodeAt(1) << 8) +
  97046. (value.charCodeAt(2) << 16) +
  97047. (value.charCodeAt(3) << 24);
  97048. }
  97049. function Int32ToFourCC(value) {
  97050. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  97051. }
  97052. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  97053. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  97054. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  97055. var FOURCC_DX10 = FourCCToInt32("DX10");
  97056. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  97057. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  97058. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  97059. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  97060. var headerLengthInt = 31; // The header length in 32 bit ints
  97061. // Offsets into the header array
  97062. var off_magic = 0;
  97063. var off_size = 1;
  97064. var off_flags = 2;
  97065. var off_height = 3;
  97066. var off_width = 4;
  97067. var off_mipmapCount = 7;
  97068. var off_pfFlags = 20;
  97069. var off_pfFourCC = 21;
  97070. var off_RGBbpp = 22;
  97071. var off_RMask = 23;
  97072. var off_GMask = 24;
  97073. var off_BMask = 25;
  97074. var off_AMask = 26;
  97075. // var off_caps1 = 27;
  97076. var off_caps2 = 28;
  97077. // var off_caps3 = 29;
  97078. // var off_caps4 = 30;
  97079. var off_dxgiFormat = 32;
  97080. /**
  97081. * Class used to provide DDS decompression tools
  97082. */
  97083. var DDSTools = /** @class */ (function () {
  97084. function DDSTools() {
  97085. }
  97086. /**
  97087. * Gets DDS information from an array buffer
  97088. * @param arrayBuffer defines the array buffer to read data from
  97089. * @returns the DDS information
  97090. */
  97091. DDSTools.GetDDSInfo = function (arrayBuffer) {
  97092. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  97093. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  97094. var mipmapCount = 1;
  97095. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  97096. mipmapCount = Math.max(1, header[off_mipmapCount]);
  97097. }
  97098. var fourCC = header[off_pfFourCC];
  97099. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  97100. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  97101. switch (fourCC) {
  97102. case FOURCC_D3DFMT_R16G16B16A16F:
  97103. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  97104. break;
  97105. case FOURCC_D3DFMT_R32G32B32A32F:
  97106. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  97107. break;
  97108. case FOURCC_DX10:
  97109. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  97110. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  97111. break;
  97112. }
  97113. }
  97114. return {
  97115. width: header[off_width],
  97116. height: header[off_height],
  97117. mipmapCount: mipmapCount,
  97118. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  97119. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  97120. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  97121. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  97122. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  97123. dxgiFormat: dxgiFormat,
  97124. textureType: textureType
  97125. };
  97126. };
  97127. DDSTools._ToHalfFloat = function (value) {
  97128. if (!DDSTools._FloatView) {
  97129. DDSTools._FloatView = new Float32Array(1);
  97130. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  97131. }
  97132. DDSTools._FloatView[0] = value;
  97133. var x = DDSTools._Int32View[0];
  97134. var bits = (x >> 16) & 0x8000; /* Get the sign */
  97135. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  97136. var e = (x >> 23) & 0xff; /* Using int is faster here */
  97137. /* If zero, or denormal, or exponent underflows too much for a denormal
  97138. * half, return signed zero. */
  97139. if (e < 103) {
  97140. return bits;
  97141. }
  97142. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  97143. if (e > 142) {
  97144. bits |= 0x7c00;
  97145. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  97146. * not Inf, so make sure we set one mantissa bit too. */
  97147. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  97148. return bits;
  97149. }
  97150. /* If exponent underflows but not too much, return a denormal */
  97151. if (e < 113) {
  97152. m |= 0x0800;
  97153. /* Extra rounding may overflow and set mantissa to 0 and exponent
  97154. * to 1, which is OK. */
  97155. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  97156. return bits;
  97157. }
  97158. bits |= ((e - 112) << 10) | (m >> 1);
  97159. bits += m & 1;
  97160. return bits;
  97161. };
  97162. DDSTools._FromHalfFloat = function (value) {
  97163. var s = (value & 0x8000) >> 15;
  97164. var e = (value & 0x7C00) >> 10;
  97165. var f = value & 0x03FF;
  97166. if (e === 0) {
  97167. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  97168. }
  97169. else if (e == 0x1F) {
  97170. return f ? NaN : ((s ? -1 : 1) * Infinity);
  97171. }
  97172. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  97173. };
  97174. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  97175. var destArray = new Float32Array(dataLength);
  97176. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  97177. var index = 0;
  97178. for (var y = 0; y < height; y++) {
  97179. for (var x = 0; x < width; x++) {
  97180. var srcPos = (x + y * width) * 4;
  97181. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  97182. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  97183. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  97184. if (DDSTools.StoreLODInAlphaChannel) {
  97185. destArray[index + 3] = lod;
  97186. }
  97187. else {
  97188. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  97189. }
  97190. index += 4;
  97191. }
  97192. }
  97193. return destArray;
  97194. };
  97195. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  97196. if (DDSTools.StoreLODInAlphaChannel) {
  97197. var destArray = new Uint16Array(dataLength);
  97198. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  97199. var index = 0;
  97200. for (var y = 0; y < height; y++) {
  97201. for (var x = 0; x < width; x++) {
  97202. var srcPos = (x + y * width) * 4;
  97203. destArray[index] = srcData[srcPos];
  97204. destArray[index + 1] = srcData[srcPos + 1];
  97205. destArray[index + 2] = srcData[srcPos + 2];
  97206. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  97207. index += 4;
  97208. }
  97209. }
  97210. return destArray;
  97211. }
  97212. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  97213. };
  97214. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  97215. if (DDSTools.StoreLODInAlphaChannel) {
  97216. var destArray = new Float32Array(dataLength);
  97217. var srcData = new Float32Array(arrayBuffer, dataOffset);
  97218. var index = 0;
  97219. for (var y = 0; y < height; y++) {
  97220. for (var x = 0; x < width; x++) {
  97221. var srcPos = (x + y * width) * 4;
  97222. destArray[index] = srcData[srcPos];
  97223. destArray[index + 1] = srcData[srcPos + 1];
  97224. destArray[index + 2] = srcData[srcPos + 2];
  97225. destArray[index + 3] = lod;
  97226. index += 4;
  97227. }
  97228. }
  97229. return destArray;
  97230. }
  97231. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  97232. };
  97233. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  97234. var destArray = new Uint8Array(dataLength);
  97235. var srcData = new Float32Array(arrayBuffer, dataOffset);
  97236. var index = 0;
  97237. for (var y = 0; y < height; y++) {
  97238. for (var x = 0; x < width; x++) {
  97239. var srcPos = (x + y * width) * 4;
  97240. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  97241. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  97242. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  97243. if (DDSTools.StoreLODInAlphaChannel) {
  97244. destArray[index + 3] = lod;
  97245. }
  97246. else {
  97247. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  97248. }
  97249. index += 4;
  97250. }
  97251. }
  97252. return destArray;
  97253. };
  97254. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  97255. var destArray = new Uint8Array(dataLength);
  97256. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  97257. var index = 0;
  97258. for (var y = 0; y < height; y++) {
  97259. for (var x = 0; x < width; x++) {
  97260. var srcPos = (x + y * width) * 4;
  97261. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  97262. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  97263. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  97264. if (DDSTools.StoreLODInAlphaChannel) {
  97265. destArray[index + 3] = lod;
  97266. }
  97267. else {
  97268. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  97269. }
  97270. index += 4;
  97271. }
  97272. }
  97273. return destArray;
  97274. };
  97275. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  97276. var byteArray = new Uint8Array(dataLength);
  97277. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  97278. var index = 0;
  97279. for (var y = 0; y < height; y++) {
  97280. for (var x = 0; x < width; x++) {
  97281. var srcPos = (x + y * width) * 4;
  97282. byteArray[index] = srcData[srcPos + rOffset];
  97283. byteArray[index + 1] = srcData[srcPos + gOffset];
  97284. byteArray[index + 2] = srcData[srcPos + bOffset];
  97285. byteArray[index + 3] = srcData[srcPos + aOffset];
  97286. index += 4;
  97287. }
  97288. }
  97289. return byteArray;
  97290. };
  97291. DDSTools._ExtractLongWordOrder = function (value) {
  97292. if (value === 0 || value === 255 || value === -16777216) {
  97293. return 0;
  97294. }
  97295. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  97296. };
  97297. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  97298. var byteArray = new Uint8Array(dataLength);
  97299. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  97300. var index = 0;
  97301. for (var y = 0; y < height; y++) {
  97302. for (var x = 0; x < width; x++) {
  97303. var srcPos = (x + y * width) * 3;
  97304. byteArray[index] = srcData[srcPos + rOffset];
  97305. byteArray[index + 1] = srcData[srcPos + gOffset];
  97306. byteArray[index + 2] = srcData[srcPos + bOffset];
  97307. index += 3;
  97308. }
  97309. }
  97310. return byteArray;
  97311. };
  97312. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  97313. var byteArray = new Uint8Array(dataLength);
  97314. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  97315. var index = 0;
  97316. for (var y = 0; y < height; y++) {
  97317. for (var x = 0; x < width; x++) {
  97318. var srcPos = (x + y * width);
  97319. byteArray[index] = srcData[srcPos];
  97320. index++;
  97321. }
  97322. }
  97323. return byteArray;
  97324. };
  97325. /**
  97326. * Uploads DDS Levels to a Babylon Texture
  97327. * @hidden
  97328. */
  97329. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  97330. if (lodIndex === void 0) { lodIndex = -1; }
  97331. var sphericalPolynomialFaces = null;
  97332. if (info.sphericalPolynomial) {
  97333. sphericalPolynomialFaces = new Array();
  97334. }
  97335. var ext = engine.getCaps().s3tc;
  97336. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  97337. var fourCC, width, height, dataLength = 0, dataOffset;
  97338. var byteArray, mipmapCount, mip;
  97339. var internalCompressedFormat = 0;
  97340. var blockBytes = 1;
  97341. if (header[off_magic] !== DDS_MAGIC) {
  97342. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  97343. return;
  97344. }
  97345. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  97346. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  97347. return;
  97348. }
  97349. if (info.isCompressed && !ext) {
  97350. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  97351. return;
  97352. }
  97353. var bpp = header[off_RGBbpp];
  97354. dataOffset = header[off_size] + 4;
  97355. var computeFormats = false;
  97356. if (info.isFourCC) {
  97357. fourCC = header[off_pfFourCC];
  97358. switch (fourCC) {
  97359. case FOURCC_DXT1:
  97360. blockBytes = 8;
  97361. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  97362. break;
  97363. case FOURCC_DXT3:
  97364. blockBytes = 16;
  97365. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  97366. break;
  97367. case FOURCC_DXT5:
  97368. blockBytes = 16;
  97369. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  97370. break;
  97371. case FOURCC_D3DFMT_R16G16B16A16F:
  97372. computeFormats = true;
  97373. break;
  97374. case FOURCC_D3DFMT_R32G32B32A32F:
  97375. computeFormats = true;
  97376. break;
  97377. case FOURCC_DX10:
  97378. // There is an additionnal header so dataOffset need to be changed
  97379. dataOffset += 5 * 4; // 5 uints
  97380. var supported = false;
  97381. switch (info.dxgiFormat) {
  97382. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  97383. computeFormats = true;
  97384. supported = true;
  97385. break;
  97386. case DXGI_FORMAT_B8G8R8X8_UNORM:
  97387. info.isRGB = true;
  97388. info.isFourCC = false;
  97389. bpp = 32;
  97390. supported = true;
  97391. break;
  97392. }
  97393. if (supported) {
  97394. break;
  97395. }
  97396. default:
  97397. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  97398. return;
  97399. }
  97400. }
  97401. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  97402. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  97403. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  97404. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  97405. if (computeFormats) {
  97406. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  97407. }
  97408. mipmapCount = 1;
  97409. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  97410. mipmapCount = Math.max(1, header[off_mipmapCount]);
  97411. }
  97412. var startFace = currentFace || 0;
  97413. for (var face = startFace; face < faces; face++) {
  97414. width = header[off_width];
  97415. height = header[off_height];
  97416. for (mip = 0; mip < mipmapCount; ++mip) {
  97417. if (lodIndex === -1 || lodIndex === mip) {
  97418. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  97419. var i = (lodIndex === -1) ? mip : 0;
  97420. if (!info.isCompressed && info.isFourCC) {
  97421. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  97422. dataLength = width * height * 4;
  97423. var floatArray = null;
  97424. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  97425. if (bpp === 128) {
  97426. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  97427. if (sphericalPolynomialFaces && i == 0) {
  97428. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  97429. }
  97430. }
  97431. else if (bpp === 64) {
  97432. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  97433. if (sphericalPolynomialFaces && i == 0) {
  97434. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  97435. }
  97436. }
  97437. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  97438. }
  97439. else {
  97440. if (bpp === 128) {
  97441. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  97442. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  97443. if (sphericalPolynomialFaces && i == 0) {
  97444. sphericalPolynomialFaces.push(floatArray);
  97445. }
  97446. }
  97447. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  97448. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  97449. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  97450. if (sphericalPolynomialFaces && i == 0) {
  97451. sphericalPolynomialFaces.push(floatArray);
  97452. }
  97453. }
  97454. else { // 64
  97455. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  97456. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  97457. if (sphericalPolynomialFaces && i == 0) {
  97458. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  97459. }
  97460. }
  97461. }
  97462. if (floatArray) {
  97463. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  97464. }
  97465. }
  97466. else if (info.isRGB) {
  97467. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  97468. if (bpp === 24) {
  97469. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  97470. dataLength = width * height * 3;
  97471. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  97472. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  97473. }
  97474. else { // 32
  97475. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  97476. dataLength = width * height * 4;
  97477. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  97478. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  97479. }
  97480. }
  97481. else if (info.isLuminance) {
  97482. var unpackAlignment = engine._getUnpackAlignement();
  97483. var unpaddedRowSize = width;
  97484. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  97485. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  97486. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  97487. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  97488. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  97489. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  97490. }
  97491. else {
  97492. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  97493. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  97494. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  97495. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  97496. }
  97497. }
  97498. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  97499. width *= 0.5;
  97500. height *= 0.5;
  97501. width = Math.max(1.0, width);
  97502. height = Math.max(1.0, height);
  97503. }
  97504. if (currentFace !== undefined) {
  97505. // Loading a single face
  97506. break;
  97507. }
  97508. }
  97509. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  97510. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  97511. size: header[off_width],
  97512. right: sphericalPolynomialFaces[0],
  97513. left: sphericalPolynomialFaces[1],
  97514. up: sphericalPolynomialFaces[2],
  97515. down: sphericalPolynomialFaces[3],
  97516. front: sphericalPolynomialFaces[4],
  97517. back: sphericalPolynomialFaces[5],
  97518. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  97519. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  97520. gammaSpace: false,
  97521. });
  97522. }
  97523. else {
  97524. info.sphericalPolynomial = undefined;
  97525. }
  97526. };
  97527. /**
  97528. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  97529. */
  97530. DDSTools.StoreLODInAlphaChannel = false;
  97531. return DDSTools;
  97532. }());
  97533. /**
  97534. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  97535. * @param rootUrl defines the url where the file to load is located
  97536. * @param scene defines the current scene
  97537. * @param lodScale defines scale to apply to the mip map selection
  97538. * @param lodOffset defines offset to apply to the mip map selection
  97539. * @param onLoad defines an optional callback raised when the texture is loaded
  97540. * @param onError defines an optional callback raised if there is an issue to load the texture
  97541. * @param format defines the format of the data
  97542. * @param forcedExtension defines the extension to use to pick the right loader
  97543. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  97544. * @returns the cube texture as an InternalTexture
  97545. */
  97546. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  97547. var _this = this;
  97548. if (onLoad === void 0) { onLoad = null; }
  97549. if (onError === void 0) { onError = null; }
  97550. if (forcedExtension === void 0) { forcedExtension = null; }
  97551. if (createPolynomials === void 0) { createPolynomials = true; }
  97552. var callback = function (loadData) {
  97553. if (!loadData) {
  97554. if (onLoad) {
  97555. onLoad(null);
  97556. }
  97557. return;
  97558. }
  97559. var texture = loadData.texture;
  97560. if (!createPolynomials) {
  97561. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  97562. }
  97563. else if (loadData.info.sphericalPolynomial) {
  97564. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  97565. }
  97566. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  97567. if (_this.getCaps().textureLOD) {
  97568. // Do not add extra process if texture lod is supported.
  97569. if (onLoad) {
  97570. onLoad(texture);
  97571. }
  97572. return;
  97573. }
  97574. var mipSlices = 3;
  97575. var gl = _this._gl;
  97576. var width = loadData.width;
  97577. if (!width) {
  97578. return;
  97579. }
  97580. var textures = [];
  97581. for (var i = 0; i < mipSlices; i++) {
  97582. //compute LOD from even spacing in smoothness (matching shader calculation)
  97583. var smoothness = i / (mipSlices - 1);
  97584. var roughness = 1 - smoothness;
  97585. var minLODIndex = lodOffset; // roughness = 0
  97586. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  97587. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  97588. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  97589. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  97590. glTextureFromLod.type = texture.type;
  97591. glTextureFromLod.format = texture.format;
  97592. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  97593. glTextureFromLod.height = glTextureFromLod.width;
  97594. glTextureFromLod.isCube = true;
  97595. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  97596. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  97597. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  97598. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  97599. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  97600. if (loadData.isDDS) {
  97601. var info = loadData.info;
  97602. var data = loadData.data;
  97603. _this._unpackFlipY(info.isCompressed);
  97604. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  97605. }
  97606. else {
  97607. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  97608. }
  97609. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  97610. // Wrap in a base texture for easy binding.
  97611. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  97612. lodTexture.isCube = true;
  97613. lodTexture._texture = glTextureFromLod;
  97614. glTextureFromLod.isReady = true;
  97615. textures.push(lodTexture);
  97616. }
  97617. texture._lodTextureHigh = textures[2];
  97618. texture._lodTextureMid = textures[1];
  97619. texture._lodTextureLow = textures[0];
  97620. if (onLoad) {
  97621. onLoad(texture);
  97622. }
  97623. };
  97624. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  97625. };
  97626. /***/ }),
  97627. /***/ "./Misc/decorators.ts":
  97628. /*!****************************!*\
  97629. !*** ./Misc/decorators.ts ***!
  97630. \****************************/
  97631. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsMatrix, serializeAsCameraReference, SerializationHelper */
  97632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97633. "use strict";
  97634. __webpack_require__.r(__webpack_exports__);
  97635. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  97636. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  97637. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  97638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  97639. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  97640. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  97641. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  97642. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  97643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  97644. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  97645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  97646. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  97647. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return serializeAsMatrix; });
  97648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  97649. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  97650. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  97651. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  97652. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  97653. var __decoratorInitialStore = {};
  97654. var __mergedStore = {};
  97655. var _copySource = function (creationFunction, source, instanciate) {
  97656. var destination = creationFunction();
  97657. // Tags
  97658. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  97659. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  97660. }
  97661. var classStore = getMergedStore(destination);
  97662. // Properties
  97663. for (var property in classStore) {
  97664. var propertyDescriptor = classStore[property];
  97665. var sourceProperty = source[property];
  97666. var propertyType = propertyDescriptor.type;
  97667. if (sourceProperty !== undefined && sourceProperty !== null && property !== "uniqueId") {
  97668. switch (propertyType) {
  97669. case 0: // Value
  97670. case 6: // Mesh reference
  97671. case 11: // Camera reference
  97672. destination[property] = sourceProperty;
  97673. break;
  97674. case 1: // Texture
  97675. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  97676. break;
  97677. case 2: // Color3
  97678. case 3: // FresnelParameters
  97679. case 4: // Vector2
  97680. case 5: // Vector3
  97681. case 7: // Color Curves
  97682. case 10: // Quaternion
  97683. case 12: // Matrix
  97684. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  97685. break;
  97686. }
  97687. }
  97688. }
  97689. return destination;
  97690. };
  97691. function getDirectStore(target) {
  97692. var classKey = target.getClassName();
  97693. if (!__decoratorInitialStore[classKey]) {
  97694. __decoratorInitialStore[classKey] = {};
  97695. }
  97696. return __decoratorInitialStore[classKey];
  97697. }
  97698. /**
  97699. * Return the list of properties flagged as serializable
  97700. * @param target: host object
  97701. */
  97702. function getMergedStore(target) {
  97703. var classKey = target.getClassName();
  97704. if (__mergedStore[classKey]) {
  97705. return __mergedStore[classKey];
  97706. }
  97707. __mergedStore[classKey] = {};
  97708. var store = __mergedStore[classKey];
  97709. var currentTarget = target;
  97710. var currentKey = classKey;
  97711. while (currentKey) {
  97712. var initialStore = __decoratorInitialStore[currentKey];
  97713. for (var property in initialStore) {
  97714. store[property] = initialStore[property];
  97715. }
  97716. var parent_1 = void 0;
  97717. var done = false;
  97718. do {
  97719. parent_1 = Object.getPrototypeOf(currentTarget);
  97720. if (!parent_1.getClassName) {
  97721. done = true;
  97722. break;
  97723. }
  97724. if (parent_1.getClassName() !== currentKey) {
  97725. break;
  97726. }
  97727. currentTarget = parent_1;
  97728. } while (parent_1);
  97729. if (done) {
  97730. break;
  97731. }
  97732. currentKey = parent_1.getClassName();
  97733. currentTarget = parent_1;
  97734. }
  97735. return store;
  97736. }
  97737. function generateSerializableMember(type, sourceName) {
  97738. return function (target, propertyKey) {
  97739. var classStore = getDirectStore(target);
  97740. if (!classStore[propertyKey]) {
  97741. classStore[propertyKey] = { type: type, sourceName: sourceName };
  97742. }
  97743. };
  97744. }
  97745. function generateExpandMember(setCallback, targetKey) {
  97746. if (targetKey === void 0) { targetKey = null; }
  97747. return function (target, propertyKey) {
  97748. var key = targetKey || ("_" + propertyKey);
  97749. Object.defineProperty(target, propertyKey, {
  97750. get: function () {
  97751. return this[key];
  97752. },
  97753. set: function (value) {
  97754. if (this[key] === value) {
  97755. return;
  97756. }
  97757. this[key] = value;
  97758. target[setCallback].apply(this);
  97759. },
  97760. enumerable: true,
  97761. configurable: true
  97762. });
  97763. };
  97764. }
  97765. function expandToProperty(callback, targetKey) {
  97766. if (targetKey === void 0) { targetKey = null; }
  97767. return generateExpandMember(callback, targetKey);
  97768. }
  97769. function serialize(sourceName) {
  97770. return generateSerializableMember(0, sourceName); // value member
  97771. }
  97772. function serializeAsTexture(sourceName) {
  97773. return generateSerializableMember(1, sourceName); // texture member
  97774. }
  97775. function serializeAsColor3(sourceName) {
  97776. return generateSerializableMember(2, sourceName); // color3 member
  97777. }
  97778. function serializeAsFresnelParameters(sourceName) {
  97779. return generateSerializableMember(3, sourceName); // fresnel parameters member
  97780. }
  97781. function serializeAsVector2(sourceName) {
  97782. return generateSerializableMember(4, sourceName); // vector2 member
  97783. }
  97784. function serializeAsVector3(sourceName) {
  97785. return generateSerializableMember(5, sourceName); // vector3 member
  97786. }
  97787. function serializeAsMeshReference(sourceName) {
  97788. return generateSerializableMember(6, sourceName); // mesh reference member
  97789. }
  97790. function serializeAsColorCurves(sourceName) {
  97791. return generateSerializableMember(7, sourceName); // color curves
  97792. }
  97793. function serializeAsColor4(sourceName) {
  97794. return generateSerializableMember(8, sourceName); // color 4
  97795. }
  97796. function serializeAsImageProcessingConfiguration(sourceName) {
  97797. return generateSerializableMember(9, sourceName); // image processing
  97798. }
  97799. function serializeAsQuaternion(sourceName) {
  97800. return generateSerializableMember(10, sourceName); // quaternion member
  97801. }
  97802. function serializeAsMatrix(sourceName) {
  97803. return generateSerializableMember(12, sourceName); // matrix member
  97804. }
  97805. /**
  97806. * Decorator used to define property that can be serialized as reference to a camera
  97807. * @param sourceName defines the name of the property to decorate
  97808. */
  97809. function serializeAsCameraReference(sourceName) {
  97810. return generateSerializableMember(11, sourceName); // camera reference member
  97811. }
  97812. /**
  97813. * Class used to help serialization objects
  97814. */
  97815. var SerializationHelper = /** @class */ (function () {
  97816. function SerializationHelper() {
  97817. }
  97818. /**
  97819. * Appends the serialized animations from the source animations
  97820. * @param source Source containing the animations
  97821. * @param destination Target to store the animations
  97822. */
  97823. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  97824. if (source.animations) {
  97825. destination.animations = [];
  97826. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  97827. var animation = source.animations[animationIndex];
  97828. destination.animations.push(animation.serialize());
  97829. }
  97830. }
  97831. };
  97832. /**
  97833. * Static function used to serialized a specific entity
  97834. * @param entity defines the entity to serialize
  97835. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  97836. * @returns a JSON compatible object representing the serialization of the entity
  97837. */
  97838. SerializationHelper.Serialize = function (entity, serializationObject) {
  97839. if (!serializationObject) {
  97840. serializationObject = {};
  97841. }
  97842. // Tags
  97843. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  97844. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  97845. }
  97846. var serializedProperties = getMergedStore(entity);
  97847. // Properties
  97848. for (var property in serializedProperties) {
  97849. var propertyDescriptor = serializedProperties[property];
  97850. var targetPropertyName = propertyDescriptor.sourceName || property;
  97851. var propertyType = propertyDescriptor.type;
  97852. var sourceProperty = entity[property];
  97853. if (sourceProperty !== undefined && sourceProperty !== null) {
  97854. switch (propertyType) {
  97855. case 0: // Value
  97856. serializationObject[targetPropertyName] = sourceProperty;
  97857. break;
  97858. case 1: // Texture
  97859. serializationObject[targetPropertyName] = sourceProperty.serialize();
  97860. break;
  97861. case 2: // Color3
  97862. serializationObject[targetPropertyName] = sourceProperty.asArray();
  97863. break;
  97864. case 3: // FresnelParameters
  97865. serializationObject[targetPropertyName] = sourceProperty.serialize();
  97866. break;
  97867. case 4: // Vector2
  97868. serializationObject[targetPropertyName] = sourceProperty.asArray();
  97869. break;
  97870. case 5: // Vector3
  97871. serializationObject[targetPropertyName] = sourceProperty.asArray();
  97872. break;
  97873. case 6: // Mesh reference
  97874. serializationObject[targetPropertyName] = sourceProperty.id;
  97875. break;
  97876. case 7: // Color Curves
  97877. serializationObject[targetPropertyName] = sourceProperty.serialize();
  97878. break;
  97879. case 8: // Color 4
  97880. serializationObject[targetPropertyName] = sourceProperty.asArray();
  97881. break;
  97882. case 9: // Image Processing
  97883. serializationObject[targetPropertyName] = sourceProperty.serialize();
  97884. break;
  97885. case 10: // Quaternion
  97886. serializationObject[targetPropertyName] = sourceProperty.asArray();
  97887. break;
  97888. case 11: // Camera reference
  97889. serializationObject[targetPropertyName] = sourceProperty.id;
  97890. case 12: // Matrix
  97891. serializationObject[targetPropertyName] = sourceProperty.asArray();
  97892. break;
  97893. }
  97894. }
  97895. }
  97896. return serializationObject;
  97897. };
  97898. /**
  97899. * Creates a new entity from a serialization data object
  97900. * @param creationFunction defines a function used to instanciated the new entity
  97901. * @param source defines the source serialization data
  97902. * @param scene defines the hosting scene
  97903. * @param rootUrl defines the root url for resources
  97904. * @returns a new entity
  97905. */
  97906. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  97907. if (rootUrl === void 0) { rootUrl = null; }
  97908. var destination = creationFunction();
  97909. if (!rootUrl) {
  97910. rootUrl = "";
  97911. }
  97912. // Tags
  97913. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  97914. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  97915. }
  97916. var classStore = getMergedStore(destination);
  97917. // Properties
  97918. for (var property in classStore) {
  97919. var propertyDescriptor = classStore[property];
  97920. var sourceProperty = source[propertyDescriptor.sourceName || property];
  97921. var propertyType = propertyDescriptor.type;
  97922. if (sourceProperty !== undefined && sourceProperty !== null) {
  97923. var dest = destination;
  97924. switch (propertyType) {
  97925. case 0: // Value
  97926. dest[property] = sourceProperty;
  97927. break;
  97928. case 1: // Texture
  97929. if (scene) {
  97930. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  97931. }
  97932. break;
  97933. case 2: // Color3
  97934. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(sourceProperty);
  97935. break;
  97936. case 3: // FresnelParameters
  97937. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  97938. break;
  97939. case 4: // Vector2
  97940. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  97941. break;
  97942. case 5: // Vector3
  97943. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  97944. break;
  97945. case 6: // Mesh reference
  97946. if (scene) {
  97947. dest[property] = scene.getLastMeshByID(sourceProperty);
  97948. }
  97949. break;
  97950. case 7: // Color Curves
  97951. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  97952. break;
  97953. case 8: // Color 4
  97954. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(sourceProperty);
  97955. break;
  97956. case 9: // Image Processing
  97957. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  97958. break;
  97959. case 10: // Quaternion
  97960. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  97961. break;
  97962. case 11: // Camera reference
  97963. if (scene) {
  97964. dest[property] = scene.getCameraByID(sourceProperty);
  97965. }
  97966. case 12: // Matrix
  97967. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromArray(sourceProperty);
  97968. break;
  97969. }
  97970. }
  97971. }
  97972. return destination;
  97973. };
  97974. /**
  97975. * Clones an object
  97976. * @param creationFunction defines the function used to instanciate the new object
  97977. * @param source defines the source object
  97978. * @returns the cloned object
  97979. */
  97980. SerializationHelper.Clone = function (creationFunction, source) {
  97981. return _copySource(creationFunction, source, false);
  97982. };
  97983. /**
  97984. * Instanciates a new object based on a source one (some data will be shared between both object)
  97985. * @param creationFunction defines the function used to instanciate the new object
  97986. * @param source defines the source object
  97987. * @returns the new object
  97988. */
  97989. SerializationHelper.Instanciate = function (creationFunction, source) {
  97990. return _copySource(creationFunction, source, true);
  97991. };
  97992. /** hidden */
  97993. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  97994. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ImageProcessingConfiguration");
  97995. };
  97996. /** hidden */
  97997. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  97998. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("FresnelParameters");
  97999. };
  98000. /** hidden */
  98001. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  98002. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ColorCurves");
  98003. };
  98004. /** hidden */
  98005. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  98006. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("Texture");
  98007. };
  98008. return SerializationHelper;
  98009. }());
  98010. /***/ }),
  98011. /***/ "./Misc/deepCopier.ts":
  98012. /*!****************************!*\
  98013. !*** ./Misc/deepCopier.ts ***!
  98014. \****************************/
  98015. /*! exports provided: DeepCopier */
  98016. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98017. "use strict";
  98018. __webpack_require__.r(__webpack_exports__);
  98019. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  98020. var cloneValue = function (source, destinationObject) {
  98021. if (!source) {
  98022. return null;
  98023. }
  98024. if (source.getClassName && source.getClassName() === "Mesh") {
  98025. return null;
  98026. }
  98027. if (source.getClassName && source.getClassName() === "SubMesh") {
  98028. return source.clone(destinationObject);
  98029. }
  98030. else if (source.clone) {
  98031. return source.clone();
  98032. }
  98033. return null;
  98034. };
  98035. /**
  98036. * Class containing a set of static utilities functions for deep copy.
  98037. */
  98038. var DeepCopier = /** @class */ (function () {
  98039. function DeepCopier() {
  98040. }
  98041. /**
  98042. * Tries to copy an object by duplicating every property
  98043. * @param source defines the source object
  98044. * @param destination defines the target object
  98045. * @param doNotCopyList defines a list of properties to avoid
  98046. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98047. */
  98048. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  98049. for (var prop in source) {
  98050. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  98051. continue;
  98052. }
  98053. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  98054. continue;
  98055. }
  98056. var sourceValue = source[prop];
  98057. var typeOfSourceValue = typeof sourceValue;
  98058. if (typeOfSourceValue === "function") {
  98059. continue;
  98060. }
  98061. try {
  98062. if (typeOfSourceValue === "object") {
  98063. if (sourceValue instanceof Array) {
  98064. destination[prop] = [];
  98065. if (sourceValue.length > 0) {
  98066. if (typeof sourceValue[0] == "object") {
  98067. for (var index = 0; index < sourceValue.length; index++) {
  98068. var clonedValue = cloneValue(sourceValue[index], destination);
  98069. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  98070. destination[prop].push(clonedValue);
  98071. }
  98072. }
  98073. }
  98074. else {
  98075. destination[prop] = sourceValue.slice(0);
  98076. }
  98077. }
  98078. }
  98079. else {
  98080. destination[prop] = cloneValue(sourceValue, destination);
  98081. }
  98082. }
  98083. else {
  98084. destination[prop] = sourceValue;
  98085. }
  98086. }
  98087. catch (e) {
  98088. // Just ignore error (it could be because of a read-only property)
  98089. }
  98090. }
  98091. };
  98092. return DeepCopier;
  98093. }());
  98094. /***/ }),
  98095. /***/ "./Misc/deferred.ts":
  98096. /*!**************************!*\
  98097. !*** ./Misc/deferred.ts ***!
  98098. \**************************/
  98099. /*! exports provided: Deferred */
  98100. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98101. "use strict";
  98102. __webpack_require__.r(__webpack_exports__);
  98103. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  98104. /**
  98105. * Wrapper class for promise with external resolve and reject.
  98106. */
  98107. var Deferred = /** @class */ (function () {
  98108. /**
  98109. * Constructor for this deferred object.
  98110. */
  98111. function Deferred() {
  98112. var _this = this;
  98113. this.promise = new Promise(function (resolve, reject) {
  98114. _this._resolve = resolve;
  98115. _this._reject = reject;
  98116. });
  98117. }
  98118. Object.defineProperty(Deferred.prototype, "resolve", {
  98119. /**
  98120. * The resolve method of the promise associated with this deferred object.
  98121. */
  98122. get: function () {
  98123. return this._resolve;
  98124. },
  98125. enumerable: true,
  98126. configurable: true
  98127. });
  98128. Object.defineProperty(Deferred.prototype, "reject", {
  98129. /**
  98130. * The reject method of the promise associated with this deferred object.
  98131. */
  98132. get: function () {
  98133. return this._reject;
  98134. },
  98135. enumerable: true,
  98136. configurable: true
  98137. });
  98138. return Deferred;
  98139. }());
  98140. /***/ }),
  98141. /***/ "./Misc/devTools.ts":
  98142. /*!**************************!*\
  98143. !*** ./Misc/devTools.ts ***!
  98144. \**************************/
  98145. /*! exports provided: _DevTools */
  98146. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98147. "use strict";
  98148. __webpack_require__.r(__webpack_exports__);
  98149. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DevTools", function() { return _DevTools; });
  98150. /** @hidden */
  98151. var _DevTools = /** @class */ (function () {
  98152. function _DevTools() {
  98153. }
  98154. _DevTools.WarnImport = function (name) {
  98155. return name + " needs to be imported before as it contains a side-effect required by your code.";
  98156. };
  98157. return _DevTools;
  98158. }());
  98159. /***/ }),
  98160. /***/ "./Misc/domManagement.ts":
  98161. /*!*******************************!*\
  98162. !*** ./Misc/domManagement.ts ***!
  98163. \*******************************/
  98164. /*! exports provided: DomManagement */
  98165. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98166. "use strict";
  98167. __webpack_require__.r(__webpack_exports__);
  98168. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  98169. /**
  98170. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  98171. * Babylon.js
  98172. */
  98173. var DomManagement = /** @class */ (function () {
  98174. function DomManagement() {
  98175. }
  98176. /**
  98177. * Checks if the window object exists
  98178. * @returns true if the window object exists
  98179. */
  98180. DomManagement.IsWindowObjectExist = function () {
  98181. return (typeof window) !== "undefined";
  98182. };
  98183. /**
  98184. * Extracts text content from a DOM element hierarchy
  98185. * @param element defines the root element
  98186. * @returns a string
  98187. */
  98188. DomManagement.GetDOMTextContent = function (element) {
  98189. var result = "";
  98190. var child = element.firstChild;
  98191. while (child) {
  98192. if (child.nodeType === 3) {
  98193. result += child.textContent;
  98194. }
  98195. child = (child.nextSibling);
  98196. }
  98197. return result;
  98198. };
  98199. return DomManagement;
  98200. }());
  98201. /***/ }),
  98202. /***/ "./Misc/environmentTextureTools.ts":
  98203. /*!*****************************************!*\
  98204. !*** ./Misc/environmentTextureTools.ts ***!
  98205. \*****************************************/
  98206. /*! exports provided: EnvironmentTextureTools */
  98207. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98208. "use strict";
  98209. __webpack_require__.r(__webpack_exports__);
  98210. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  98211. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  98212. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  98213. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  98214. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  98215. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  98216. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  98217. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  98218. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  98219. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  98220. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  98221. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  98222. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  98223. /**
  98224. * Sets of helpers addressing the serialization and deserialization of environment texture
  98225. * stored in a BabylonJS env file.
  98226. * Those files are usually stored as .env files.
  98227. */
  98228. var EnvironmentTextureTools = /** @class */ (function () {
  98229. function EnvironmentTextureTools() {
  98230. }
  98231. /**
  98232. * Gets the environment info from an env file.
  98233. * @param data The array buffer containing the .env bytes.
  98234. * @returns the environment file info (the json header) if successfully parsed.
  98235. */
  98236. EnvironmentTextureTools.GetEnvInfo = function (data) {
  98237. var dataView = new DataView(data);
  98238. var pos = 0;
  98239. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  98240. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  98241. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  98242. return null;
  98243. }
  98244. }
  98245. // Read json manifest - collect characters up to null terminator
  98246. var manifestString = '';
  98247. var charCode = 0x00;
  98248. while ((charCode = dataView.getUint8(pos++))) {
  98249. manifestString += String.fromCharCode(charCode);
  98250. }
  98251. var manifest = JSON.parse(manifestString);
  98252. if (manifest.specular) {
  98253. // Extend the header with the position of the payload.
  98254. manifest.specular.specularDataPosition = pos;
  98255. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  98256. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  98257. }
  98258. return manifest;
  98259. };
  98260. /**
  98261. * Creates an environment texture from a loaded cube texture.
  98262. * @param texture defines the cube texture to convert in env file
  98263. * @return a promise containing the environment data if succesfull.
  98264. */
  98265. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  98266. var _this = this;
  98267. var internalTexture = texture.getInternalTexture();
  98268. if (!internalTexture) {
  98269. return Promise.reject("The cube texture is invalid.");
  98270. }
  98271. if (!texture._prefiltered) {
  98272. return Promise.reject("The cube texture is invalid (not prefiltered).");
  98273. }
  98274. var engine = internalTexture.getEngine();
  98275. if (engine && engine.premultipliedAlpha) {
  98276. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  98277. }
  98278. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  98279. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  98280. }
  98281. var canvas = engine.getRenderingCanvas();
  98282. if (!canvas) {
  98283. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  98284. }
  98285. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  98286. if (!engine.getCaps().textureFloatRender) {
  98287. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  98288. if (!engine.getCaps().textureHalfFloatRender) {
  98289. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  98290. }
  98291. }
  98292. var cubeWidth = internalTexture.width;
  98293. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  98294. var specularTextures = {};
  98295. var promises = [];
  98296. // Read and collect all mipmaps data from the cube.
  98297. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  98298. mipmapsCount = Math.round(mipmapsCount);
  98299. var _loop_1 = function (i) {
  98300. var faceWidth = Math.pow(2, mipmapsCount - i);
  98301. var _loop_2 = function (face) {
  98302. var data = texture.readPixels(face, i);
  98303. // Creates a temp texture with the face data.
  98304. 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);
  98305. // And rgbdEncode them.
  98306. var promise = new Promise(function (resolve, reject) {
  98307. 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);
  98308. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  98309. rgbdPostProcess.onApply = function (effect) {
  98310. effect._bindTexture("textureSampler", tempTexture);
  98311. };
  98312. // As the process needs to happen on the main canvas, keep track of the current size
  98313. var currentW = engine.getRenderWidth();
  98314. var currentH = engine.getRenderHeight();
  98315. // Set the desired size for the texture
  98316. engine.setSize(faceWidth, faceWidth);
  98317. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  98318. // Reading datas from WebGL
  98319. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  98320. var fileReader = new FileReader();
  98321. fileReader.onload = function (event) {
  98322. var arrayBuffer = event.target.result;
  98323. specularTextures[i * 6 + face] = arrayBuffer;
  98324. resolve();
  98325. };
  98326. fileReader.readAsArrayBuffer(blob);
  98327. });
  98328. // Reapply the previous canvas size
  98329. engine.setSize(currentW, currentH);
  98330. });
  98331. });
  98332. promises.push(promise);
  98333. };
  98334. // All faces of the cube.
  98335. for (var face = 0; face < 6; face++) {
  98336. _loop_2(face);
  98337. }
  98338. };
  98339. for (var i = 0; i <= mipmapsCount; i++) {
  98340. _loop_1(i);
  98341. }
  98342. // Once all the textures haves been collected as RGBD stored in PNGs
  98343. return Promise.all(promises).then(function () {
  98344. // We can delete the hosting scene keeping track of all the creation objects
  98345. hostingScene.dispose();
  98346. // Creates the json header for the env texture
  98347. var info = {
  98348. version: 1,
  98349. width: cubeWidth,
  98350. irradiance: _this._CreateEnvTextureIrradiance(texture),
  98351. specular: {
  98352. mipmaps: [],
  98353. lodGenerationScale: texture.lodGenerationScale
  98354. }
  98355. };
  98356. // Sets the specular image data information
  98357. var position = 0;
  98358. for (var i = 0; i <= mipmapsCount; i++) {
  98359. for (var face = 0; face < 6; face++) {
  98360. var byteLength = specularTextures[i * 6 + face].byteLength;
  98361. info.specular.mipmaps.push({
  98362. length: byteLength,
  98363. position: position
  98364. });
  98365. position += byteLength;
  98366. }
  98367. }
  98368. // Encode the JSON as an array buffer
  98369. var infoString = JSON.stringify(info);
  98370. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  98371. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  98372. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  98373. infoView[i] = infoString.charCodeAt(i);
  98374. }
  98375. // Ends up with a null terminator for easier parsing
  98376. infoView[infoString.length] = 0x00;
  98377. // Computes the final required size and creates the storage
  98378. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  98379. var finalBuffer = new ArrayBuffer(totalSize);
  98380. var finalBufferView = new Uint8Array(finalBuffer);
  98381. var dataView = new DataView(finalBuffer);
  98382. // Copy the magic bytes identifying the file in
  98383. var pos = 0;
  98384. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  98385. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  98386. }
  98387. // Add the json info
  98388. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  98389. pos += infoBuffer.byteLength;
  98390. // Finally inserts the texture data
  98391. for (var i = 0; i <= mipmapsCount; i++) {
  98392. for (var face = 0; face < 6; face++) {
  98393. var dataBuffer = specularTextures[i * 6 + face];
  98394. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  98395. pos += dataBuffer.byteLength;
  98396. }
  98397. }
  98398. // Voila
  98399. return finalBuffer;
  98400. });
  98401. };
  98402. /**
  98403. * Creates a JSON representation of the spherical data.
  98404. * @param texture defines the texture containing the polynomials
  98405. * @return the JSON representation of the spherical info
  98406. */
  98407. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  98408. var polynmials = texture.sphericalPolynomial;
  98409. if (polynmials == null) {
  98410. return null;
  98411. }
  98412. return {
  98413. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  98414. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  98415. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  98416. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  98417. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  98418. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  98419. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  98420. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  98421. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  98422. };
  98423. };
  98424. /**
  98425. * Uploads the texture info contained in the env file to the GPU.
  98426. * @param texture defines the internal texture to upload to
  98427. * @param arrayBuffer defines the buffer cotaining the data to load
  98428. * @param info defines the texture info retrieved through the GetEnvInfo method
  98429. * @returns a promise
  98430. */
  98431. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  98432. if (info.version !== 1) {
  98433. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  98434. }
  98435. var specularInfo = info.specular;
  98436. if (!specularInfo) {
  98437. // Nothing else parsed so far
  98438. return Promise.resolve();
  98439. }
  98440. // Double checks the enclosed info
  98441. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  98442. mipmapsCount = Math.round(mipmapsCount) + 1;
  98443. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  98444. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  98445. }
  98446. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  98447. var imageData = new Array(mipmapsCount);
  98448. for (var i = 0; i < mipmapsCount; i++) {
  98449. imageData[i] = new Array(6);
  98450. for (var face = 0; face < 6; face++) {
  98451. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  98452. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  98453. }
  98454. }
  98455. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  98456. };
  98457. /**
  98458. * Uploads the levels of image data to the GPU.
  98459. * @param texture defines the internal texture to upload to
  98460. * @param imageData defines the array buffer views of image data [mipmap][face]
  98461. * @returns a promise
  98462. */
  98463. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  98464. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  98465. throw new Error("Texture size must be a power of two");
  98466. }
  98467. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  98468. // Gets everything ready.
  98469. var engine = texture.getEngine();
  98470. var expandTexture = false;
  98471. var generateNonLODTextures = false;
  98472. var rgbdPostProcess = null;
  98473. var cubeRtt = null;
  98474. var lodTextures = null;
  98475. var caps = engine.getCaps();
  98476. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  98477. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  98478. texture.generateMipMaps = true;
  98479. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  98480. // Add extra process if texture lod is not supported
  98481. if (!caps.textureLOD) {
  98482. expandTexture = false;
  98483. generateNonLODTextures = true;
  98484. lodTextures = {};
  98485. }
  98486. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  98487. else if (engine.webGLVersion < 2) {
  98488. expandTexture = false;
  98489. }
  98490. // If half float available we can uncompress the texture
  98491. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  98492. expandTexture = true;
  98493. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  98494. }
  98495. // If full float available we can uncompress the texture
  98496. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  98497. expandTexture = true;
  98498. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  98499. }
  98500. // Expand the texture if possible
  98501. if (expandTexture) {
  98502. // Simply run through the decode PP
  98503. 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);
  98504. texture._isRGBD = false;
  98505. texture.invertY = false;
  98506. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  98507. generateDepthBuffer: false,
  98508. generateMipMaps: true,
  98509. generateStencilBuffer: false,
  98510. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  98511. type: texture.type,
  98512. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  98513. });
  98514. }
  98515. else {
  98516. texture._isRGBD = true;
  98517. texture.invertY = true;
  98518. // In case of missing support, applies the same patch than DDS files.
  98519. if (generateNonLODTextures) {
  98520. var mipSlices = 3;
  98521. var scale = texture._lodGenerationScale;
  98522. var offset = texture._lodGenerationOffset;
  98523. for (var i = 0; i < mipSlices; i++) {
  98524. //compute LOD from even spacing in smoothness (matching shader calculation)
  98525. var smoothness = i / (mipSlices - 1);
  98526. var roughness = 1 - smoothness;
  98527. var minLODIndex = offset; // roughness = 0
  98528. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  98529. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  98530. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  98531. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  98532. glTextureFromLod.isCube = true;
  98533. glTextureFromLod.invertY = true;
  98534. glTextureFromLod.generateMipMaps = false;
  98535. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  98536. // Wrap in a base texture for easy binding.
  98537. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  98538. lodTexture.isCube = true;
  98539. lodTexture._texture = glTextureFromLod;
  98540. lodTextures[mipmapIndex] = lodTexture;
  98541. switch (i) {
  98542. case 0:
  98543. texture._lodTextureLow = lodTexture;
  98544. break;
  98545. case 1:
  98546. texture._lodTextureMid = lodTexture;
  98547. break;
  98548. case 2:
  98549. texture._lodTextureHigh = lodTexture;
  98550. break;
  98551. }
  98552. }
  98553. }
  98554. }
  98555. var promises = [];
  98556. var _loop_3 = function (i) {
  98557. var _loop_4 = function (face) {
  98558. // Constructs an image element from image data
  98559. var bytes = imageData[i][face];
  98560. var blob = new Blob([bytes], { type: 'image/png' });
  98561. var url = URL.createObjectURL(blob);
  98562. var image = new Image();
  98563. image.src = url;
  98564. // Enqueue promise to upload to the texture.
  98565. var promise = new Promise(function (resolve, reject) {
  98566. image.onload = function () {
  98567. if (expandTexture) {
  98568. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  98569. reject(message);
  98570. }, image);
  98571. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  98572. // Uncompress the data to a RTT
  98573. rgbdPostProcess.onApply = function (effect) {
  98574. effect._bindTexture("textureSampler", tempTexture_1);
  98575. effect.setFloat2("scale", 1, 1);
  98576. };
  98577. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  98578. // Cleanup
  98579. engine.restoreDefaultFramebuffer();
  98580. tempTexture_1.dispose();
  98581. window.URL.revokeObjectURL(url);
  98582. resolve();
  98583. });
  98584. }
  98585. else {
  98586. engine._uploadImageToTexture(texture, image, face, i);
  98587. // Upload the face to the non lod texture support
  98588. if (generateNonLODTextures) {
  98589. var lodTexture = lodTextures[i];
  98590. if (lodTexture) {
  98591. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  98592. }
  98593. }
  98594. resolve();
  98595. }
  98596. };
  98597. image.onerror = function (error) {
  98598. reject(error);
  98599. };
  98600. });
  98601. promises.push(promise);
  98602. };
  98603. // All faces
  98604. for (var face = 0; face < 6; face++) {
  98605. _loop_4(face);
  98606. }
  98607. };
  98608. // All mipmaps up to provided number of images
  98609. for (var i = 0; i < imageData.length; i++) {
  98610. _loop_3(i);
  98611. }
  98612. // Fill remaining mipmaps with black textures.
  98613. if (imageData.length < mipmapsCount) {
  98614. var data = void 0;
  98615. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  98616. var dataLength = size * size * 4;
  98617. switch (texture.type) {
  98618. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  98619. data = new Uint8Array(dataLength);
  98620. break;
  98621. }
  98622. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  98623. data = new Uint16Array(dataLength);
  98624. break;
  98625. }
  98626. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  98627. data = new Float32Array(dataLength);
  98628. break;
  98629. }
  98630. }
  98631. for (var i = imageData.length; i < mipmapsCount; i++) {
  98632. for (var face = 0; face < 6; face++) {
  98633. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  98634. }
  98635. }
  98636. }
  98637. // Once all done, finishes the cleanup and return
  98638. return Promise.all(promises).then(function () {
  98639. // Release temp RTT.
  98640. if (cubeRtt) {
  98641. engine._releaseFramebufferObjects(cubeRtt);
  98642. cubeRtt._swapAndDie(texture);
  98643. }
  98644. // Release temp Post Process.
  98645. if (rgbdPostProcess) {
  98646. rgbdPostProcess.dispose();
  98647. }
  98648. // Flag internal texture as ready in case they are in use.
  98649. if (generateNonLODTextures) {
  98650. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  98651. texture._lodTextureHigh._texture.isReady = true;
  98652. }
  98653. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  98654. texture._lodTextureMid._texture.isReady = true;
  98655. }
  98656. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  98657. texture._lodTextureLow._texture.isReady = true;
  98658. }
  98659. }
  98660. });
  98661. };
  98662. /**
  98663. * Uploads spherical polynomials information to the texture.
  98664. * @param texture defines the texture we are trying to upload the information to
  98665. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  98666. */
  98667. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  98668. if (info.version !== 1) {
  98669. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  98670. }
  98671. var irradianceInfo = info.irradiance;
  98672. if (!irradianceInfo) {
  98673. return;
  98674. }
  98675. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  98676. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  98677. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  98678. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  98679. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  98680. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  98681. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  98682. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  98683. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  98684. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  98685. texture._sphericalPolynomial = sp;
  98686. };
  98687. /** @hidden */
  98688. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  98689. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  98690. internalTexture._bufferViewArrayArray = data;
  98691. internalTexture._lodGenerationScale = lodScale;
  98692. internalTexture._lodGenerationOffset = lodOffset;
  98693. internalTexture._sphericalPolynomial = sphericalPolynomial;
  98694. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  98695. internalTexture.isReady = true;
  98696. });
  98697. };
  98698. /**
  98699. * Magic number identifying the env file.
  98700. */
  98701. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  98702. return EnvironmentTextureTools;
  98703. }());
  98704. // References the dependencies.
  98705. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  98706. /***/ }),
  98707. /***/ "./Misc/filesInput.ts":
  98708. /*!****************************!*\
  98709. !*** ./Misc/filesInput.ts ***!
  98710. \****************************/
  98711. /*! exports provided: FilesInput */
  98712. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98713. "use strict";
  98714. __webpack_require__.r(__webpack_exports__);
  98715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  98716. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  98717. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  98718. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  98719. /**
  98720. * Class used to help managing file picking and drag'n'drop
  98721. */
  98722. var FilesInput = /** @class */ (function () {
  98723. /**
  98724. * Creates a new FilesInput
  98725. * @param engine defines the rendering engine
  98726. * @param scene defines the hosting scene
  98727. * @param sceneLoadedCallback callback called when scene is loaded
  98728. * @param progressCallback callback called to track progress
  98729. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  98730. * @param textureLoadingCallback callback called when a texture is loading
  98731. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  98732. * @param onReloadCallback callback called when a reload is requested
  98733. * @param errorCallback callback call if an error occurs
  98734. */
  98735. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  98736. /**
  98737. * Callback called when a file is processed
  98738. */
  98739. this.onProcessFileCallback = function () { return true; };
  98740. this._engine = engine;
  98741. this._currentScene = scene;
  98742. this._sceneLoadedCallback = sceneLoadedCallback;
  98743. this._progressCallback = progressCallback;
  98744. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  98745. this._textureLoadingCallback = textureLoadingCallback;
  98746. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  98747. this._onReloadCallback = onReloadCallback;
  98748. this._errorCallback = errorCallback;
  98749. }
  98750. Object.defineProperty(FilesInput, "FilesToLoad", {
  98751. /**
  98752. * List of files ready to be loaded
  98753. */
  98754. get: function () {
  98755. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  98756. },
  98757. enumerable: true,
  98758. configurable: true
  98759. });
  98760. /**
  98761. * Calls this function to listen to drag'n'drop events on a specific DOM element
  98762. * @param elementToMonitor defines the DOM element to track
  98763. */
  98764. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  98765. var _this = this;
  98766. if (elementToMonitor) {
  98767. this._elementToMonitor = elementToMonitor;
  98768. this._dragEnterHandler = function (e) { _this.drag(e); };
  98769. this._dragOverHandler = function (e) { _this.drag(e); };
  98770. this._dropHandler = function (e) { _this.drop(e); };
  98771. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  98772. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  98773. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  98774. }
  98775. };
  98776. /**
  98777. * Release all associated resources
  98778. */
  98779. FilesInput.prototype.dispose = function () {
  98780. if (!this._elementToMonitor) {
  98781. return;
  98782. }
  98783. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  98784. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  98785. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  98786. };
  98787. FilesInput.prototype.renderFunction = function () {
  98788. if (this._additionalRenderLoopLogicCallback) {
  98789. this._additionalRenderLoopLogicCallback();
  98790. }
  98791. if (this._currentScene) {
  98792. if (this._textureLoadingCallback) {
  98793. var remaining = this._currentScene.getWaitingItemsCount();
  98794. if (remaining > 0) {
  98795. this._textureLoadingCallback(remaining);
  98796. }
  98797. }
  98798. this._currentScene.render();
  98799. }
  98800. };
  98801. FilesInput.prototype.drag = function (e) {
  98802. e.stopPropagation();
  98803. e.preventDefault();
  98804. };
  98805. FilesInput.prototype.drop = function (eventDrop) {
  98806. eventDrop.stopPropagation();
  98807. eventDrop.preventDefault();
  98808. this.loadFiles(eventDrop);
  98809. };
  98810. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  98811. var _this = this;
  98812. var reader = folder.createReader();
  98813. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  98814. reader.readEntries(function (entries) {
  98815. remaining.count += entries.length;
  98816. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  98817. var entry = entries_1[_i];
  98818. if (entry.isFile) {
  98819. entry.file(function (file) {
  98820. file.correctName = relativePath + file.name;
  98821. files.push(file);
  98822. if (--remaining.count === 0) {
  98823. callback();
  98824. }
  98825. });
  98826. }
  98827. else if (entry.isDirectory) {
  98828. _this._traverseFolder(entry, files, remaining, callback);
  98829. }
  98830. }
  98831. if (--remaining.count) {
  98832. callback();
  98833. }
  98834. });
  98835. };
  98836. FilesInput.prototype._processFiles = function (files) {
  98837. for (var i = 0; i < files.length; i++) {
  98838. var name = files[i].correctName.toLowerCase();
  98839. var extension = name.split('.').pop();
  98840. if (!this.onProcessFileCallback(files[i], name, extension)) {
  98841. continue;
  98842. }
  98843. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  98844. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  98845. this._sceneFileToLoad = files[i];
  98846. }
  98847. FilesInput.FilesToLoad[name] = files[i];
  98848. }
  98849. };
  98850. /**
  98851. * Load files from a drop event
  98852. * @param event defines the drop event to use as source
  98853. */
  98854. FilesInput.prototype.loadFiles = function (event) {
  98855. var _this = this;
  98856. // Handling data transfer via drag'n'drop
  98857. if (event && event.dataTransfer && event.dataTransfer.files) {
  98858. this._filesToLoad = event.dataTransfer.files;
  98859. }
  98860. // Handling files from input files
  98861. if (event && event.target && event.target.files) {
  98862. this._filesToLoad = event.target.files;
  98863. }
  98864. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  98865. return;
  98866. }
  98867. if (this._startingProcessingFilesCallback) {
  98868. this._startingProcessingFilesCallback(this._filesToLoad);
  98869. }
  98870. if (this._filesToLoad && this._filesToLoad.length > 0) {
  98871. var files_1 = new Array();
  98872. var folders = [];
  98873. var items = event.dataTransfer ? event.dataTransfer.items : null;
  98874. for (var i = 0; i < this._filesToLoad.length; i++) {
  98875. var fileToLoad = this._filesToLoad[i];
  98876. var name_1 = fileToLoad.name.toLowerCase();
  98877. var entry = void 0;
  98878. fileToLoad.correctName = name_1;
  98879. if (items) {
  98880. var item = items[i];
  98881. if (item.getAsEntry) {
  98882. entry = item.getAsEntry();
  98883. }
  98884. else if (item.webkitGetAsEntry) {
  98885. entry = item.webkitGetAsEntry();
  98886. }
  98887. }
  98888. if (!entry) {
  98889. files_1.push(fileToLoad);
  98890. }
  98891. else {
  98892. if (entry.isDirectory) {
  98893. folders.push(entry);
  98894. }
  98895. else {
  98896. files_1.push(fileToLoad);
  98897. }
  98898. }
  98899. }
  98900. if (folders.length === 0) {
  98901. this._processFiles(files_1);
  98902. this._processReload();
  98903. }
  98904. else {
  98905. var remaining = { count: folders.length };
  98906. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  98907. var folder = folders_1[_i];
  98908. this._traverseFolder(folder, files_1, remaining, function () {
  98909. _this._processFiles(files_1);
  98910. if (remaining.count === 0) {
  98911. _this._processReload();
  98912. }
  98913. });
  98914. }
  98915. }
  98916. }
  98917. };
  98918. FilesInput.prototype._processReload = function () {
  98919. if (this._onReloadCallback) {
  98920. this._onReloadCallback(this._sceneFileToLoad);
  98921. }
  98922. else {
  98923. this.reload();
  98924. }
  98925. };
  98926. /**
  98927. * Reload the current scene from the loaded files
  98928. */
  98929. FilesInput.prototype.reload = function () {
  98930. var _this = this;
  98931. // If a scene file has been provided
  98932. if (this._sceneFileToLoad) {
  98933. if (this._currentScene) {
  98934. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  98935. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  98936. }
  98937. this._engine.stopRenderLoop();
  98938. }
  98939. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  98940. if (_this._progressCallback) {
  98941. _this._progressCallback(progress);
  98942. }
  98943. }).then(function (scene) {
  98944. if (_this._currentScene) {
  98945. _this._currentScene.dispose();
  98946. }
  98947. _this._currentScene = scene;
  98948. if (_this._sceneLoadedCallback) {
  98949. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  98950. }
  98951. // Wait for textures and shaders to be ready
  98952. _this._currentScene.executeWhenReady(function () {
  98953. _this._engine.runRenderLoop(function () {
  98954. _this.renderFunction();
  98955. });
  98956. });
  98957. }).catch(function (error) {
  98958. if (_this._errorCallback) {
  98959. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  98960. }
  98961. });
  98962. }
  98963. else {
  98964. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  98965. }
  98966. };
  98967. return FilesInput;
  98968. }());
  98969. /***/ }),
  98970. /***/ "./Misc/filesInputStore.ts":
  98971. /*!*********************************!*\
  98972. !*** ./Misc/filesInputStore.ts ***!
  98973. \*********************************/
  98974. /*! exports provided: FilesInputStore */
  98975. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98976. "use strict";
  98977. __webpack_require__.r(__webpack_exports__);
  98978. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  98979. /**
  98980. * Class used to help managing file picking and drag'n'drop
  98981. * File Storage
  98982. */
  98983. var FilesInputStore = /** @class */ (function () {
  98984. function FilesInputStore() {
  98985. }
  98986. /**
  98987. * List of files ready to be loaded
  98988. */
  98989. FilesInputStore.FilesToLoad = {};
  98990. return FilesInputStore;
  98991. }());
  98992. /***/ }),
  98993. /***/ "./Misc/iInspectable.ts":
  98994. /*!******************************!*\
  98995. !*** ./Misc/iInspectable.ts ***!
  98996. \******************************/
  98997. /*! exports provided: InspectableType */
  98998. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98999. "use strict";
  99000. __webpack_require__.r(__webpack_exports__);
  99001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return InspectableType; });
  99002. /**
  99003. * Enum that determines the text-wrapping mode to use.
  99004. */
  99005. var InspectableType;
  99006. (function (InspectableType) {
  99007. /**
  99008. * Checkbox for booleans
  99009. */
  99010. InspectableType[InspectableType["Checkbox"] = 0] = "Checkbox";
  99011. /**
  99012. * Sliders for numbers
  99013. */
  99014. InspectableType[InspectableType["Slider"] = 1] = "Slider";
  99015. /**
  99016. * Vector3
  99017. */
  99018. InspectableType[InspectableType["Vector3"] = 2] = "Vector3";
  99019. /**
  99020. * Quaternions
  99021. */
  99022. InspectableType[InspectableType["Quaternion"] = 3] = "Quaternion";
  99023. /**
  99024. * Color3
  99025. */
  99026. InspectableType[InspectableType["Color3"] = 4] = "Color3";
  99027. })(InspectableType || (InspectableType = {}));
  99028. /***/ }),
  99029. /***/ "./Misc/index.ts":
  99030. /*!***********************!*\
  99031. !*** ./Misc/index.ts ***!
  99032. \***********************/
  99033. /*! exports provided: AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, EquiRectangularCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsMatrix, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, MeshExploder, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, WebRequest, InspectableType, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  99034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99035. "use strict";
  99036. __webpack_require__.r(__webpack_exports__);
  99037. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  99038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  99039. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  99040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  99041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  99042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  99043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  99044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  99045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  99046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  99047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  99048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  99049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  99050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["EquiRectangularCubeTextureAssetTask"]; });
  99051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  99052. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  99053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  99054. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  99055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  99056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  99057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  99058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  99059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  99060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  99061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  99062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  99063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  99064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  99065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  99066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  99067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMatrix"]; });
  99068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  99069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  99070. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  99071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  99072. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  99073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  99074. /* harmony import */ var _meshExploder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshExploder */ "./Misc/meshExploder.ts");
  99075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _meshExploder__WEBPACK_IMPORTED_MODULE_6__["MeshExploder"]; });
  99076. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  99077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_7__["FilesInput"]; });
  99078. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  99079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["CubeMapToSphericalPolynomialTools"]; });
  99080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["HDRTools"]; });
  99081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_8__["PanoramaToCubeMapTools"]; });
  99082. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  99083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_9__["KhronosTextureContainer"]; });
  99084. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  99085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["EventState"]; });
  99086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["Observer"]; });
  99087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["MultiObserver"]; });
  99088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_10__["Observable"]; });
  99089. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  99090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__["PerformanceMonitor"]; });
  99091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_11__["RollingAverage"]; });
  99092. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  99093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_12__["PromisePolyfill"]; });
  99094. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  99095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimization"]; });
  99096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["TextureOptimization"]; });
  99097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["HardwareScalingOptimization"]; });
  99098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["ShadowsOptimization"]; });
  99099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["PostProcessesOptimization"]; });
  99100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["LensFlaresOptimization"]; });
  99101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["CustomOptimization"]; });
  99102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["ParticlesOptimization"]; });
  99103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["RenderTargetsOptimization"]; });
  99104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["MergeMeshesOptimization"]; });
  99105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimizerOptions"]; });
  99106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_13__["SceneOptimizer"]; });
  99107. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  99108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_14__["SceneSerializer"]; });
  99109. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  99110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_15__["SmartArray"]; });
  99111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_15__["SmartArrayNoDuplicate"]; });
  99112. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  99113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_16__["StringDictionary"]; });
  99114. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  99115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_17__["Tags"]; });
  99116. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  99117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_18__["TextureTools"]; });
  99118. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  99119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_19__["TGATools"]; });
  99120. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  99121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["ColorGradient"]; });
  99122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["Color3Gradient"]; });
  99123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["FactorGradient"]; });
  99124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["LoadFileError"]; });
  99125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["RetryStrategy"]; });
  99126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["Tools"]; });
  99127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["PerfCounter"]; });
  99128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["className"]; });
  99129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_20__["AsyncLoop"]; });
  99130. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  99131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_21__["VideoRecorder"]; });
  99132. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  99133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__["JoystickAxis"]; });
  99134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_22__["VirtualJoystick"]; });
  99135. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  99136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_23__["WorkerPool"]; });
  99137. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  99138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_24__["Logger"]; });
  99139. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  99140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_25__["_TypeStore"]; });
  99141. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  99142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_26__["FilesInputStore"]; });
  99143. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  99144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_27__["DeepCopier"]; });
  99145. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  99146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_28__["PivotTools"]; });
  99147. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  99148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_29__["PrecisionDate"]; });
  99149. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  99150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_30__["ScreenshotTools"]; });
  99151. /* empty/unused harmony star reexport *//* harmony import */ var _webRequest__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./webRequest */ "./Misc/webRequest.ts");
  99152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _webRequest__WEBPACK_IMPORTED_MODULE_31__["WebRequest"]; });
  99153. /* harmony import */ var _iInspectable__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./iInspectable */ "./Misc/iInspectable.ts");
  99154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _iInspectable__WEBPACK_IMPORTED_MODULE_32__["InspectableType"]; });
  99155. /***/ }),
  99156. /***/ "./Misc/khronosTextureContainer.ts":
  99157. /*!*****************************************!*\
  99158. !*** ./Misc/khronosTextureContainer.ts ***!
  99159. \*****************************************/
  99160. /*! exports provided: KhronosTextureContainer */
  99161. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99162. "use strict";
  99163. __webpack_require__.r(__webpack_exports__);
  99164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  99165. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  99166. /**
  99167. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  99168. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  99169. */
  99170. var KhronosTextureContainer = /** @class */ (function () {
  99171. /**
  99172. * Creates a new KhronosTextureContainer
  99173. * @param arrayBuffer contents of the KTX container file
  99174. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  99175. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  99176. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  99177. */
  99178. function KhronosTextureContainer(
  99179. /** contents of the KTX container file */
  99180. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  99181. this.arrayBuffer = arrayBuffer;
  99182. /**
  99183. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  99184. */
  99185. this.isInvalid = false;
  99186. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  99187. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  99188. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  99189. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  99190. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  99191. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  99192. this.isInvalid = true;
  99193. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  99194. return;
  99195. }
  99196. // load the reset of the header in native 32 bit uint
  99197. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  99198. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  99199. var endianness = headerDataView.getUint32(0, true);
  99200. var littleEndian = endianness === 0x04030201;
  99201. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  99202. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  99203. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  99204. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  99205. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  99206. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  99207. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  99208. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  99209. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  99210. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  99211. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  99212. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  99213. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  99214. if (this.glType !== 0) {
  99215. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  99216. return;
  99217. }
  99218. else {
  99219. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  99220. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  99221. }
  99222. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  99223. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  99224. return;
  99225. }
  99226. if (this.numberOfArrayElements !== 0) {
  99227. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  99228. return;
  99229. }
  99230. if (this.numberOfFaces !== facesExpected) {
  99231. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  99232. return;
  99233. }
  99234. // we now have a completely validated file, so could use existence of loadType as success
  99235. // would need to make this more elaborate & adjust checks above to support more than one load type
  99236. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  99237. }
  99238. /**
  99239. * Uploads KTX content to a Babylon Texture.
  99240. * It is assumed that the texture has already been created & is currently bound
  99241. * @hidden
  99242. */
  99243. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  99244. switch (this.loadType) {
  99245. case KhronosTextureContainer.COMPRESSED_2D:
  99246. this._upload2DCompressedLevels(texture, loadMipmaps);
  99247. break;
  99248. case KhronosTextureContainer.TEX_2D:
  99249. case KhronosTextureContainer.COMPRESSED_3D:
  99250. case KhronosTextureContainer.TEX_3D:
  99251. }
  99252. };
  99253. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  99254. // initialize width & height for level 1
  99255. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  99256. var width = this.pixelWidth;
  99257. var height = this.pixelHeight;
  99258. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  99259. for (var level = 0; level < mipmapCount; level++) {
  99260. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  99261. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  99262. for (var face = 0; face < this.numberOfFaces; face++) {
  99263. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  99264. var engine = texture.getEngine();
  99265. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  99266. dataOffset += imageSize; // add size of the image for the next face/mipmap
  99267. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  99268. }
  99269. width = Math.max(1.0, width * 0.5);
  99270. height = Math.max(1.0, height * 0.5);
  99271. }
  99272. };
  99273. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  99274. // load types
  99275. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  99276. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  99277. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  99278. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  99279. return KhronosTextureContainer;
  99280. }());
  99281. /***/ }),
  99282. /***/ "./Misc/logger.ts":
  99283. /*!************************!*\
  99284. !*** ./Misc/logger.ts ***!
  99285. \************************/
  99286. /*! exports provided: Logger */
  99287. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99288. "use strict";
  99289. __webpack_require__.r(__webpack_exports__);
  99290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  99291. /**
  99292. * Logger used througouht the application to allow configuration of
  99293. * the log level required for the messages.
  99294. */
  99295. var Logger = /** @class */ (function () {
  99296. function Logger() {
  99297. }
  99298. Logger._AddLogEntry = function (entry) {
  99299. Logger._LogCache = entry + Logger._LogCache;
  99300. if (Logger.OnNewCacheEntry) {
  99301. Logger.OnNewCacheEntry(entry);
  99302. }
  99303. };
  99304. Logger._FormatMessage = function (message) {
  99305. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  99306. var date = new Date();
  99307. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  99308. };
  99309. Logger._LogDisabled = function (message) {
  99310. // nothing to do
  99311. };
  99312. Logger._LogEnabled = function (message) {
  99313. var formattedMessage = Logger._FormatMessage(message);
  99314. console.log("BJS - " + formattedMessage);
  99315. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  99316. Logger._AddLogEntry(entry);
  99317. };
  99318. Logger._WarnDisabled = function (message) {
  99319. // nothing to do
  99320. };
  99321. Logger._WarnEnabled = function (message) {
  99322. var formattedMessage = Logger._FormatMessage(message);
  99323. console.warn("BJS - " + formattedMessage);
  99324. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  99325. Logger._AddLogEntry(entry);
  99326. };
  99327. Logger._ErrorDisabled = function (message) {
  99328. // nothing to do
  99329. };
  99330. Logger._ErrorEnabled = function (message) {
  99331. Logger.errorsCount++;
  99332. var formattedMessage = Logger._FormatMessage(message);
  99333. console.error("BJS - " + formattedMessage);
  99334. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  99335. Logger._AddLogEntry(entry);
  99336. };
  99337. Object.defineProperty(Logger, "LogCache", {
  99338. /**
  99339. * Gets current log cache (list of logs)
  99340. */
  99341. get: function () {
  99342. return Logger._LogCache;
  99343. },
  99344. enumerable: true,
  99345. configurable: true
  99346. });
  99347. /**
  99348. * Clears the log cache
  99349. */
  99350. Logger.ClearLogCache = function () {
  99351. Logger._LogCache = "";
  99352. Logger.errorsCount = 0;
  99353. };
  99354. Object.defineProperty(Logger, "LogLevels", {
  99355. /**
  99356. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99357. */
  99358. set: function (level) {
  99359. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  99360. Logger.Log = Logger._LogEnabled;
  99361. }
  99362. else {
  99363. Logger.Log = Logger._LogDisabled;
  99364. }
  99365. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  99366. Logger.Warn = Logger._WarnEnabled;
  99367. }
  99368. else {
  99369. Logger.Warn = Logger._WarnDisabled;
  99370. }
  99371. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  99372. Logger.Error = Logger._ErrorEnabled;
  99373. }
  99374. else {
  99375. Logger.Error = Logger._ErrorDisabled;
  99376. }
  99377. },
  99378. enumerable: true,
  99379. configurable: true
  99380. });
  99381. /**
  99382. * No log
  99383. */
  99384. Logger.NoneLogLevel = 0;
  99385. /**
  99386. * Only message logs
  99387. */
  99388. Logger.MessageLogLevel = 1;
  99389. /**
  99390. * Only warning logs
  99391. */
  99392. Logger.WarningLogLevel = 2;
  99393. /**
  99394. * Only error logs
  99395. */
  99396. Logger.ErrorLogLevel = 4;
  99397. /**
  99398. * All logs
  99399. */
  99400. Logger.AllLogLevel = 7;
  99401. Logger._LogCache = "";
  99402. /**
  99403. * Gets a value indicating the number of loading errors
  99404. * @ignorenaming
  99405. */
  99406. Logger.errorsCount = 0;
  99407. /**
  99408. * Log a message to the console
  99409. */
  99410. Logger.Log = Logger._LogEnabled;
  99411. /**
  99412. * Write a warning message to the console
  99413. */
  99414. Logger.Warn = Logger._WarnEnabled;
  99415. /**
  99416. * Write an error message to the console
  99417. */
  99418. Logger.Error = Logger._ErrorEnabled;
  99419. return Logger;
  99420. }());
  99421. /***/ }),
  99422. /***/ "./Misc/meshExploder.ts":
  99423. /*!******************************!*\
  99424. !*** ./Misc/meshExploder.ts ***!
  99425. \******************************/
  99426. /*! exports provided: MeshExploder */
  99427. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99428. "use strict";
  99429. __webpack_require__.r(__webpack_exports__);
  99430. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return MeshExploder; });
  99431. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  99432. /**
  99433. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  99434. */
  99435. var MeshExploder = /** @class */ (function () {
  99436. /**
  99437. * Explodes meshes from a center mesh.
  99438. * @param meshes The meshes to explode.
  99439. * @param centerMesh The mesh to be center of explosion.
  99440. */
  99441. function MeshExploder(meshes, centerMesh) {
  99442. this._meshesOrigins = [];
  99443. this._toCenterVectors = [];
  99444. this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99445. this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99446. this._centerPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99447. this._meshes = meshes.slice();
  99448. if (centerMesh) {
  99449. this._centerMesh = centerMesh;
  99450. }
  99451. else {
  99452. this._setCenterMesh();
  99453. }
  99454. var centerMeshIndex = this._meshes.indexOf(this._centerMesh);
  99455. if (centerMeshIndex >= 0) {
  99456. this._meshes.splice(centerMeshIndex, 1);
  99457. }
  99458. this._centerPosition = this._centerMesh.getAbsolutePosition().clone();
  99459. for (var index = 0; index < this._meshes.length; index++) {
  99460. if (this._meshes[index]) {
  99461. var mesh = this._meshes[index];
  99462. this._meshesOrigins[index] = mesh.getAbsolutePosition().clone();
  99463. this._toCenterVectors[index] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99464. if (mesh._boundingInfo && this._centerMesh._boundingInfo) {
  99465. mesh._boundingInfo.boundingBox.centerWorld.subtractToRef(this._centerMesh._boundingInfo.boundingBox.centerWorld, this._toCenterVectors[index]);
  99466. }
  99467. }
  99468. }
  99469. }
  99470. MeshExploder.prototype._setCenterMesh = function () {
  99471. var averageCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99472. var totalCenters = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  99473. var shortestToCenter = Number.MAX_VALUE;
  99474. for (var index = 0; index < this._meshes.length; index++) {
  99475. if (this._meshes[index]) {
  99476. var mesh = this._meshes[index];
  99477. var boundingInfo = mesh.getBoundingInfo();
  99478. if (boundingInfo) {
  99479. totalCenters.addInPlace(boundingInfo.boundingBox.centerWorld);
  99480. }
  99481. }
  99482. }
  99483. averageCenter = totalCenters.scale(1 / this._meshes.length);
  99484. for (var index = 0; index < this._meshes.length; index++) {
  99485. if (this._meshes[index]) {
  99486. var mesh = this._meshes[index];
  99487. var boundingInfo = mesh.getBoundingInfo();
  99488. if (boundingInfo) {
  99489. var distanceToCenter = boundingInfo.boundingBox.centerWorld.subtract(averageCenter).lengthSquared();
  99490. if (distanceToCenter < shortestToCenter) {
  99491. this._centerMesh = mesh;
  99492. shortestToCenter = distanceToCenter;
  99493. }
  99494. }
  99495. }
  99496. }
  99497. };
  99498. /**
  99499. * Get class name
  99500. * @returns "MeshExploder"
  99501. */
  99502. MeshExploder.prototype.getClassName = function () {
  99503. return "MeshExploder";
  99504. };
  99505. /**
  99506. * "Exploded meshes"
  99507. * @returns Array of meshes with the centerMesh at index 0.
  99508. */
  99509. MeshExploder.prototype.getMeshes = function () {
  99510. var meshArray = this._meshes.slice();
  99511. meshArray.unshift(this._centerMesh);
  99512. return meshArray;
  99513. };
  99514. /**
  99515. * Explodes meshes giving a specific direction
  99516. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  99517. */
  99518. MeshExploder.prototype.explode = function (direction) {
  99519. if (direction === void 0) { direction = 1.0; }
  99520. for (var index = 0; index < this._meshes.length; index++) {
  99521. if (this._meshes[index] && this._meshesOrigins[index] && this._toCenterVectors[index]) {
  99522. this._toCenterVectors[index].scaleToRef(direction, this._scaledDirection);
  99523. this._meshesOrigins[index].addToRef(this._scaledDirection, this._newPosition);
  99524. this._meshes[index].setAbsolutePosition(this._newPosition);
  99525. }
  99526. }
  99527. this._centerMesh.setAbsolutePosition(this._centerPosition);
  99528. };
  99529. return MeshExploder;
  99530. }());
  99531. /***/ }),
  99532. /***/ "./Misc/observable.ts":
  99533. /*!****************************!*\
  99534. !*** ./Misc/observable.ts ***!
  99535. \****************************/
  99536. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  99537. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99538. "use strict";
  99539. __webpack_require__.r(__webpack_exports__);
  99540. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  99541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  99542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  99543. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  99544. /**
  99545. * A class serves as a medium between the observable and its observers
  99546. */
  99547. var EventState = /** @class */ (function () {
  99548. /**
  99549. * Create a new EventState
  99550. * @param mask defines the mask associated with this state
  99551. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  99552. * @param target defines the original target of the state
  99553. * @param currentTarget defines the current target of the state
  99554. */
  99555. function EventState(mask, skipNextObservers, target, currentTarget) {
  99556. if (skipNextObservers === void 0) { skipNextObservers = false; }
  99557. this.initalize(mask, skipNextObservers, target, currentTarget);
  99558. }
  99559. /**
  99560. * Initialize the current event state
  99561. * @param mask defines the mask associated with this state
  99562. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  99563. * @param target defines the original target of the state
  99564. * @param currentTarget defines the current target of the state
  99565. * @returns the current event state
  99566. */
  99567. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  99568. if (skipNextObservers === void 0) { skipNextObservers = false; }
  99569. this.mask = mask;
  99570. this.skipNextObservers = skipNextObservers;
  99571. this.target = target;
  99572. this.currentTarget = currentTarget;
  99573. return this;
  99574. };
  99575. return EventState;
  99576. }());
  99577. /**
  99578. * Represent an Observer registered to a given Observable object.
  99579. */
  99580. var Observer = /** @class */ (function () {
  99581. /**
  99582. * Creates a new observer
  99583. * @param callback defines the callback to call when the observer is notified
  99584. * @param mask defines the mask of the observer (used to filter notifications)
  99585. * @param scope defines the current scope used to restore the JS context
  99586. */
  99587. function Observer(
  99588. /**
  99589. * Defines the callback to call when the observer is notified
  99590. */
  99591. callback,
  99592. /**
  99593. * Defines the mask of the observer (used to filter notifications)
  99594. */
  99595. mask,
  99596. /**
  99597. * Defines the current scope used to restore the JS context
  99598. */
  99599. scope) {
  99600. if (scope === void 0) { scope = null; }
  99601. this.callback = callback;
  99602. this.mask = mask;
  99603. this.scope = scope;
  99604. /** @hidden */
  99605. this._willBeUnregistered = false;
  99606. /**
  99607. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  99608. */
  99609. this.unregisterOnNextCall = false;
  99610. }
  99611. return Observer;
  99612. }());
  99613. /**
  99614. * Represent a list of observers registered to multiple Observables object.
  99615. */
  99616. var MultiObserver = /** @class */ (function () {
  99617. function MultiObserver() {
  99618. }
  99619. /**
  99620. * Release associated resources
  99621. */
  99622. MultiObserver.prototype.dispose = function () {
  99623. if (this._observers && this._observables) {
  99624. for (var index = 0; index < this._observers.length; index++) {
  99625. this._observables[index].remove(this._observers[index]);
  99626. }
  99627. }
  99628. this._observers = null;
  99629. this._observables = null;
  99630. };
  99631. /**
  99632. * Raise a callback when one of the observable will notify
  99633. * @param observables defines a list of observables to watch
  99634. * @param callback defines the callback to call on notification
  99635. * @param mask defines the mask used to filter notifications
  99636. * @param scope defines the current scope used to restore the JS context
  99637. * @returns the new MultiObserver
  99638. */
  99639. MultiObserver.Watch = function (observables, callback, mask, scope) {
  99640. if (mask === void 0) { mask = -1; }
  99641. if (scope === void 0) { scope = null; }
  99642. var result = new MultiObserver();
  99643. result._observers = new Array();
  99644. result._observables = observables;
  99645. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  99646. var observable = observables_1[_i];
  99647. var observer = observable.add(callback, mask, false, scope);
  99648. if (observer) {
  99649. result._observers.push(observer);
  99650. }
  99651. }
  99652. return result;
  99653. };
  99654. return MultiObserver;
  99655. }());
  99656. /**
  99657. * The Observable class is a simple implementation of the Observable pattern.
  99658. *
  99659. * 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.
  99660. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  99661. * 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).
  99662. * 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.
  99663. */
  99664. var Observable = /** @class */ (function () {
  99665. /**
  99666. * Creates a new observable
  99667. * @param onObserverAdded defines a callback to call when a new observer is added
  99668. */
  99669. function Observable(onObserverAdded) {
  99670. this._observers = new Array();
  99671. this._eventState = new EventState(0);
  99672. if (onObserverAdded) {
  99673. this._onObserverAdded = onObserverAdded;
  99674. }
  99675. }
  99676. /**
  99677. * Create a new Observer with the specified callback
  99678. * @param callback the callback that will be executed for that Observer
  99679. * @param mask the mask used to filter observers
  99680. * @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.
  99681. * @param scope optional scope for the callback to be called from
  99682. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  99683. * @returns the new observer created for the callback
  99684. */
  99685. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  99686. if (mask === void 0) { mask = -1; }
  99687. if (insertFirst === void 0) { insertFirst = false; }
  99688. if (scope === void 0) { scope = null; }
  99689. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  99690. if (!callback) {
  99691. return null;
  99692. }
  99693. var observer = new Observer(callback, mask, scope);
  99694. observer.unregisterOnNextCall = unregisterOnFirstCall;
  99695. if (insertFirst) {
  99696. this._observers.unshift(observer);
  99697. }
  99698. else {
  99699. this._observers.push(observer);
  99700. }
  99701. if (this._onObserverAdded) {
  99702. this._onObserverAdded(observer);
  99703. }
  99704. return observer;
  99705. };
  99706. /**
  99707. * Create a new Observer with the specified callback and unregisters after the next notification
  99708. * @param callback the callback that will be executed for that Observer
  99709. * @returns the new observer created for the callback
  99710. */
  99711. Observable.prototype.addOnce = function (callback) {
  99712. return this.add(callback, undefined, undefined, undefined, true);
  99713. };
  99714. /**
  99715. * Remove an Observer from the Observable object
  99716. * @param observer the instance of the Observer to remove
  99717. * @returns false if it doesn't belong to this Observable
  99718. */
  99719. Observable.prototype.remove = function (observer) {
  99720. if (!observer) {
  99721. return false;
  99722. }
  99723. var index = this._observers.indexOf(observer);
  99724. if (index !== -1) {
  99725. this._deferUnregister(observer);
  99726. return true;
  99727. }
  99728. return false;
  99729. };
  99730. /**
  99731. * Remove a callback from the Observable object
  99732. * @param callback the callback to remove
  99733. * @param scope optional scope. If used only the callbacks with this scope will be removed
  99734. * @returns false if it doesn't belong to this Observable
  99735. */
  99736. Observable.prototype.removeCallback = function (callback, scope) {
  99737. for (var index = 0; index < this._observers.length; index++) {
  99738. if (this._observers[index].callback === callback && (!scope || scope === this._observers[index].scope)) {
  99739. this._deferUnregister(this._observers[index]);
  99740. return true;
  99741. }
  99742. }
  99743. return false;
  99744. };
  99745. Observable.prototype._deferUnregister = function (observer) {
  99746. var _this = this;
  99747. observer.unregisterOnNextCall = false;
  99748. observer._willBeUnregistered = true;
  99749. setTimeout(function () {
  99750. _this._remove(observer);
  99751. }, 0);
  99752. };
  99753. // This should only be called when not iterating over _observers to avoid callback skipping.
  99754. // Removes an observer from the _observer Array.
  99755. Observable.prototype._remove = function (observer) {
  99756. if (!observer) {
  99757. return false;
  99758. }
  99759. var index = this._observers.indexOf(observer);
  99760. if (index !== -1) {
  99761. this._observers.splice(index, 1);
  99762. return true;
  99763. }
  99764. return false;
  99765. };
  99766. /**
  99767. * Moves the observable to the top of the observer list making it get called first when notified
  99768. * @param observer the observer to move
  99769. */
  99770. Observable.prototype.makeObserverTopPriority = function (observer) {
  99771. this._remove(observer);
  99772. this._observers.unshift(observer);
  99773. };
  99774. /**
  99775. * Moves the observable to the bottom of the observer list making it get called last when notified
  99776. * @param observer the observer to move
  99777. */
  99778. Observable.prototype.makeObserverBottomPriority = function (observer) {
  99779. this._remove(observer);
  99780. this._observers.push(observer);
  99781. };
  99782. /**
  99783. * Notify all Observers by calling their respective callback with the given data
  99784. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  99785. * @param eventData defines the data to send to all observers
  99786. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  99787. * @param target defines the original target of the state
  99788. * @param currentTarget defines the current target of the state
  99789. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  99790. */
  99791. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  99792. if (mask === void 0) { mask = -1; }
  99793. if (!this._observers.length) {
  99794. return true;
  99795. }
  99796. var state = this._eventState;
  99797. state.mask = mask;
  99798. state.target = target;
  99799. state.currentTarget = currentTarget;
  99800. state.skipNextObservers = false;
  99801. state.lastReturnValue = eventData;
  99802. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  99803. var obs = _a[_i];
  99804. if (obs._willBeUnregistered) {
  99805. continue;
  99806. }
  99807. if (obs.mask & mask) {
  99808. if (obs.scope) {
  99809. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  99810. }
  99811. else {
  99812. state.lastReturnValue = obs.callback(eventData, state);
  99813. }
  99814. if (obs.unregisterOnNextCall) {
  99815. this._deferUnregister(obs);
  99816. }
  99817. }
  99818. if (state.skipNextObservers) {
  99819. return false;
  99820. }
  99821. }
  99822. return true;
  99823. };
  99824. /**
  99825. * Calling this will execute each callback, expecting it to be a promise or return a value.
  99826. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  99827. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  99828. * and it is crucial that all callbacks will be executed.
  99829. * The order of the callbacks is kept, callbacks are not executed parallel.
  99830. *
  99831. * @param eventData The data to be sent to each callback
  99832. * @param mask is used to filter observers defaults to -1
  99833. * @param target defines the callback target (see EventState)
  99834. * @param currentTarget defines he current object in the bubbling phase
  99835. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  99836. */
  99837. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  99838. var _this = this;
  99839. if (mask === void 0) { mask = -1; }
  99840. // create an empty promise
  99841. var p = Promise.resolve(eventData);
  99842. // no observers? return this promise.
  99843. if (!this._observers.length) {
  99844. return p;
  99845. }
  99846. var state = this._eventState;
  99847. state.mask = mask;
  99848. state.target = target;
  99849. state.currentTarget = currentTarget;
  99850. state.skipNextObservers = false;
  99851. // execute one callback after another (not using Promise.all, the order is important)
  99852. this._observers.forEach(function (obs) {
  99853. if (state.skipNextObservers) {
  99854. return;
  99855. }
  99856. if (obs._willBeUnregistered) {
  99857. return;
  99858. }
  99859. if (obs.mask & mask) {
  99860. if (obs.scope) {
  99861. p = p.then(function (lastReturnedValue) {
  99862. state.lastReturnValue = lastReturnedValue;
  99863. return obs.callback.apply(obs.scope, [eventData, state]);
  99864. });
  99865. }
  99866. else {
  99867. p = p.then(function (lastReturnedValue) {
  99868. state.lastReturnValue = lastReturnedValue;
  99869. return obs.callback(eventData, state);
  99870. });
  99871. }
  99872. if (obs.unregisterOnNextCall) {
  99873. _this._deferUnregister(obs);
  99874. }
  99875. }
  99876. });
  99877. // return the eventData
  99878. return p.then(function () { return eventData; });
  99879. };
  99880. /**
  99881. * Notify a specific observer
  99882. * @param observer defines the observer to notify
  99883. * @param eventData defines the data to be sent to each callback
  99884. * @param mask is used to filter observers defaults to -1
  99885. */
  99886. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  99887. if (mask === void 0) { mask = -1; }
  99888. var state = this._eventState;
  99889. state.mask = mask;
  99890. state.skipNextObservers = false;
  99891. observer.callback(eventData, state);
  99892. };
  99893. /**
  99894. * Gets a boolean indicating if the observable has at least one observer
  99895. * @returns true is the Observable has at least one Observer registered
  99896. */
  99897. Observable.prototype.hasObservers = function () {
  99898. return this._observers.length > 0;
  99899. };
  99900. /**
  99901. * Clear the list of observers
  99902. */
  99903. Observable.prototype.clear = function () {
  99904. this._observers = new Array();
  99905. this._onObserverAdded = null;
  99906. };
  99907. /**
  99908. * Clone the current observable
  99909. * @returns a new observable
  99910. */
  99911. Observable.prototype.clone = function () {
  99912. var result = new Observable();
  99913. result._observers = this._observers.slice(0);
  99914. return result;
  99915. };
  99916. /**
  99917. * Does this observable handles observer registered with a given mask
  99918. * @param mask defines the mask to be tested
  99919. * @return whether or not one observer registered with the given mask is handeled
  99920. **/
  99921. Observable.prototype.hasSpecificMask = function (mask) {
  99922. if (mask === void 0) { mask = -1; }
  99923. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  99924. var obs = _a[_i];
  99925. if (obs.mask & mask || obs.mask === mask) {
  99926. return true;
  99927. }
  99928. }
  99929. return false;
  99930. };
  99931. return Observable;
  99932. }());
  99933. /***/ }),
  99934. /***/ "./Misc/performanceMonitor.ts":
  99935. /*!************************************!*\
  99936. !*** ./Misc/performanceMonitor.ts ***!
  99937. \************************************/
  99938. /*! exports provided: PerformanceMonitor, RollingAverage */
  99939. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99940. "use strict";
  99941. __webpack_require__.r(__webpack_exports__);
  99942. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  99943. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  99944. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  99945. /**
  99946. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  99947. */
  99948. var PerformanceMonitor = /** @class */ (function () {
  99949. /**
  99950. * constructor
  99951. * @param frameSampleSize The number of samples required to saturate the sliding window
  99952. */
  99953. function PerformanceMonitor(frameSampleSize) {
  99954. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  99955. this._enabled = true;
  99956. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  99957. }
  99958. /**
  99959. * Samples current frame
  99960. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  99961. */
  99962. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  99963. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  99964. if (!this._enabled) {
  99965. return;
  99966. }
  99967. if (this._lastFrameTimeMs != null) {
  99968. var dt = timeMs - this._lastFrameTimeMs;
  99969. this._rollingFrameTime.add(dt);
  99970. }
  99971. this._lastFrameTimeMs = timeMs;
  99972. };
  99973. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  99974. /**
  99975. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99976. */
  99977. get: function () {
  99978. return this._rollingFrameTime.average;
  99979. },
  99980. enumerable: true,
  99981. configurable: true
  99982. });
  99983. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  99984. /**
  99985. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  99986. */
  99987. get: function () {
  99988. return this._rollingFrameTime.variance;
  99989. },
  99990. enumerable: true,
  99991. configurable: true
  99992. });
  99993. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  99994. /**
  99995. * Returns the frame time of the most recent frame
  99996. */
  99997. get: function () {
  99998. return this._rollingFrameTime.history(0);
  99999. },
  100000. enumerable: true,
  100001. configurable: true
  100002. });
  100003. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  100004. /**
  100005. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  100006. */
  100007. get: function () {
  100008. return 1000.0 / this._rollingFrameTime.average;
  100009. },
  100010. enumerable: true,
  100011. configurable: true
  100012. });
  100013. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  100014. /**
  100015. * Returns the average framerate in frames per second using the most recent frame time
  100016. */
  100017. get: function () {
  100018. var history = this._rollingFrameTime.history(0);
  100019. if (history === 0) {
  100020. return 0;
  100021. }
  100022. return 1000.0 / history;
  100023. },
  100024. enumerable: true,
  100025. configurable: true
  100026. });
  100027. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  100028. /**
  100029. * Returns true if enough samples have been taken to completely fill the sliding window
  100030. */
  100031. get: function () {
  100032. return this._rollingFrameTime.isSaturated();
  100033. },
  100034. enumerable: true,
  100035. configurable: true
  100036. });
  100037. /**
  100038. * Enables contributions to the sliding window sample set
  100039. */
  100040. PerformanceMonitor.prototype.enable = function () {
  100041. this._enabled = true;
  100042. };
  100043. /**
  100044. * Disables contributions to the sliding window sample set
  100045. * Samples will not be interpolated over the disabled period
  100046. */
  100047. PerformanceMonitor.prototype.disable = function () {
  100048. this._enabled = false;
  100049. //clear last sample to avoid interpolating over the disabled period when next enabled
  100050. this._lastFrameTimeMs = null;
  100051. };
  100052. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  100053. /**
  100054. * Returns true if sampling is enabled
  100055. */
  100056. get: function () {
  100057. return this._enabled;
  100058. },
  100059. enumerable: true,
  100060. configurable: true
  100061. });
  100062. /**
  100063. * Resets performance monitor
  100064. */
  100065. PerformanceMonitor.prototype.reset = function () {
  100066. //clear last sample to avoid interpolating over the disabled period when next enabled
  100067. this._lastFrameTimeMs = null;
  100068. //wipe record
  100069. this._rollingFrameTime.reset();
  100070. };
  100071. return PerformanceMonitor;
  100072. }());
  100073. /**
  100074. * RollingAverage
  100075. *
  100076. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  100077. */
  100078. var RollingAverage = /** @class */ (function () {
  100079. /**
  100080. * constructor
  100081. * @param length The number of samples required to saturate the sliding window
  100082. */
  100083. function RollingAverage(length) {
  100084. this._samples = new Array(length);
  100085. this.reset();
  100086. }
  100087. /**
  100088. * Adds a sample to the sample set
  100089. * @param v The sample value
  100090. */
  100091. RollingAverage.prototype.add = function (v) {
  100092. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  100093. var delta;
  100094. //we need to check if we've already wrapped round
  100095. if (this.isSaturated()) {
  100096. //remove bottom of stack from mean
  100097. var bottomValue = this._samples[this._pos];
  100098. delta = bottomValue - this.average;
  100099. this.average -= delta / (this._sampleCount - 1);
  100100. this._m2 -= delta * (bottomValue - this.average);
  100101. }
  100102. else {
  100103. this._sampleCount++;
  100104. }
  100105. //add new value to mean
  100106. delta = v - this.average;
  100107. this.average += delta / (this._sampleCount);
  100108. this._m2 += delta * (v - this.average);
  100109. //set the new variance
  100110. this.variance = this._m2 / (this._sampleCount - 1);
  100111. this._samples[this._pos] = v;
  100112. this._pos++;
  100113. this._pos %= this._samples.length; //positive wrap around
  100114. };
  100115. /**
  100116. * Returns previously added values or null if outside of history or outside the sliding window domain
  100117. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  100118. * @return Value previously recorded with add() or null if outside of range
  100119. */
  100120. RollingAverage.prototype.history = function (i) {
  100121. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  100122. return 0;
  100123. }
  100124. var i0 = this._wrapPosition(this._pos - 1.0);
  100125. return this._samples[this._wrapPosition(i0 - i)];
  100126. };
  100127. /**
  100128. * Returns true if enough samples have been taken to completely fill the sliding window
  100129. * @return true if sample-set saturated
  100130. */
  100131. RollingAverage.prototype.isSaturated = function () {
  100132. return this._sampleCount >= this._samples.length;
  100133. };
  100134. /**
  100135. * Resets the rolling average (equivalent to 0 samples taken so far)
  100136. */
  100137. RollingAverage.prototype.reset = function () {
  100138. this.average = 0;
  100139. this.variance = 0;
  100140. this._sampleCount = 0;
  100141. this._pos = 0;
  100142. this._m2 = 0;
  100143. };
  100144. /**
  100145. * Wraps a value around the sample range boundaries
  100146. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  100147. * @return Wrapped position in sample range
  100148. */
  100149. RollingAverage.prototype._wrapPosition = function (i) {
  100150. var max = this._samples.length;
  100151. return ((i % max) + max) % max;
  100152. };
  100153. return RollingAverage;
  100154. }());
  100155. /***/ }),
  100156. /***/ "./Misc/pivotTools.ts":
  100157. /*!****************************!*\
  100158. !*** ./Misc/pivotTools.ts ***!
  100159. \****************************/
  100160. /*! exports provided: PivotTools */
  100161. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100162. "use strict";
  100163. __webpack_require__.r(__webpack_exports__);
  100164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  100165. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  100166. /**
  100167. * Class containing a set of static utilities functions for managing Pivots
  100168. * @hidden
  100169. */
  100170. var PivotTools = /** @class */ (function () {
  100171. function PivotTools() {
  100172. }
  100173. /** @hidden */
  100174. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  100175. if (mesh && PivotTools._PivotCached === 0) {
  100176. // Save old pivot and set pivot to 0,0,0
  100177. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  100178. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  100179. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  100180. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  100181. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  100182. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  100183. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  100184. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  100185. }
  100186. }
  100187. PivotTools._PivotCached++;
  100188. };
  100189. /** @hidden */
  100190. PivotTools._RestorePivotPoint = function (mesh) {
  100191. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  100192. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  100193. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  100194. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  100195. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  100196. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  100197. }
  100198. this._PivotCached--;
  100199. };
  100200. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  100201. // store/remove pivot point should only be applied during their outermost calls
  100202. PivotTools._PivotCached = 0;
  100203. PivotTools._OldPivotPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  100204. PivotTools._PivotTranslation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  100205. PivotTools._PivotTmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  100206. return PivotTools;
  100207. }());
  100208. /***/ }),
  100209. /***/ "./Misc/precisionDate.ts":
  100210. /*!*******************************!*\
  100211. !*** ./Misc/precisionDate.ts ***!
  100212. \*******************************/
  100213. /*! exports provided: PrecisionDate */
  100214. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100215. "use strict";
  100216. __webpack_require__.r(__webpack_exports__);
  100217. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  100218. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  100219. /**
  100220. * Class containing a set of static utilities functions for precision date
  100221. */
  100222. var PrecisionDate = /** @class */ (function () {
  100223. function PrecisionDate() {
  100224. }
  100225. Object.defineProperty(PrecisionDate, "Now", {
  100226. /**
  100227. * Gets either window.performance.now() if supported or Date.now() else
  100228. */
  100229. get: function () {
  100230. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  100231. return window.performance.now();
  100232. }
  100233. return Date.now();
  100234. },
  100235. enumerable: true,
  100236. configurable: true
  100237. });
  100238. return PrecisionDate;
  100239. }());
  100240. /***/ }),
  100241. /***/ "./Misc/promise.ts":
  100242. /*!*************************!*\
  100243. !*** ./Misc/promise.ts ***!
  100244. \*************************/
  100245. /*! exports provided: PromisePolyfill */
  100246. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100247. "use strict";
  100248. __webpack_require__.r(__webpack_exports__);
  100249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  100250. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  100251. var PromiseStates;
  100252. (function (PromiseStates) {
  100253. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  100254. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  100255. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  100256. })(PromiseStates || (PromiseStates = {}));
  100257. var FulFillmentAgregator = /** @class */ (function () {
  100258. function FulFillmentAgregator() {
  100259. this.count = 0;
  100260. this.target = 0;
  100261. this.results = [];
  100262. }
  100263. return FulFillmentAgregator;
  100264. }());
  100265. var InternalPromise = /** @class */ (function () {
  100266. function InternalPromise(resolver) {
  100267. var _this = this;
  100268. this._state = PromiseStates.Pending;
  100269. this._children = new Array();
  100270. this._rejectWasConsumed = false;
  100271. if (!resolver) {
  100272. return;
  100273. }
  100274. try {
  100275. resolver(function (value) {
  100276. _this._resolve(value);
  100277. }, function (reason) {
  100278. _this._reject(reason);
  100279. });
  100280. }
  100281. catch (e) {
  100282. this._reject(e);
  100283. }
  100284. }
  100285. Object.defineProperty(InternalPromise.prototype, "_result", {
  100286. get: function () {
  100287. return this._resultValue;
  100288. },
  100289. set: function (value) {
  100290. this._resultValue = value;
  100291. if (this._parent && this._parent._result === undefined) {
  100292. this._parent._result = value;
  100293. }
  100294. },
  100295. enumerable: true,
  100296. configurable: true
  100297. });
  100298. InternalPromise.prototype.catch = function (onRejected) {
  100299. return this.then(undefined, onRejected);
  100300. };
  100301. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  100302. var _this = this;
  100303. var newPromise = new InternalPromise();
  100304. newPromise._onFulfilled = onFulfilled;
  100305. newPromise._onRejected = onRejected;
  100306. // Composition
  100307. this._children.push(newPromise);
  100308. newPromise._parent = this;
  100309. if (this._state !== PromiseStates.Pending) {
  100310. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  100311. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  100312. var returnedValue = newPromise._resolve(_this._result);
  100313. if (returnedValue !== undefined && returnedValue !== null) {
  100314. if (returnedValue._state !== undefined) {
  100315. var returnedPromise = returnedValue;
  100316. newPromise._children.push(returnedPromise);
  100317. returnedPromise._parent = newPromise;
  100318. newPromise = returnedPromise;
  100319. }
  100320. else {
  100321. newPromise._result = returnedValue;
  100322. }
  100323. }
  100324. }
  100325. else {
  100326. newPromise._reject(_this._reason);
  100327. }
  100328. });
  100329. }
  100330. return newPromise;
  100331. };
  100332. InternalPromise.prototype._moveChildren = function (children) {
  100333. var _this = this;
  100334. var _a;
  100335. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  100336. this._children.forEach(function (child) {
  100337. child._parent = _this;
  100338. });
  100339. if (this._state === PromiseStates.Fulfilled) {
  100340. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  100341. var child = _b[_i];
  100342. child._resolve(this._result);
  100343. }
  100344. }
  100345. else if (this._state === PromiseStates.Rejected) {
  100346. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  100347. var child = _d[_c];
  100348. child._reject(this._reason);
  100349. }
  100350. }
  100351. };
  100352. InternalPromise.prototype._resolve = function (value) {
  100353. try {
  100354. this._state = PromiseStates.Fulfilled;
  100355. var returnedValue = null;
  100356. if (this._onFulfilled) {
  100357. returnedValue = this._onFulfilled(value);
  100358. }
  100359. if (returnedValue !== undefined && returnedValue !== null) {
  100360. if (returnedValue._state !== undefined) {
  100361. // Transmit children
  100362. var returnedPromise = returnedValue;
  100363. returnedPromise._parent = this;
  100364. returnedPromise._moveChildren(this._children);
  100365. value = returnedPromise._result;
  100366. }
  100367. else {
  100368. value = returnedValue;
  100369. }
  100370. }
  100371. this._result = value;
  100372. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  100373. var child = _a[_i];
  100374. child._resolve(value);
  100375. }
  100376. this._children.length = 0;
  100377. delete this._onFulfilled;
  100378. delete this._onRejected;
  100379. }
  100380. catch (e) {
  100381. this._reject(e, true);
  100382. }
  100383. };
  100384. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  100385. if (onLocalThrow === void 0) { onLocalThrow = false; }
  100386. this._state = PromiseStates.Rejected;
  100387. this._reason = reason;
  100388. if (this._onRejected && !onLocalThrow) {
  100389. try {
  100390. this._onRejected(reason);
  100391. this._rejectWasConsumed = true;
  100392. }
  100393. catch (e) {
  100394. reason = e;
  100395. }
  100396. }
  100397. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  100398. var child = _a[_i];
  100399. if (this._rejectWasConsumed) {
  100400. child._resolve(null);
  100401. }
  100402. else {
  100403. child._reject(reason);
  100404. }
  100405. }
  100406. this._children.length = 0;
  100407. delete this._onFulfilled;
  100408. delete this._onRejected;
  100409. };
  100410. InternalPromise.resolve = function (value) {
  100411. var newPromise = new InternalPromise();
  100412. newPromise._resolve(value);
  100413. return newPromise;
  100414. };
  100415. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  100416. promise.then(function (value) {
  100417. agregator.results[index] = value;
  100418. agregator.count++;
  100419. if (agregator.count === agregator.target) {
  100420. agregator.rootPromise._resolve(agregator.results);
  100421. }
  100422. return null;
  100423. }, function (reason) {
  100424. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  100425. agregator.rootPromise._reject(reason);
  100426. }
  100427. });
  100428. };
  100429. InternalPromise.all = function (promises) {
  100430. var newPromise = new InternalPromise();
  100431. var agregator = new FulFillmentAgregator();
  100432. agregator.target = promises.length;
  100433. agregator.rootPromise = newPromise;
  100434. if (promises.length) {
  100435. for (var index = 0; index < promises.length; index++) {
  100436. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  100437. }
  100438. }
  100439. else {
  100440. newPromise._resolve([]);
  100441. }
  100442. return newPromise;
  100443. };
  100444. InternalPromise.race = function (promises) {
  100445. var newPromise = new InternalPromise();
  100446. if (promises.length) {
  100447. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  100448. var promise = promises_1[_i];
  100449. promise.then(function (value) {
  100450. if (newPromise) {
  100451. newPromise._resolve(value);
  100452. newPromise = null;
  100453. }
  100454. return null;
  100455. }, function (reason) {
  100456. if (newPromise) {
  100457. newPromise._reject(reason);
  100458. newPromise = null;
  100459. }
  100460. });
  100461. }
  100462. }
  100463. return newPromise;
  100464. };
  100465. return InternalPromise;
  100466. }());
  100467. /**
  100468. * Helper class that provides a small promise polyfill
  100469. */
  100470. var PromisePolyfill = /** @class */ (function () {
  100471. function PromisePolyfill() {
  100472. }
  100473. /**
  100474. * Static function used to check if the polyfill is required
  100475. * If this is the case then the function will inject the polyfill to window.Promise
  100476. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  100477. */
  100478. PromisePolyfill.Apply = function (force) {
  100479. if (force === void 0) { force = false; }
  100480. if (force || typeof Promise === 'undefined') {
  100481. var root = window;
  100482. root.Promise = InternalPromise;
  100483. }
  100484. };
  100485. return PromisePolyfill;
  100486. }());
  100487. /***/ }),
  100488. /***/ "./Misc/sceneOptimizer.ts":
  100489. /*!********************************!*\
  100490. !*** ./Misc/sceneOptimizer.ts ***!
  100491. \********************************/
  100492. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  100493. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100494. "use strict";
  100495. __webpack_require__.r(__webpack_exports__);
  100496. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  100497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  100498. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  100499. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  100500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  100501. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  100502. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  100503. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  100504. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  100505. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  100506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  100507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  100508. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  100509. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  100510. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  100511. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  100512. /**
  100513. * Defines the root class used to create scene optimization to use with SceneOptimizer
  100514. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100515. */
  100516. var SceneOptimization = /** @class */ (function () {
  100517. /**
  100518. * Creates the SceneOptimization object
  100519. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  100520. * @param desc defines the description associated with the optimization
  100521. */
  100522. function SceneOptimization(
  100523. /**
  100524. * Defines the priority of this optimization (0 by default which means first in the list)
  100525. */
  100526. priority) {
  100527. if (priority === void 0) { priority = 0; }
  100528. this.priority = priority;
  100529. }
  100530. /**
  100531. * Gets a string describing the action executed by the current optimization
  100532. * @returns description string
  100533. */
  100534. SceneOptimization.prototype.getDescription = function () {
  100535. return "";
  100536. };
  100537. /**
  100538. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100539. * @param scene defines the current scene where to apply this optimization
  100540. * @param optimizer defines the current optimizer
  100541. * @returns true if everything that can be done was applied
  100542. */
  100543. SceneOptimization.prototype.apply = function (scene, optimizer) {
  100544. return true;
  100545. };
  100546. return SceneOptimization;
  100547. }());
  100548. /**
  100549. * Defines an optimization used to reduce the size of render target textures
  100550. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100551. */
  100552. var TextureOptimization = /** @class */ (function (_super) {
  100553. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  100554. /**
  100555. * Creates the TextureOptimization object
  100556. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  100557. * @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
  100558. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  100559. */
  100560. function TextureOptimization(
  100561. /**
  100562. * Defines the priority of this optimization (0 by default which means first in the list)
  100563. */
  100564. priority,
  100565. /**
  100566. * 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
  100567. */
  100568. maximumSize,
  100569. /**
  100570. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  100571. */
  100572. step) {
  100573. if (priority === void 0) { priority = 0; }
  100574. if (maximumSize === void 0) { maximumSize = 1024; }
  100575. if (step === void 0) { step = 0.5; }
  100576. var _this = _super.call(this, priority) || this;
  100577. _this.priority = priority;
  100578. _this.maximumSize = maximumSize;
  100579. _this.step = step;
  100580. return _this;
  100581. }
  100582. /**
  100583. * Gets a string describing the action executed by the current optimization
  100584. * @returns description string
  100585. */
  100586. TextureOptimization.prototype.getDescription = function () {
  100587. return "Reducing render target texture size to " + this.maximumSize;
  100588. };
  100589. /**
  100590. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100591. * @param scene defines the current scene where to apply this optimization
  100592. * @param optimizer defines the current optimizer
  100593. * @returns true if everything that can be done was applied
  100594. */
  100595. TextureOptimization.prototype.apply = function (scene, optimizer) {
  100596. var allDone = true;
  100597. for (var index = 0; index < scene.textures.length; index++) {
  100598. var texture = scene.textures[index];
  100599. if (!texture.canRescale || texture.getContext) {
  100600. continue;
  100601. }
  100602. var currentSize = texture.getSize();
  100603. var maxDimension = Math.max(currentSize.width, currentSize.height);
  100604. if (maxDimension > this.maximumSize) {
  100605. texture.scale(this.step);
  100606. allDone = false;
  100607. }
  100608. }
  100609. return allDone;
  100610. };
  100611. return TextureOptimization;
  100612. }(SceneOptimization));
  100613. /**
  100614. * Defines an optimization used to increase or decrease the rendering resolution
  100615. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100616. */
  100617. var HardwareScalingOptimization = /** @class */ (function (_super) {
  100618. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  100619. /**
  100620. * Creates the HardwareScalingOptimization object
  100621. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  100622. * @param maximumScale defines the maximum scale to use (2 by default)
  100623. * @param step defines the step to use between two passes (0.5 by default)
  100624. */
  100625. function HardwareScalingOptimization(
  100626. /**
  100627. * Defines the priority of this optimization (0 by default which means first in the list)
  100628. */
  100629. priority,
  100630. /**
  100631. * Defines the maximum scale to use (2 by default)
  100632. */
  100633. maximumScale,
  100634. /**
  100635. * Defines the step to use between two passes (0.5 by default)
  100636. */
  100637. step) {
  100638. if (priority === void 0) { priority = 0; }
  100639. if (maximumScale === void 0) { maximumScale = 2; }
  100640. if (step === void 0) { step = 0.25; }
  100641. var _this = _super.call(this, priority) || this;
  100642. _this.priority = priority;
  100643. _this.maximumScale = maximumScale;
  100644. _this.step = step;
  100645. _this._currentScale = -1;
  100646. _this._directionOffset = 1;
  100647. return _this;
  100648. }
  100649. /**
  100650. * Gets a string describing the action executed by the current optimization
  100651. * @return description string
  100652. */
  100653. HardwareScalingOptimization.prototype.getDescription = function () {
  100654. return "Setting hardware scaling level to " + this._currentScale;
  100655. };
  100656. /**
  100657. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100658. * @param scene defines the current scene where to apply this optimization
  100659. * @param optimizer defines the current optimizer
  100660. * @returns true if everything that can be done was applied
  100661. */
  100662. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  100663. if (this._currentScale === -1) {
  100664. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  100665. if (this._currentScale > this.maximumScale) {
  100666. this._directionOffset = -1;
  100667. }
  100668. }
  100669. this._currentScale += this._directionOffset * this.step;
  100670. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  100671. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  100672. };
  100673. return HardwareScalingOptimization;
  100674. }(SceneOptimization));
  100675. /**
  100676. * Defines an optimization used to remove shadows
  100677. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100678. */
  100679. var ShadowsOptimization = /** @class */ (function (_super) {
  100680. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  100681. function ShadowsOptimization() {
  100682. return _super !== null && _super.apply(this, arguments) || this;
  100683. }
  100684. /**
  100685. * Gets a string describing the action executed by the current optimization
  100686. * @return description string
  100687. */
  100688. ShadowsOptimization.prototype.getDescription = function () {
  100689. return "Turning shadows on/off";
  100690. };
  100691. /**
  100692. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100693. * @param scene defines the current scene where to apply this optimization
  100694. * @param optimizer defines the current optimizer
  100695. * @returns true if everything that can be done was applied
  100696. */
  100697. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  100698. scene.shadowsEnabled = optimizer.isInImprovementMode;
  100699. return true;
  100700. };
  100701. return ShadowsOptimization;
  100702. }(SceneOptimization));
  100703. /**
  100704. * Defines an optimization used to turn post-processes off
  100705. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100706. */
  100707. var PostProcessesOptimization = /** @class */ (function (_super) {
  100708. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  100709. function PostProcessesOptimization() {
  100710. return _super !== null && _super.apply(this, arguments) || this;
  100711. }
  100712. /**
  100713. * Gets a string describing the action executed by the current optimization
  100714. * @return description string
  100715. */
  100716. PostProcessesOptimization.prototype.getDescription = function () {
  100717. return "Turning post-processes on/off";
  100718. };
  100719. /**
  100720. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100721. * @param scene defines the current scene where to apply this optimization
  100722. * @param optimizer defines the current optimizer
  100723. * @returns true if everything that can be done was applied
  100724. */
  100725. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  100726. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  100727. return true;
  100728. };
  100729. return PostProcessesOptimization;
  100730. }(SceneOptimization));
  100731. /**
  100732. * Defines an optimization used to turn lens flares off
  100733. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100734. */
  100735. var LensFlaresOptimization = /** @class */ (function (_super) {
  100736. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  100737. function LensFlaresOptimization() {
  100738. return _super !== null && _super.apply(this, arguments) || this;
  100739. }
  100740. /**
  100741. * Gets a string describing the action executed by the current optimization
  100742. * @return description string
  100743. */
  100744. LensFlaresOptimization.prototype.getDescription = function () {
  100745. return "Turning lens flares on/off";
  100746. };
  100747. /**
  100748. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100749. * @param scene defines the current scene where to apply this optimization
  100750. * @param optimizer defines the current optimizer
  100751. * @returns true if everything that can be done was applied
  100752. */
  100753. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  100754. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  100755. return true;
  100756. };
  100757. return LensFlaresOptimization;
  100758. }(SceneOptimization));
  100759. /**
  100760. * Defines an optimization based on user defined callback.
  100761. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100762. */
  100763. var CustomOptimization = /** @class */ (function (_super) {
  100764. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  100765. function CustomOptimization() {
  100766. return _super !== null && _super.apply(this, arguments) || this;
  100767. }
  100768. /**
  100769. * Gets a string describing the action executed by the current optimization
  100770. * @returns description string
  100771. */
  100772. CustomOptimization.prototype.getDescription = function () {
  100773. if (this.onGetDescription) {
  100774. return this.onGetDescription();
  100775. }
  100776. return "Running user defined callback";
  100777. };
  100778. /**
  100779. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100780. * @param scene defines the current scene where to apply this optimization
  100781. * @param optimizer defines the current optimizer
  100782. * @returns true if everything that can be done was applied
  100783. */
  100784. CustomOptimization.prototype.apply = function (scene, optimizer) {
  100785. if (this.onApply) {
  100786. return this.onApply(scene, optimizer);
  100787. }
  100788. return true;
  100789. };
  100790. return CustomOptimization;
  100791. }(SceneOptimization));
  100792. /**
  100793. * Defines an optimization used to turn particles off
  100794. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100795. */
  100796. var ParticlesOptimization = /** @class */ (function (_super) {
  100797. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  100798. function ParticlesOptimization() {
  100799. return _super !== null && _super.apply(this, arguments) || this;
  100800. }
  100801. /**
  100802. * Gets a string describing the action executed by the current optimization
  100803. * @return description string
  100804. */
  100805. ParticlesOptimization.prototype.getDescription = function () {
  100806. return "Turning particles on/off";
  100807. };
  100808. /**
  100809. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100810. * @param scene defines the current scene where to apply this optimization
  100811. * @param optimizer defines the current optimizer
  100812. * @returns true if everything that can be done was applied
  100813. */
  100814. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  100815. scene.particlesEnabled = optimizer.isInImprovementMode;
  100816. return true;
  100817. };
  100818. return ParticlesOptimization;
  100819. }(SceneOptimization));
  100820. /**
  100821. * Defines an optimization used to turn render targets off
  100822. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100823. */
  100824. var RenderTargetsOptimization = /** @class */ (function (_super) {
  100825. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  100826. function RenderTargetsOptimization() {
  100827. return _super !== null && _super.apply(this, arguments) || this;
  100828. }
  100829. /**
  100830. * Gets a string describing the action executed by the current optimization
  100831. * @return description string
  100832. */
  100833. RenderTargetsOptimization.prototype.getDescription = function () {
  100834. return "Turning render targets off";
  100835. };
  100836. /**
  100837. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100838. * @param scene defines the current scene where to apply this optimization
  100839. * @param optimizer defines the current optimizer
  100840. * @returns true if everything that can be done was applied
  100841. */
  100842. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  100843. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  100844. return true;
  100845. };
  100846. return RenderTargetsOptimization;
  100847. }(SceneOptimization));
  100848. /**
  100849. * Defines an optimization used to merge meshes with compatible materials
  100850. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100851. */
  100852. var MergeMeshesOptimization = /** @class */ (function (_super) {
  100853. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  100854. function MergeMeshesOptimization() {
  100855. var _this = _super !== null && _super.apply(this, arguments) || this;
  100856. _this._canBeMerged = function (abstractMesh) {
  100857. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  100858. return false;
  100859. }
  100860. var mesh = abstractMesh;
  100861. if (mesh.isDisposed()) {
  100862. return false;
  100863. }
  100864. if (!mesh.isVisible || !mesh.isEnabled()) {
  100865. return false;
  100866. }
  100867. if (mesh.instances.length > 0) {
  100868. return false;
  100869. }
  100870. if (mesh.skeleton || mesh.hasLODLevels) {
  100871. return false;
  100872. }
  100873. return true;
  100874. };
  100875. return _this;
  100876. }
  100877. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  100878. /**
  100879. * Gets or sets a boolean which defines if optimization octree has to be updated
  100880. */
  100881. get: function () {
  100882. return MergeMeshesOptimization._UpdateSelectionTree;
  100883. },
  100884. /**
  100885. * Gets or sets a boolean which defines if optimization octree has to be updated
  100886. */
  100887. set: function (value) {
  100888. MergeMeshesOptimization._UpdateSelectionTree = value;
  100889. },
  100890. enumerable: true,
  100891. configurable: true
  100892. });
  100893. /**
  100894. * Gets a string describing the action executed by the current optimization
  100895. * @return description string
  100896. */
  100897. MergeMeshesOptimization.prototype.getDescription = function () {
  100898. return "Merging similar meshes together";
  100899. };
  100900. /**
  100901. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  100902. * @param scene defines the current scene where to apply this optimization
  100903. * @param optimizer defines the current optimizer
  100904. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  100905. * @returns true if everything that can be done was applied
  100906. */
  100907. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  100908. var globalPool = scene.meshes.slice(0);
  100909. var globalLength = globalPool.length;
  100910. for (var index = 0; index < globalLength; index++) {
  100911. var currentPool = new Array();
  100912. var current = globalPool[index];
  100913. // Checks
  100914. if (!this._canBeMerged(current)) {
  100915. continue;
  100916. }
  100917. currentPool.push(current);
  100918. // Find compatible meshes
  100919. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  100920. var otherMesh = globalPool[subIndex];
  100921. if (!this._canBeMerged(otherMesh)) {
  100922. continue;
  100923. }
  100924. if (otherMesh.material !== current.material) {
  100925. continue;
  100926. }
  100927. if (otherMesh.checkCollisions !== current.checkCollisions) {
  100928. continue;
  100929. }
  100930. currentPool.push(otherMesh);
  100931. globalLength--;
  100932. globalPool.splice(subIndex, 1);
  100933. subIndex--;
  100934. }
  100935. if (currentPool.length < 2) {
  100936. continue;
  100937. }
  100938. // Merge meshes
  100939. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  100940. }
  100941. // Call the octree system optimization if it is defined.
  100942. var sceneAsAny = scene;
  100943. if (sceneAsAny.createOrUpdateSelectionOctree) {
  100944. if (updateSelectionTree != undefined) {
  100945. if (updateSelectionTree) {
  100946. sceneAsAny.createOrUpdateSelectionOctree();
  100947. }
  100948. }
  100949. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  100950. sceneAsAny.createOrUpdateSelectionOctree();
  100951. }
  100952. }
  100953. return true;
  100954. };
  100955. MergeMeshesOptimization._UpdateSelectionTree = false;
  100956. return MergeMeshesOptimization;
  100957. }(SceneOptimization));
  100958. /**
  100959. * Defines a list of options used by SceneOptimizer
  100960. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100961. */
  100962. var SceneOptimizerOptions = /** @class */ (function () {
  100963. /**
  100964. * Creates a new list of options used by SceneOptimizer
  100965. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  100966. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  100967. */
  100968. function SceneOptimizerOptions(
  100969. /**
  100970. * Defines the target frame rate to reach (60 by default)
  100971. */
  100972. targetFrameRate,
  100973. /**
  100974. * Defines the interval between two checkes (2000ms by default)
  100975. */
  100976. trackerDuration) {
  100977. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  100978. if (trackerDuration === void 0) { trackerDuration = 2000; }
  100979. this.targetFrameRate = targetFrameRate;
  100980. this.trackerDuration = trackerDuration;
  100981. /**
  100982. * Gets the list of optimizations to apply
  100983. */
  100984. this.optimizations = new Array();
  100985. }
  100986. /**
  100987. * Add a new optimization
  100988. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  100989. * @returns the current SceneOptimizerOptions
  100990. */
  100991. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  100992. this.optimizations.push(optimization);
  100993. return this;
  100994. };
  100995. /**
  100996. * Add a new custom optimization
  100997. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  100998. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  100999. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  101000. * @returns the current SceneOptimizerOptions
  101001. */
  101002. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  101003. if (priority === void 0) { priority = 0; }
  101004. var optimization = new CustomOptimization(priority);
  101005. optimization.onApply = onApply;
  101006. optimization.onGetDescription = onGetDescription;
  101007. this.optimizations.push(optimization);
  101008. return this;
  101009. };
  101010. /**
  101011. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  101012. * @param targetFrameRate defines the target frame rate (60 by default)
  101013. * @returns a SceneOptimizerOptions object
  101014. */
  101015. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  101016. var result = new SceneOptimizerOptions(targetFrameRate);
  101017. var priority = 0;
  101018. result.addOptimization(new MergeMeshesOptimization(priority));
  101019. result.addOptimization(new ShadowsOptimization(priority));
  101020. result.addOptimization(new LensFlaresOptimization(priority));
  101021. // Next priority
  101022. priority++;
  101023. result.addOptimization(new PostProcessesOptimization(priority));
  101024. result.addOptimization(new ParticlesOptimization(priority));
  101025. // Next priority
  101026. priority++;
  101027. result.addOptimization(new TextureOptimization(priority, 1024));
  101028. return result;
  101029. };
  101030. /**
  101031. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  101032. * @param targetFrameRate defines the target frame rate (60 by default)
  101033. * @returns a SceneOptimizerOptions object
  101034. */
  101035. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  101036. var result = new SceneOptimizerOptions(targetFrameRate);
  101037. var priority = 0;
  101038. result.addOptimization(new MergeMeshesOptimization(priority));
  101039. result.addOptimization(new ShadowsOptimization(priority));
  101040. result.addOptimization(new LensFlaresOptimization(priority));
  101041. // Next priority
  101042. priority++;
  101043. result.addOptimization(new PostProcessesOptimization(priority));
  101044. result.addOptimization(new ParticlesOptimization(priority));
  101045. // Next priority
  101046. priority++;
  101047. result.addOptimization(new TextureOptimization(priority, 512));
  101048. // Next priority
  101049. priority++;
  101050. result.addOptimization(new RenderTargetsOptimization(priority));
  101051. // Next priority
  101052. priority++;
  101053. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  101054. return result;
  101055. };
  101056. /**
  101057. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  101058. * @param targetFrameRate defines the target frame rate (60 by default)
  101059. * @returns a SceneOptimizerOptions object
  101060. */
  101061. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  101062. var result = new SceneOptimizerOptions(targetFrameRate);
  101063. var priority = 0;
  101064. result.addOptimization(new MergeMeshesOptimization(priority));
  101065. result.addOptimization(new ShadowsOptimization(priority));
  101066. result.addOptimization(new LensFlaresOptimization(priority));
  101067. // Next priority
  101068. priority++;
  101069. result.addOptimization(new PostProcessesOptimization(priority));
  101070. result.addOptimization(new ParticlesOptimization(priority));
  101071. // Next priority
  101072. priority++;
  101073. result.addOptimization(new TextureOptimization(priority, 256));
  101074. // Next priority
  101075. priority++;
  101076. result.addOptimization(new RenderTargetsOptimization(priority));
  101077. // Next priority
  101078. priority++;
  101079. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  101080. return result;
  101081. };
  101082. return SceneOptimizerOptions;
  101083. }());
  101084. /**
  101085. * Class used to run optimizations in order to reach a target frame rate
  101086. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  101087. */
  101088. var SceneOptimizer = /** @class */ (function () {
  101089. /**
  101090. * Creates a new SceneOptimizer
  101091. * @param scene defines the scene to work on
  101092. * @param options defines the options to use with the SceneOptimizer
  101093. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  101094. * @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)
  101095. */
  101096. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  101097. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  101098. if (improvementMode === void 0) { improvementMode = false; }
  101099. var _this = this;
  101100. this._isRunning = false;
  101101. this._currentPriorityLevel = 0;
  101102. this._targetFrameRate = 60;
  101103. this._trackerDuration = 2000;
  101104. this._currentFrameRate = 0;
  101105. this._improvementMode = false;
  101106. /**
  101107. * Defines an observable called when the optimizer reaches the target frame rate
  101108. */
  101109. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  101110. /**
  101111. * Defines an observable called when the optimizer enables an optimization
  101112. */
  101113. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  101114. /**
  101115. * Defines an observable called when the optimizer is not able to reach the target frame rate
  101116. */
  101117. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  101118. if (!options) {
  101119. this._options = new SceneOptimizerOptions();
  101120. }
  101121. else {
  101122. this._options = options;
  101123. }
  101124. if (this._options.targetFrameRate) {
  101125. this._targetFrameRate = this._options.targetFrameRate;
  101126. }
  101127. if (this._options.trackerDuration) {
  101128. this._trackerDuration = this._options.trackerDuration;
  101129. }
  101130. if (autoGeneratePriorities) {
  101131. var priority = 0;
  101132. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  101133. var optim = _a[_i];
  101134. optim.priority = priority++;
  101135. }
  101136. }
  101137. this._improvementMode = improvementMode;
  101138. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  101139. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  101140. _this._sceneDisposeObserver = null;
  101141. _this.dispose();
  101142. });
  101143. }
  101144. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  101145. /**
  101146. * Gets a boolean indicating if the optimizer is in improvement mode
  101147. */
  101148. get: function () {
  101149. return this._improvementMode;
  101150. },
  101151. enumerable: true,
  101152. configurable: true
  101153. });
  101154. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  101155. /**
  101156. * Gets the current priority level (0 at start)
  101157. */
  101158. get: function () {
  101159. return this._currentPriorityLevel;
  101160. },
  101161. enumerable: true,
  101162. configurable: true
  101163. });
  101164. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  101165. /**
  101166. * Gets the current frame rate checked by the SceneOptimizer
  101167. */
  101168. get: function () {
  101169. return this._currentFrameRate;
  101170. },
  101171. enumerable: true,
  101172. configurable: true
  101173. });
  101174. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  101175. /**
  101176. * Gets or sets the current target frame rate (60 by default)
  101177. */
  101178. get: function () {
  101179. return this._targetFrameRate;
  101180. },
  101181. /**
  101182. * Gets or sets the current target frame rate (60 by default)
  101183. */
  101184. set: function (value) {
  101185. this._targetFrameRate = value;
  101186. },
  101187. enumerable: true,
  101188. configurable: true
  101189. });
  101190. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  101191. /**
  101192. * Gets or sets the current interval between two checks (every 2000ms by default)
  101193. */
  101194. get: function () {
  101195. return this._trackerDuration;
  101196. },
  101197. /**
  101198. * Gets or sets the current interval between two checks (every 2000ms by default)
  101199. */
  101200. set: function (value) {
  101201. this._trackerDuration = value;
  101202. },
  101203. enumerable: true,
  101204. configurable: true
  101205. });
  101206. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  101207. /**
  101208. * Gets the list of active optimizations
  101209. */
  101210. get: function () {
  101211. return this._options.optimizations;
  101212. },
  101213. enumerable: true,
  101214. configurable: true
  101215. });
  101216. /**
  101217. * Stops the current optimizer
  101218. */
  101219. SceneOptimizer.prototype.stop = function () {
  101220. this._isRunning = false;
  101221. };
  101222. /**
  101223. * Reset the optimizer to initial step (current priority level = 0)
  101224. */
  101225. SceneOptimizer.prototype.reset = function () {
  101226. this._currentPriorityLevel = 0;
  101227. };
  101228. /**
  101229. * Start the optimizer. By default it will try to reach a specific framerate
  101230. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  101231. */
  101232. SceneOptimizer.prototype.start = function () {
  101233. var _this = this;
  101234. if (this._isRunning) {
  101235. return;
  101236. }
  101237. this._isRunning = true;
  101238. // Let's wait for the scene to be ready before running our check
  101239. this._scene.executeWhenReady(function () {
  101240. setTimeout(function () {
  101241. _this._checkCurrentState();
  101242. }, _this._trackerDuration);
  101243. });
  101244. };
  101245. SceneOptimizer.prototype._checkCurrentState = function () {
  101246. var _this = this;
  101247. if (!this._isRunning) {
  101248. return;
  101249. }
  101250. var scene = this._scene;
  101251. var options = this._options;
  101252. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  101253. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  101254. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  101255. this._isRunning = false;
  101256. this.onSuccessObservable.notifyObservers(this);
  101257. return;
  101258. }
  101259. // Apply current level of optimizations
  101260. var allDone = true;
  101261. var noOptimizationApplied = true;
  101262. for (var index = 0; index < options.optimizations.length; index++) {
  101263. var optimization = options.optimizations[index];
  101264. if (optimization.priority === this._currentPriorityLevel) {
  101265. noOptimizationApplied = false;
  101266. allDone = allDone && optimization.apply(scene, this);
  101267. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  101268. }
  101269. }
  101270. // If no optimization was applied, this is a failure :(
  101271. if (noOptimizationApplied) {
  101272. this._isRunning = false;
  101273. this.onFailureObservable.notifyObservers(this);
  101274. return;
  101275. }
  101276. // If all optimizations were done, move to next level
  101277. if (allDone) {
  101278. this._currentPriorityLevel++;
  101279. }
  101280. // Let's the system running for a specific amount of time before checking FPS
  101281. scene.executeWhenReady(function () {
  101282. setTimeout(function () {
  101283. _this._checkCurrentState();
  101284. }, _this._trackerDuration);
  101285. });
  101286. };
  101287. /**
  101288. * Release all resources
  101289. */
  101290. SceneOptimizer.prototype.dispose = function () {
  101291. this.stop();
  101292. this.onSuccessObservable.clear();
  101293. this.onFailureObservable.clear();
  101294. this.onNewOptimizationAppliedObservable.clear();
  101295. if (this._sceneDisposeObserver) {
  101296. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  101297. }
  101298. };
  101299. /**
  101300. * Helper function to create a SceneOptimizer with one single line of code
  101301. * @param scene defines the scene to work on
  101302. * @param options defines the options to use with the SceneOptimizer
  101303. * @param onSuccess defines a callback to call on success
  101304. * @param onFailure defines a callback to call on failure
  101305. * @returns the new SceneOptimizer object
  101306. */
  101307. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  101308. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  101309. if (onSuccess) {
  101310. optimizer.onSuccessObservable.add(function () {
  101311. onSuccess();
  101312. });
  101313. }
  101314. if (onFailure) {
  101315. optimizer.onFailureObservable.add(function () {
  101316. onFailure();
  101317. });
  101318. }
  101319. optimizer.start();
  101320. return optimizer;
  101321. };
  101322. return SceneOptimizer;
  101323. }());
  101324. /***/ }),
  101325. /***/ "./Misc/sceneSerializer.ts":
  101326. /*!*********************************!*\
  101327. !*** ./Misc/sceneSerializer.ts ***!
  101328. \*********************************/
  101329. /*! exports provided: SceneSerializer */
  101330. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101331. "use strict";
  101332. __webpack_require__.r(__webpack_exports__);
  101333. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  101334. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  101335. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  101336. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  101337. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  101338. var serializedGeometries = [];
  101339. var serializeGeometry = function (geometry, serializationGeometries) {
  101340. if (serializedGeometries[geometry.id]) {
  101341. return;
  101342. }
  101343. if (geometry.doNotSerialize) {
  101344. return;
  101345. }
  101346. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  101347. serializedGeometries[geometry.id] = true;
  101348. };
  101349. var serializeMesh = function (mesh, serializationScene) {
  101350. var serializationObject = {};
  101351. // Geometry
  101352. var geometry = mesh._geometry;
  101353. if (geometry) {
  101354. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  101355. // 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
  101356. serializeGeometry(geometry, serializationScene.geometries);
  101357. }
  101358. }
  101359. // Custom
  101360. if (mesh.serialize) {
  101361. mesh.serialize(serializationObject);
  101362. }
  101363. return serializationObject;
  101364. };
  101365. var finalizeSingleMesh = function (mesh, serializationObject) {
  101366. //only works if the mesh is already loaded
  101367. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  101368. //serialize material
  101369. if (mesh.material) {
  101370. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__["MultiMaterial"]) {
  101371. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  101372. serializationObject.materials = serializationObject.materials || [];
  101373. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  101374. serializationObject.multiMaterials.push(mesh.material.serialize());
  101375. var _loop_1 = function (submaterial) {
  101376. if (submaterial) {
  101377. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  101378. serializationObject.materials.push(submaterial.serialize());
  101379. }
  101380. }
  101381. };
  101382. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  101383. var submaterial = _a[_i];
  101384. _loop_1(submaterial);
  101385. }
  101386. }
  101387. }
  101388. else {
  101389. serializationObject.materials = serializationObject.materials || [];
  101390. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  101391. serializationObject.materials.push(mesh.material.serialize());
  101392. }
  101393. }
  101394. }
  101395. //serialize geometry
  101396. var geometry = mesh._geometry;
  101397. if (geometry) {
  101398. if (!serializationObject.geometries) {
  101399. serializationObject.geometries = {};
  101400. serializationObject.geometries.boxes = [];
  101401. serializationObject.geometries.spheres = [];
  101402. serializationObject.geometries.cylinders = [];
  101403. serializationObject.geometries.toruses = [];
  101404. serializationObject.geometries.grounds = [];
  101405. serializationObject.geometries.planes = [];
  101406. serializationObject.geometries.torusKnots = [];
  101407. serializationObject.geometries.vertexData = [];
  101408. }
  101409. serializeGeometry(geometry, serializationObject.geometries);
  101410. }
  101411. // Skeletons
  101412. if (mesh.skeleton) {
  101413. serializationObject.skeletons = serializationObject.skeletons || [];
  101414. serializationObject.skeletons.push(mesh.skeleton.serialize());
  101415. }
  101416. //serialize the actual mesh
  101417. serializationObject.meshes = serializationObject.meshes || [];
  101418. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  101419. }
  101420. };
  101421. /**
  101422. * Class used to serialize a scene into a string
  101423. */
  101424. var SceneSerializer = /** @class */ (function () {
  101425. function SceneSerializer() {
  101426. }
  101427. /**
  101428. * Clear cache used by a previous serialization
  101429. */
  101430. SceneSerializer.ClearCache = function () {
  101431. serializedGeometries = [];
  101432. };
  101433. /**
  101434. * Serialize a scene into a JSON compatible object
  101435. * @param scene defines the scene to serialize
  101436. * @returns a JSON compatible object
  101437. */
  101438. SceneSerializer.Serialize = function (scene) {
  101439. var serializationObject = {};
  101440. SceneSerializer.ClearCache();
  101441. // Scene
  101442. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  101443. serializationObject.autoClear = scene.autoClear;
  101444. serializationObject.clearColor = scene.clearColor.asArray();
  101445. serializationObject.ambientColor = scene.ambientColor.asArray();
  101446. serializationObject.gravity = scene.gravity.asArray();
  101447. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  101448. // Fog
  101449. if (scene.fogMode && scene.fogMode !== 0) {
  101450. serializationObject.fogMode = scene.fogMode;
  101451. serializationObject.fogColor = scene.fogColor.asArray();
  101452. serializationObject.fogStart = scene.fogStart;
  101453. serializationObject.fogEnd = scene.fogEnd;
  101454. serializationObject.fogDensity = scene.fogDensity;
  101455. }
  101456. //Physics
  101457. if (scene.isPhysicsEnabled()) {
  101458. var physicEngine = scene.getPhysicsEngine();
  101459. if (physicEngine) {
  101460. serializationObject.physicsEnabled = true;
  101461. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  101462. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  101463. }
  101464. }
  101465. // Metadata
  101466. if (scene.metadata) {
  101467. serializationObject.metadata = scene.metadata;
  101468. }
  101469. // Morph targets
  101470. serializationObject.morphTargetManagers = [];
  101471. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  101472. var abstractMesh = _a[_i];
  101473. var manager = abstractMesh.morphTargetManager;
  101474. if (manager) {
  101475. serializationObject.morphTargetManagers.push(manager.serialize());
  101476. }
  101477. }
  101478. // Lights
  101479. serializationObject.lights = [];
  101480. var index;
  101481. var light;
  101482. for (index = 0; index < scene.lights.length; index++) {
  101483. light = scene.lights[index];
  101484. if (!light.doNotSerialize) {
  101485. serializationObject.lights.push(light.serialize());
  101486. }
  101487. }
  101488. // Cameras
  101489. serializationObject.cameras = [];
  101490. for (index = 0; index < scene.cameras.length; index++) {
  101491. var camera = scene.cameras[index];
  101492. if (!camera.doNotSerialize) {
  101493. serializationObject.cameras.push(camera.serialize());
  101494. }
  101495. }
  101496. if (scene.activeCamera) {
  101497. serializationObject.activeCameraID = scene.activeCamera.id;
  101498. }
  101499. // Animations
  101500. _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  101501. // Reflection probes
  101502. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  101503. serializationObject.reflectionProbes = [];
  101504. for (index = 0; index < scene.reflectionProbes.length; index++) {
  101505. var reflectionProbe = scene.reflectionProbes[index];
  101506. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  101507. }
  101508. }
  101509. // Materials
  101510. serializationObject.materials = [];
  101511. serializationObject.multiMaterials = [];
  101512. var material;
  101513. for (index = 0; index < scene.materials.length; index++) {
  101514. material = scene.materials[index];
  101515. if (!material.doNotSerialize) {
  101516. serializationObject.materials.push(material.serialize());
  101517. }
  101518. }
  101519. // MultiMaterials
  101520. serializationObject.multiMaterials = [];
  101521. for (index = 0; index < scene.multiMaterials.length; index++) {
  101522. var multiMaterial = scene.multiMaterials[index];
  101523. serializationObject.multiMaterials.push(multiMaterial.serialize());
  101524. }
  101525. // Environment texture
  101526. if (scene.environmentTexture) {
  101527. serializationObject.environmentTexture = scene.environmentTexture.name;
  101528. }
  101529. // Skeletons
  101530. serializationObject.skeletons = [];
  101531. for (index = 0; index < scene.skeletons.length; index++) {
  101532. var skeleton = scene.skeletons[index];
  101533. if (!skeleton.doNotSerialize) {
  101534. serializationObject.skeletons.push(skeleton.serialize());
  101535. }
  101536. }
  101537. // Transform nodes
  101538. serializationObject.transformNodes = [];
  101539. for (index = 0; index < scene.transformNodes.length; index++) {
  101540. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  101541. }
  101542. // Geometries
  101543. serializationObject.geometries = {};
  101544. serializationObject.geometries.boxes = [];
  101545. serializationObject.geometries.spheres = [];
  101546. serializationObject.geometries.cylinders = [];
  101547. serializationObject.geometries.toruses = [];
  101548. serializationObject.geometries.grounds = [];
  101549. serializationObject.geometries.planes = [];
  101550. serializationObject.geometries.torusKnots = [];
  101551. serializationObject.geometries.vertexData = [];
  101552. serializedGeometries = [];
  101553. var geometries = scene.getGeometries();
  101554. for (index = 0; index < geometries.length; index++) {
  101555. var geometry = geometries[index];
  101556. if (geometry.isReady()) {
  101557. serializeGeometry(geometry, serializationObject.geometries);
  101558. }
  101559. }
  101560. // Meshes
  101561. serializationObject.meshes = [];
  101562. for (index = 0; index < scene.meshes.length; index++) {
  101563. var abstractMesh = scene.meshes[index];
  101564. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]) {
  101565. var mesh = abstractMesh;
  101566. if (!mesh.doNotSerialize) {
  101567. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  101568. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  101569. }
  101570. }
  101571. }
  101572. }
  101573. // Particles Systems
  101574. serializationObject.particleSystems = [];
  101575. for (index = 0; index < scene.particleSystems.length; index++) {
  101576. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  101577. }
  101578. // Action Manager
  101579. if (scene.actionManager) {
  101580. serializationObject.actions = scene.actionManager.serialize("scene");
  101581. }
  101582. // Components
  101583. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  101584. var component = _c[_b];
  101585. component.serialize(serializationObject);
  101586. }
  101587. return serializationObject;
  101588. };
  101589. /**
  101590. * Serialize a mesh into a JSON compatible object
  101591. * @param toSerialize defines the mesh to serialize
  101592. * @param withParents defines if parents must be serialized as well
  101593. * @param withChildren defines if children must be serialized as well
  101594. * @returns a JSON compatible object
  101595. */
  101596. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  101597. if (withParents === void 0) { withParents = false; }
  101598. if (withChildren === void 0) { withChildren = false; }
  101599. var serializationObject = {};
  101600. SceneSerializer.ClearCache();
  101601. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  101602. if (withParents || withChildren) {
  101603. //deliberate for loop! not for each, appended should be processed as well.
  101604. for (var i = 0; i < toSerialize.length; ++i) {
  101605. if (withChildren) {
  101606. toSerialize[i].getDescendants().forEach(function (node) {
  101607. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"] && (toSerialize.indexOf(node) < 0)) {
  101608. toSerialize.push(node);
  101609. }
  101610. });
  101611. }
  101612. //make sure the array doesn't contain the object already
  101613. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0)) {
  101614. toSerialize.push(toSerialize[i].parent);
  101615. }
  101616. }
  101617. }
  101618. toSerialize.forEach(function (mesh) {
  101619. finalizeSingleMesh(mesh, serializationObject);
  101620. });
  101621. return serializationObject;
  101622. };
  101623. return SceneSerializer;
  101624. }());
  101625. /***/ }),
  101626. /***/ "./Misc/screenshotTools.ts":
  101627. /*!*********************************!*\
  101628. !*** ./Misc/screenshotTools.ts ***!
  101629. \*********************************/
  101630. /*! exports provided: ScreenshotTools */
  101631. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101632. "use strict";
  101633. __webpack_require__.r(__webpack_exports__);
  101634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  101635. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  101636. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  101637. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  101638. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  101639. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  101640. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  101641. /**
  101642. * Class containing a set of static utilities functions for screenshots
  101643. */
  101644. var ScreenshotTools = /** @class */ (function () {
  101645. function ScreenshotTools() {
  101646. }
  101647. /**
  101648. * Captures a screenshot of the current rendering
  101649. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  101650. * @param engine defines the rendering engine
  101651. * @param camera defines the source camera
  101652. * @param size This parameter can be set to a single number or to an object with the
  101653. * following (optional) properties: precision, width, height. If a single number is passed,
  101654. * it will be used for both width and height. If an object is passed, the screenshot size
  101655. * will be derived from the parameters. The precision property is a multiplier allowing
  101656. * rendering at a higher or lower resolution
  101657. * @param successCallback defines the callback receives a single parameter which contains the
  101658. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  101659. * src parameter of an <img> to display it
  101660. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  101661. * Check your browser for supported MIME types
  101662. */
  101663. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  101664. if (mimeType === void 0) { mimeType = "image/png"; }
  101665. var width;
  101666. var height;
  101667. // If a precision value is specified
  101668. if (size.precision) {
  101669. width = Math.round(engine.getRenderWidth() * size.precision);
  101670. height = Math.round(width / engine.getAspectRatio(camera));
  101671. }
  101672. else if (size.width && size.height) {
  101673. width = size.width;
  101674. height = size.height;
  101675. }
  101676. //If passing only width, computing height to keep display canvas ratio.
  101677. else if (size.width && !size.height) {
  101678. width = size.width;
  101679. height = Math.round(width / engine.getAspectRatio(camera));
  101680. }
  101681. //If passing only height, computing width to keep display canvas ratio.
  101682. else if (size.height && !size.width) {
  101683. height = size.height;
  101684. width = Math.round(height * engine.getAspectRatio(camera));
  101685. }
  101686. //Assuming here that "size" parameter is a number
  101687. else if (!isNaN(size)) {
  101688. height = size;
  101689. width = size;
  101690. }
  101691. else {
  101692. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  101693. return;
  101694. }
  101695. if (!_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas) {
  101696. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas = document.createElement('canvas');
  101697. }
  101698. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.width = width;
  101699. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.height = height;
  101700. var renderContext = _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"]._ScreenshotCanvas.getContext("2d");
  101701. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  101702. var newWidth = width;
  101703. var newHeight = newWidth / ratio;
  101704. if (newHeight > height) {
  101705. newHeight = height;
  101706. newWidth = newHeight * ratio;
  101707. }
  101708. var offsetX = Math.max(0, width - newWidth) / 2;
  101709. var offsetY = Math.max(0, height - newHeight) / 2;
  101710. var renderingCanvas = engine.getRenderingCanvas();
  101711. if (renderContext && renderingCanvas) {
  101712. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  101713. }
  101714. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  101715. };
  101716. /**
  101717. * Generates an image screenshot from the specified camera.
  101718. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  101719. * @param engine The engine to use for rendering
  101720. * @param camera The camera to use for rendering
  101721. * @param size This parameter can be set to a single number or to an object with the
  101722. * following (optional) properties: precision, width, height. If a single number is passed,
  101723. * it will be used for both width and height. If an object is passed, the screenshot size
  101724. * will be derived from the parameters. The precision property is a multiplier allowing
  101725. * rendering at a higher or lower resolution
  101726. * @param successCallback The callback receives a single parameter which contains the
  101727. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  101728. * src parameter of an <img> to display it
  101729. * @param mimeType The MIME type of the screenshot image (default: image/png).
  101730. * Check your browser for supported MIME types
  101731. * @param samples Texture samples (default: 1)
  101732. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  101733. * @param fileName A name for for the downloaded file.
  101734. */
  101735. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  101736. if (mimeType === void 0) { mimeType = "image/png"; }
  101737. if (samples === void 0) { samples = 1; }
  101738. if (antialiasing === void 0) { antialiasing = false; }
  101739. var width;
  101740. var height;
  101741. //If a precision value is specified
  101742. if (size.precision) {
  101743. width = Math.round(engine.getRenderWidth() * size.precision);
  101744. height = Math.round(width / engine.getAspectRatio(camera));
  101745. size = { width: width, height: height };
  101746. }
  101747. else if (size.width && size.height) {
  101748. width = size.width;
  101749. height = size.height;
  101750. }
  101751. //If passing only width, computing height to keep display canvas ratio.
  101752. else if (size.width && !size.height) {
  101753. width = size.width;
  101754. height = Math.round(width / engine.getAspectRatio(camera));
  101755. size = { width: width, height: height };
  101756. }
  101757. //If passing only height, computing width to keep display canvas ratio.
  101758. else if (size.height && !size.width) {
  101759. height = size.height;
  101760. width = Math.round(height * engine.getAspectRatio(camera));
  101761. size = { width: width, height: height };
  101762. }
  101763. //Assuming here that "size" parameter is a number
  101764. else if (!isNaN(size)) {
  101765. height = size;
  101766. width = size;
  101767. }
  101768. else {
  101769. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  101770. return;
  101771. }
  101772. var scene = camera.getScene();
  101773. var previousCamera = null;
  101774. if (scene.activeCamera !== camera) {
  101775. previousCamera = scene.activeCamera;
  101776. scene.activeCamera = camera;
  101777. }
  101778. var renderCanvas = engine.getRenderingCanvas();
  101779. if (!renderCanvas) {
  101780. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  101781. return;
  101782. }
  101783. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  101784. engine.setSize(width, height);
  101785. scene.render();
  101786. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  101787. 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);
  101788. texture.renderList = null;
  101789. texture.samples = samples;
  101790. if (antialiasing) {
  101791. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  101792. }
  101793. texture.onAfterRenderObservable.add(function () {
  101794. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  101795. });
  101796. scene.incrementRenderId();
  101797. scene.resetCachedMaterial();
  101798. texture.render(true);
  101799. texture.dispose();
  101800. if (previousCamera) {
  101801. scene.activeCamera = previousCamera;
  101802. }
  101803. engine.setSize(originalSize.width, originalSize.height);
  101804. camera.getProjectionMatrix(true); // Force cache refresh;
  101805. };
  101806. return ScreenshotTools;
  101807. }());
  101808. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  101809. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  101810. /***/ }),
  101811. /***/ "./Misc/smartArray.ts":
  101812. /*!****************************!*\
  101813. !*** ./Misc/smartArray.ts ***!
  101814. \****************************/
  101815. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  101816. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101817. "use strict";
  101818. __webpack_require__.r(__webpack_exports__);
  101819. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  101820. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  101821. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  101822. /**
  101823. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  101824. */
  101825. var SmartArray = /** @class */ (function () {
  101826. /**
  101827. * Instantiates a Smart Array.
  101828. * @param capacity defines the default capacity of the array.
  101829. */
  101830. function SmartArray(capacity) {
  101831. /**
  101832. * The active length of the array.
  101833. */
  101834. this.length = 0;
  101835. this.data = new Array(capacity);
  101836. this._id = SmartArray._GlobalId++;
  101837. }
  101838. /**
  101839. * Pushes a value at the end of the active data.
  101840. * @param value defines the object to push in the array.
  101841. */
  101842. SmartArray.prototype.push = function (value) {
  101843. this.data[this.length++] = value;
  101844. if (this.length > this.data.length) {
  101845. this.data.length *= 2;
  101846. }
  101847. };
  101848. /**
  101849. * Iterates over the active data and apply the lambda to them.
  101850. * @param func defines the action to apply on each value.
  101851. */
  101852. SmartArray.prototype.forEach = function (func) {
  101853. for (var index = 0; index < this.length; index++) {
  101854. func(this.data[index]);
  101855. }
  101856. };
  101857. /**
  101858. * Sorts the full sets of data.
  101859. * @param compareFn defines the comparison function to apply.
  101860. */
  101861. SmartArray.prototype.sort = function (compareFn) {
  101862. this.data.sort(compareFn);
  101863. };
  101864. /**
  101865. * Resets the active data to an empty array.
  101866. */
  101867. SmartArray.prototype.reset = function () {
  101868. this.length = 0;
  101869. };
  101870. /**
  101871. * Releases all the data from the array as well as the array.
  101872. */
  101873. SmartArray.prototype.dispose = function () {
  101874. this.reset();
  101875. if (this.data) {
  101876. this.data.length = 0;
  101877. this.data = [];
  101878. }
  101879. };
  101880. /**
  101881. * Concats the active data with a given array.
  101882. * @param array defines the data to concatenate with.
  101883. */
  101884. SmartArray.prototype.concat = function (array) {
  101885. if (array.length === 0) {
  101886. return;
  101887. }
  101888. if (this.length + array.length > this.data.length) {
  101889. this.data.length = (this.length + array.length) * 2;
  101890. }
  101891. for (var index = 0; index < array.length; index++) {
  101892. this.data[this.length++] = (array.data || array)[index];
  101893. }
  101894. };
  101895. /**
  101896. * Returns the position of a value in the active data.
  101897. * @param value defines the value to find the index for
  101898. * @returns the index if found in the active data otherwise -1
  101899. */
  101900. SmartArray.prototype.indexOf = function (value) {
  101901. var position = this.data.indexOf(value);
  101902. if (position >= this.length) {
  101903. return -1;
  101904. }
  101905. return position;
  101906. };
  101907. /**
  101908. * Returns whether an element is part of the active data.
  101909. * @param value defines the value to look for
  101910. * @returns true if found in the active data otherwise false
  101911. */
  101912. SmartArray.prototype.contains = function (value) {
  101913. return this.indexOf(value) !== -1;
  101914. };
  101915. // Statics
  101916. SmartArray._GlobalId = 0;
  101917. return SmartArray;
  101918. }());
  101919. /**
  101920. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  101921. * The data in this array can only be present once
  101922. */
  101923. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  101924. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  101925. function SmartArrayNoDuplicate() {
  101926. var _this = _super !== null && _super.apply(this, arguments) || this;
  101927. _this._duplicateId = 0;
  101928. return _this;
  101929. }
  101930. /**
  101931. * Pushes a value at the end of the active data.
  101932. * THIS DOES NOT PREVENT DUPPLICATE DATA
  101933. * @param value defines the object to push in the array.
  101934. */
  101935. SmartArrayNoDuplicate.prototype.push = function (value) {
  101936. _super.prototype.push.call(this, value);
  101937. if (!value.__smartArrayFlags) {
  101938. value.__smartArrayFlags = {};
  101939. }
  101940. value.__smartArrayFlags[this._id] = this._duplicateId;
  101941. };
  101942. /**
  101943. * Pushes a value at the end of the active data.
  101944. * If the data is already present, it won t be added again
  101945. * @param value defines the object to push in the array.
  101946. * @returns true if added false if it was already present
  101947. */
  101948. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  101949. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  101950. return false;
  101951. }
  101952. this.push(value);
  101953. return true;
  101954. };
  101955. /**
  101956. * Resets the active data to an empty array.
  101957. */
  101958. SmartArrayNoDuplicate.prototype.reset = function () {
  101959. _super.prototype.reset.call(this);
  101960. this._duplicateId++;
  101961. };
  101962. /**
  101963. * Concats the active data with a given array.
  101964. * This ensures no dupplicate will be present in the result.
  101965. * @param array defines the data to concatenate with.
  101966. */
  101967. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  101968. if (array.length === 0) {
  101969. return;
  101970. }
  101971. if (this.length + array.length > this.data.length) {
  101972. this.data.length = (this.length + array.length) * 2;
  101973. }
  101974. for (var index = 0; index < array.length; index++) {
  101975. var item = (array.data || array)[index];
  101976. this.pushNoDuplicate(item);
  101977. }
  101978. };
  101979. return SmartArrayNoDuplicate;
  101980. }(SmartArray));
  101981. /***/ }),
  101982. /***/ "./Misc/stringDictionary.ts":
  101983. /*!**********************************!*\
  101984. !*** ./Misc/stringDictionary.ts ***!
  101985. \**********************************/
  101986. /*! exports provided: StringDictionary */
  101987. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101988. "use strict";
  101989. __webpack_require__.r(__webpack_exports__);
  101990. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  101991. /**
  101992. * This class implement a typical dictionary using a string as key and the generic type T as value.
  101993. * The underlying implementation relies on an associative array to ensure the best performances.
  101994. * The value can be anything including 'null' but except 'undefined'
  101995. */
  101996. var StringDictionary = /** @class */ (function () {
  101997. function StringDictionary() {
  101998. this._count = 0;
  101999. this._data = {};
  102000. }
  102001. /**
  102002. * This will clear this dictionary and copy the content from the 'source' one.
  102003. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  102004. * @param source the dictionary to take the content from and copy to this dictionary
  102005. */
  102006. StringDictionary.prototype.copyFrom = function (source) {
  102007. var _this = this;
  102008. this.clear();
  102009. source.forEach(function (t, v) { return _this.add(t, v); });
  102010. };
  102011. /**
  102012. * Get a value based from its key
  102013. * @param key the given key to get the matching value from
  102014. * @return the value if found, otherwise undefined is returned
  102015. */
  102016. StringDictionary.prototype.get = function (key) {
  102017. var val = this._data[key];
  102018. if (val !== undefined) {
  102019. return val;
  102020. }
  102021. return undefined;
  102022. };
  102023. /**
  102024. * Get a value from its key or add it if it doesn't exist.
  102025. * This method will ensure you that a given key/data will be present in the dictionary.
  102026. * @param key the given key to get the matching value from
  102027. * @param factory the factory that will create the value if the key is not present in the dictionary.
  102028. * The factory will only be invoked if there's no data for the given key.
  102029. * @return the value corresponding to the key.
  102030. */
  102031. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  102032. var val = this.get(key);
  102033. if (val !== undefined) {
  102034. return val;
  102035. }
  102036. val = factory(key);
  102037. if (val) {
  102038. this.add(key, val);
  102039. }
  102040. return val;
  102041. };
  102042. /**
  102043. * Get a value from its key if present in the dictionary otherwise add it
  102044. * @param key the key to get the value from
  102045. * @param val if there's no such key/value pair in the dictionary add it with this value
  102046. * @return the value corresponding to the key
  102047. */
  102048. StringDictionary.prototype.getOrAdd = function (key, val) {
  102049. var curVal = this.get(key);
  102050. if (curVal !== undefined) {
  102051. return curVal;
  102052. }
  102053. this.add(key, val);
  102054. return val;
  102055. };
  102056. /**
  102057. * Check if there's a given key in the dictionary
  102058. * @param key the key to check for
  102059. * @return true if the key is present, false otherwise
  102060. */
  102061. StringDictionary.prototype.contains = function (key) {
  102062. return this._data[key] !== undefined;
  102063. };
  102064. /**
  102065. * Add a new key and its corresponding value
  102066. * @param key the key to add
  102067. * @param value the value corresponding to the key
  102068. * @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
  102069. */
  102070. StringDictionary.prototype.add = function (key, value) {
  102071. if (this._data[key] !== undefined) {
  102072. return false;
  102073. }
  102074. this._data[key] = value;
  102075. ++this._count;
  102076. return true;
  102077. };
  102078. /**
  102079. * Update a specific value associated to a key
  102080. * @param key defines the key to use
  102081. * @param value defines the value to store
  102082. * @returns true if the value was updated (or false if the key was not found)
  102083. */
  102084. StringDictionary.prototype.set = function (key, value) {
  102085. if (this._data[key] === undefined) {
  102086. return false;
  102087. }
  102088. this._data[key] = value;
  102089. return true;
  102090. };
  102091. /**
  102092. * Get the element of the given key and remove it from the dictionary
  102093. * @param key defines the key to search
  102094. * @returns the value associated with the key or null if not found
  102095. */
  102096. StringDictionary.prototype.getAndRemove = function (key) {
  102097. var val = this.get(key);
  102098. if (val !== undefined) {
  102099. delete this._data[key];
  102100. --this._count;
  102101. return val;
  102102. }
  102103. return null;
  102104. };
  102105. /**
  102106. * Remove a key/value from the dictionary.
  102107. * @param key the key to remove
  102108. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  102109. */
  102110. StringDictionary.prototype.remove = function (key) {
  102111. if (this.contains(key)) {
  102112. delete this._data[key];
  102113. --this._count;
  102114. return true;
  102115. }
  102116. return false;
  102117. };
  102118. /**
  102119. * Clear the whole content of the dictionary
  102120. */
  102121. StringDictionary.prototype.clear = function () {
  102122. this._data = {};
  102123. this._count = 0;
  102124. };
  102125. Object.defineProperty(StringDictionary.prototype, "count", {
  102126. /**
  102127. * Gets the current count
  102128. */
  102129. get: function () {
  102130. return this._count;
  102131. },
  102132. enumerable: true,
  102133. configurable: true
  102134. });
  102135. /**
  102136. * Execute a callback on each key/val of the dictionary.
  102137. * Note that you can remove any element in this dictionary in the callback implementation
  102138. * @param callback the callback to execute on a given key/value pair
  102139. */
  102140. StringDictionary.prototype.forEach = function (callback) {
  102141. for (var cur in this._data) {
  102142. var val = this._data[cur];
  102143. callback(cur, val);
  102144. }
  102145. };
  102146. /**
  102147. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  102148. * If the callback returns null or undefined the method will iterate to the next key/value pair
  102149. * Note that you can remove any element in this dictionary in the callback implementation
  102150. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  102151. * @returns the first item
  102152. */
  102153. StringDictionary.prototype.first = function (callback) {
  102154. for (var cur in this._data) {
  102155. var val = this._data[cur];
  102156. var res = callback(cur, val);
  102157. if (res) {
  102158. return res;
  102159. }
  102160. }
  102161. return null;
  102162. };
  102163. return StringDictionary;
  102164. }());
  102165. /***/ }),
  102166. /***/ "./Misc/tags.ts":
  102167. /*!**********************!*\
  102168. !*** ./Misc/tags.ts ***!
  102169. \**********************/
  102170. /*! exports provided: Tags */
  102171. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102172. "use strict";
  102173. __webpack_require__.r(__webpack_exports__);
  102174. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  102175. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  102176. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  102177. /**
  102178. * Class used to store custom tags
  102179. */
  102180. var Tags = /** @class */ (function () {
  102181. function Tags() {
  102182. }
  102183. /**
  102184. * Adds support for tags on the given object
  102185. * @param obj defines the object to use
  102186. */
  102187. Tags.EnableFor = function (obj) {
  102188. obj._tags = obj._tags || {};
  102189. obj.hasTags = function () {
  102190. return Tags.HasTags(obj);
  102191. };
  102192. obj.addTags = function (tagsString) {
  102193. return Tags.AddTagsTo(obj, tagsString);
  102194. };
  102195. obj.removeTags = function (tagsString) {
  102196. return Tags.RemoveTagsFrom(obj, tagsString);
  102197. };
  102198. obj.matchesTagsQuery = function (tagsQuery) {
  102199. return Tags.MatchesQuery(obj, tagsQuery);
  102200. };
  102201. };
  102202. /**
  102203. * Removes tags support
  102204. * @param obj defines the object to use
  102205. */
  102206. Tags.DisableFor = function (obj) {
  102207. delete obj._tags;
  102208. delete obj.hasTags;
  102209. delete obj.addTags;
  102210. delete obj.removeTags;
  102211. delete obj.matchesTagsQuery;
  102212. };
  102213. /**
  102214. * Gets a boolean indicating if the given object has tags
  102215. * @param obj defines the object to use
  102216. * @returns a boolean
  102217. */
  102218. Tags.HasTags = function (obj) {
  102219. if (!obj._tags) {
  102220. return false;
  102221. }
  102222. return !_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsEmpty(obj._tags);
  102223. };
  102224. /**
  102225. * Gets the tags available on a given object
  102226. * @param obj defines the object to use
  102227. * @param asString defines if the tags must be returned as a string instead of an array of strings
  102228. * @returns the tags
  102229. */
  102230. Tags.GetTags = function (obj, asString) {
  102231. if (asString === void 0) { asString = true; }
  102232. if (!obj._tags) {
  102233. return null;
  102234. }
  102235. if (asString) {
  102236. var tagsArray = [];
  102237. for (var tag in obj._tags) {
  102238. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  102239. tagsArray.push(tag);
  102240. }
  102241. }
  102242. return tagsArray.join(" ");
  102243. }
  102244. else {
  102245. return obj._tags;
  102246. }
  102247. };
  102248. /**
  102249. * Adds tags to an object
  102250. * @param obj defines the object to use
  102251. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  102252. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  102253. */
  102254. Tags.AddTagsTo = function (obj, tagsString) {
  102255. if (!tagsString) {
  102256. return;
  102257. }
  102258. if (typeof tagsString !== "string") {
  102259. return;
  102260. }
  102261. var tags = tagsString.split(" ");
  102262. tags.forEach(function (tag, index, array) {
  102263. Tags._AddTagTo(obj, tag);
  102264. });
  102265. };
  102266. /**
  102267. * @hidden
  102268. */
  102269. Tags._AddTagTo = function (obj, tag) {
  102270. tag = tag.trim();
  102271. if (tag === "" || tag === "true" || tag === "false") {
  102272. return;
  102273. }
  102274. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  102275. return;
  102276. }
  102277. Tags.EnableFor(obj);
  102278. obj._tags[tag] = true;
  102279. };
  102280. /**
  102281. * Removes specific tags from a specific object
  102282. * @param obj defines the object to use
  102283. * @param tagsString defines the tags to remove
  102284. */
  102285. Tags.RemoveTagsFrom = function (obj, tagsString) {
  102286. if (!Tags.HasTags(obj)) {
  102287. return;
  102288. }
  102289. var tags = tagsString.split(" ");
  102290. for (var t in tags) {
  102291. Tags._RemoveTagFrom(obj, tags[t]);
  102292. }
  102293. };
  102294. /**
  102295. * @hidden
  102296. */
  102297. Tags._RemoveTagFrom = function (obj, tag) {
  102298. delete obj._tags[tag];
  102299. };
  102300. /**
  102301. * Defines if tags hosted on an object match a given query
  102302. * @param obj defines the object to use
  102303. * @param tagsQuery defines the tag query
  102304. * @returns a boolean
  102305. */
  102306. Tags.MatchesQuery = function (obj, tagsQuery) {
  102307. if (tagsQuery === undefined) {
  102308. return true;
  102309. }
  102310. if (tagsQuery === "") {
  102311. return Tags.HasTags(obj);
  102312. }
  102313. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  102314. };
  102315. return Tags;
  102316. }());
  102317. /***/ }),
  102318. /***/ "./Misc/textureTools.ts":
  102319. /*!******************************!*\
  102320. !*** ./Misc/textureTools.ts ***!
  102321. \******************************/
  102322. /*! exports provided: TextureTools */
  102323. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102324. "use strict";
  102325. __webpack_require__.r(__webpack_exports__);
  102326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  102327. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  102328. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  102329. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  102330. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  102331. /**
  102332. * Class used to host texture specific utilities
  102333. */
  102334. var TextureTools = /** @class */ (function () {
  102335. function TextureTools() {
  102336. }
  102337. /**
  102338. * Uses the GPU to create a copy texture rescaled at a given size
  102339. * @param texture Texture to copy from
  102340. * @param width defines the desired width
  102341. * @param height defines the desired height
  102342. * @param useBilinearMode defines if bilinear mode has to be used
  102343. * @return the generated texture
  102344. */
  102345. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  102346. if (useBilinearMode === void 0) { useBilinearMode = true; }
  102347. var scene = texture.getScene();
  102348. var engine = scene.getEngine();
  102349. 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);
  102350. rtt.wrapU = texture.wrapU;
  102351. rtt.wrapV = texture.wrapV;
  102352. rtt.uOffset = texture.uOffset;
  102353. rtt.vOffset = texture.vOffset;
  102354. rtt.uScale = texture.uScale;
  102355. rtt.vScale = texture.vScale;
  102356. rtt.uAng = texture.uAng;
  102357. rtt.vAng = texture.vAng;
  102358. rtt.wAng = texture.wAng;
  102359. rtt.coordinatesIndex = texture.coordinatesIndex;
  102360. rtt.level = texture.level;
  102361. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  102362. rtt._texture.isReady = false;
  102363. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  102364. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  102365. 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);
  102366. passPostProcess.getEffect().executeWhenCompiled(function () {
  102367. passPostProcess.onApply = function (effect) {
  102368. effect.setTexture("textureSampler", texture);
  102369. };
  102370. var internalTexture = rtt.getInternalTexture();
  102371. if (internalTexture) {
  102372. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  102373. engine.unBindFramebuffer(internalTexture);
  102374. rtt.disposeFramebufferObjects();
  102375. passPostProcess.dispose();
  102376. internalTexture.isReady = true;
  102377. }
  102378. });
  102379. return rtt;
  102380. };
  102381. return TextureTools;
  102382. }());
  102383. /***/ }),
  102384. /***/ "./Misc/tga.ts":
  102385. /*!*********************!*\
  102386. !*** ./Misc/tga.ts ***!
  102387. \*********************/
  102388. /*! exports provided: TGATools */
  102389. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102390. "use strict";
  102391. __webpack_require__.r(__webpack_exports__);
  102392. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  102393. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  102394. /**
  102395. * Based on jsTGALoader - Javascript loader for TGA file
  102396. * By Vincent Thibault
  102397. * @see http://blog.robrowser.com/javascript-tga-loader.html
  102398. */
  102399. var TGATools = /** @class */ (function () {
  102400. function TGATools() {
  102401. }
  102402. /**
  102403. * Gets the header of a TGA file
  102404. * @param data defines the TGA data
  102405. * @returns the header
  102406. */
  102407. TGATools.GetTGAHeader = function (data) {
  102408. var offset = 0;
  102409. var header = {
  102410. id_length: data[offset++],
  102411. colormap_type: data[offset++],
  102412. image_type: data[offset++],
  102413. colormap_index: data[offset++] | data[offset++] << 8,
  102414. colormap_length: data[offset++] | data[offset++] << 8,
  102415. colormap_size: data[offset++],
  102416. origin: [
  102417. data[offset++] | data[offset++] << 8,
  102418. data[offset++] | data[offset++] << 8
  102419. ],
  102420. width: data[offset++] | data[offset++] << 8,
  102421. height: data[offset++] | data[offset++] << 8,
  102422. pixel_size: data[offset++],
  102423. flags: data[offset++]
  102424. };
  102425. return header;
  102426. };
  102427. /**
  102428. * Uploads TGA content to a Babylon Texture
  102429. * @hidden
  102430. */
  102431. TGATools.UploadContent = function (texture, data) {
  102432. // Not enough data to contain header ?
  102433. if (data.length < 19) {
  102434. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  102435. return;
  102436. }
  102437. // Read Header
  102438. var offset = 18;
  102439. var header = TGATools.GetTGAHeader(data);
  102440. // Assume it's a valid Targa file.
  102441. if (header.id_length + offset > data.length) {
  102442. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  102443. return;
  102444. }
  102445. // Skip not needed data
  102446. offset += header.id_length;
  102447. var use_rle = false;
  102448. var use_pal = false;
  102449. var use_grey = false;
  102450. // Get some informations.
  102451. switch (header.image_type) {
  102452. case TGATools._TYPE_RLE_INDEXED:
  102453. use_rle = true;
  102454. case TGATools._TYPE_INDEXED:
  102455. use_pal = true;
  102456. break;
  102457. case TGATools._TYPE_RLE_RGB:
  102458. use_rle = true;
  102459. case TGATools._TYPE_RGB:
  102460. // use_rgb = true;
  102461. break;
  102462. case TGATools._TYPE_RLE_GREY:
  102463. use_rle = true;
  102464. case TGATools._TYPE_GREY:
  102465. use_grey = true;
  102466. break;
  102467. }
  102468. var pixel_data;
  102469. // var numAlphaBits = header.flags & 0xf;
  102470. var pixel_size = header.pixel_size >> 3;
  102471. var pixel_total = header.width * header.height * pixel_size;
  102472. // Read palettes
  102473. var palettes;
  102474. if (use_pal) {
  102475. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  102476. }
  102477. // Read LRE
  102478. if (use_rle) {
  102479. pixel_data = new Uint8Array(pixel_total);
  102480. var c, count, i;
  102481. var localOffset = 0;
  102482. var pixels = new Uint8Array(pixel_size);
  102483. while (offset < pixel_total && localOffset < pixel_total) {
  102484. c = data[offset++];
  102485. count = (c & 0x7f) + 1;
  102486. // RLE pixels
  102487. if (c & 0x80) {
  102488. // Bind pixel tmp array
  102489. for (i = 0; i < pixel_size; ++i) {
  102490. pixels[i] = data[offset++];
  102491. }
  102492. // Copy pixel array
  102493. for (i = 0; i < count; ++i) {
  102494. pixel_data.set(pixels, localOffset + i * pixel_size);
  102495. }
  102496. localOffset += pixel_size * count;
  102497. }
  102498. // Raw pixels
  102499. else {
  102500. count *= pixel_size;
  102501. for (i = 0; i < count; ++i) {
  102502. pixel_data[localOffset + i] = data[offset++];
  102503. }
  102504. localOffset += count;
  102505. }
  102506. }
  102507. }
  102508. // RAW Pixels
  102509. else {
  102510. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  102511. }
  102512. // Load to texture
  102513. var x_start, y_start, x_step, y_step, y_end, x_end;
  102514. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  102515. default:
  102516. case TGATools._ORIGIN_UL:
  102517. x_start = 0;
  102518. x_step = 1;
  102519. x_end = header.width;
  102520. y_start = 0;
  102521. y_step = 1;
  102522. y_end = header.height;
  102523. break;
  102524. case TGATools._ORIGIN_BL:
  102525. x_start = 0;
  102526. x_step = 1;
  102527. x_end = header.width;
  102528. y_start = header.height - 1;
  102529. y_step = -1;
  102530. y_end = -1;
  102531. break;
  102532. case TGATools._ORIGIN_UR:
  102533. x_start = header.width - 1;
  102534. x_step = -1;
  102535. x_end = -1;
  102536. y_start = 0;
  102537. y_step = 1;
  102538. y_end = header.height;
  102539. break;
  102540. case TGATools._ORIGIN_BR:
  102541. x_start = header.width - 1;
  102542. x_step = -1;
  102543. x_end = -1;
  102544. y_start = header.height - 1;
  102545. y_step = -1;
  102546. y_end = -1;
  102547. break;
  102548. }
  102549. // Load the specify method
  102550. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  102551. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  102552. var engine = texture.getEngine();
  102553. engine._uploadDataToTextureDirectly(texture, imageData);
  102554. };
  102555. /** @hidden */
  102556. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  102557. var image = pixel_data, colormap = palettes;
  102558. var width = header.width, height = header.height;
  102559. var color, i = 0, x, y;
  102560. var imageData = new Uint8Array(width * height * 4);
  102561. for (y = y_start; y !== y_end; y += y_step) {
  102562. for (x = x_start; x !== x_end; x += x_step, i++) {
  102563. color = image[i];
  102564. imageData[(x + width * y) * 4 + 3] = 255;
  102565. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  102566. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  102567. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  102568. }
  102569. }
  102570. return imageData;
  102571. };
  102572. /** @hidden */
  102573. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  102574. var image = pixel_data;
  102575. var width = header.width, height = header.height;
  102576. var color, i = 0, x, y;
  102577. var imageData = new Uint8Array(width * height * 4);
  102578. for (y = y_start; y !== y_end; y += y_step) {
  102579. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  102580. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  102581. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  102582. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  102583. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  102584. imageData[(x + width * y) * 4 + 0] = r;
  102585. imageData[(x + width * y) * 4 + 1] = g;
  102586. imageData[(x + width * y) * 4 + 2] = b;
  102587. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  102588. }
  102589. }
  102590. return imageData;
  102591. };
  102592. /** @hidden */
  102593. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  102594. var image = pixel_data;
  102595. var width = header.width, height = header.height;
  102596. var i = 0, x, y;
  102597. var imageData = new Uint8Array(width * height * 4);
  102598. for (y = y_start; y !== y_end; y += y_step) {
  102599. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  102600. imageData[(x + width * y) * 4 + 3] = 255;
  102601. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  102602. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  102603. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  102604. }
  102605. }
  102606. return imageData;
  102607. };
  102608. /** @hidden */
  102609. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  102610. var image = pixel_data;
  102611. var width = header.width, height = header.height;
  102612. var i = 0, x, y;
  102613. var imageData = new Uint8Array(width * height * 4);
  102614. for (y = y_start; y !== y_end; y += y_step) {
  102615. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  102616. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  102617. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  102618. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  102619. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  102620. }
  102621. }
  102622. return imageData;
  102623. };
  102624. /** @hidden */
  102625. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  102626. var image = pixel_data;
  102627. var width = header.width, height = header.height;
  102628. var color, i = 0, x, y;
  102629. var imageData = new Uint8Array(width * height * 4);
  102630. for (y = y_start; y !== y_end; y += y_step) {
  102631. for (x = x_start; x !== x_end; x += x_step, i++) {
  102632. color = image[i];
  102633. imageData[(x + width * y) * 4 + 0] = color;
  102634. imageData[(x + width * y) * 4 + 1] = color;
  102635. imageData[(x + width * y) * 4 + 2] = color;
  102636. imageData[(x + width * y) * 4 + 3] = 255;
  102637. }
  102638. }
  102639. return imageData;
  102640. };
  102641. /** @hidden */
  102642. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  102643. var image = pixel_data;
  102644. var width = header.width, height = header.height;
  102645. var i = 0, x, y;
  102646. var imageData = new Uint8Array(width * height * 4);
  102647. for (y = y_start; y !== y_end; y += y_step) {
  102648. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  102649. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  102650. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  102651. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  102652. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  102653. }
  102654. }
  102655. return imageData;
  102656. };
  102657. //private static _TYPE_NO_DATA = 0;
  102658. TGATools._TYPE_INDEXED = 1;
  102659. TGATools._TYPE_RGB = 2;
  102660. TGATools._TYPE_GREY = 3;
  102661. TGATools._TYPE_RLE_INDEXED = 9;
  102662. TGATools._TYPE_RLE_RGB = 10;
  102663. TGATools._TYPE_RLE_GREY = 11;
  102664. TGATools._ORIGIN_MASK = 0x30;
  102665. TGATools._ORIGIN_SHIFT = 0x04;
  102666. TGATools._ORIGIN_BL = 0x00;
  102667. TGATools._ORIGIN_BR = 0x01;
  102668. TGATools._ORIGIN_UL = 0x02;
  102669. TGATools._ORIGIN_UR = 0x03;
  102670. return TGATools;
  102671. }());
  102672. /***/ }),
  102673. /***/ "./Misc/tools.ts":
  102674. /*!***********************!*\
  102675. !*** ./Misc/tools.ts ***!
  102676. \***********************/
  102677. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop */
  102678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102679. "use strict";
  102680. __webpack_require__.r(__webpack_exports__);
  102681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  102682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  102683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  102684. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  102685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  102686. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  102687. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  102688. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  102689. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  102690. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102691. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  102692. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102693. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  102694. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  102695. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  102696. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  102697. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  102698. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  102699. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  102700. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  102701. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  102702. /* harmony import */ var _webRequest__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./webRequest */ "./Misc/webRequest.ts");
  102703. /** Class used to store color4 gradient */
  102704. var ColorGradient = /** @class */ (function () {
  102705. function ColorGradient() {
  102706. }
  102707. /**
  102708. * Will get a color picked randomly between color1 and color2.
  102709. * If color2 is undefined then color1 will be used
  102710. * @param result defines the target Color4 to store the result in
  102711. */
  102712. ColorGradient.prototype.getColorToRef = function (result) {
  102713. if (!this.color2) {
  102714. result.copyFrom(this.color1);
  102715. return;
  102716. }
  102717. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  102718. };
  102719. return ColorGradient;
  102720. }());
  102721. /** Class used to store color 3 gradient */
  102722. var Color3Gradient = /** @class */ (function () {
  102723. function Color3Gradient() {
  102724. }
  102725. return Color3Gradient;
  102726. }());
  102727. /** Class used to store factor gradient */
  102728. var FactorGradient = /** @class */ (function () {
  102729. function FactorGradient() {
  102730. }
  102731. /**
  102732. * Will get a number picked randomly between factor1 and factor2.
  102733. * If factor2 is undefined then factor1 will be used
  102734. * @returns the picked number
  102735. */
  102736. FactorGradient.prototype.getFactor = function () {
  102737. if (this.factor2 === undefined) {
  102738. return this.factor1;
  102739. }
  102740. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(this.factor1, this.factor2, Math.random());
  102741. };
  102742. return FactorGradient;
  102743. }());
  102744. /**
  102745. * @ignore
  102746. * Application error to support additional information when loading a file
  102747. */
  102748. var LoadFileError = /** @class */ (function (_super) {
  102749. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  102750. /**
  102751. * Creates a new LoadFileError
  102752. * @param message defines the message of the error
  102753. * @param request defines the optional web request
  102754. */
  102755. function LoadFileError(message,
  102756. /** defines the optional web request */
  102757. request) {
  102758. var _this = _super.call(this, message) || this;
  102759. _this.request = request;
  102760. _this.name = "LoadFileError";
  102761. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  102762. return _this;
  102763. }
  102764. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  102765. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  102766. // Polyfill for Object.setPrototypeOf if necessary.
  102767. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  102768. return LoadFileError;
  102769. }(Error));
  102770. /**
  102771. * Class used to define a retry strategy when error happens while loading assets
  102772. */
  102773. var RetryStrategy = /** @class */ (function () {
  102774. function RetryStrategy() {
  102775. }
  102776. /**
  102777. * Function used to defines an exponential back off strategy
  102778. * @param maxRetries defines the maximum number of retries (3 by default)
  102779. * @param baseInterval defines the interval between retries
  102780. * @returns the strategy function to use
  102781. */
  102782. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  102783. if (maxRetries === void 0) { maxRetries = 3; }
  102784. if (baseInterval === void 0) { baseInterval = 500; }
  102785. return function (url, request, retryIndex) {
  102786. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  102787. return -1;
  102788. }
  102789. return Math.pow(2, retryIndex) * baseInterval;
  102790. };
  102791. };
  102792. return RetryStrategy;
  102793. }());
  102794. /**
  102795. * Class containing a set of static utilities functions
  102796. */
  102797. var Tools = /** @class */ (function () {
  102798. function Tools() {
  102799. }
  102800. /**
  102801. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  102802. * @param u defines the coordinate on X axis
  102803. * @param v defines the coordinate on Y axis
  102804. * @param width defines the width of the source data
  102805. * @param height defines the height of the source data
  102806. * @param pixels defines the source byte array
  102807. * @param color defines the output color
  102808. */
  102809. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  102810. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  102811. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  102812. var position = (wrappedU + wrappedV * width) * 4;
  102813. color.r = pixels[position] / 255;
  102814. color.g = pixels[position + 1] / 255;
  102815. color.b = pixels[position + 2] / 255;
  102816. color.a = pixels[position + 3] / 255;
  102817. };
  102818. /**
  102819. * Interpolates between a and b via alpha
  102820. * @param a The lower value (returned when alpha = 0)
  102821. * @param b The upper value (returned when alpha = 1)
  102822. * @param alpha The interpolation-factor
  102823. * @return The mixed value
  102824. */
  102825. Tools.Mix = function (a, b, alpha) {
  102826. return a * (1 - alpha) + b * alpha;
  102827. };
  102828. /**
  102829. * Tries to instantiate a new object from a given class name
  102830. * @param className defines the class name to instantiate
  102831. * @returns the new object or null if the system was not able to do the instantiation
  102832. */
  102833. Tools.Instantiate = function (className) {
  102834. if (Tools.RegisteredExternalClasses && Tools.RegisteredExternalClasses[className]) {
  102835. return Tools.RegisteredExternalClasses[className];
  102836. }
  102837. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass(className);
  102838. if (internalClass) {
  102839. return internalClass;
  102840. }
  102841. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(className + " not found, you may have missed an import.");
  102842. var arr = className.split(".");
  102843. var fn = (window || this);
  102844. for (var i = 0, len = arr.length; i < len; i++) {
  102845. fn = fn[arr[i]];
  102846. }
  102847. if (typeof fn !== "function") {
  102848. return null;
  102849. }
  102850. return fn;
  102851. };
  102852. /**
  102853. * Provides a slice function that will work even on IE
  102854. * @param data defines the array to slice
  102855. * @param start defines the start of the data (optional)
  102856. * @param end defines the end of the data (optional)
  102857. * @returns the new sliced array
  102858. */
  102859. Tools.Slice = function (data, start, end) {
  102860. if (data.slice) {
  102861. return data.slice(start, end);
  102862. }
  102863. return Array.prototype.slice.call(data, start, end);
  102864. };
  102865. /**
  102866. * Polyfill for setImmediate
  102867. * @param action defines the action to execute after the current execution block
  102868. */
  102869. Tools.SetImmediate = function (action) {
  102870. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  102871. window.setImmediate(action);
  102872. }
  102873. else {
  102874. setTimeout(action, 1);
  102875. }
  102876. };
  102877. /**
  102878. * Function indicating if a number is an exponent of 2
  102879. * @param value defines the value to test
  102880. * @returns true if the value is an exponent of 2
  102881. */
  102882. Tools.IsExponentOfTwo = function (value) {
  102883. var count = 1;
  102884. do {
  102885. count *= 2;
  102886. } while (count < value);
  102887. return count === value;
  102888. };
  102889. /**
  102890. * Returns the nearest 32-bit single precision float representation of a Number
  102891. * @param value A Number. If the parameter is of a different type, it will get converted
  102892. * to a number or to NaN if it cannot be converted
  102893. * @returns number
  102894. */
  102895. Tools.FloatRound = function (value) {
  102896. if (Math.fround) {
  102897. return Math.fround(value);
  102898. }
  102899. return (Tools._tmpFloatArray[0] = value);
  102900. };
  102901. /**
  102902. * Find the next highest power of two.
  102903. * @param x Number to start search from.
  102904. * @return Next highest power of two.
  102905. */
  102906. Tools.CeilingPOT = function (x) {
  102907. x--;
  102908. x |= x >> 1;
  102909. x |= x >> 2;
  102910. x |= x >> 4;
  102911. x |= x >> 8;
  102912. x |= x >> 16;
  102913. x++;
  102914. return x;
  102915. };
  102916. /**
  102917. * Find the next lowest power of two.
  102918. * @param x Number to start search from.
  102919. * @return Next lowest power of two.
  102920. */
  102921. Tools.FloorPOT = function (x) {
  102922. x = x | (x >> 1);
  102923. x = x | (x >> 2);
  102924. x = x | (x >> 4);
  102925. x = x | (x >> 8);
  102926. x = x | (x >> 16);
  102927. return x - (x >> 1);
  102928. };
  102929. /**
  102930. * Find the nearest power of two.
  102931. * @param x Number to start search from.
  102932. * @return Next nearest power of two.
  102933. */
  102934. Tools.NearestPOT = function (x) {
  102935. var c = Tools.CeilingPOT(x);
  102936. var f = Tools.FloorPOT(x);
  102937. return (c - x) > (x - f) ? f : c;
  102938. };
  102939. /**
  102940. * Get the closest exponent of two
  102941. * @param value defines the value to approximate
  102942. * @param max defines the maximum value to return
  102943. * @param mode defines how to define the closest value
  102944. * @returns closest exponent of two of the given value
  102945. */
  102946. Tools.GetExponentOfTwo = function (value, max, mode) {
  102947. if (mode === void 0) { mode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST; }
  102948. var pot;
  102949. switch (mode) {
  102950. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_FLOOR:
  102951. pot = Tools.FloorPOT(value);
  102952. break;
  102953. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST:
  102954. pot = Tools.NearestPOT(value);
  102955. break;
  102956. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_CEILING:
  102957. default:
  102958. pot = Tools.CeilingPOT(value);
  102959. break;
  102960. }
  102961. return Math.min(pot, max);
  102962. };
  102963. /**
  102964. * Extracts the filename from a path
  102965. * @param path defines the path to use
  102966. * @returns the filename
  102967. */
  102968. Tools.GetFilename = function (path) {
  102969. var index = path.lastIndexOf("/");
  102970. if (index < 0) {
  102971. return path;
  102972. }
  102973. return path.substring(index + 1);
  102974. };
  102975. /**
  102976. * Extracts the "folder" part of a path (everything before the filename).
  102977. * @param uri The URI to extract the info from
  102978. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  102979. * @returns The "folder" part of the path
  102980. */
  102981. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  102982. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  102983. var index = uri.lastIndexOf("/");
  102984. if (index < 0) {
  102985. if (returnUnchangedIfNoSlash) {
  102986. return uri;
  102987. }
  102988. return "";
  102989. }
  102990. return uri.substring(0, index + 1);
  102991. };
  102992. /**
  102993. * Convert an angle in radians to degrees
  102994. * @param angle defines the angle to convert
  102995. * @returns the angle in degrees
  102996. */
  102997. Tools.ToDegrees = function (angle) {
  102998. return angle * 180 / Math.PI;
  102999. };
  103000. /**
  103001. * Convert an angle in degrees to radians
  103002. * @param angle defines the angle to convert
  103003. * @returns the angle in radians
  103004. */
  103005. Tools.ToRadians = function (angle) {
  103006. return angle * Math.PI / 180;
  103007. };
  103008. /**
  103009. * Encode a buffer to a base64 string
  103010. * @param buffer defines the buffer to encode
  103011. * @returns the encoded string
  103012. */
  103013. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  103014. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  103015. var output = "";
  103016. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  103017. var i = 0;
  103018. var bytes = new Uint8Array(buffer);
  103019. while (i < bytes.length) {
  103020. chr1 = bytes[i++];
  103021. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  103022. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  103023. enc1 = chr1 >> 2;
  103024. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  103025. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  103026. enc4 = chr3 & 63;
  103027. if (isNaN(chr2)) {
  103028. enc3 = enc4 = 64;
  103029. }
  103030. else if (isNaN(chr3)) {
  103031. enc4 = 64;
  103032. }
  103033. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  103034. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  103035. }
  103036. return "data:image/png;base64," + output;
  103037. };
  103038. /**
  103039. * Extracts minimum and maximum values from a list of indexed positions
  103040. * @param positions defines the positions to use
  103041. * @param indices defines the indices to the positions
  103042. * @param indexStart defines the start index
  103043. * @param indexCount defines the end index
  103044. * @param bias defines bias value to add to the result
  103045. * @return minimum and maximum values
  103046. */
  103047. Tools.ExtractMinAndMaxIndexed = function (positions, indices, indexStart, indexCount, bias) {
  103048. if (bias === void 0) { bias = null; }
  103049. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  103050. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  103051. for (var index = indexStart; index < indexStart + indexCount; index++) {
  103052. var offset = indices[index] * 3;
  103053. var x = positions[offset];
  103054. var y = positions[offset + 1];
  103055. var z = positions[offset + 2];
  103056. minimum.minimizeInPlaceFromFloats(x, y, z);
  103057. maximum.maximizeInPlaceFromFloats(x, y, z);
  103058. }
  103059. if (bias) {
  103060. minimum.x -= minimum.x * bias.x + bias.y;
  103061. minimum.y -= minimum.y * bias.x + bias.y;
  103062. minimum.z -= minimum.z * bias.x + bias.y;
  103063. maximum.x += maximum.x * bias.x + bias.y;
  103064. maximum.y += maximum.y * bias.x + bias.y;
  103065. maximum.z += maximum.z * bias.x + bias.y;
  103066. }
  103067. return {
  103068. minimum: minimum,
  103069. maximum: maximum
  103070. };
  103071. };
  103072. /**
  103073. * Extracts minimum and maximum values from a list of positions
  103074. * @param positions defines the positions to use
  103075. * @param start defines the start index in the positions array
  103076. * @param count defines the number of positions to handle
  103077. * @param bias defines bias value to add to the result
  103078. * @param stride defines the stride size to use (distance between two positions in the positions array)
  103079. * @return minimum and maximum values
  103080. */
  103081. Tools.ExtractMinAndMax = function (positions, start, count, bias, stride) {
  103082. if (bias === void 0) { bias = null; }
  103083. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  103084. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  103085. if (!stride) {
  103086. stride = 3;
  103087. }
  103088. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  103089. var x = positions[offset];
  103090. var y = positions[offset + 1];
  103091. var z = positions[offset + 2];
  103092. minimum.minimizeInPlaceFromFloats(x, y, z);
  103093. maximum.maximizeInPlaceFromFloats(x, y, z);
  103094. }
  103095. if (bias) {
  103096. minimum.x -= minimum.x * bias.x + bias.y;
  103097. minimum.y -= minimum.y * bias.x + bias.y;
  103098. minimum.z -= minimum.z * bias.x + bias.y;
  103099. maximum.x += maximum.x * bias.x + bias.y;
  103100. maximum.y += maximum.y * bias.x + bias.y;
  103101. maximum.z += maximum.z * bias.x + bias.y;
  103102. }
  103103. return {
  103104. minimum: minimum,
  103105. maximum: maximum
  103106. };
  103107. };
  103108. /**
  103109. * Returns an array if obj is not an array
  103110. * @param obj defines the object to evaluate as an array
  103111. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  103112. * @returns either obj directly if obj is an array or a new array containing obj
  103113. */
  103114. Tools.MakeArray = function (obj, allowsNullUndefined) {
  103115. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  103116. return null;
  103117. }
  103118. return Array.isArray(obj) ? obj : [obj];
  103119. };
  103120. /**
  103121. * Gets the pointer prefix to use
  103122. * @returns "pointer" if touch is enabled. Else returns "mouse"
  103123. */
  103124. Tools.GetPointerPrefix = function () {
  103125. var eventPrefix = "pointer";
  103126. // Check if pointer events are supported
  103127. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  103128. eventPrefix = "mouse";
  103129. }
  103130. return eventPrefix;
  103131. };
  103132. /**
  103133. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  103134. * @param func - the function to be called
  103135. * @param requester - the object that will request the next frame. Falls back to window.
  103136. * @returns frame number
  103137. */
  103138. Tools.QueueNewFrame = function (func, requester) {
  103139. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  103140. return setTimeout(func, 16);
  103141. }
  103142. if (!requester) {
  103143. requester = window;
  103144. }
  103145. if (requester.requestAnimationFrame) {
  103146. return requester.requestAnimationFrame(func);
  103147. }
  103148. else if (requester.msRequestAnimationFrame) {
  103149. return requester.msRequestAnimationFrame(func);
  103150. }
  103151. else if (requester.webkitRequestAnimationFrame) {
  103152. return requester.webkitRequestAnimationFrame(func);
  103153. }
  103154. else if (requester.mozRequestAnimationFrame) {
  103155. return requester.mozRequestAnimationFrame(func);
  103156. }
  103157. else if (requester.oRequestAnimationFrame) {
  103158. return requester.oRequestAnimationFrame(func);
  103159. }
  103160. else {
  103161. return window.setTimeout(func, 16);
  103162. }
  103163. };
  103164. /**
  103165. * Ask the browser to promote the current element to fullscreen rendering mode
  103166. * @param element defines the DOM element to promote
  103167. */
  103168. Tools.RequestFullscreen = function (element) {
  103169. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  103170. if (!requestFunction) {
  103171. return;
  103172. }
  103173. requestFunction.call(element);
  103174. };
  103175. /**
  103176. * Asks the browser to exit fullscreen mode
  103177. */
  103178. Tools.ExitFullscreen = function () {
  103179. var anyDoc = document;
  103180. if (document.exitFullscreen) {
  103181. document.exitFullscreen();
  103182. }
  103183. else if (anyDoc.mozCancelFullScreen) {
  103184. anyDoc.mozCancelFullScreen();
  103185. }
  103186. else if (anyDoc.webkitCancelFullScreen) {
  103187. anyDoc.webkitCancelFullScreen();
  103188. }
  103189. else if (anyDoc.msCancelFullScreen) {
  103190. anyDoc.msCancelFullScreen();
  103191. }
  103192. };
  103193. /**
  103194. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  103195. * @param url define the url we are trying
  103196. * @param element define the dom element where to configure the cors policy
  103197. */
  103198. Tools.SetCorsBehavior = function (url, element) {
  103199. if (url && url.indexOf("data:") === 0) {
  103200. return;
  103201. }
  103202. if (Tools.CorsBehavior) {
  103203. if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
  103204. element.crossOrigin = Tools.CorsBehavior;
  103205. }
  103206. else {
  103207. var result = Tools.CorsBehavior(url);
  103208. if (result) {
  103209. element.crossOrigin = result;
  103210. }
  103211. }
  103212. }
  103213. };
  103214. // External files
  103215. /**
  103216. * Removes unwanted characters from an url
  103217. * @param url defines the url to clean
  103218. * @returns the cleaned url
  103219. */
  103220. Tools.CleanUrl = function (url) {
  103221. url = url.replace(/#/mg, "%23");
  103222. return url;
  103223. };
  103224. /**
  103225. * Loads an image as an HTMLImageElement.
  103226. * @param input url string, ArrayBuffer, or Blob to load
  103227. * @param onLoad callback called when the image successfully loads
  103228. * @param onError callback called when the image fails to load
  103229. * @param offlineProvider offline provider for caching
  103230. * @returns the HTMLImageElement of the loaded image
  103231. */
  103232. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  103233. var url;
  103234. var usingObjectURL = false;
  103235. if (input instanceof ArrayBuffer) {
  103236. url = URL.createObjectURL(new Blob([input]));
  103237. usingObjectURL = true;
  103238. }
  103239. else if (input instanceof Blob) {
  103240. url = URL.createObjectURL(input);
  103241. usingObjectURL = true;
  103242. }
  103243. else {
  103244. url = Tools.CleanUrl(input);
  103245. url = Tools.PreprocessUrl(input);
  103246. }
  103247. var img = new Image();
  103248. Tools.SetCorsBehavior(url, img);
  103249. var loadHandler = function () {
  103250. img.removeEventListener("load", loadHandler);
  103251. img.removeEventListener("error", errorHandler);
  103252. onLoad(img);
  103253. // Must revoke the URL after calling onLoad to avoid security exceptions in
  103254. // certain scenarios (e.g. when hosted in vscode).
  103255. if (usingObjectURL && img.src) {
  103256. URL.revokeObjectURL(img.src);
  103257. }
  103258. };
  103259. var errorHandler = function (err) {
  103260. img.removeEventListener("load", loadHandler);
  103261. img.removeEventListener("error", errorHandler);
  103262. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error while trying to load image: " + input);
  103263. if (onError) {
  103264. onError("Error while trying to load image: " + input, err);
  103265. }
  103266. if (usingObjectURL && img.src) {
  103267. URL.revokeObjectURL(img.src);
  103268. }
  103269. };
  103270. img.addEventListener("load", loadHandler);
  103271. img.addEventListener("error", errorHandler);
  103272. var noOfflineSupport = function () {
  103273. img.src = url;
  103274. };
  103275. var loadFromOfflineSupport = function () {
  103276. if (offlineProvider) {
  103277. offlineProvider.loadImage(url, img);
  103278. }
  103279. };
  103280. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  103281. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  103282. }
  103283. else {
  103284. if (url.indexOf("file:") !== -1) {
  103285. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  103286. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  103287. try {
  103288. var blobURL;
  103289. try {
  103290. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  103291. }
  103292. catch (ex) {
  103293. // Chrome doesn't support oneTimeOnly parameter
  103294. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  103295. }
  103296. img.src = blobURL;
  103297. usingObjectURL = true;
  103298. }
  103299. catch (e) {
  103300. img.src = "";
  103301. }
  103302. return img;
  103303. }
  103304. }
  103305. noOfflineSupport();
  103306. }
  103307. return img;
  103308. };
  103309. /**
  103310. * Loads a file
  103311. * @param url url string, ArrayBuffer, or Blob to load
  103312. * @param onSuccess callback called when the file successfully loads
  103313. * @param onProgress callback called while file is loading (if the server supports this mode)
  103314. * @param offlineProvider defines the offline provider for caching
  103315. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  103316. * @param onError callback called when the file fails to load
  103317. * @returns a file request object
  103318. */
  103319. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  103320. url = Tools.CleanUrl(url);
  103321. url = Tools.PreprocessUrl(url);
  103322. // If file and file input are set
  103323. if (url.indexOf("file:") !== -1) {
  103324. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  103325. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  103326. return Tools.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  103327. }
  103328. }
  103329. var loadUrl = Tools.BaseUrl + url;
  103330. var aborted = false;
  103331. var fileRequest = {
  103332. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  103333. abort: function () { return aborted = true; },
  103334. };
  103335. var requestFile = function () {
  103336. var request = new _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"]();
  103337. var retryHandle = null;
  103338. fileRequest.abort = function () {
  103339. aborted = true;
  103340. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  103341. request.abort();
  103342. }
  103343. if (retryHandle !== null) {
  103344. clearTimeout(retryHandle);
  103345. retryHandle = null;
  103346. }
  103347. };
  103348. var retryLoop = function (retryIndex) {
  103349. request.open('GET', loadUrl);
  103350. if (useArrayBuffer) {
  103351. request.responseType = "arraybuffer";
  103352. }
  103353. if (onProgress) {
  103354. request.addEventListener("progress", onProgress);
  103355. }
  103356. var onLoadEnd = function () {
  103357. request.removeEventListener("loadend", onLoadEnd);
  103358. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  103359. fileRequest.onCompleteObservable.clear();
  103360. };
  103361. request.addEventListener("loadend", onLoadEnd);
  103362. var onReadyStateChange = function () {
  103363. if (aborted) {
  103364. return;
  103365. }
  103366. // In case of undefined state in some browsers.
  103367. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  103368. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  103369. request.removeEventListener("readystatechange", onReadyStateChange);
  103370. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() || Tools.IsFileURL()))) {
  103371. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  103372. return;
  103373. }
  103374. var retryStrategy = Tools.DefaultRetryStrategy;
  103375. if (retryStrategy) {
  103376. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  103377. if (waitTime !== -1) {
  103378. // Prevent the request from completing for retry.
  103379. request.removeEventListener("loadend", onLoadEnd);
  103380. request = new _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"]();
  103381. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  103382. return;
  103383. }
  103384. }
  103385. var e = new LoadFileError("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  103386. if (onError) {
  103387. onError(request, e);
  103388. }
  103389. else {
  103390. throw e;
  103391. }
  103392. }
  103393. };
  103394. request.addEventListener("readystatechange", onReadyStateChange);
  103395. request.send();
  103396. };
  103397. retryLoop(0);
  103398. };
  103399. // Caching all files
  103400. if (offlineProvider && offlineProvider.enableSceneOffline) {
  103401. var noOfflineSupport_1 = function (request) {
  103402. if (request && request.status > 400) {
  103403. if (onError) {
  103404. onError(request);
  103405. }
  103406. }
  103407. else {
  103408. if (!aborted) {
  103409. requestFile();
  103410. }
  103411. }
  103412. };
  103413. var loadFromOfflineSupport = function () {
  103414. // TODO: database needs to support aborting and should return a IFileRequest
  103415. if (aborted) {
  103416. return;
  103417. }
  103418. if (offlineProvider) {
  103419. offlineProvider.loadFile(url, function (data) {
  103420. if (!aborted) {
  103421. onSuccess(data);
  103422. }
  103423. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  103424. }, onProgress ? function (event) {
  103425. if (!aborted) {
  103426. onProgress(event);
  103427. }
  103428. } : undefined, noOfflineSupport_1, useArrayBuffer);
  103429. }
  103430. };
  103431. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  103432. }
  103433. else {
  103434. requestFile();
  103435. }
  103436. return fileRequest;
  103437. };
  103438. /**
  103439. * Load a script (identified by an url). When the url returns, the
  103440. * content of this file is added into a new script element, attached to the DOM (body element)
  103441. * @param scriptUrl defines the url of the script to laod
  103442. * @param onSuccess defines the callback called when the script is loaded
  103443. * @param onError defines the callback to call if an error occurs
  103444. * @param scriptId defines the id of the script element
  103445. */
  103446. Tools.LoadScript = function (scriptUrl, onSuccess, onError, scriptId) {
  103447. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  103448. return;
  103449. }
  103450. var head = document.getElementsByTagName('head')[0];
  103451. var script = document.createElement('script');
  103452. script.setAttribute('type', 'text/javascript');
  103453. script.setAttribute('src', scriptUrl);
  103454. if (scriptId) {
  103455. script.id = scriptId;
  103456. }
  103457. script.onload = function () {
  103458. if (onSuccess) {
  103459. onSuccess();
  103460. }
  103461. };
  103462. script.onerror = function (e) {
  103463. if (onError) {
  103464. onError("Unable to load script '" + scriptUrl + "'", e);
  103465. }
  103466. };
  103467. head.appendChild(script);
  103468. };
  103469. /**
  103470. * Load an asynchronous script (identified by an url). When the url returns, the
  103471. * content of this file is added into a new script element, attached to the DOM (body element)
  103472. * @param scriptUrl defines the url of the script to laod
  103473. * @param scriptId defines the id of the script element
  103474. * @returns a promise request object
  103475. */
  103476. Tools.LoadScriptAsync = function (scriptUrl, scriptId) {
  103477. return new Promise(function (resolve, reject) {
  103478. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  103479. resolve(false);
  103480. return;
  103481. }
  103482. var head = document.getElementsByTagName('head')[0];
  103483. var script = document.createElement('script');
  103484. script.setAttribute('type', 'text/javascript');
  103485. script.setAttribute('src', scriptUrl);
  103486. if (scriptId) {
  103487. script.id = scriptId;
  103488. }
  103489. script.onload = function () {
  103490. resolve(true);
  103491. };
  103492. script.onerror = function (e) {
  103493. resolve(false);
  103494. };
  103495. head.appendChild(script);
  103496. });
  103497. };
  103498. /**
  103499. * Loads a file from a blob
  103500. * @param fileToLoad defines the blob to use
  103501. * @param callback defines the callback to call when data is loaded
  103502. * @param progressCallback defines the callback to call during loading process
  103503. * @returns a file request object
  103504. */
  103505. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  103506. var reader = new FileReader();
  103507. var request = {
  103508. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  103509. abort: function () { return reader.abort(); },
  103510. };
  103511. reader.onloadend = function (e) {
  103512. request.onCompleteObservable.notifyObservers(request);
  103513. };
  103514. reader.onload = function (e) {
  103515. //target doesn't have result from ts 1.3
  103516. callback(e.target['result']);
  103517. };
  103518. reader.onprogress = progressCallback;
  103519. reader.readAsDataURL(fileToLoad);
  103520. return request;
  103521. };
  103522. /**
  103523. * Loads a file
  103524. * @param fileToLoad defines the file to load
  103525. * @param callback defines the callback to call when data is loaded
  103526. * @param progressCallBack defines the callback to call during loading process
  103527. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  103528. * @returns a file request object
  103529. */
  103530. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  103531. var reader = new FileReader();
  103532. var request = {
  103533. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  103534. abort: function () { return reader.abort(); },
  103535. };
  103536. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  103537. reader.onerror = function (e) {
  103538. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log("Error while reading file: " + fileToLoad.name);
  103539. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  103540. };
  103541. reader.onload = function (e) {
  103542. //target doesn't have result from ts 1.3
  103543. callback(e.target['result']);
  103544. };
  103545. if (progressCallBack) {
  103546. reader.onprogress = progressCallBack;
  103547. }
  103548. if (!useArrayBuffer) {
  103549. // Asynchronous read
  103550. reader.readAsText(fileToLoad);
  103551. }
  103552. else {
  103553. reader.readAsArrayBuffer(fileToLoad);
  103554. }
  103555. return request;
  103556. };
  103557. /**
  103558. * Creates a data url from a given string content
  103559. * @param content defines the content to convert
  103560. * @returns the new data url link
  103561. */
  103562. Tools.FileAsURL = function (content) {
  103563. var fileBlob = new Blob([content]);
  103564. var url = window.URL || window.webkitURL;
  103565. var link = url.createObjectURL(fileBlob);
  103566. return link;
  103567. };
  103568. /**
  103569. * Format the given number to a specific decimal format
  103570. * @param value defines the number to format
  103571. * @param decimals defines the number of decimals to use
  103572. * @returns the formatted string
  103573. */
  103574. Tools.Format = function (value, decimals) {
  103575. if (decimals === void 0) { decimals = 2; }
  103576. return value.toFixed(decimals);
  103577. };
  103578. /**
  103579. * Checks if a given vector is inside a specific range
  103580. * @param v defines the vector to test
  103581. * @param min defines the minimum range
  103582. * @param max defines the maximum range
  103583. */
  103584. Tools.CheckExtends = function (v, min, max) {
  103585. min.minimizeInPlace(v);
  103586. max.maximizeInPlace(v);
  103587. };
  103588. /**
  103589. * Tries to copy an object by duplicating every property
  103590. * @param source defines the source object
  103591. * @param destination defines the target object
  103592. * @param doNotCopyList defines a list of properties to avoid
  103593. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  103594. */
  103595. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  103596. _deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  103597. };
  103598. /**
  103599. * Gets a boolean indicating if the given object has no own property
  103600. * @param obj defines the object to test
  103601. * @returns true if object has no own property
  103602. */
  103603. Tools.IsEmpty = function (obj) {
  103604. for (var i in obj) {
  103605. if (obj.hasOwnProperty(i)) {
  103606. return false;
  103607. }
  103608. }
  103609. return true;
  103610. };
  103611. /**
  103612. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  103613. * @param str Source string
  103614. * @param suffix Suffix to search for in the source string
  103615. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  103616. */
  103617. Tools.EndsWith = function (str, suffix) {
  103618. return str.indexOf(suffix, str.length - suffix.length) !== -1;
  103619. };
  103620. /**
  103621. * Function used to register events at window level
  103622. * @param events defines the events to register
  103623. */
  103624. Tools.RegisterTopRootEvents = function (events) {
  103625. for (var index = 0; index < events.length; index++) {
  103626. var event = events[index];
  103627. window.addEventListener(event.name, event.handler, false);
  103628. try {
  103629. if (window.parent) {
  103630. window.parent.addEventListener(event.name, event.handler, false);
  103631. }
  103632. }
  103633. catch (e) {
  103634. // Silently fails...
  103635. }
  103636. }
  103637. };
  103638. /**
  103639. * Function used to unregister events from window level
  103640. * @param events defines the events to unregister
  103641. */
  103642. Tools.UnregisterTopRootEvents = function (events) {
  103643. for (var index = 0; index < events.length; index++) {
  103644. var event = events[index];
  103645. window.removeEventListener(event.name, event.handler);
  103646. try {
  103647. if (window.parent) {
  103648. window.parent.removeEventListener(event.name, event.handler);
  103649. }
  103650. }
  103651. catch (e) {
  103652. // Silently fails...
  103653. }
  103654. }
  103655. };
  103656. /**
  103657. * Dumps the current bound framebuffer
  103658. * @param width defines the rendering width
  103659. * @param height defines the rendering height
  103660. * @param engine defines the hosting engine
  103661. * @param successCallback defines the callback triggered once the data are available
  103662. * @param mimeType defines the mime type of the result
  103663. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  103664. */
  103665. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  103666. if (mimeType === void 0) { mimeType = "image/png"; }
  103667. // Read the contents of the framebuffer
  103668. var numberOfChannelsByLine = width * 4;
  103669. var halfHeight = height / 2;
  103670. //Reading datas from WebGL
  103671. var data = engine.readPixels(0, 0, width, height);
  103672. //To flip image on Y axis.
  103673. for (var i = 0; i < halfHeight; i++) {
  103674. for (var j = 0; j < numberOfChannelsByLine; j++) {
  103675. var currentCell = j + i * numberOfChannelsByLine;
  103676. var targetLine = height - i - 1;
  103677. var targetCell = j + targetLine * numberOfChannelsByLine;
  103678. var temp = data[currentCell];
  103679. data[currentCell] = data[targetCell];
  103680. data[targetCell] = temp;
  103681. }
  103682. }
  103683. // Create a 2D canvas to store the result
  103684. if (!Tools._ScreenshotCanvas) {
  103685. Tools._ScreenshotCanvas = document.createElement('canvas');
  103686. }
  103687. Tools._ScreenshotCanvas.width = width;
  103688. Tools._ScreenshotCanvas.height = height;
  103689. var context = Tools._ScreenshotCanvas.getContext('2d');
  103690. if (context) {
  103691. // Copy the pixels to a 2D canvas
  103692. var imageData = context.createImageData(width, height);
  103693. var castData = (imageData.data);
  103694. castData.set(data);
  103695. context.putImageData(imageData, 0, 0);
  103696. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  103697. }
  103698. };
  103699. /**
  103700. * Converts the canvas data to blob.
  103701. * This acts as a polyfill for browsers not supporting the to blob function.
  103702. * @param canvas Defines the canvas to extract the data from
  103703. * @param successCallback Defines the callback triggered once the data are available
  103704. * @param mimeType Defines the mime type of the result
  103705. */
  103706. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  103707. if (mimeType === void 0) { mimeType = "image/png"; }
  103708. // We need HTMLCanvasElement.toBlob for HD screenshots
  103709. if (!canvas.toBlob) {
  103710. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  103711. canvas.toBlob = function (callback, type, quality) {
  103712. var _this = this;
  103713. setTimeout(function () {
  103714. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  103715. for (var i = 0; i < len; i++) {
  103716. arr[i] = binStr.charCodeAt(i);
  103717. }
  103718. callback(new Blob([arr]));
  103719. });
  103720. };
  103721. }
  103722. canvas.toBlob(function (blob) {
  103723. successCallback(blob);
  103724. }, mimeType);
  103725. };
  103726. /**
  103727. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  103728. * @param successCallback defines the callback triggered once the data are available
  103729. * @param mimeType defines the mime type of the result
  103730. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  103731. */
  103732. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  103733. if (mimeType === void 0) { mimeType = "image/png"; }
  103734. if (successCallback) {
  103735. var base64Image = Tools._ScreenshotCanvas.toDataURL(mimeType);
  103736. successCallback(base64Image);
  103737. }
  103738. else {
  103739. this.ToBlob(Tools._ScreenshotCanvas, function (blob) {
  103740. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  103741. if (("download" in document.createElement("a"))) {
  103742. if (!fileName) {
  103743. var date = new Date();
  103744. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  103745. fileName = "screenshot_" + stringDate + ".png";
  103746. }
  103747. Tools.Download(blob, fileName);
  103748. }
  103749. else {
  103750. var url = URL.createObjectURL(blob);
  103751. var newWindow = window.open("");
  103752. if (!newWindow) {
  103753. return;
  103754. }
  103755. var img = newWindow.document.createElement("img");
  103756. img.onload = function () {
  103757. // no longer need to read the blob so it's revoked
  103758. URL.revokeObjectURL(url);
  103759. };
  103760. img.src = url;
  103761. newWindow.document.body.appendChild(img);
  103762. }
  103763. }, mimeType);
  103764. }
  103765. };
  103766. /**
  103767. * Downloads a blob in the browser
  103768. * @param blob defines the blob to download
  103769. * @param fileName defines the name of the downloaded file
  103770. */
  103771. Tools.Download = function (blob, fileName) {
  103772. if (navigator && navigator.msSaveBlob) {
  103773. navigator.msSaveBlob(blob, fileName);
  103774. return;
  103775. }
  103776. var url = window.URL.createObjectURL(blob);
  103777. var a = document.createElement("a");
  103778. document.body.appendChild(a);
  103779. a.style.display = "none";
  103780. a.href = url;
  103781. a.download = fileName;
  103782. a.addEventListener("click", function () {
  103783. if (a.parentElement) {
  103784. a.parentElement.removeChild(a);
  103785. }
  103786. });
  103787. a.click();
  103788. window.URL.revokeObjectURL(url);
  103789. };
  103790. /**
  103791. * Captures a screenshot of the current rendering
  103792. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103793. * @param engine defines the rendering engine
  103794. * @param camera defines the source camera
  103795. * @param size This parameter can be set to a single number or to an object with the
  103796. * following (optional) properties: precision, width, height. If a single number is passed,
  103797. * it will be used for both width and height. If an object is passed, the screenshot size
  103798. * will be derived from the parameters. The precision property is a multiplier allowing
  103799. * rendering at a higher or lower resolution
  103800. * @param successCallback defines the callback receives a single parameter which contains the
  103801. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  103802. * src parameter of an <img> to display it
  103803. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  103804. * Check your browser for supported MIME types
  103805. */
  103806. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  103807. if (mimeType === void 0) { mimeType = "image/png"; }
  103808. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  103809. };
  103810. /**
  103811. * Generates an image screenshot from the specified camera.
  103812. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  103813. * @param engine The engine to use for rendering
  103814. * @param camera The camera to use for rendering
  103815. * @param size This parameter can be set to a single number or to an object with the
  103816. * following (optional) properties: precision, width, height. If a single number is passed,
  103817. * it will be used for both width and height. If an object is passed, the screenshot size
  103818. * will be derived from the parameters. The precision property is a multiplier allowing
  103819. * rendering at a higher or lower resolution
  103820. * @param successCallback The callback receives a single parameter which contains the
  103821. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  103822. * src parameter of an <img> to display it
  103823. * @param mimeType The MIME type of the screenshot image (default: image/png).
  103824. * Check your browser for supported MIME types
  103825. * @param samples Texture samples (default: 1)
  103826. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  103827. * @param fileName A name for for the downloaded file.
  103828. */
  103829. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  103830. if (mimeType === void 0) { mimeType = "image/png"; }
  103831. if (samples === void 0) { samples = 1; }
  103832. if (antialiasing === void 0) { antialiasing = false; }
  103833. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  103834. };
  103835. /**
  103836. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103837. * Be aware Math.random() could cause collisions, but:
  103838. * "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"
  103839. * @returns a pseudo random id
  103840. */
  103841. Tools.RandomId = function () {
  103842. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  103843. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  103844. return v.toString(16);
  103845. });
  103846. };
  103847. /**
  103848. * Test if the given uri is a base64 string
  103849. * @param uri The uri to test
  103850. * @return True if the uri is a base64 string or false otherwise
  103851. */
  103852. Tools.IsBase64 = function (uri) {
  103853. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  103854. };
  103855. /**
  103856. * Decode the given base64 uri.
  103857. * @param uri The uri to decode
  103858. * @return The decoded base64 data.
  103859. */
  103860. Tools.DecodeBase64 = function (uri) {
  103861. var decodedString = atob(uri.split(",")[1]);
  103862. var bufferLength = decodedString.length;
  103863. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  103864. for (var i = 0; i < bufferLength; i++) {
  103865. bufferView[i] = decodedString.charCodeAt(i);
  103866. }
  103867. return bufferView.buffer;
  103868. };
  103869. /**
  103870. * Gets the absolute url.
  103871. * @param url the input url
  103872. * @return the absolute url
  103873. */
  103874. Tools.GetAbsoluteUrl = function (url) {
  103875. var a = document.createElement("a");
  103876. a.href = url;
  103877. return a.href;
  103878. };
  103879. Object.defineProperty(Tools, "errorsCount", {
  103880. /**
  103881. * Gets a value indicating the number of loading errors
  103882. * @ignorenaming
  103883. */
  103884. get: function () {
  103885. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].errorsCount;
  103886. },
  103887. enumerable: true,
  103888. configurable: true
  103889. });
  103890. /**
  103891. * Log a message to the console
  103892. * @param message defines the message to log
  103893. */
  103894. Tools.Log = function (message) {
  103895. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log(message);
  103896. };
  103897. /**
  103898. * Write a warning message to the console
  103899. * @param message defines the message to log
  103900. */
  103901. Tools.Warn = function (message) {
  103902. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(message);
  103903. };
  103904. /**
  103905. * Write an error message to the console
  103906. * @param message defines the message to log
  103907. */
  103908. Tools.Error = function (message) {
  103909. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error(message);
  103910. };
  103911. Object.defineProperty(Tools, "LogCache", {
  103912. /**
  103913. * Gets current log cache (list of logs)
  103914. */
  103915. get: function () {
  103916. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogCache;
  103917. },
  103918. enumerable: true,
  103919. configurable: true
  103920. });
  103921. /**
  103922. * Clears the log cache
  103923. */
  103924. Tools.ClearLogCache = function () {
  103925. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ClearLogCache();
  103926. };
  103927. Object.defineProperty(Tools, "LogLevels", {
  103928. /**
  103929. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  103930. */
  103931. set: function (level) {
  103932. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogLevels = level;
  103933. },
  103934. enumerable: true,
  103935. configurable: true
  103936. });
  103937. /**
  103938. * Checks if the loaded document was accessed via `file:`-Protocol.
  103939. * @returns boolean
  103940. */
  103941. Tools.IsFileURL = function () {
  103942. return location.protocol === "file:";
  103943. };
  103944. Object.defineProperty(Tools, "PerformanceLogLevel", {
  103945. /**
  103946. * Sets the current performance log level
  103947. */
  103948. set: function (level) {
  103949. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  103950. Tools.StartPerformanceCounter = Tools._StartUserMark;
  103951. Tools.EndPerformanceCounter = Tools._EndUserMark;
  103952. return;
  103953. }
  103954. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  103955. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  103956. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  103957. return;
  103958. }
  103959. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  103960. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  103961. },
  103962. enumerable: true,
  103963. configurable: true
  103964. });
  103965. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  103966. };
  103967. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  103968. };
  103969. Tools._StartUserMark = function (counterName, condition) {
  103970. if (condition === void 0) { condition = true; }
  103971. if (!Tools._performance) {
  103972. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  103973. return;
  103974. }
  103975. Tools._performance = window.performance;
  103976. }
  103977. if (!condition || !Tools._performance.mark) {
  103978. return;
  103979. }
  103980. Tools._performance.mark(counterName + "-Begin");
  103981. };
  103982. Tools._EndUserMark = function (counterName, condition) {
  103983. if (condition === void 0) { condition = true; }
  103984. if (!condition || !Tools._performance.mark) {
  103985. return;
  103986. }
  103987. Tools._performance.mark(counterName + "-End");
  103988. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  103989. };
  103990. Tools._StartPerformanceConsole = function (counterName, condition) {
  103991. if (condition === void 0) { condition = true; }
  103992. if (!condition) {
  103993. return;
  103994. }
  103995. Tools._StartUserMark(counterName, condition);
  103996. if (console.time) {
  103997. console.time(counterName);
  103998. }
  103999. };
  104000. Tools._EndPerformanceConsole = function (counterName, condition) {
  104001. if (condition === void 0) { condition = true; }
  104002. if (!condition) {
  104003. return;
  104004. }
  104005. Tools._EndUserMark(counterName, condition);
  104006. if (console.time) {
  104007. console.timeEnd(counterName);
  104008. }
  104009. };
  104010. Object.defineProperty(Tools, "Now", {
  104011. /**
  104012. * Gets either window.performance.now() if supported or Date.now() else
  104013. */
  104014. get: function () {
  104015. return _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  104016. },
  104017. enumerable: true,
  104018. configurable: true
  104019. });
  104020. /**
  104021. * This method will return the name of the class used to create the instance of the given object.
  104022. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  104023. * @param object the object to get the class name from
  104024. * @param isType defines if the object is actually a type
  104025. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  104026. */
  104027. Tools.GetClassName = function (object, isType) {
  104028. if (isType === void 0) { isType = false; }
  104029. var name = null;
  104030. if (!isType && object.getClassName) {
  104031. name = object.getClassName();
  104032. }
  104033. else {
  104034. if (object instanceof Object) {
  104035. var classObj = isType ? object : Object.getPrototypeOf(object);
  104036. name = classObj.constructor["__bjsclassName__"];
  104037. }
  104038. if (!name) {
  104039. name = typeof object;
  104040. }
  104041. }
  104042. return name;
  104043. };
  104044. /**
  104045. * Gets the first element of an array satisfying a given predicate
  104046. * @param array defines the array to browse
  104047. * @param predicate defines the predicate to use
  104048. * @returns null if not found or the element
  104049. */
  104050. Tools.First = function (array, predicate) {
  104051. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  104052. var el = array_1[_i];
  104053. if (predicate(el)) {
  104054. return el;
  104055. }
  104056. }
  104057. return null;
  104058. };
  104059. /**
  104060. * This method will return the name of the full name of the class, including its owning module (if any).
  104061. * 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).
  104062. * @param object the object to get the class name from
  104063. * @param isType defines if the object is actually a type
  104064. * @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.
  104065. * @ignorenaming
  104066. */
  104067. Tools.getFullClassName = function (object, isType) {
  104068. if (isType === void 0) { isType = false; }
  104069. var className = null;
  104070. var moduleName = null;
  104071. if (!isType && object.getClassName) {
  104072. className = object.getClassName();
  104073. }
  104074. else {
  104075. if (object instanceof Object) {
  104076. var classObj = isType ? object : Object.getPrototypeOf(object);
  104077. className = classObj.constructor["__bjsclassName__"];
  104078. moduleName = classObj.constructor["__bjsmoduleName__"];
  104079. }
  104080. if (!className) {
  104081. className = typeof object;
  104082. }
  104083. }
  104084. if (!className) {
  104085. return null;
  104086. }
  104087. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  104088. };
  104089. /**
  104090. * Returns a promise that resolves after the given amount of time.
  104091. * @param delay Number of milliseconds to delay
  104092. * @returns Promise that resolves after the given amount of time
  104093. */
  104094. Tools.DelayAsync = function (delay) {
  104095. return new Promise(function (resolve) {
  104096. setTimeout(function () {
  104097. resolve();
  104098. }, delay);
  104099. });
  104100. };
  104101. /**
  104102. * Gets the current gradient from an array of IValueGradient
  104103. * @param ratio defines the current ratio to get
  104104. * @param gradients defines the array of IValueGradient
  104105. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  104106. */
  104107. Tools.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  104108. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  104109. var currentGradient = gradients[gradientIndex];
  104110. var nextGradient = gradients[gradientIndex + 1];
  104111. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  104112. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  104113. updateFunc(currentGradient, nextGradient, scale);
  104114. return;
  104115. }
  104116. }
  104117. // Use last index if over
  104118. var lastIndex = gradients.length - 1;
  104119. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  104120. };
  104121. /**
  104122. * Gets or sets the base URL to use to load assets
  104123. */
  104124. Tools.BaseUrl = "";
  104125. /**
  104126. * Enable/Disable Custom HTTP Request Headers globally.
  104127. * default = false
  104128. * @see CustomRequestHeaders
  104129. */
  104130. Tools.UseCustomRequestHeaders = false;
  104131. /**
  104132. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  104133. * i.e. when loading files, where the server/service expects an Authorization header
  104134. */
  104135. Tools.CustomRequestHeaders = _webRequest__WEBPACK_IMPORTED_MODULE_12__["WebRequest"].CustomRequestHeaders;
  104136. /**
  104137. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  104138. */
  104139. Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
  104140. /**
  104141. * Default behaviour for cors in the application.
  104142. * It can be a string if the expected behavior is identical in the entire app.
  104143. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  104144. */
  104145. Tools.CorsBehavior = "anonymous";
  104146. /**
  104147. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  104148. * @ignorenaming
  104149. */
  104150. Tools.UseFallbackTexture = true;
  104151. /**
  104152. * Use this object to register external classes like custom textures or material
  104153. * to allow the laoders to instantiate them
  104154. */
  104155. Tools.RegisteredExternalClasses = {};
  104156. /**
  104157. * Texture content used if a texture cannot loaded
  104158. * @ignorenaming
  104159. */
  104160. 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";
  104161. Tools._tmpFloatArray = new Float32Array(1);
  104162. /**
  104163. * Extracts text content from a DOM element hierarchy
  104164. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  104165. */
  104166. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].GetDOMTextContent;
  104167. /**
  104168. * Gets or sets a function used to pre-process url before using them to load assets
  104169. */
  104170. Tools.PreprocessUrl = function (url) {
  104171. return url;
  104172. };
  104173. // Logs
  104174. /**
  104175. * No log
  104176. */
  104177. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].NoneLogLevel;
  104178. /**
  104179. * Only message logs
  104180. */
  104181. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].MessageLogLevel;
  104182. /**
  104183. * Only warning logs
  104184. */
  104185. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].WarningLogLevel;
  104186. /**
  104187. * Only error logs
  104188. */
  104189. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ErrorLogLevel;
  104190. /**
  104191. * All logs
  104192. */
  104193. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].AllLogLevel;
  104194. /**
  104195. * Checks if the window object exists
  104196. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  104197. */
  104198. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist;
  104199. // Performances
  104200. /**
  104201. * No performance log
  104202. */
  104203. Tools.PerformanceNoneLogLevel = 0;
  104204. /**
  104205. * Use user marks to log performance
  104206. */
  104207. Tools.PerformanceUserMarkLogLevel = 1;
  104208. /**
  104209. * Log performance to the console
  104210. */
  104211. Tools.PerformanceConsoleLogLevel = 2;
  104212. /**
  104213. * Starts a performance counter
  104214. */
  104215. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  104216. /**
  104217. * Ends a specific performance coutner
  104218. */
  104219. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  104220. return Tools;
  104221. }());
  104222. /**
  104223. * This class is used to track a performance counter which is number based.
  104224. * The user has access to many properties which give statistics of different nature.
  104225. *
  104226. * The implementer can track two kinds of Performance Counter: time and count.
  104227. * 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.
  104228. * 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.
  104229. */
  104230. var PerfCounter = /** @class */ (function () {
  104231. /**
  104232. * Creates a new counter
  104233. */
  104234. function PerfCounter() {
  104235. this._startMonitoringTime = 0;
  104236. this._min = 0;
  104237. this._max = 0;
  104238. this._average = 0;
  104239. this._lastSecAverage = 0;
  104240. this._current = 0;
  104241. this._totalValueCount = 0;
  104242. this._totalAccumulated = 0;
  104243. this._lastSecAccumulated = 0;
  104244. this._lastSecTime = 0;
  104245. this._lastSecValueCount = 0;
  104246. }
  104247. Object.defineProperty(PerfCounter.prototype, "min", {
  104248. /**
  104249. * Returns the smallest value ever
  104250. */
  104251. get: function () {
  104252. return this._min;
  104253. },
  104254. enumerable: true,
  104255. configurable: true
  104256. });
  104257. Object.defineProperty(PerfCounter.prototype, "max", {
  104258. /**
  104259. * Returns the biggest value ever
  104260. */
  104261. get: function () {
  104262. return this._max;
  104263. },
  104264. enumerable: true,
  104265. configurable: true
  104266. });
  104267. Object.defineProperty(PerfCounter.prototype, "average", {
  104268. /**
  104269. * Returns the average value since the performance counter is running
  104270. */
  104271. get: function () {
  104272. return this._average;
  104273. },
  104274. enumerable: true,
  104275. configurable: true
  104276. });
  104277. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  104278. /**
  104279. * Returns the average value of the last second the counter was monitored
  104280. */
  104281. get: function () {
  104282. return this._lastSecAverage;
  104283. },
  104284. enumerable: true,
  104285. configurable: true
  104286. });
  104287. Object.defineProperty(PerfCounter.prototype, "current", {
  104288. /**
  104289. * Returns the current value
  104290. */
  104291. get: function () {
  104292. return this._current;
  104293. },
  104294. enumerable: true,
  104295. configurable: true
  104296. });
  104297. Object.defineProperty(PerfCounter.prototype, "total", {
  104298. /**
  104299. * Gets the accumulated total
  104300. */
  104301. get: function () {
  104302. return this._totalAccumulated;
  104303. },
  104304. enumerable: true,
  104305. configurable: true
  104306. });
  104307. Object.defineProperty(PerfCounter.prototype, "count", {
  104308. /**
  104309. * Gets the total value count
  104310. */
  104311. get: function () {
  104312. return this._totalValueCount;
  104313. },
  104314. enumerable: true,
  104315. configurable: true
  104316. });
  104317. /**
  104318. * Call this method to start monitoring a new frame.
  104319. * 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.
  104320. */
  104321. PerfCounter.prototype.fetchNewFrame = function () {
  104322. this._totalValueCount++;
  104323. this._current = 0;
  104324. this._lastSecValueCount++;
  104325. };
  104326. /**
  104327. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  104328. * @param newCount the count value to add to the monitored count
  104329. * @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.
  104330. */
  104331. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  104332. if (!PerfCounter.Enabled) {
  104333. return;
  104334. }
  104335. this._current += newCount;
  104336. if (fetchResult) {
  104337. this._fetchResult();
  104338. }
  104339. };
  104340. /**
  104341. * Start monitoring this performance counter
  104342. */
  104343. PerfCounter.prototype.beginMonitoring = function () {
  104344. if (!PerfCounter.Enabled) {
  104345. return;
  104346. }
  104347. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  104348. };
  104349. /**
  104350. * Compute the time lapsed since the previous beginMonitoring() call.
  104351. * @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
  104352. */
  104353. PerfCounter.prototype.endMonitoring = function (newFrame) {
  104354. if (newFrame === void 0) { newFrame = true; }
  104355. if (!PerfCounter.Enabled) {
  104356. return;
  104357. }
  104358. if (newFrame) {
  104359. this.fetchNewFrame();
  104360. }
  104361. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  104362. this._current = currentTime - this._startMonitoringTime;
  104363. if (newFrame) {
  104364. this._fetchResult();
  104365. }
  104366. };
  104367. PerfCounter.prototype._fetchResult = function () {
  104368. this._totalAccumulated += this._current;
  104369. this._lastSecAccumulated += this._current;
  104370. // Min/Max update
  104371. this._min = Math.min(this._min, this._current);
  104372. this._max = Math.max(this._max, this._current);
  104373. this._average = this._totalAccumulated / this._totalValueCount;
  104374. // Reset last sec?
  104375. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  104376. if ((now - this._lastSecTime) > 1000) {
  104377. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  104378. this._lastSecTime = now;
  104379. this._lastSecAccumulated = 0;
  104380. this._lastSecValueCount = 0;
  104381. }
  104382. };
  104383. /**
  104384. * Gets or sets a global boolean to turn on and off all the counters
  104385. */
  104386. PerfCounter.Enabled = true;
  104387. return PerfCounter;
  104388. }());
  104389. /**
  104390. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  104391. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  104392. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  104393. * @param name The name of the class, case should be preserved
  104394. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  104395. */
  104396. function className(name, module) {
  104397. return function (target) {
  104398. target["__bjsclassName__"] = name;
  104399. target["__bjsmoduleName__"] = (module != null) ? module : null;
  104400. };
  104401. }
  104402. /**
  104403. * An implementation of a loop for asynchronous functions.
  104404. */
  104405. var AsyncLoop = /** @class */ (function () {
  104406. /**
  104407. * Constructor.
  104408. * @param iterations the number of iterations.
  104409. * @param func the function to run each iteration
  104410. * @param successCallback the callback that will be called upon succesful execution
  104411. * @param offset starting offset.
  104412. */
  104413. function AsyncLoop(
  104414. /**
  104415. * Defines the number of iterations for the loop
  104416. */
  104417. iterations, func, successCallback, offset) {
  104418. if (offset === void 0) { offset = 0; }
  104419. this.iterations = iterations;
  104420. this.index = offset - 1;
  104421. this._done = false;
  104422. this._fn = func;
  104423. this._successCallback = successCallback;
  104424. }
  104425. /**
  104426. * Execute the next iteration. Must be called after the last iteration was finished.
  104427. */
  104428. AsyncLoop.prototype.executeNext = function () {
  104429. if (!this._done) {
  104430. if (this.index + 1 < this.iterations) {
  104431. ++this.index;
  104432. this._fn(this);
  104433. }
  104434. else {
  104435. this.breakLoop();
  104436. }
  104437. }
  104438. };
  104439. /**
  104440. * Break the loop and run the success callback.
  104441. */
  104442. AsyncLoop.prototype.breakLoop = function () {
  104443. this._done = true;
  104444. this._successCallback();
  104445. };
  104446. /**
  104447. * Create and run an async loop.
  104448. * @param iterations the number of iterations.
  104449. * @param fn the function to run each iteration
  104450. * @param successCallback the callback that will be called upon succesful execution
  104451. * @param offset starting offset.
  104452. * @returns the created async loop object
  104453. */
  104454. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  104455. if (offset === void 0) { offset = 0; }
  104456. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  104457. loop.executeNext();
  104458. return loop;
  104459. };
  104460. /**
  104461. * A for-loop that will run a given number of iterations synchronous and the rest async.
  104462. * @param iterations total number of iterations
  104463. * @param syncedIterations number of synchronous iterations in each async iteration.
  104464. * @param fn the function to call each iteration.
  104465. * @param callback a success call back that will be called when iterating stops.
  104466. * @param breakFunction a break condition (optional)
  104467. * @param timeout timeout settings for the setTimeout function. default - 0.
  104468. * @returns the created async loop object
  104469. */
  104470. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  104471. if (timeout === void 0) { timeout = 0; }
  104472. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  104473. if (breakFunction && breakFunction()) {
  104474. loop.breakLoop();
  104475. }
  104476. else {
  104477. setTimeout(function () {
  104478. for (var i = 0; i < syncedIterations; ++i) {
  104479. var iteration = (loop.index * syncedIterations) + i;
  104480. if (iteration >= iterations) {
  104481. break;
  104482. }
  104483. fn(iteration);
  104484. if (breakFunction && breakFunction()) {
  104485. loop.breakLoop();
  104486. break;
  104487. }
  104488. }
  104489. loop.executeNext();
  104490. }, timeout);
  104491. }
  104492. }, callback);
  104493. };
  104494. return AsyncLoop;
  104495. }());
  104496. /***/ }),
  104497. /***/ "./Misc/typeStore.ts":
  104498. /*!***************************!*\
  104499. !*** ./Misc/typeStore.ts ***!
  104500. \***************************/
  104501. /*! exports provided: _TypeStore */
  104502. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104503. "use strict";
  104504. __webpack_require__.r(__webpack_exports__);
  104505. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  104506. /** @hidden */
  104507. var _TypeStore = /** @class */ (function () {
  104508. function _TypeStore() {
  104509. }
  104510. /** @hidden */
  104511. _TypeStore.GetClass = function (fqdn) {
  104512. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  104513. return this.RegisteredTypes[fqdn];
  104514. }
  104515. return null;
  104516. };
  104517. /** @hidden */
  104518. _TypeStore.RegisteredTypes = {};
  104519. return _TypeStore;
  104520. }());
  104521. /***/ }),
  104522. /***/ "./Misc/videoRecorder.ts":
  104523. /*!*******************************!*\
  104524. !*** ./Misc/videoRecorder.ts ***!
  104525. \*******************************/
  104526. /*! exports provided: VideoRecorder */
  104527. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104528. "use strict";
  104529. __webpack_require__.r(__webpack_exports__);
  104530. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  104531. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  104532. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  104533. /**
  104534. * This can helps recording videos from BabylonJS.
  104535. * This is based on the available WebRTC functionalities of the browser.
  104536. *
  104537. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  104538. */
  104539. var VideoRecorder = /** @class */ (function () {
  104540. /**
  104541. * Create a new VideoCapture object which can help converting what you see in Babylon to
  104542. * a video file.
  104543. * @param engine Defines the BabylonJS Engine you wish to record
  104544. * @param options Defines options that can be used to customized the capture
  104545. */
  104546. function VideoRecorder(engine, options) {
  104547. if (options === void 0) { options = null; }
  104548. if (!VideoRecorder.IsSupported(engine)) {
  104549. throw "Your browser does not support recording so far.";
  104550. }
  104551. var canvas = engine.getRenderingCanvas();
  104552. if (!canvas) {
  104553. throw "The babylon engine must have a canvas to be recorded";
  104554. }
  104555. this._canvas = canvas;
  104556. this._canvas.isRecording = false;
  104557. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  104558. var stream = this._canvas.captureStream(this._options.fps);
  104559. if (this._options.audioTracks) {
  104560. for (var _i = 0, _a = this._options.audioTracks; _i < _a.length; _i++) {
  104561. var track = _a[_i];
  104562. stream.addTrack(track);
  104563. }
  104564. }
  104565. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  104566. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  104567. this._mediaRecorder.onerror = this._handleError.bind(this);
  104568. this._mediaRecorder.onstop = this._handleStop.bind(this);
  104569. }
  104570. /**
  104571. * Returns wehther or not the VideoRecorder is available in your browser.
  104572. * @param engine Defines the Babylon Engine to check the support for
  104573. * @returns true if supported otherwise false
  104574. */
  104575. VideoRecorder.IsSupported = function (engine) {
  104576. var canvas = engine.getRenderingCanvas();
  104577. return (!!canvas && typeof canvas.captureStream === "function");
  104578. };
  104579. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  104580. /**
  104581. * True wether a recording is already in progress.
  104582. */
  104583. get: function () {
  104584. return !!this._canvas && this._canvas.isRecording;
  104585. },
  104586. enumerable: true,
  104587. configurable: true
  104588. });
  104589. /**
  104590. * Stops the current recording before the default capture timeout passed in the startRecording
  104591. * functions.
  104592. */
  104593. VideoRecorder.prototype.stopRecording = function () {
  104594. if (!this._canvas || !this._mediaRecorder) {
  104595. return;
  104596. }
  104597. if (!this.isRecording) {
  104598. return;
  104599. }
  104600. this._canvas.isRecording = false;
  104601. this._mediaRecorder.stop();
  104602. };
  104603. /**
  104604. * Starts recording the canvas for a max duration specified in parameters.
  104605. * @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.
  104606. * @param maxDuration Defines the maximum recording time in seconds.
  104607. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  104608. * @return a promise callback at the end of the recording with the video data in Blob.
  104609. */
  104610. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  104611. var _this = this;
  104612. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  104613. if (maxDuration === void 0) { maxDuration = 7; }
  104614. if (!this._canvas || !this._mediaRecorder) {
  104615. throw "Recorder has already been disposed";
  104616. }
  104617. if (this.isRecording) {
  104618. throw "Recording already in progress";
  104619. }
  104620. if (maxDuration > 0) {
  104621. setTimeout(function () {
  104622. _this.stopRecording();
  104623. }, maxDuration * 1000);
  104624. }
  104625. this._fileName = fileName;
  104626. this._recordedChunks = [];
  104627. this._resolve = null;
  104628. this._reject = null;
  104629. this._canvas.isRecording = true;
  104630. this._mediaRecorder.start(this._options.recordChunckSize);
  104631. return new Promise(function (resolve, reject) {
  104632. _this._resolve = resolve;
  104633. _this._reject = reject;
  104634. });
  104635. };
  104636. /**
  104637. * Releases internal resources used during the recording.
  104638. */
  104639. VideoRecorder.prototype.dispose = function () {
  104640. this._canvas = null;
  104641. this._mediaRecorder = null;
  104642. this._recordedChunks = [];
  104643. this._fileName = null;
  104644. this._resolve = null;
  104645. this._reject = null;
  104646. };
  104647. VideoRecorder.prototype._handleDataAvailable = function (event) {
  104648. if (event.data.size > 0) {
  104649. this._recordedChunks.push(event.data);
  104650. }
  104651. };
  104652. VideoRecorder.prototype._handleError = function (event) {
  104653. this.stopRecording();
  104654. if (this._reject) {
  104655. this._reject(event.error);
  104656. }
  104657. else {
  104658. throw new event.error();
  104659. }
  104660. };
  104661. VideoRecorder.prototype._handleStop = function () {
  104662. this.stopRecording();
  104663. var superBuffer = new Blob(this._recordedChunks);
  104664. if (this._resolve) {
  104665. this._resolve(superBuffer);
  104666. }
  104667. window.URL.createObjectURL(superBuffer);
  104668. if (this._fileName) {
  104669. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  104670. }
  104671. };
  104672. VideoRecorder._defaultOptions = {
  104673. mimeType: "video/webm",
  104674. fps: 25,
  104675. recordChunckSize: 3000
  104676. };
  104677. return VideoRecorder;
  104678. }());
  104679. /***/ }),
  104680. /***/ "./Misc/virtualJoystick.ts":
  104681. /*!*********************************!*\
  104682. !*** ./Misc/virtualJoystick.ts ***!
  104683. \*********************************/
  104684. /*! exports provided: JoystickAxis, VirtualJoystick */
  104685. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104686. "use strict";
  104687. __webpack_require__.r(__webpack_exports__);
  104688. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  104689. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  104690. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  104691. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  104692. // Mainly based on these 2 articles :
  104693. // 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
  104694. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  104695. /**
  104696. * Defines the potential axis of a Joystick
  104697. */
  104698. var JoystickAxis;
  104699. (function (JoystickAxis) {
  104700. /** X axis */
  104701. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  104702. /** Y axis */
  104703. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  104704. /** Z axis */
  104705. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  104706. })(JoystickAxis || (JoystickAxis = {}));
  104707. /**
  104708. * Class used to define virtual joystick (used in touch mode)
  104709. */
  104710. var VirtualJoystick = /** @class */ (function () {
  104711. /**
  104712. * Creates a new virtual joystick
  104713. * @param leftJoystick defines that the joystick is for left hand (false by default)
  104714. */
  104715. function VirtualJoystick(leftJoystick) {
  104716. var _this = this;
  104717. if (leftJoystick) {
  104718. this._leftJoystick = true;
  104719. }
  104720. else {
  104721. this._leftJoystick = false;
  104722. }
  104723. VirtualJoystick._globalJoystickIndex++;
  104724. // By default left & right arrow keys are moving the X
  104725. // and up & down keys are moving the Y
  104726. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  104727. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  104728. this.reverseLeftRight = false;
  104729. this.reverseUpDown = false;
  104730. // collections of pointers
  104731. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  104732. this.deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  104733. this._joystickSensibility = 25;
  104734. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  104735. this._onResize = function (evt) {
  104736. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  104737. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  104738. if (VirtualJoystick.Canvas) {
  104739. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  104740. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  104741. }
  104742. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  104743. };
  104744. // injecting a canvas element on top of the canvas 3D game
  104745. if (!VirtualJoystick.Canvas) {
  104746. window.addEventListener("resize", this._onResize, false);
  104747. VirtualJoystick.Canvas = document.createElement("canvas");
  104748. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  104749. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  104750. VirtualJoystick.Canvas.width = window.innerWidth;
  104751. VirtualJoystick.Canvas.height = window.innerHeight;
  104752. VirtualJoystick.Canvas.style.width = "100%";
  104753. VirtualJoystick.Canvas.style.height = "100%";
  104754. VirtualJoystick.Canvas.style.position = "absolute";
  104755. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  104756. VirtualJoystick.Canvas.style.top = "0px";
  104757. VirtualJoystick.Canvas.style.left = "0px";
  104758. VirtualJoystick.Canvas.style.zIndex = "5";
  104759. VirtualJoystick.Canvas.style.msTouchAction = "none";
  104760. // Support for jQuery PEP polyfill
  104761. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  104762. var context = VirtualJoystick.Canvas.getContext('2d');
  104763. if (!context) {
  104764. throw new Error("Unable to create canvas for virtual joystick");
  104765. }
  104766. VirtualJoystick.vjCanvasContext = context;
  104767. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  104768. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  104769. document.body.appendChild(VirtualJoystick.Canvas);
  104770. }
  104771. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  104772. this.pressed = false;
  104773. // default joystick color
  104774. this._joystickColor = "cyan";
  104775. this._joystickPointerID = -1;
  104776. // current joystick position
  104777. this._joystickPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  104778. this._joystickPreviousPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  104779. // origin joystick position
  104780. this._joystickPointerStartPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  104781. this._deltaJoystickVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  104782. this._onPointerDownHandlerRef = function (evt) {
  104783. _this._onPointerDown(evt);
  104784. };
  104785. this._onPointerMoveHandlerRef = function (evt) {
  104786. _this._onPointerMove(evt);
  104787. };
  104788. this._onPointerUpHandlerRef = function (evt) {
  104789. _this._onPointerUp(evt);
  104790. };
  104791. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  104792. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  104793. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  104794. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  104795. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  104796. evt.preventDefault(); // Disables system menu
  104797. }, false);
  104798. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  104799. }
  104800. /**
  104801. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  104802. * @param newJoystickSensibility defines the new sensibility
  104803. */
  104804. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  104805. this._joystickSensibility = newJoystickSensibility;
  104806. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  104807. };
  104808. VirtualJoystick.prototype._onPointerDown = function (e) {
  104809. var positionOnScreenCondition;
  104810. e.preventDefault();
  104811. if (this._leftJoystick === true) {
  104812. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  104813. }
  104814. else {
  104815. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  104816. }
  104817. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  104818. // First contact will be dedicated to the virtual joystick
  104819. this._joystickPointerID = e.pointerId;
  104820. this._joystickPointerStartPos.x = e.clientX;
  104821. this._joystickPointerStartPos.y = e.clientY;
  104822. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  104823. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  104824. this._deltaJoystickVector.x = 0;
  104825. this._deltaJoystickVector.y = 0;
  104826. this.pressed = true;
  104827. this._touches.add(e.pointerId.toString(), e);
  104828. }
  104829. else {
  104830. // You can only trigger the action buttons with a joystick declared
  104831. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  104832. this._action();
  104833. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  104834. }
  104835. }
  104836. };
  104837. VirtualJoystick.prototype._onPointerMove = function (e) {
  104838. // If the current pointer is the one associated to the joystick (first touch contact)
  104839. if (this._joystickPointerID == e.pointerId) {
  104840. this._joystickPointerPos.x = e.clientX;
  104841. this._joystickPointerPos.y = e.clientY;
  104842. this._deltaJoystickVector = this._joystickPointerPos.clone();
  104843. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  104844. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  104845. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  104846. switch (this._axisTargetedByLeftAndRight) {
  104847. case JoystickAxis.X:
  104848. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  104849. break;
  104850. case JoystickAxis.Y:
  104851. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  104852. break;
  104853. case JoystickAxis.Z:
  104854. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  104855. break;
  104856. }
  104857. var directionUpDown = this.reverseUpDown ? 1 : -1;
  104858. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  104859. switch (this._axisTargetedByUpAndDown) {
  104860. case JoystickAxis.X:
  104861. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  104862. break;
  104863. case JoystickAxis.Y:
  104864. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  104865. break;
  104866. case JoystickAxis.Z:
  104867. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  104868. break;
  104869. }
  104870. }
  104871. else {
  104872. var data = this._touches.get(e.pointerId.toString());
  104873. if (data) {
  104874. data.x = e.clientX;
  104875. data.y = e.clientY;
  104876. }
  104877. }
  104878. };
  104879. VirtualJoystick.prototype._onPointerUp = function (e) {
  104880. if (this._joystickPointerID == e.pointerId) {
  104881. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  104882. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  104883. this._joystickPointerID = -1;
  104884. this.pressed = false;
  104885. }
  104886. else {
  104887. var touch = this._touches.get(e.pointerId.toString());
  104888. if (touch) {
  104889. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  104890. }
  104891. }
  104892. this._deltaJoystickVector.x = 0;
  104893. this._deltaJoystickVector.y = 0;
  104894. this._touches.remove(e.pointerId.toString());
  104895. };
  104896. /**
  104897. * Change the color of the virtual joystick
  104898. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  104899. */
  104900. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  104901. this._joystickColor = newColor;
  104902. };
  104903. /**
  104904. * Defines a callback to call when the joystick is touched
  104905. * @param action defines the callback
  104906. */
  104907. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  104908. this._action = action;
  104909. };
  104910. /**
  104911. * Defines which axis you'd like to control for left & right
  104912. * @param axis defines the axis to use
  104913. */
  104914. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  104915. switch (axis) {
  104916. case JoystickAxis.X:
  104917. case JoystickAxis.Y:
  104918. case JoystickAxis.Z:
  104919. this._axisTargetedByLeftAndRight = axis;
  104920. break;
  104921. default:
  104922. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  104923. break;
  104924. }
  104925. };
  104926. /**
  104927. * Defines which axis you'd like to control for up & down
  104928. * @param axis defines the axis to use
  104929. */
  104930. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  104931. switch (axis) {
  104932. case JoystickAxis.X:
  104933. case JoystickAxis.Y:
  104934. case JoystickAxis.Z:
  104935. this._axisTargetedByUpAndDown = axis;
  104936. break;
  104937. default:
  104938. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  104939. break;
  104940. }
  104941. };
  104942. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  104943. var _this = this;
  104944. if (this.pressed) {
  104945. this._touches.forEach(function (key, touch) {
  104946. if (touch.pointerId === _this._joystickPointerID) {
  104947. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  104948. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  104949. VirtualJoystick.vjCanvasContext.beginPath();
  104950. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  104951. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  104952. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  104953. VirtualJoystick.vjCanvasContext.stroke();
  104954. VirtualJoystick.vjCanvasContext.closePath();
  104955. VirtualJoystick.vjCanvasContext.beginPath();
  104956. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  104957. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  104958. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  104959. VirtualJoystick.vjCanvasContext.stroke();
  104960. VirtualJoystick.vjCanvasContext.closePath();
  104961. VirtualJoystick.vjCanvasContext.beginPath();
  104962. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  104963. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  104964. VirtualJoystick.vjCanvasContext.stroke();
  104965. VirtualJoystick.vjCanvasContext.closePath();
  104966. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  104967. }
  104968. else {
  104969. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  104970. VirtualJoystick.vjCanvasContext.beginPath();
  104971. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  104972. VirtualJoystick.vjCanvasContext.beginPath();
  104973. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  104974. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  104975. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  104976. VirtualJoystick.vjCanvasContext.stroke();
  104977. VirtualJoystick.vjCanvasContext.closePath();
  104978. touch.prevX = touch.x;
  104979. touch.prevY = touch.y;
  104980. }
  104981. });
  104982. }
  104983. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  104984. };
  104985. /**
  104986. * Release internal HTML canvas
  104987. */
  104988. VirtualJoystick.prototype.releaseCanvas = function () {
  104989. if (VirtualJoystick.Canvas) {
  104990. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  104991. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  104992. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  104993. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  104994. window.removeEventListener("resize", this._onResize);
  104995. document.body.removeChild(VirtualJoystick.Canvas);
  104996. VirtualJoystick.Canvas = null;
  104997. }
  104998. };
  104999. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  105000. VirtualJoystick._globalJoystickIndex = 0;
  105001. return VirtualJoystick;
  105002. }());
  105003. /***/ }),
  105004. /***/ "./Misc/webRequest.ts":
  105005. /*!****************************!*\
  105006. !*** ./Misc/webRequest.ts ***!
  105007. \****************************/
  105008. /*! exports provided: WebRequest */
  105009. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105010. "use strict";
  105011. __webpack_require__.r(__webpack_exports__);
  105012. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return WebRequest; });
  105013. /**
  105014. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  105015. */
  105016. var WebRequest = /** @class */ (function () {
  105017. function WebRequest() {
  105018. this._xhr = new XMLHttpRequest();
  105019. }
  105020. WebRequest.prototype._injectCustomRequestHeaders = function () {
  105021. for (var key in WebRequest.CustomRequestHeaders) {
  105022. var val = WebRequest.CustomRequestHeaders[key];
  105023. if (val) {
  105024. this._xhr.setRequestHeader(key, val);
  105025. }
  105026. }
  105027. };
  105028. Object.defineProperty(WebRequest.prototype, "onprogress", {
  105029. /**
  105030. * Gets or sets a function to be called when loading progress changes
  105031. */
  105032. get: function () {
  105033. return this._xhr.onprogress;
  105034. },
  105035. set: function (value) {
  105036. this._xhr.onprogress = value;
  105037. },
  105038. enumerable: true,
  105039. configurable: true
  105040. });
  105041. Object.defineProperty(WebRequest.prototype, "readyState", {
  105042. /**
  105043. * Returns client's state
  105044. */
  105045. get: function () {
  105046. return this._xhr.readyState;
  105047. },
  105048. enumerable: true,
  105049. configurable: true
  105050. });
  105051. Object.defineProperty(WebRequest.prototype, "status", {
  105052. /**
  105053. * Returns client's status
  105054. */
  105055. get: function () {
  105056. return this._xhr.status;
  105057. },
  105058. enumerable: true,
  105059. configurable: true
  105060. });
  105061. Object.defineProperty(WebRequest.prototype, "statusText", {
  105062. /**
  105063. * Returns client's status as a text
  105064. */
  105065. get: function () {
  105066. return this._xhr.statusText;
  105067. },
  105068. enumerable: true,
  105069. configurable: true
  105070. });
  105071. Object.defineProperty(WebRequest.prototype, "response", {
  105072. /**
  105073. * Returns client's response
  105074. */
  105075. get: function () {
  105076. return this._xhr.response;
  105077. },
  105078. enumerable: true,
  105079. configurable: true
  105080. });
  105081. Object.defineProperty(WebRequest.prototype, "responseURL", {
  105082. /**
  105083. * Returns client's response url
  105084. */
  105085. get: function () {
  105086. return this._xhr.responseURL;
  105087. },
  105088. enumerable: true,
  105089. configurable: true
  105090. });
  105091. Object.defineProperty(WebRequest.prototype, "responseText", {
  105092. /**
  105093. * Returns client's response as text
  105094. */
  105095. get: function () {
  105096. return this._xhr.responseText;
  105097. },
  105098. enumerable: true,
  105099. configurable: true
  105100. });
  105101. Object.defineProperty(WebRequest.prototype, "responseType", {
  105102. /**
  105103. * Gets or sets the expected response type
  105104. */
  105105. get: function () {
  105106. return this._xhr.responseType;
  105107. },
  105108. set: function (value) {
  105109. this._xhr.responseType = value;
  105110. },
  105111. enumerable: true,
  105112. configurable: true
  105113. });
  105114. WebRequest.prototype.addEventListener = function (type, listener, options) {
  105115. this._xhr.addEventListener(type, listener, options);
  105116. };
  105117. WebRequest.prototype.removeEventListener = function (type, listener, options) {
  105118. this._xhr.removeEventListener(type, listener, options);
  105119. };
  105120. /**
  105121. * Cancels any network activity
  105122. */
  105123. WebRequest.prototype.abort = function () {
  105124. this._xhr.abort();
  105125. };
  105126. /**
  105127. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  105128. * @param body defines an optional request body
  105129. */
  105130. WebRequest.prototype.send = function (body) {
  105131. if (WebRequest.CustomRequestHeaders) {
  105132. this._injectCustomRequestHeaders();
  105133. }
  105134. this._xhr.send(body);
  105135. };
  105136. /**
  105137. * Sets the request method, request URL
  105138. * @param method defines the method to use (GET, POST, etc..)
  105139. * @param url defines the url to connect with
  105140. */
  105141. WebRequest.prototype.open = function (method, url) {
  105142. for (var _i = 0, _a = WebRequest.CustomRequestModifiers; _i < _a.length; _i++) {
  105143. var update = _a[_i];
  105144. update(this._xhr);
  105145. }
  105146. return this._xhr.open(method, url, true);
  105147. };
  105148. /**
  105149. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  105150. * i.e. when loading files, where the server/service expects an Authorization header
  105151. */
  105152. WebRequest.CustomRequestHeaders = {};
  105153. /**
  105154. * Add callback functions in this array to update all the requests before they get sent to the network
  105155. */
  105156. WebRequest.CustomRequestModifiers = new Array();
  105157. return WebRequest;
  105158. }());
  105159. /***/ }),
  105160. /***/ "./Misc/workerPool.ts":
  105161. /*!****************************!*\
  105162. !*** ./Misc/workerPool.ts ***!
  105163. \****************************/
  105164. /*! exports provided: WorkerPool */
  105165. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105166. "use strict";
  105167. __webpack_require__.r(__webpack_exports__);
  105168. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  105169. /**
  105170. * Helper class to push actions to a pool of workers.
  105171. */
  105172. var WorkerPool = /** @class */ (function () {
  105173. /**
  105174. * Constructor
  105175. * @param workers Array of workers to use for actions
  105176. */
  105177. function WorkerPool(workers) {
  105178. this._pendingActions = new Array();
  105179. this._workerInfos = workers.map(function (worker) { return ({
  105180. worker: worker,
  105181. active: false
  105182. }); });
  105183. }
  105184. /**
  105185. * Terminates all workers and clears any pending actions.
  105186. */
  105187. WorkerPool.prototype.dispose = function () {
  105188. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  105189. var workerInfo = _a[_i];
  105190. workerInfo.worker.terminate();
  105191. }
  105192. delete this._workerInfos;
  105193. delete this._pendingActions;
  105194. };
  105195. /**
  105196. * Pushes an action to the worker pool. If all the workers are active, the action will be
  105197. * pended until a worker has completed its action.
  105198. * @param action The action to perform. Call onComplete when the action is complete.
  105199. */
  105200. WorkerPool.prototype.push = function (action) {
  105201. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  105202. var workerInfo = _a[_i];
  105203. if (!workerInfo.active) {
  105204. this._execute(workerInfo, action);
  105205. return;
  105206. }
  105207. }
  105208. this._pendingActions.push(action);
  105209. };
  105210. WorkerPool.prototype._execute = function (workerInfo, action) {
  105211. var _this = this;
  105212. workerInfo.active = true;
  105213. action(workerInfo.worker, function () {
  105214. workerInfo.active = false;
  105215. var nextAction = _this._pendingActions.shift();
  105216. if (nextAction) {
  105217. _this._execute(workerInfo, nextAction);
  105218. }
  105219. });
  105220. };
  105221. return WorkerPool;
  105222. }());
  105223. /***/ }),
  105224. /***/ "./Morph/index.ts":
  105225. /*!************************!*\
  105226. !*** ./Morph/index.ts ***!
  105227. \************************/
  105228. /*! exports provided: MorphTarget, MorphTargetManager */
  105229. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105230. "use strict";
  105231. __webpack_require__.r(__webpack_exports__);
  105232. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  105233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  105234. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  105235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  105236. /***/ }),
  105237. /***/ "./Morph/morphTarget.ts":
  105238. /*!******************************!*\
  105239. !*** ./Morph/morphTarget.ts ***!
  105240. \******************************/
  105241. /*! exports provided: MorphTarget */
  105242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105243. "use strict";
  105244. __webpack_require__.r(__webpack_exports__);
  105245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  105246. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  105247. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  105248. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  105249. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  105250. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  105251. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  105252. /**
  105253. * Defines a target to use with MorphTargetManager
  105254. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105255. */
  105256. var MorphTarget = /** @class */ (function () {
  105257. /**
  105258. * Creates a new MorphTarget
  105259. * @param name defines the name of the target
  105260. * @param influence defines the influence to use
  105261. * @param scene defines the scene the morphtarget belongs to
  105262. */
  105263. function MorphTarget(
  105264. /** defines the name of the target */
  105265. name, influence, scene) {
  105266. if (influence === void 0) { influence = 0; }
  105267. if (scene === void 0) { scene = null; }
  105268. this.name = name;
  105269. /**
  105270. * Gets or sets the list of animations
  105271. */
  105272. this.animations = new Array();
  105273. this._positions = null;
  105274. this._normals = null;
  105275. this._tangents = null;
  105276. /**
  105277. * Observable raised when the influence changes
  105278. */
  105279. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  105280. /** @hidden */
  105281. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  105282. this._animationPropertiesOverride = null;
  105283. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  105284. this.influence = influence;
  105285. }
  105286. Object.defineProperty(MorphTarget.prototype, "influence", {
  105287. /**
  105288. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  105289. */
  105290. get: function () {
  105291. return this._influence;
  105292. },
  105293. set: function (influence) {
  105294. if (this._influence === influence) {
  105295. return;
  105296. }
  105297. var previous = this._influence;
  105298. this._influence = influence;
  105299. if (this.onInfluenceChanged.hasObservers) {
  105300. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  105301. }
  105302. },
  105303. enumerable: true,
  105304. configurable: true
  105305. });
  105306. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  105307. /**
  105308. * Gets or sets the animation properties override
  105309. */
  105310. get: function () {
  105311. if (!this._animationPropertiesOverride && this._scene) {
  105312. return this._scene.animationPropertiesOverride;
  105313. }
  105314. return this._animationPropertiesOverride;
  105315. },
  105316. set: function (value) {
  105317. this._animationPropertiesOverride = value;
  105318. },
  105319. enumerable: true,
  105320. configurable: true
  105321. });
  105322. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  105323. /**
  105324. * Gets a boolean defining if the target contains position data
  105325. */
  105326. get: function () {
  105327. return !!this._positions;
  105328. },
  105329. enumerable: true,
  105330. configurable: true
  105331. });
  105332. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  105333. /**
  105334. * Gets a boolean defining if the target contains normal data
  105335. */
  105336. get: function () {
  105337. return !!this._normals;
  105338. },
  105339. enumerable: true,
  105340. configurable: true
  105341. });
  105342. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  105343. /**
  105344. * Gets a boolean defining if the target contains tangent data
  105345. */
  105346. get: function () {
  105347. return !!this._tangents;
  105348. },
  105349. enumerable: true,
  105350. configurable: true
  105351. });
  105352. /**
  105353. * Affects position data to this target
  105354. * @param data defines the position data to use
  105355. */
  105356. MorphTarget.prototype.setPositions = function (data) {
  105357. var hadPositions = this.hasPositions;
  105358. this._positions = data;
  105359. if (hadPositions !== this.hasPositions) {
  105360. this._onDataLayoutChanged.notifyObservers(undefined);
  105361. }
  105362. };
  105363. /**
  105364. * Gets the position data stored in this target
  105365. * @returns a FloatArray containing the position data (or null if not present)
  105366. */
  105367. MorphTarget.prototype.getPositions = function () {
  105368. return this._positions;
  105369. };
  105370. /**
  105371. * Affects normal data to this target
  105372. * @param data defines the normal data to use
  105373. */
  105374. MorphTarget.prototype.setNormals = function (data) {
  105375. var hadNormals = this.hasNormals;
  105376. this._normals = data;
  105377. if (hadNormals !== this.hasNormals) {
  105378. this._onDataLayoutChanged.notifyObservers(undefined);
  105379. }
  105380. };
  105381. /**
  105382. * Gets the normal data stored in this target
  105383. * @returns a FloatArray containing the normal data (or null if not present)
  105384. */
  105385. MorphTarget.prototype.getNormals = function () {
  105386. return this._normals;
  105387. };
  105388. /**
  105389. * Affects tangent data to this target
  105390. * @param data defines the tangent data to use
  105391. */
  105392. MorphTarget.prototype.setTangents = function (data) {
  105393. var hadTangents = this.hasTangents;
  105394. this._tangents = data;
  105395. if (hadTangents !== this.hasTangents) {
  105396. this._onDataLayoutChanged.notifyObservers(undefined);
  105397. }
  105398. };
  105399. /**
  105400. * Gets the tangent data stored in this target
  105401. * @returns a FloatArray containing the tangent data (or null if not present)
  105402. */
  105403. MorphTarget.prototype.getTangents = function () {
  105404. return this._tangents;
  105405. };
  105406. /**
  105407. * Serializes the current target into a Serialization object
  105408. * @returns the serialized object
  105409. */
  105410. MorphTarget.prototype.serialize = function () {
  105411. var serializationObject = {};
  105412. serializationObject.name = this.name;
  105413. serializationObject.influence = this.influence;
  105414. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  105415. if (this.id != null) {
  105416. serializationObject.id = this.id;
  105417. }
  105418. if (this.hasNormals) {
  105419. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  105420. }
  105421. if (this.hasTangents) {
  105422. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  105423. }
  105424. // Animations
  105425. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  105426. return serializationObject;
  105427. };
  105428. /**
  105429. * Returns the string "MorphTarget"
  105430. * @returns "MorphTarget"
  105431. */
  105432. MorphTarget.prototype.getClassName = function () {
  105433. return "MorphTarget";
  105434. };
  105435. // Statics
  105436. /**
  105437. * Creates a new target from serialized data
  105438. * @param serializationObject defines the serialized data to use
  105439. * @returns a new MorphTarget
  105440. */
  105441. MorphTarget.Parse = function (serializationObject) {
  105442. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  105443. result.setPositions(serializationObject.positions);
  105444. if (serializationObject.id != null) {
  105445. result.id = serializationObject.id;
  105446. }
  105447. if (serializationObject.normals) {
  105448. result.setNormals(serializationObject.normals);
  105449. }
  105450. if (serializationObject.tangents) {
  105451. result.setTangents(serializationObject.tangents);
  105452. }
  105453. // Animations
  105454. if (serializationObject.animations) {
  105455. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  105456. var parsedAnimation = serializationObject.animations[animationIndex];
  105457. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  105458. if (internalClass) {
  105459. result.animations.push(internalClass.Parse(parsedAnimation));
  105460. }
  105461. }
  105462. }
  105463. return result;
  105464. };
  105465. /**
  105466. * Creates a MorphTarget from mesh data
  105467. * @param mesh defines the source mesh
  105468. * @param name defines the name to use for the new target
  105469. * @param influence defines the influence to attach to the target
  105470. * @returns a new MorphTarget
  105471. */
  105472. MorphTarget.FromMesh = function (mesh, name, influence) {
  105473. if (!name) {
  105474. name = mesh.name;
  105475. }
  105476. var result = new MorphTarget(name, influence, mesh.getScene());
  105477. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  105478. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  105479. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  105480. }
  105481. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  105482. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  105483. }
  105484. return result;
  105485. };
  105486. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  105487. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["serialize"])()
  105488. ], MorphTarget.prototype, "id", void 0);
  105489. return MorphTarget;
  105490. }());
  105491. /***/ }),
  105492. /***/ "./Morph/morphTargetManager.ts":
  105493. /*!*************************************!*\
  105494. !*** ./Morph/morphTargetManager.ts ***!
  105495. \*************************************/
  105496. /*! exports provided: MorphTargetManager */
  105497. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105498. "use strict";
  105499. __webpack_require__.r(__webpack_exports__);
  105500. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  105501. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  105502. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  105503. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  105504. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  105505. /**
  105506. * This class is used to deform meshes using morphing between different targets
  105507. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105508. */
  105509. var MorphTargetManager = /** @class */ (function () {
  105510. /**
  105511. * Creates a new MorphTargetManager
  105512. * @param scene defines the current scene
  105513. */
  105514. function MorphTargetManager(scene) {
  105515. if (scene === void 0) { scene = null; }
  105516. this._targets = new Array();
  105517. this._targetInfluenceChangedObservers = new Array();
  105518. this._targetDataLayoutChangedObservers = new Array();
  105519. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  105520. this._supportsNormals = false;
  105521. this._supportsTangents = false;
  105522. this._vertexCount = 0;
  105523. this._uniqueId = 0;
  105524. this._tempInfluences = new Array();
  105525. if (!scene) {
  105526. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  105527. }
  105528. this._scene = scene;
  105529. if (this._scene) {
  105530. this._scene.morphTargetManagers.push(this);
  105531. this._uniqueId = this._scene.getUniqueId();
  105532. }
  105533. }
  105534. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  105535. /**
  105536. * Gets the unique ID of this manager
  105537. */
  105538. get: function () {
  105539. return this._uniqueId;
  105540. },
  105541. enumerable: true,
  105542. configurable: true
  105543. });
  105544. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  105545. /**
  105546. * Gets the number of vertices handled by this manager
  105547. */
  105548. get: function () {
  105549. return this._vertexCount;
  105550. },
  105551. enumerable: true,
  105552. configurable: true
  105553. });
  105554. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  105555. /**
  105556. * Gets a boolean indicating if this manager supports morphing of normals
  105557. */
  105558. get: function () {
  105559. return this._supportsNormals;
  105560. },
  105561. enumerable: true,
  105562. configurable: true
  105563. });
  105564. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  105565. /**
  105566. * Gets a boolean indicating if this manager supports morphing of tangents
  105567. */
  105568. get: function () {
  105569. return this._supportsTangents;
  105570. },
  105571. enumerable: true,
  105572. configurable: true
  105573. });
  105574. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  105575. /**
  105576. * Gets the number of targets stored in this manager
  105577. */
  105578. get: function () {
  105579. return this._targets.length;
  105580. },
  105581. enumerable: true,
  105582. configurable: true
  105583. });
  105584. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  105585. /**
  105586. * Gets the number of influencers (ie. the number of targets with influences > 0)
  105587. */
  105588. get: function () {
  105589. return this._activeTargets.length;
  105590. },
  105591. enumerable: true,
  105592. configurable: true
  105593. });
  105594. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  105595. /**
  105596. * Gets the list of influences (one per target)
  105597. */
  105598. get: function () {
  105599. return this._influences;
  105600. },
  105601. enumerable: true,
  105602. configurable: true
  105603. });
  105604. /**
  105605. * Gets the active target at specified index. An active target is a target with an influence > 0
  105606. * @param index defines the index to check
  105607. * @returns the requested target
  105608. */
  105609. MorphTargetManager.prototype.getActiveTarget = function (index) {
  105610. return this._activeTargets.data[index];
  105611. };
  105612. /**
  105613. * Gets the target at specified index
  105614. * @param index defines the index to check
  105615. * @returns the requested target
  105616. */
  105617. MorphTargetManager.prototype.getTarget = function (index) {
  105618. return this._targets[index];
  105619. };
  105620. /**
  105621. * Add a new target to this manager
  105622. * @param target defines the target to add
  105623. */
  105624. MorphTargetManager.prototype.addTarget = function (target) {
  105625. var _this = this;
  105626. this._targets.push(target);
  105627. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  105628. _this._syncActiveTargets(needUpdate);
  105629. }));
  105630. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  105631. _this._syncActiveTargets(true);
  105632. }));
  105633. this._syncActiveTargets(true);
  105634. };
  105635. /**
  105636. * Removes a target from the manager
  105637. * @param target defines the target to remove
  105638. */
  105639. MorphTargetManager.prototype.removeTarget = function (target) {
  105640. var index = this._targets.indexOf(target);
  105641. if (index >= 0) {
  105642. this._targets.splice(index, 1);
  105643. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  105644. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  105645. this._syncActiveTargets(true);
  105646. }
  105647. };
  105648. /**
  105649. * Serializes the current manager into a Serialization object
  105650. * @returns the serialized object
  105651. */
  105652. MorphTargetManager.prototype.serialize = function () {
  105653. var serializationObject = {};
  105654. serializationObject.id = this.uniqueId;
  105655. serializationObject.targets = [];
  105656. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  105657. var target = _a[_i];
  105658. serializationObject.targets.push(target.serialize());
  105659. }
  105660. return serializationObject;
  105661. };
  105662. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  105663. var influenceCount = 0;
  105664. this._activeTargets.reset();
  105665. this._supportsNormals = true;
  105666. this._supportsTangents = true;
  105667. this._vertexCount = 0;
  105668. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  105669. var target = _a[_i];
  105670. if (target.influence === 0) {
  105671. continue;
  105672. }
  105673. this._activeTargets.push(target);
  105674. this._tempInfluences[influenceCount++] = target.influence;
  105675. this._supportsNormals = this._supportsNormals && target.hasNormals;
  105676. this._supportsTangents = this._supportsTangents && target.hasTangents;
  105677. var positions = target.getPositions();
  105678. if (positions) {
  105679. var vertexCount = positions.length / 3;
  105680. if (this._vertexCount === 0) {
  105681. this._vertexCount = vertexCount;
  105682. }
  105683. else if (this._vertexCount !== vertexCount) {
  105684. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  105685. return;
  105686. }
  105687. }
  105688. }
  105689. if (!this._influences || this._influences.length !== influenceCount) {
  105690. this._influences = new Float32Array(influenceCount);
  105691. }
  105692. for (var index = 0; index < influenceCount; index++) {
  105693. this._influences[index] = this._tempInfluences[index];
  105694. }
  105695. if (needUpdate) {
  105696. this.synchronize();
  105697. }
  105698. };
  105699. /**
  105700. * Syncrhonize the targets with all the meshes using this morph target manager
  105701. */
  105702. MorphTargetManager.prototype.synchronize = function () {
  105703. if (!this._scene) {
  105704. return;
  105705. }
  105706. // Flag meshes as dirty to resync with the active targets
  105707. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  105708. var mesh = _a[_i];
  105709. if (mesh.morphTargetManager === this) {
  105710. mesh._syncGeometryWithMorphTargetManager();
  105711. }
  105712. }
  105713. };
  105714. // Statics
  105715. /**
  105716. * Creates a new MorphTargetManager from serialized data
  105717. * @param serializationObject defines the serialized data
  105718. * @param scene defines the hosting scene
  105719. * @returns the new MorphTargetManager
  105720. */
  105721. MorphTargetManager.Parse = function (serializationObject, scene) {
  105722. var result = new MorphTargetManager(scene);
  105723. result._uniqueId = serializationObject.id;
  105724. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  105725. var targetData = _a[_i];
  105726. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  105727. }
  105728. return result;
  105729. };
  105730. return MorphTargetManager;
  105731. }());
  105732. /***/ }),
  105733. /***/ "./Offline/database.ts":
  105734. /*!*****************************!*\
  105735. !*** ./Offline/database.ts ***!
  105736. \*****************************/
  105737. /*! exports provided: Database */
  105738. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105739. "use strict";
  105740. __webpack_require__.r(__webpack_exports__);
  105741. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  105742. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  105743. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  105744. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  105745. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  105746. /* harmony import */ var _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/webRequest */ "./Misc/webRequest.ts");
  105747. // Sets the default offline provider to Babylon.js
  105748. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  105749. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  105750. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  105751. };
  105752. /**
  105753. * Class used to enable access to IndexedDB
  105754. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  105755. */
  105756. var Database = /** @class */ (function () {
  105757. /**
  105758. * Creates a new Database
  105759. * @param urlToScene defines the url to load the scene
  105760. * @param callbackManifestChecked defines the callback to use when manifest is checked
  105761. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  105762. */
  105763. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  105764. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  105765. var _this = this;
  105766. // Handling various flavors of prefixed version of IndexedDB
  105767. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  105768. this._callbackManifestChecked = callbackManifestChecked;
  105769. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  105770. this._db = null;
  105771. this._enableSceneOffline = false;
  105772. this._enableTexturesOffline = false;
  105773. this._manifestVersionFound = 0;
  105774. this._mustUpdateRessources = false;
  105775. this._hasReachedQuota = false;
  105776. if (!Database.IDBStorageEnabled) {
  105777. this._callbackManifestChecked(true);
  105778. }
  105779. else {
  105780. if (disableManifestCheck) {
  105781. this._enableSceneOffline = true;
  105782. this._enableTexturesOffline = true;
  105783. this._manifestVersionFound = 1;
  105784. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  105785. _this._callbackManifestChecked(true);
  105786. });
  105787. }
  105788. else {
  105789. this._checkManifestFile();
  105790. }
  105791. }
  105792. }
  105793. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  105794. /**
  105795. * Gets a boolean indicating if scene must be saved in the database
  105796. */
  105797. get: function () {
  105798. return this._enableSceneOffline;
  105799. },
  105800. enumerable: true,
  105801. configurable: true
  105802. });
  105803. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  105804. /**
  105805. * Gets a boolean indicating if textures must be saved in the database
  105806. */
  105807. get: function () {
  105808. return this._enableTexturesOffline;
  105809. },
  105810. enumerable: true,
  105811. configurable: true
  105812. });
  105813. Database.prototype._checkManifestFile = function () {
  105814. var _this = this;
  105815. var noManifestFile = function () {
  105816. _this._enableSceneOffline = false;
  105817. _this._enableTexturesOffline = false;
  105818. _this._callbackManifestChecked(false);
  105819. };
  105820. var timeStampUsed = false;
  105821. var manifestURL = this._currentSceneUrl + ".manifest";
  105822. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"]();
  105823. if (navigator.onLine) {
  105824. // Adding a timestamp to by-pass browsers' cache
  105825. timeStampUsed = true;
  105826. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  105827. }
  105828. xhr.open("GET", manifestURL);
  105829. xhr.addEventListener("load", function () {
  105830. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  105831. try {
  105832. var manifestFile = JSON.parse(xhr.response);
  105833. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  105834. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  105835. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  105836. _this._manifestVersionFound = manifestFile.version;
  105837. }
  105838. if (_this._callbackManifestChecked) {
  105839. _this._callbackManifestChecked(true);
  105840. }
  105841. }
  105842. catch (ex) {
  105843. noManifestFile();
  105844. }
  105845. }
  105846. else {
  105847. noManifestFile();
  105848. }
  105849. }, false);
  105850. xhr.addEventListener("error", function () {
  105851. if (timeStampUsed) {
  105852. timeStampUsed = false;
  105853. // Let's retry without the timeStamp
  105854. // It could fail when coupled with HTML5 Offline API
  105855. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  105856. xhr.open("GET", retryManifestURL);
  105857. xhr.send();
  105858. }
  105859. else {
  105860. noManifestFile();
  105861. }
  105862. }, false);
  105863. try {
  105864. xhr.send();
  105865. }
  105866. catch (ex) {
  105867. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  105868. this._callbackManifestChecked(false);
  105869. }
  105870. };
  105871. /**
  105872. * Open the database and make it available
  105873. * @param successCallback defines the callback to call on success
  105874. * @param errorCallback defines the callback to call on error
  105875. */
  105876. Database.prototype.open = function (successCallback, errorCallback) {
  105877. var _this = this;
  105878. var handleError = function () {
  105879. _this._isSupported = false;
  105880. if (errorCallback) {
  105881. errorCallback();
  105882. }
  105883. };
  105884. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  105885. // Your browser doesn't support IndexedDB
  105886. this._isSupported = false;
  105887. if (errorCallback) {
  105888. errorCallback();
  105889. }
  105890. }
  105891. else {
  105892. // If the DB hasn't been opened or created yet
  105893. if (!this._db) {
  105894. this._hasReachedQuota = false;
  105895. this._isSupported = true;
  105896. var request = this._idbFactory.open("babylonjs", 1);
  105897. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  105898. request.onerror = function () {
  105899. handleError();
  105900. };
  105901. // executes when a version change transaction cannot complete due to other active transactions
  105902. request.onblocked = function () {
  105903. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  105904. handleError();
  105905. };
  105906. // DB has been opened successfully
  105907. request.onsuccess = function () {
  105908. _this._db = request.result;
  105909. successCallback();
  105910. };
  105911. // Initialization of the DB. Creating Scenes & Textures stores
  105912. request.onupgradeneeded = function (event) {
  105913. _this._db = (event.target).result;
  105914. if (_this._db) {
  105915. try {
  105916. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  105917. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  105918. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  105919. }
  105920. catch (ex) {
  105921. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  105922. handleError();
  105923. }
  105924. }
  105925. };
  105926. }
  105927. // DB has already been created and opened
  105928. else {
  105929. if (successCallback) {
  105930. successCallback();
  105931. }
  105932. }
  105933. }
  105934. };
  105935. /**
  105936. * Loads an image from the database
  105937. * @param url defines the url to load from
  105938. * @param image defines the target DOM image
  105939. */
  105940. Database.prototype.loadImage = function (url, image) {
  105941. var _this = this;
  105942. var completeURL = Database._ReturnFullUrlLocation(url);
  105943. var saveAndLoadImage = function () {
  105944. if (!_this._hasReachedQuota && _this._db !== null) {
  105945. // the texture is not yet in the DB, let's try to save it
  105946. _this._saveImageIntoDBAsync(completeURL, image);
  105947. }
  105948. // If the texture is not in the DB and we've reached the DB quota limit
  105949. // let's load it directly from the web
  105950. else {
  105951. image.src = url;
  105952. }
  105953. };
  105954. if (!this._mustUpdateRessources) {
  105955. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  105956. }
  105957. // First time we're download the images or update requested in the manifest file by a version change
  105958. else {
  105959. saveAndLoadImage();
  105960. }
  105961. };
  105962. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  105963. if (this._isSupported && this._db !== null) {
  105964. var texture;
  105965. var transaction = this._db.transaction(["textures"]);
  105966. transaction.onabort = function () {
  105967. image.src = url;
  105968. };
  105969. transaction.oncomplete = function () {
  105970. var blobTextureURL;
  105971. if (texture) {
  105972. var URL = window.URL || window.webkitURL;
  105973. blobTextureURL = URL.createObjectURL(texture.data);
  105974. image.onerror = function () {
  105975. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  105976. image.src = url;
  105977. };
  105978. image.src = blobTextureURL;
  105979. }
  105980. else {
  105981. notInDBCallback();
  105982. }
  105983. };
  105984. var getRequest = transaction.objectStore("textures").get(url);
  105985. getRequest.onsuccess = function (event) {
  105986. texture = (event.target).result;
  105987. };
  105988. getRequest.onerror = function () {
  105989. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  105990. image.src = url;
  105991. };
  105992. }
  105993. else {
  105994. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  105995. image.src = url;
  105996. }
  105997. };
  105998. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  105999. var _this = this;
  106000. if (this._isSupported) {
  106001. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  106002. var generateBlobUrl = function () {
  106003. var blobTextureURL;
  106004. if (blob) {
  106005. var URL = window.URL || window.webkitURL;
  106006. try {
  106007. blobTextureURL = URL.createObjectURL(blob);
  106008. }
  106009. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  106010. catch (ex) {
  106011. blobTextureURL = URL.createObjectURL(blob);
  106012. }
  106013. }
  106014. if (blobTextureURL) {
  106015. image.src = blobTextureURL;
  106016. }
  106017. };
  106018. if (Database.IsUASupportingBlobStorage) { // Create XHR
  106019. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"](), blob;
  106020. xhr.open("GET", url);
  106021. xhr.responseType = "blob";
  106022. xhr.addEventListener("load", function () {
  106023. if (xhr.status === 200 && _this._db) {
  106024. // Blob as response (XHR2)
  106025. blob = xhr.response;
  106026. var transaction = _this._db.transaction(["textures"], "readwrite");
  106027. // the transaction could abort because of a QuotaExceededError error
  106028. transaction.onabort = function (event) {
  106029. try {
  106030. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  106031. var srcElement = (event.srcElement || event.target);
  106032. var error = srcElement.error;
  106033. if (error && error.name === "QuotaExceededError") {
  106034. _this._hasReachedQuota = true;
  106035. }
  106036. }
  106037. catch (ex) { }
  106038. generateBlobUrl();
  106039. };
  106040. transaction.oncomplete = function () {
  106041. generateBlobUrl();
  106042. };
  106043. var newTexture = { textureUrl: url, data: blob };
  106044. try {
  106045. // Put the blob into the dabase
  106046. var addRequest = transaction.objectStore("textures").put(newTexture);
  106047. addRequest.onsuccess = function () {
  106048. };
  106049. addRequest.onerror = function () {
  106050. generateBlobUrl();
  106051. };
  106052. }
  106053. catch (ex) {
  106054. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  106055. if (ex.code === 25) {
  106056. Database.IsUASupportingBlobStorage = false;
  106057. _this._enableTexturesOffline = false;
  106058. }
  106059. image.src = url;
  106060. }
  106061. }
  106062. else {
  106063. image.src = url;
  106064. }
  106065. }, false);
  106066. xhr.addEventListener("error", function () {
  106067. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  106068. image.src = url;
  106069. }, false);
  106070. xhr.send();
  106071. }
  106072. else {
  106073. image.src = url;
  106074. }
  106075. }
  106076. else {
  106077. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  106078. image.src = url;
  106079. }
  106080. };
  106081. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  106082. var _this = this;
  106083. var updateVersion = function () {
  106084. // the version is not yet in the DB or we need to update it
  106085. _this._saveVersionIntoDBAsync(url, versionLoaded);
  106086. };
  106087. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  106088. };
  106089. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  106090. var _this = this;
  106091. if (this._isSupported && this._db) {
  106092. var version;
  106093. try {
  106094. var transaction = this._db.transaction(["versions"]);
  106095. transaction.oncomplete = function () {
  106096. if (version) {
  106097. // If the version in the JSON file is different from the version in DB
  106098. if (_this._manifestVersionFound !== version.data) {
  106099. _this._mustUpdateRessources = true;
  106100. updateInDBCallback();
  106101. }
  106102. else {
  106103. callback(version.data);
  106104. }
  106105. }
  106106. // version was not found in DB
  106107. else {
  106108. _this._mustUpdateRessources = true;
  106109. updateInDBCallback();
  106110. }
  106111. };
  106112. transaction.onabort = function () {
  106113. callback(-1);
  106114. };
  106115. var getRequest = transaction.objectStore("versions").get(url);
  106116. getRequest.onsuccess = function (event) {
  106117. version = (event.target).result;
  106118. };
  106119. getRequest.onerror = function () {
  106120. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  106121. callback(-1);
  106122. };
  106123. }
  106124. catch (ex) {
  106125. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  106126. callback(-1);
  106127. }
  106128. }
  106129. else {
  106130. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  106131. callback(-1);
  106132. }
  106133. };
  106134. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  106135. var _this = this;
  106136. if (this._isSupported && !this._hasReachedQuota && this._db) {
  106137. try {
  106138. // Open a transaction to the database
  106139. var transaction = this._db.transaction(["versions"], "readwrite");
  106140. // the transaction could abort because of a QuotaExceededError error
  106141. transaction.onabort = function (event) {
  106142. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  106143. var error = event.srcElement['error'];
  106144. if (error && error.name === "QuotaExceededError") {
  106145. _this._hasReachedQuota = true;
  106146. }
  106147. }
  106148. catch (ex) { }
  106149. callback(-1);
  106150. };
  106151. transaction.oncomplete = function () {
  106152. callback(_this._manifestVersionFound);
  106153. };
  106154. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  106155. // Put the scene into the database
  106156. var addRequest = transaction.objectStore("versions").put(newVersion);
  106157. addRequest.onsuccess = function () {
  106158. };
  106159. addRequest.onerror = function () {
  106160. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  106161. };
  106162. }
  106163. catch (ex) {
  106164. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  106165. callback(-1);
  106166. }
  106167. }
  106168. else {
  106169. callback(-1);
  106170. }
  106171. };
  106172. /**
  106173. * Loads a file from database
  106174. * @param url defines the URL to load from
  106175. * @param sceneLoaded defines a callback to call on success
  106176. * @param progressCallBack defines a callback to call when progress changed
  106177. * @param errorCallback defines a callback to call on error
  106178. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  106179. */
  106180. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  106181. var _this = this;
  106182. var completeUrl = Database._ReturnFullUrlLocation(url);
  106183. var saveAndLoadFile = function () {
  106184. // the scene is not yet in the DB, let's try to save it
  106185. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  106186. };
  106187. this._checkVersionFromDB(completeUrl, function (version) {
  106188. if (version !== -1) {
  106189. if (!_this._mustUpdateRessources) {
  106190. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  106191. }
  106192. else {
  106193. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  106194. }
  106195. }
  106196. else {
  106197. if (errorCallback) {
  106198. errorCallback();
  106199. }
  106200. }
  106201. });
  106202. };
  106203. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  106204. if (this._isSupported && this._db) {
  106205. var targetStore;
  106206. if (url.indexOf(".babylon") !== -1) {
  106207. targetStore = "scenes";
  106208. }
  106209. else {
  106210. targetStore = "textures";
  106211. }
  106212. var file;
  106213. var transaction = this._db.transaction([targetStore]);
  106214. transaction.oncomplete = function () {
  106215. if (file) {
  106216. callback(file.data);
  106217. }
  106218. // file was not found in DB
  106219. else {
  106220. notInDBCallback();
  106221. }
  106222. };
  106223. transaction.onabort = function () {
  106224. notInDBCallback();
  106225. };
  106226. var getRequest = transaction.objectStore(targetStore).get(url);
  106227. getRequest.onsuccess = function (event) {
  106228. file = (event.target).result;
  106229. };
  106230. getRequest.onerror = function () {
  106231. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  106232. notInDBCallback();
  106233. };
  106234. }
  106235. else {
  106236. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  106237. callback();
  106238. }
  106239. };
  106240. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  106241. var _this = this;
  106242. if (this._isSupported) {
  106243. var targetStore;
  106244. if (url.indexOf(".babylon") !== -1) {
  106245. targetStore = "scenes";
  106246. }
  106247. else {
  106248. targetStore = "textures";
  106249. }
  106250. // Create XHR
  106251. var xhr = new _Misc_webRequest__WEBPACK_IMPORTED_MODULE_4__["WebRequest"]();
  106252. var fileData;
  106253. xhr.open("GET", url + "?" + Date.now());
  106254. if (useArrayBuffer) {
  106255. xhr.responseType = "arraybuffer";
  106256. }
  106257. if (progressCallback) {
  106258. xhr.onprogress = progressCallback;
  106259. }
  106260. xhr.addEventListener("load", function () {
  106261. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  106262. // Blob as response (XHR2)
  106263. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  106264. if (!_this._hasReachedQuota && _this._db) {
  106265. // Open a transaction to the database
  106266. var transaction = _this._db.transaction([targetStore], "readwrite");
  106267. // the transaction could abort because of a QuotaExceededError error
  106268. transaction.onabort = function (event) {
  106269. try {
  106270. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  106271. var error = event.srcElement['error'];
  106272. if (error && error.name === "QuotaExceededError") {
  106273. _this._hasReachedQuota = true;
  106274. }
  106275. }
  106276. catch (ex) { }
  106277. callback(fileData);
  106278. };
  106279. transaction.oncomplete = function () {
  106280. callback(fileData);
  106281. };
  106282. var newFile;
  106283. if (targetStore === "scenes") {
  106284. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  106285. }
  106286. else {
  106287. newFile = { textureUrl: url, data: fileData };
  106288. }
  106289. try {
  106290. // Put the scene into the database
  106291. var addRequest = transaction.objectStore(targetStore).put(newFile);
  106292. addRequest.onsuccess = function () {
  106293. };
  106294. addRequest.onerror = function () {
  106295. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  106296. };
  106297. }
  106298. catch (ex) {
  106299. callback(fileData);
  106300. }
  106301. }
  106302. else {
  106303. callback(fileData);
  106304. }
  106305. }
  106306. else {
  106307. if (xhr.status >= 400 && errorCallback) {
  106308. errorCallback(xhr);
  106309. }
  106310. else {
  106311. callback();
  106312. }
  106313. }
  106314. }, false);
  106315. xhr.addEventListener("error", function () {
  106316. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  106317. callback();
  106318. }, false);
  106319. xhr.send();
  106320. }
  106321. else {
  106322. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  106323. callback();
  106324. }
  106325. };
  106326. /**
  106327. * Validates if xhr data is correct
  106328. * @param xhr defines the request to validate
  106329. * @param dataType defines the expected data type
  106330. * @returns true if data is correct
  106331. */
  106332. Database._ValidateXHRData = function (xhr, dataType) {
  106333. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  106334. if (dataType === void 0) { dataType = 7; }
  106335. try {
  106336. if (dataType & 1) {
  106337. if (xhr.responseText && xhr.responseText.length > 0) {
  106338. return true;
  106339. }
  106340. else if (dataType === 1) {
  106341. return false;
  106342. }
  106343. }
  106344. if (dataType & 2) {
  106345. // Check header width and height since there is no "TGA" magic number
  106346. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  106347. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  106348. return true;
  106349. }
  106350. else if (dataType === 2) {
  106351. return false;
  106352. }
  106353. }
  106354. if (dataType & 4) {
  106355. // Check for the "DDS" magic number
  106356. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  106357. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  106358. return true;
  106359. }
  106360. else {
  106361. return false;
  106362. }
  106363. }
  106364. }
  106365. catch (e) {
  106366. // Global protection
  106367. }
  106368. return false;
  106369. };
  106370. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  106371. Database.IsUASupportingBlobStorage = true;
  106372. /**
  106373. * Gets a boolean indicating if Database storate is enabled (off by default)
  106374. */
  106375. Database.IDBStorageEnabled = false;
  106376. Database._ParseURL = function (url) {
  106377. var a = document.createElement('a');
  106378. a.href = url;
  106379. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  106380. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  106381. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  106382. return absLocation;
  106383. };
  106384. Database._ReturnFullUrlLocation = function (url) {
  106385. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  106386. return (Database._ParseURL(window.location.href) + url);
  106387. }
  106388. else {
  106389. return url;
  106390. }
  106391. };
  106392. return Database;
  106393. }());
  106394. /***/ }),
  106395. /***/ "./Offline/index.ts":
  106396. /*!**************************!*\
  106397. !*** ./Offline/index.ts ***!
  106398. \**************************/
  106399. /*! exports provided: Database */
  106400. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106401. "use strict";
  106402. __webpack_require__.r(__webpack_exports__);
  106403. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  106404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  106405. /***/ }),
  106406. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  106407. /*!******************************************************!*\
  106408. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  106409. \******************************************************/
  106410. /*! exports provided: BoxParticleEmitter */
  106411. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106412. "use strict";
  106413. __webpack_require__.r(__webpack_exports__);
  106414. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  106415. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  106416. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  106417. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  106418. /**
  106419. * Particle emitter emitting particles from the inside of a box.
  106420. * It emits the particles randomly between 2 given directions.
  106421. */
  106422. var BoxParticleEmitter = /** @class */ (function () {
  106423. /**
  106424. * Creates a new instance BoxParticleEmitter
  106425. */
  106426. function BoxParticleEmitter() {
  106427. /**
  106428. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  106429. */
  106430. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  106431. /**
  106432. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  106433. */
  106434. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  106435. /**
  106436. * 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.
  106437. */
  106438. this.minEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  106439. /**
  106440. * 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.
  106441. */
  106442. this.maxEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  106443. }
  106444. /**
  106445. * Called by the particle System when the direction is computed for the created particle.
  106446. * @param worldMatrix is the world matrix of the particle system
  106447. * @param directionToUpdate is the direction vector to update with the result
  106448. * @param particle is the particle we are computed the direction for
  106449. */
  106450. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  106451. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  106452. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  106453. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  106454. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  106455. };
  106456. /**
  106457. * Called by the particle System when the position is computed for the created particle.
  106458. * @param worldMatrix is the world matrix of the particle system
  106459. * @param positionToUpdate is the position vector to update with the result
  106460. * @param particle is the particle we are computed the position for
  106461. */
  106462. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  106463. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  106464. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  106465. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  106466. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  106467. };
  106468. /**
  106469. * Clones the current emitter and returns a copy of it
  106470. * @returns the new emitter
  106471. */
  106472. BoxParticleEmitter.prototype.clone = function () {
  106473. var newOne = new BoxParticleEmitter();
  106474. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  106475. return newOne;
  106476. };
  106477. /**
  106478. * Called by the GPUParticleSystem to setup the update shader
  106479. * @param effect defines the update shader
  106480. */
  106481. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  106482. effect.setVector3("direction1", this.direction1);
  106483. effect.setVector3("direction2", this.direction2);
  106484. effect.setVector3("minEmitBox", this.minEmitBox);
  106485. effect.setVector3("maxEmitBox", this.maxEmitBox);
  106486. };
  106487. /**
  106488. * Returns a string to use to update the GPU particles update shader
  106489. * @returns a string containng the defines string
  106490. */
  106491. BoxParticleEmitter.prototype.getEffectDefines = function () {
  106492. return "#define BOXEMITTER";
  106493. };
  106494. /**
  106495. * Returns the string "BoxParticleEmitter"
  106496. * @returns a string containing the class name
  106497. */
  106498. BoxParticleEmitter.prototype.getClassName = function () {
  106499. return "BoxParticleEmitter";
  106500. };
  106501. /**
  106502. * Serializes the particle system to a JSON object.
  106503. * @returns the JSON object
  106504. */
  106505. BoxParticleEmitter.prototype.serialize = function () {
  106506. var serializationObject = {};
  106507. serializationObject.type = this.getClassName();
  106508. serializationObject.direction1 = this.direction1.asArray();
  106509. serializationObject.direction2 = this.direction2.asArray();
  106510. serializationObject.minEmitBox = this.minEmitBox.asArray();
  106511. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  106512. return serializationObject;
  106513. };
  106514. /**
  106515. * Parse properties from a JSON object
  106516. * @param serializationObject defines the JSON object
  106517. */
  106518. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  106519. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  106520. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  106521. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  106522. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  106523. };
  106524. return BoxParticleEmitter;
  106525. }());
  106526. /***/ }),
  106527. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  106528. /*!*******************************************************!*\
  106529. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  106530. \*******************************************************/
  106531. /*! exports provided: ConeParticleEmitter */
  106532. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106533. "use strict";
  106534. __webpack_require__.r(__webpack_exports__);
  106535. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  106536. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  106537. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  106538. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  106539. /**
  106540. * Particle emitter emitting particles from the inside of a cone.
  106541. * It emits the particles alongside the cone volume from the base to the particle.
  106542. * The emission direction might be randomized.
  106543. */
  106544. var ConeParticleEmitter = /** @class */ (function () {
  106545. /**
  106546. * Creates a new instance ConeParticleEmitter
  106547. * @param radius the radius of the emission cone (1 by default)
  106548. * @param angle the cone base angle (PI by default)
  106549. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  106550. */
  106551. function ConeParticleEmitter(radius, angle,
  106552. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  106553. directionRandomizer) {
  106554. if (radius === void 0) { radius = 1; }
  106555. if (angle === void 0) { angle = Math.PI; }
  106556. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  106557. this.directionRandomizer = directionRandomizer;
  106558. /**
  106559. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  106560. */
  106561. this.radiusRange = 1;
  106562. /**
  106563. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  106564. */
  106565. this.heightRange = 1;
  106566. /**
  106567. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  106568. */
  106569. this.emitFromSpawnPointOnly = false;
  106570. this.angle = angle;
  106571. this.radius = radius;
  106572. }
  106573. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  106574. /**
  106575. * Gets or sets the radius of the emission cone
  106576. */
  106577. get: function () {
  106578. return this._radius;
  106579. },
  106580. set: function (value) {
  106581. this._radius = value;
  106582. this._buildHeight();
  106583. },
  106584. enumerable: true,
  106585. configurable: true
  106586. });
  106587. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  106588. /**
  106589. * Gets or sets the angle of the emission cone
  106590. */
  106591. get: function () {
  106592. return this._angle;
  106593. },
  106594. set: function (value) {
  106595. this._angle = value;
  106596. this._buildHeight();
  106597. },
  106598. enumerable: true,
  106599. configurable: true
  106600. });
  106601. ConeParticleEmitter.prototype._buildHeight = function () {
  106602. if (this._angle !== 0) {
  106603. this._height = this._radius / Math.tan(this._angle / 2);
  106604. }
  106605. else {
  106606. this._height = 1;
  106607. }
  106608. };
  106609. /**
  106610. * Called by the particle System when the direction is computed for the created particle.
  106611. * @param worldMatrix is the world matrix of the particle system
  106612. * @param directionToUpdate is the direction vector to update with the result
  106613. * @param particle is the particle we are computed the direction for
  106614. */
  106615. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  106616. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  106617. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  106618. }
  106619. else {
  106620. // measure the direction Vector from the emitter to the particle.
  106621. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  106622. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  106623. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  106624. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  106625. direction.x += randX;
  106626. direction.y += randY;
  106627. direction.z += randZ;
  106628. direction.normalize();
  106629. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  106630. }
  106631. };
  106632. /**
  106633. * Called by the particle System when the position is computed for the created particle.
  106634. * @param worldMatrix is the world matrix of the particle system
  106635. * @param positionToUpdate is the position vector to update with the result
  106636. * @param particle is the particle we are computed the position for
  106637. */
  106638. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  106639. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  106640. var h;
  106641. if (!this.emitFromSpawnPointOnly) {
  106642. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  106643. // Better distribution in a cone at normal angles.
  106644. h = 1 - h * h;
  106645. }
  106646. else {
  106647. h = 0.0001;
  106648. }
  106649. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  106650. radius = radius * h;
  106651. var randX = radius * Math.sin(s);
  106652. var randZ = radius * Math.cos(s);
  106653. var randY = h * this._height;
  106654. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  106655. };
  106656. /**
  106657. * Clones the current emitter and returns a copy of it
  106658. * @returns the new emitter
  106659. */
  106660. ConeParticleEmitter.prototype.clone = function () {
  106661. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  106662. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  106663. return newOne;
  106664. };
  106665. /**
  106666. * Called by the GPUParticleSystem to setup the update shader
  106667. * @param effect defines the update shader
  106668. */
  106669. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  106670. effect.setFloat2("radius", this._radius, this.radiusRange);
  106671. effect.setFloat("coneAngle", this._angle);
  106672. effect.setFloat2("height", this._height, this.heightRange);
  106673. effect.setFloat("directionRandomizer", this.directionRandomizer);
  106674. };
  106675. /**
  106676. * Returns a string to use to update the GPU particles update shader
  106677. * @returns a string containng the defines string
  106678. */
  106679. ConeParticleEmitter.prototype.getEffectDefines = function () {
  106680. var defines = "#define CONEEMITTER";
  106681. if (this.emitFromSpawnPointOnly) {
  106682. defines += "\n#define CONEEMITTERSPAWNPOINT";
  106683. }
  106684. return defines;
  106685. };
  106686. /**
  106687. * Returns the string "ConeParticleEmitter"
  106688. * @returns a string containing the class name
  106689. */
  106690. ConeParticleEmitter.prototype.getClassName = function () {
  106691. return "ConeParticleEmitter";
  106692. };
  106693. /**
  106694. * Serializes the particle system to a JSON object.
  106695. * @returns the JSON object
  106696. */
  106697. ConeParticleEmitter.prototype.serialize = function () {
  106698. var serializationObject = {};
  106699. serializationObject.type = this.getClassName();
  106700. serializationObject.radius = this._radius;
  106701. serializationObject.angle = this._angle;
  106702. serializationObject.directionRandomizer = this.directionRandomizer;
  106703. return serializationObject;
  106704. };
  106705. /**
  106706. * Parse properties from a JSON object
  106707. * @param serializationObject defines the JSON object
  106708. */
  106709. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  106710. this.radius = serializationObject.radius;
  106711. this.angle = serializationObject.angle;
  106712. this.directionRandomizer = serializationObject.directionRandomizer;
  106713. };
  106714. return ConeParticleEmitter;
  106715. }());
  106716. /***/ }),
  106717. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  106718. /*!***********************************************************!*\
  106719. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  106720. \***********************************************************/
  106721. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  106722. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106723. "use strict";
  106724. __webpack_require__.r(__webpack_exports__);
  106725. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  106726. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  106727. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  106728. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  106729. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  106730. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  106731. /**
  106732. * Particle emitter emitting particles from the inside of a cylinder.
  106733. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  106734. */
  106735. var CylinderParticleEmitter = /** @class */ (function () {
  106736. /**
  106737. * Creates a new instance CylinderParticleEmitter
  106738. * @param radius the radius of the emission cylinder (1 by default)
  106739. * @param height the height of the emission cylinder (1 by default)
  106740. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  106741. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  106742. */
  106743. function CylinderParticleEmitter(
  106744. /**
  106745. * The radius of the emission cylinder.
  106746. */
  106747. radius,
  106748. /**
  106749. * The height of the emission cylinder.
  106750. */
  106751. height,
  106752. /**
  106753. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  106754. */
  106755. radiusRange,
  106756. /**
  106757. * How much to randomize the particle direction [0-1].
  106758. */
  106759. directionRandomizer) {
  106760. if (radius === void 0) { radius = 1; }
  106761. if (height === void 0) { height = 1; }
  106762. if (radiusRange === void 0) { radiusRange = 1; }
  106763. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  106764. this.radius = radius;
  106765. this.height = height;
  106766. this.radiusRange = radiusRange;
  106767. this.directionRandomizer = directionRandomizer;
  106768. }
  106769. /**
  106770. * Called by the particle System when the direction is computed for the created particle.
  106771. * @param worldMatrix is the world matrix of the particle system
  106772. * @param directionToUpdate is the direction vector to update with the result
  106773. * @param particle is the particle we are computed the direction for
  106774. */
  106775. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  106776. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  106777. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  106778. var angle = Math.atan2(direction.x, direction.z);
  106779. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  106780. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  106781. direction.x = Math.sin(angle);
  106782. direction.z = Math.cos(angle);
  106783. direction.normalize();
  106784. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  106785. };
  106786. /**
  106787. * Called by the particle System when the position is computed for the created particle.
  106788. * @param worldMatrix is the world matrix of the particle system
  106789. * @param positionToUpdate is the position vector to update with the result
  106790. * @param particle is the particle we are computed the position for
  106791. */
  106792. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  106793. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  106794. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  106795. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  106796. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  106797. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  106798. var xPos = positionRadius * Math.cos(angle);
  106799. var zPos = positionRadius * Math.sin(angle);
  106800. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  106801. };
  106802. /**
  106803. * Clones the current emitter and returns a copy of it
  106804. * @returns the new emitter
  106805. */
  106806. CylinderParticleEmitter.prototype.clone = function () {
  106807. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  106808. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  106809. return newOne;
  106810. };
  106811. /**
  106812. * Called by the GPUParticleSystem to setup the update shader
  106813. * @param effect defines the update shader
  106814. */
  106815. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  106816. effect.setFloat("radius", this.radius);
  106817. effect.setFloat("height", this.height);
  106818. effect.setFloat("radiusRange", this.radiusRange);
  106819. effect.setFloat("directionRandomizer", this.directionRandomizer);
  106820. };
  106821. /**
  106822. * Returns a string to use to update the GPU particles update shader
  106823. * @returns a string containng the defines string
  106824. */
  106825. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  106826. return "#define CYLINDEREMITTER";
  106827. };
  106828. /**
  106829. * Returns the string "CylinderParticleEmitter"
  106830. * @returns a string containing the class name
  106831. */
  106832. CylinderParticleEmitter.prototype.getClassName = function () {
  106833. return "CylinderParticleEmitter";
  106834. };
  106835. /**
  106836. * Serializes the particle system to a JSON object.
  106837. * @returns the JSON object
  106838. */
  106839. CylinderParticleEmitter.prototype.serialize = function () {
  106840. var serializationObject = {};
  106841. serializationObject.type = this.getClassName();
  106842. serializationObject.radius = this.radius;
  106843. serializationObject.height = this.height;
  106844. serializationObject.radiusRange = this.radiusRange;
  106845. serializationObject.directionRandomizer = this.directionRandomizer;
  106846. return serializationObject;
  106847. };
  106848. /**
  106849. * Parse properties from a JSON object
  106850. * @param serializationObject defines the JSON object
  106851. */
  106852. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  106853. this.radius = serializationObject.radius;
  106854. this.height = serializationObject.height;
  106855. this.radiusRange = serializationObject.radiusRange;
  106856. this.directionRandomizer = serializationObject.directionRandomizer;
  106857. };
  106858. return CylinderParticleEmitter;
  106859. }());
  106860. /**
  106861. * Particle emitter emitting particles from the inside of a cylinder.
  106862. * It emits the particles randomly between two vectors.
  106863. */
  106864. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  106865. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  106866. /**
  106867. * Creates a new instance CylinderDirectedParticleEmitter
  106868. * @param radius the radius of the emission cylinder (1 by default)
  106869. * @param height the height of the emission cylinder (1 by default)
  106870. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  106871. * @param direction1 the min limit of the emission direction (up vector by default)
  106872. * @param direction2 the max limit of the emission direction (up vector by default)
  106873. */
  106874. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  106875. /**
  106876. * The min limit of the emission direction.
  106877. */
  106878. direction1,
  106879. /**
  106880. * The max limit of the emission direction.
  106881. */
  106882. direction2) {
  106883. if (radius === void 0) { radius = 1; }
  106884. if (height === void 0) { height = 1; }
  106885. if (radiusRange === void 0) { radiusRange = 1; }
  106886. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  106887. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  106888. var _this = _super.call(this, radius, height, radiusRange) || this;
  106889. _this.direction1 = direction1;
  106890. _this.direction2 = direction2;
  106891. return _this;
  106892. }
  106893. /**
  106894. * Called by the particle System when the direction is computed for the created particle.
  106895. * @param worldMatrix is the world matrix of the particle system
  106896. * @param directionToUpdate is the direction vector to update with the result
  106897. * @param particle is the particle we are computed the direction for
  106898. */
  106899. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  106900. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  106901. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  106902. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  106903. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  106904. };
  106905. /**
  106906. * Clones the current emitter and returns a copy of it
  106907. * @returns the new emitter
  106908. */
  106909. CylinderDirectedParticleEmitter.prototype.clone = function () {
  106910. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  106911. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  106912. return newOne;
  106913. };
  106914. /**
  106915. * Called by the GPUParticleSystem to setup the update shader
  106916. * @param effect defines the update shader
  106917. */
  106918. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  106919. effect.setFloat("radius", this.radius);
  106920. effect.setFloat("height", this.height);
  106921. effect.setFloat("radiusRange", this.radiusRange);
  106922. effect.setVector3("direction1", this.direction1);
  106923. effect.setVector3("direction2", this.direction2);
  106924. };
  106925. /**
  106926. * Returns a string to use to update the GPU particles update shader
  106927. * @returns a string containng the defines string
  106928. */
  106929. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  106930. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  106931. };
  106932. /**
  106933. * Returns the string "CylinderDirectedParticleEmitter"
  106934. * @returns a string containing the class name
  106935. */
  106936. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  106937. return "CylinderDirectedParticleEmitter";
  106938. };
  106939. /**
  106940. * Serializes the particle system to a JSON object.
  106941. * @returns the JSON object
  106942. */
  106943. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  106944. var serializationObject = _super.prototype.serialize.call(this);
  106945. serializationObject.direction1 = this.direction1.asArray();
  106946. serializationObject.direction2 = this.direction2.asArray();
  106947. return serializationObject;
  106948. };
  106949. /**
  106950. * Parse properties from a JSON object
  106951. * @param serializationObject defines the JSON object
  106952. */
  106953. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  106954. _super.prototype.parse.call(this, serializationObject);
  106955. this.direction1.copyFrom(serializationObject.direction1);
  106956. this.direction2.copyFrom(serializationObject.direction2);
  106957. };
  106958. return CylinderDirectedParticleEmitter;
  106959. }(CylinderParticleEmitter));
  106960. /***/ }),
  106961. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  106962. /*!**************************************************************!*\
  106963. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  106964. \**************************************************************/
  106965. /*! exports provided: HemisphericParticleEmitter */
  106966. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  106967. "use strict";
  106968. __webpack_require__.r(__webpack_exports__);
  106969. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  106970. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  106971. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  106972. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  106973. /**
  106974. * Particle emitter emitting particles from the inside of a hemisphere.
  106975. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  106976. */
  106977. var HemisphericParticleEmitter = /** @class */ (function () {
  106978. /**
  106979. * Creates a new instance HemisphericParticleEmitter
  106980. * @param radius the radius of the emission hemisphere (1 by default)
  106981. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  106982. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  106983. */
  106984. function HemisphericParticleEmitter(
  106985. /**
  106986. * The radius of the emission hemisphere.
  106987. */
  106988. radius,
  106989. /**
  106990. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  106991. */
  106992. radiusRange,
  106993. /**
  106994. * How much to randomize the particle direction [0-1].
  106995. */
  106996. directionRandomizer) {
  106997. if (radius === void 0) { radius = 1; }
  106998. if (radiusRange === void 0) { radiusRange = 1; }
  106999. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  107000. this.radius = radius;
  107001. this.radiusRange = radiusRange;
  107002. this.directionRandomizer = directionRandomizer;
  107003. }
  107004. /**
  107005. * Called by the particle System when the direction is computed for the created particle.
  107006. * @param worldMatrix is the world matrix of the particle system
  107007. * @param directionToUpdate is the direction vector to update with the result
  107008. * @param particle is the particle we are computed the direction for
  107009. */
  107010. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  107011. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  107012. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107013. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107014. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107015. direction.x += randX;
  107016. direction.y += randY;
  107017. direction.z += randZ;
  107018. direction.normalize();
  107019. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  107020. };
  107021. /**
  107022. * Called by the particle System when the position is computed for the created particle.
  107023. * @param worldMatrix is the world matrix of the particle system
  107024. * @param positionToUpdate is the position vector to update with the result
  107025. * @param particle is the particle we are computed the position for
  107026. */
  107027. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  107028. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  107029. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  107030. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  107031. var theta = Math.acos(2 * v - 1);
  107032. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  107033. var randY = randRadius * Math.cos(theta);
  107034. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  107035. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  107036. };
  107037. /**
  107038. * Clones the current emitter and returns a copy of it
  107039. * @returns the new emitter
  107040. */
  107041. HemisphericParticleEmitter.prototype.clone = function () {
  107042. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  107043. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  107044. return newOne;
  107045. };
  107046. /**
  107047. * Called by the GPUParticleSystem to setup the update shader
  107048. * @param effect defines the update shader
  107049. */
  107050. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  107051. effect.setFloat("radius", this.radius);
  107052. effect.setFloat("radiusRange", this.radiusRange);
  107053. effect.setFloat("directionRandomizer", this.directionRandomizer);
  107054. };
  107055. /**
  107056. * Returns a string to use to update the GPU particles update shader
  107057. * @returns a string containng the defines string
  107058. */
  107059. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  107060. return "#define HEMISPHERICEMITTER";
  107061. };
  107062. /**
  107063. * Returns the string "HemisphericParticleEmitter"
  107064. * @returns a string containing the class name
  107065. */
  107066. HemisphericParticleEmitter.prototype.getClassName = function () {
  107067. return "HemisphericParticleEmitter";
  107068. };
  107069. /**
  107070. * Serializes the particle system to a JSON object.
  107071. * @returns the JSON object
  107072. */
  107073. HemisphericParticleEmitter.prototype.serialize = function () {
  107074. var serializationObject = {};
  107075. serializationObject.type = this.getClassName();
  107076. serializationObject.radius = this.radius;
  107077. serializationObject.radiusRange = this.radiusRange;
  107078. serializationObject.directionRandomizer = this.directionRandomizer;
  107079. return serializationObject;
  107080. };
  107081. /**
  107082. * Parse properties from a JSON object
  107083. * @param serializationObject defines the JSON object
  107084. */
  107085. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  107086. this.radius = serializationObject.radius;
  107087. this.radiusRange = serializationObject.radiusRange;
  107088. this.directionRandomizer = serializationObject.directionRandomizer;
  107089. };
  107090. return HemisphericParticleEmitter;
  107091. }());
  107092. /***/ }),
  107093. /***/ "./Particles/EmitterTypes/index.ts":
  107094. /*!*****************************************!*\
  107095. !*** ./Particles/EmitterTypes/index.ts ***!
  107096. \*****************************************/
  107097. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  107098. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107099. "use strict";
  107100. __webpack_require__.r(__webpack_exports__);
  107101. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  107102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  107103. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  107104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  107105. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  107106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  107107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  107108. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  107109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  107110. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  107111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  107112. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  107113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  107114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  107115. /***/ }),
  107116. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  107117. /*!********************************************************!*\
  107118. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  107119. \********************************************************/
  107120. /*! exports provided: PointParticleEmitter */
  107121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107122. "use strict";
  107123. __webpack_require__.r(__webpack_exports__);
  107124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  107125. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  107126. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  107127. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  107128. /**
  107129. * Particle emitter emitting particles from a point.
  107130. * It emits the particles randomly between 2 given directions.
  107131. */
  107132. var PointParticleEmitter = /** @class */ (function () {
  107133. /**
  107134. * Creates a new instance PointParticleEmitter
  107135. */
  107136. function PointParticleEmitter() {
  107137. /**
  107138. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  107139. */
  107140. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  107141. /**
  107142. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  107143. */
  107144. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  107145. }
  107146. /**
  107147. * Called by the particle System when the direction is computed for the created particle.
  107148. * @param worldMatrix is the world matrix of the particle system
  107149. * @param directionToUpdate is the direction vector to update with the result
  107150. * @param particle is the particle we are computed the direction for
  107151. */
  107152. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  107153. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  107154. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  107155. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  107156. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  107157. };
  107158. /**
  107159. * Called by the particle System when the position is computed for the created particle.
  107160. * @param worldMatrix is the world matrix of the particle system
  107161. * @param positionToUpdate is the position vector to update with the result
  107162. * @param particle is the particle we are computed the position for
  107163. */
  107164. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  107165. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  107166. };
  107167. /**
  107168. * Clones the current emitter and returns a copy of it
  107169. * @returns the new emitter
  107170. */
  107171. PointParticleEmitter.prototype.clone = function () {
  107172. var newOne = new PointParticleEmitter();
  107173. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  107174. return newOne;
  107175. };
  107176. /**
  107177. * Called by the GPUParticleSystem to setup the update shader
  107178. * @param effect defines the update shader
  107179. */
  107180. PointParticleEmitter.prototype.applyToShader = function (effect) {
  107181. effect.setVector3("direction1", this.direction1);
  107182. effect.setVector3("direction2", this.direction2);
  107183. };
  107184. /**
  107185. * Returns a string to use to update the GPU particles update shader
  107186. * @returns a string containng the defines string
  107187. */
  107188. PointParticleEmitter.prototype.getEffectDefines = function () {
  107189. return "#define POINTEMITTER";
  107190. };
  107191. /**
  107192. * Returns the string "PointParticleEmitter"
  107193. * @returns a string containing the class name
  107194. */
  107195. PointParticleEmitter.prototype.getClassName = function () {
  107196. return "PointParticleEmitter";
  107197. };
  107198. /**
  107199. * Serializes the particle system to a JSON object.
  107200. * @returns the JSON object
  107201. */
  107202. PointParticleEmitter.prototype.serialize = function () {
  107203. var serializationObject = {};
  107204. serializationObject.type = this.getClassName();
  107205. serializationObject.direction1 = this.direction1.asArray();
  107206. serializationObject.direction2 = this.direction2.asArray();
  107207. return serializationObject;
  107208. };
  107209. /**
  107210. * Parse properties from a JSON object
  107211. * @param serializationObject defines the JSON object
  107212. */
  107213. PointParticleEmitter.prototype.parse = function (serializationObject) {
  107214. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  107215. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  107216. };
  107217. return PointParticleEmitter;
  107218. }());
  107219. /***/ }),
  107220. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  107221. /*!*********************************************************!*\
  107222. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  107223. \*********************************************************/
  107224. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  107225. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107226. "use strict";
  107227. __webpack_require__.r(__webpack_exports__);
  107228. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  107229. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  107230. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  107231. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  107232. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  107233. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  107234. /**
  107235. * Particle emitter emitting particles from the inside of a sphere.
  107236. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  107237. */
  107238. var SphereParticleEmitter = /** @class */ (function () {
  107239. /**
  107240. * Creates a new instance SphereParticleEmitter
  107241. * @param radius the radius of the emission sphere (1 by default)
  107242. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  107243. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  107244. */
  107245. function SphereParticleEmitter(
  107246. /**
  107247. * The radius of the emission sphere.
  107248. */
  107249. radius,
  107250. /**
  107251. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  107252. */
  107253. radiusRange,
  107254. /**
  107255. * How much to randomize the particle direction [0-1].
  107256. */
  107257. directionRandomizer) {
  107258. if (radius === void 0) { radius = 1; }
  107259. if (radiusRange === void 0) { radiusRange = 1; }
  107260. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  107261. this.radius = radius;
  107262. this.radiusRange = radiusRange;
  107263. this.directionRandomizer = directionRandomizer;
  107264. }
  107265. /**
  107266. * Called by the particle System when the direction is computed for the created particle.
  107267. * @param worldMatrix is the world matrix of the particle system
  107268. * @param directionToUpdate is the direction vector to update with the result
  107269. * @param particle is the particle we are computed the direction for
  107270. */
  107271. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  107272. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  107273. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107274. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107275. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  107276. direction.x += randX;
  107277. direction.y += randY;
  107278. direction.z += randZ;
  107279. direction.normalize();
  107280. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  107281. };
  107282. /**
  107283. * Called by the particle System when the position is computed for the created particle.
  107284. * @param worldMatrix is the world matrix of the particle system
  107285. * @param positionToUpdate is the position vector to update with the result
  107286. * @param particle is the particle we are computed the position for
  107287. */
  107288. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  107289. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  107290. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  107291. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  107292. var theta = Math.acos(2 * v - 1);
  107293. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  107294. var randY = randRadius * Math.cos(theta);
  107295. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  107296. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  107297. };
  107298. /**
  107299. * Clones the current emitter and returns a copy of it
  107300. * @returns the new emitter
  107301. */
  107302. SphereParticleEmitter.prototype.clone = function () {
  107303. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  107304. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  107305. return newOne;
  107306. };
  107307. /**
  107308. * Called by the GPUParticleSystem to setup the update shader
  107309. * @param effect defines the update shader
  107310. */
  107311. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  107312. effect.setFloat("radius", this.radius);
  107313. effect.setFloat("radiusRange", this.radiusRange);
  107314. effect.setFloat("directionRandomizer", this.directionRandomizer);
  107315. };
  107316. /**
  107317. * Returns a string to use to update the GPU particles update shader
  107318. * @returns a string containng the defines string
  107319. */
  107320. SphereParticleEmitter.prototype.getEffectDefines = function () {
  107321. return "#define SPHEREEMITTER";
  107322. };
  107323. /**
  107324. * Returns the string "SphereParticleEmitter"
  107325. * @returns a string containing the class name
  107326. */
  107327. SphereParticleEmitter.prototype.getClassName = function () {
  107328. return "SphereParticleEmitter";
  107329. };
  107330. /**
  107331. * Serializes the particle system to a JSON object.
  107332. * @returns the JSON object
  107333. */
  107334. SphereParticleEmitter.prototype.serialize = function () {
  107335. var serializationObject = {};
  107336. serializationObject.type = this.getClassName();
  107337. serializationObject.radius = this.radius;
  107338. serializationObject.radiusRange = this.radiusRange;
  107339. serializationObject.directionRandomizer = this.directionRandomizer;
  107340. return serializationObject;
  107341. };
  107342. /**
  107343. * Parse properties from a JSON object
  107344. * @param serializationObject defines the JSON object
  107345. */
  107346. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  107347. this.radius = serializationObject.radius;
  107348. this.radiusRange = serializationObject.radiusRange;
  107349. this.directionRandomizer = serializationObject.directionRandomizer;
  107350. };
  107351. return SphereParticleEmitter;
  107352. }());
  107353. /**
  107354. * Particle emitter emitting particles from the inside of a sphere.
  107355. * It emits the particles randomly between two vectors.
  107356. */
  107357. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  107358. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  107359. /**
  107360. * Creates a new instance SphereDirectedParticleEmitter
  107361. * @param radius the radius of the emission sphere (1 by default)
  107362. * @param direction1 the min limit of the emission direction (up vector by default)
  107363. * @param direction2 the max limit of the emission direction (up vector by default)
  107364. */
  107365. function SphereDirectedParticleEmitter(radius,
  107366. /**
  107367. * The min limit of the emission direction.
  107368. */
  107369. direction1,
  107370. /**
  107371. * The max limit of the emission direction.
  107372. */
  107373. direction2) {
  107374. if (radius === void 0) { radius = 1; }
  107375. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  107376. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  107377. var _this = _super.call(this, radius) || this;
  107378. _this.direction1 = direction1;
  107379. _this.direction2 = direction2;
  107380. return _this;
  107381. }
  107382. /**
  107383. * Called by the particle System when the direction is computed for the created particle.
  107384. * @param worldMatrix is the world matrix of the particle system
  107385. * @param directionToUpdate is the direction vector to update with the result
  107386. * @param particle is the particle we are computed the direction for
  107387. */
  107388. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  107389. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  107390. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  107391. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  107392. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  107393. };
  107394. /**
  107395. * Clones the current emitter and returns a copy of it
  107396. * @returns the new emitter
  107397. */
  107398. SphereDirectedParticleEmitter.prototype.clone = function () {
  107399. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  107400. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  107401. return newOne;
  107402. };
  107403. /**
  107404. * Called by the GPUParticleSystem to setup the update shader
  107405. * @param effect defines the update shader
  107406. */
  107407. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  107408. effect.setFloat("radius", this.radius);
  107409. effect.setFloat("radiusRange", this.radiusRange);
  107410. effect.setVector3("direction1", this.direction1);
  107411. effect.setVector3("direction2", this.direction2);
  107412. };
  107413. /**
  107414. * Returns a string to use to update the GPU particles update shader
  107415. * @returns a string containng the defines string
  107416. */
  107417. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  107418. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  107419. };
  107420. /**
  107421. * Returns the string "SphereDirectedParticleEmitter"
  107422. * @returns a string containing the class name
  107423. */
  107424. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  107425. return "SphereDirectedParticleEmitter";
  107426. };
  107427. /**
  107428. * Serializes the particle system to a JSON object.
  107429. * @returns the JSON object
  107430. */
  107431. SphereDirectedParticleEmitter.prototype.serialize = function () {
  107432. var serializationObject = _super.prototype.serialize.call(this);
  107433. serializationObject.direction1 = this.direction1.asArray();
  107434. serializationObject.direction2 = this.direction2.asArray();
  107435. return serializationObject;
  107436. };
  107437. /**
  107438. * Parse properties from a JSON object
  107439. * @param serializationObject defines the JSON object
  107440. */
  107441. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  107442. _super.prototype.parse.call(this, serializationObject);
  107443. this.direction1.copyFrom(serializationObject.direction1);
  107444. this.direction2.copyFrom(serializationObject.direction2);
  107445. };
  107446. return SphereDirectedParticleEmitter;
  107447. }(SphereParticleEmitter));
  107448. /***/ }),
  107449. /***/ "./Particles/baseParticleSystem.ts":
  107450. /*!*****************************************!*\
  107451. !*** ./Particles/baseParticleSystem.ts ***!
  107452. \*****************************************/
  107453. /*! exports provided: BaseParticleSystem */
  107454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  107455. "use strict";
  107456. __webpack_require__.r(__webpack_exports__);
  107457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  107458. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  107459. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  107460. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  107461. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  107462. /**
  107463. * This represents the base class for particle system in Babylon.
  107464. * 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.
  107465. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  107466. * @example https://doc.babylonjs.com/babylon101/particles
  107467. */
  107468. var BaseParticleSystem = /** @class */ (function () {
  107469. /**
  107470. * Instantiates a particle system.
  107471. * 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.
  107472. * @param name The name of the particle system
  107473. */
  107474. function BaseParticleSystem(name) {
  107475. /**
  107476. * List of animations used by the particle system.
  107477. */
  107478. this.animations = [];
  107479. /**
  107480. * The rendering group used by the Particle system to chose when to render.
  107481. */
  107482. this.renderingGroupId = 0;
  107483. /**
  107484. * The emitter represents the Mesh or position we are attaching the particle system to.
  107485. */
  107486. this.emitter = null;
  107487. /**
  107488. * The maximum number of particles to emit per frame
  107489. */
  107490. this.emitRate = 10;
  107491. /**
  107492. * If you want to launch only a few particles at once, that can be done, as well.
  107493. */
  107494. this.manualEmitCount = -1;
  107495. /**
  107496. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  107497. */
  107498. this.updateSpeed = 0.01;
  107499. /**
  107500. * The amount of time the particle system is running (depends of the overall update speed).
  107501. */
  107502. this.targetStopDuration = 0;
  107503. /**
  107504. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  107505. */
  107506. this.disposeOnStop = false;
  107507. /**
  107508. * Minimum power of emitting particles.
  107509. */
  107510. this.minEmitPower = 1;
  107511. /**
  107512. * Maximum power of emitting particles.
  107513. */
  107514. this.maxEmitPower = 1;
  107515. /**
  107516. * Minimum life time of emitting particles.
  107517. */
  107518. this.minLifeTime = 1;
  107519. /**
  107520. * Maximum life time of emitting particles.
  107521. */
  107522. this.maxLifeTime = 1;
  107523. /**
  107524. * Minimum Size of emitting particles.
  107525. */
  107526. this.minSize = 1;
  107527. /**
  107528. * Maximum Size of emitting particles.
  107529. */
  107530. this.maxSize = 1;
  107531. /**
  107532. * Minimum scale of emitting particles on X axis.
  107533. */
  107534. this.minScaleX = 1;
  107535. /**
  107536. * Maximum scale of emitting particles on X axis.
  107537. */
  107538. this.maxScaleX = 1;
  107539. /**
  107540. * Minimum scale of emitting particles on Y axis.
  107541. */
  107542. this.minScaleY = 1;
  107543. /**
  107544. * Maximum scale of emitting particles on Y axis.
  107545. */
  107546. this.maxScaleY = 1;
  107547. /**
  107548. * Gets or sets the minimal initial rotation in radians.
  107549. */
  107550. this.minInitialRotation = 0;
  107551. /**
  107552. * Gets or sets the maximal initial rotation in radians.
  107553. */
  107554. this.maxInitialRotation = 0;
  107555. /**
  107556. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  107557. */
  107558. this.minAngularSpeed = 0;
  107559. /**
  107560. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  107561. */
  107562. this.maxAngularSpeed = 0;
  107563. /**
  107564. * The layer mask we are rendering the particles through.
  107565. */
  107566. this.layerMask = 0x0FFFFFFF;
  107567. /**
  107568. * This can help using your own shader to render the particle system.
  107569. * The according effect will be created
  107570. */
  107571. this.customShader = null;
  107572. /**
  107573. * By default particle system starts as soon as they are created. This prevents the
  107574. * automatic start to happen and let you decide when to start emitting particles.
  107575. */
  107576. this.preventAutoStart = false;
  107577. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  107578. this.noiseStrength = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  107579. /**
  107580. * Callback triggered when the particle animation is ending.
  107581. */
  107582. this.onAnimationEnd = null;
  107583. /**
  107584. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  107585. */
  107586. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  107587. /**
  107588. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  107589. * to override the particles.
  107590. */
  107591. this.forceDepthWrite = false;
  107592. /** 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 */
  107593. this.preWarmCycles = 0;
  107594. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  107595. this.preWarmStepOffset = 1;
  107596. /**
  107597. * 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)
  107598. */
  107599. this.spriteCellChangeSpeed = 1;
  107600. /**
  107601. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  107602. */
  107603. this.startSpriteCellID = 0;
  107604. /**
  107605. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  107606. */
  107607. this.endSpriteCellID = 0;
  107608. /**
  107609. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  107610. */
  107611. this.spriteCellWidth = 0;
  107612. /**
  107613. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  107614. */
  107615. this.spriteCellHeight = 0;
  107616. /**
  107617. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  107618. */
  107619. this.spriteRandomStartCell = false;
  107620. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  107621. this.translationPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  107622. /**
  107623. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  107624. */
  107625. this.beginAnimationOnStart = false;
  107626. /**
  107627. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  107628. */
  107629. this.beginAnimationFrom = 0;
  107630. /**
  107631. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  107632. */
  107633. this.beginAnimationTo = 60;
  107634. /**
  107635. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  107636. */
  107637. this.beginAnimationLoop = false;
  107638. /**
  107639. * Gets or sets a world offset applied to all particles
  107640. */
  107641. this.worldOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  107642. /**
  107643. * You can use gravity if you want to give an orientation to your particles.
  107644. */
  107645. this.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107646. this._colorGradients = null;
  107647. this._sizeGradients = null;
  107648. this._lifeTimeGradients = null;
  107649. this._angularSpeedGradients = null;
  107650. this._velocityGradients = null;
  107651. this._limitVelocityGradients = null;
  107652. this._dragGradients = null;
  107653. this._emitRateGradients = null;
  107654. this._startSizeGradients = null;
  107655. this._rampGradients = null;
  107656. this._colorRemapGradients = null;
  107657. this._alphaRemapGradients = null;
  107658. /**
  107659. * Defines the delay in milliseconds before starting the system (0 by default)
  107660. */
  107661. this.startDelay = 0;
  107662. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  107663. this.limitVelocityDamping = 0.4;
  107664. /**
  107665. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  107666. */
  107667. this.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  107668. /**
  107669. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  107670. */
  107671. this.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  107672. /**
  107673. * Color the particle will have at the end of its lifetime
  107674. */
  107675. this.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 1.0);
  107676. /**
  107677. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  107678. */
  107679. this.textureMask = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  107680. /** @hidden */
  107681. this._isSubEmitter = false;
  107682. /**
  107683. * Gets or sets the billboard mode to use when isBillboardBased = true.
  107684. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  107685. */
  107686. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  107687. this._isBillboardBased = true;
  107688. /**
  107689. * Local cache of defines for image processing.
  107690. */
  107691. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  107692. this.id = name;
  107693. this.name = name;
  107694. }
  107695. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  107696. /**
  107697. * Gets or sets a texture used to add random noise to particle positions
  107698. */
  107699. get: function () {
  107700. return this._noiseTexture;
  107701. },
  107702. set: function (value) {
  107703. if (this._noiseTexture === value) {
  107704. return;
  107705. }
  107706. this._noiseTexture = value;
  107707. this._reset();
  107708. },
  107709. enumerable: true,
  107710. configurable: true
  107711. });
  107712. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  107713. /**
  107714. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  107715. */
  107716. get: function () {
  107717. return this._isAnimationSheetEnabled;
  107718. },
  107719. set: function (value) {
  107720. if (this._isAnimationSheetEnabled == value) {
  107721. return;
  107722. }
  107723. this._isAnimationSheetEnabled = value;
  107724. this._reset();
  107725. },
  107726. enumerable: true,
  107727. configurable: true
  107728. });
  107729. /**
  107730. * Get hosting scene
  107731. * @returns the scene
  107732. */
  107733. BaseParticleSystem.prototype.getScene = function () {
  107734. return this._scene;
  107735. };
  107736. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  107737. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  107738. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  107739. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  107740. };
  107741. /**
  107742. * Gets the current list of drag gradients.
  107743. * You must use addDragGradient and removeDragGradient to udpate this list
  107744. * @returns the list of drag gradients
  107745. */
  107746. BaseParticleSystem.prototype.getDragGradients = function () {
  107747. return this._dragGradients;
  107748. };
  107749. /**
  107750. * Gets the current list of limit velocity gradients.
  107751. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  107752. * @returns the list of limit velocity gradients
  107753. */
  107754. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  107755. return this._limitVelocityGradients;
  107756. };
  107757. /**
  107758. * Gets the current list of color gradients.
  107759. * You must use addColorGradient and removeColorGradient to udpate this list
  107760. * @returns the list of color gradients
  107761. */
  107762. BaseParticleSystem.prototype.getColorGradients = function () {
  107763. return this._colorGradients;
  107764. };
  107765. /**
  107766. * Gets the current list of size gradients.
  107767. * You must use addSizeGradient and removeSizeGradient to udpate this list
  107768. * @returns the list of size gradients
  107769. */
  107770. BaseParticleSystem.prototype.getSizeGradients = function () {
  107771. return this._sizeGradients;
  107772. };
  107773. /**
  107774. * Gets the current list of color remap gradients.
  107775. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  107776. * @returns the list of color remap gradients
  107777. */
  107778. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  107779. return this._colorRemapGradients;
  107780. };
  107781. /**
  107782. * Gets the current list of alpha remap gradients.
  107783. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  107784. * @returns the list of alpha remap gradients
  107785. */
  107786. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  107787. return this._alphaRemapGradients;
  107788. };
  107789. /**
  107790. * Gets the current list of life time gradients.
  107791. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  107792. * @returns the list of life time gradients
  107793. */
  107794. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  107795. return this._lifeTimeGradients;
  107796. };
  107797. /**
  107798. * Gets the current list of angular speed gradients.
  107799. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  107800. * @returns the list of angular speed gradients
  107801. */
  107802. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  107803. return this._angularSpeedGradients;
  107804. };
  107805. /**
  107806. * Gets the current list of velocity gradients.
  107807. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  107808. * @returns the list of velocity gradients
  107809. */
  107810. BaseParticleSystem.prototype.getVelocityGradients = function () {
  107811. return this._velocityGradients;
  107812. };
  107813. /**
  107814. * Gets the current list of start size gradients.
  107815. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  107816. * @returns the list of start size gradients
  107817. */
  107818. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  107819. return this._startSizeGradients;
  107820. };
  107821. /**
  107822. * Gets the current list of emit rate gradients.
  107823. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  107824. * @returns the list of emit rate gradients
  107825. */
  107826. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  107827. return this._emitRateGradients;
  107828. };
  107829. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  107830. /**
  107831. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  107832. * This only works when particleEmitterTyps is a BoxParticleEmitter
  107833. */
  107834. get: function () {
  107835. if (this.particleEmitterType.direction1) {
  107836. return this.particleEmitterType.direction1;
  107837. }
  107838. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107839. },
  107840. set: function (value) {
  107841. if (this.particleEmitterType.direction1) {
  107842. this.particleEmitterType.direction1 = value;
  107843. }
  107844. },
  107845. enumerable: true,
  107846. configurable: true
  107847. });
  107848. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  107849. /**
  107850. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  107851. * This only works when particleEmitterTyps is a BoxParticleEmitter
  107852. */
  107853. get: function () {
  107854. if (this.particleEmitterType.direction2) {
  107855. return this.particleEmitterType.direction2;
  107856. }
  107857. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107858. },
  107859. set: function (value) {
  107860. if (this.particleEmitterType.direction2) {
  107861. this.particleEmitterType.direction2 = value;
  107862. }
  107863. },
  107864. enumerable: true,
  107865. configurable: true
  107866. });
  107867. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  107868. /**
  107869. * 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.
  107870. * This only works when particleEmitterTyps is a BoxParticleEmitter
  107871. */
  107872. get: function () {
  107873. if (this.particleEmitterType.minEmitBox) {
  107874. return this.particleEmitterType.minEmitBox;
  107875. }
  107876. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107877. },
  107878. set: function (value) {
  107879. if (this.particleEmitterType.minEmitBox) {
  107880. this.particleEmitterType.minEmitBox = value;
  107881. }
  107882. },
  107883. enumerable: true,
  107884. configurable: true
  107885. });
  107886. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  107887. /**
  107888. * 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.
  107889. * This only works when particleEmitterTyps is a BoxParticleEmitter
  107890. */
  107891. get: function () {
  107892. if (this.particleEmitterType.maxEmitBox) {
  107893. return this.particleEmitterType.maxEmitBox;
  107894. }
  107895. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  107896. },
  107897. set: function (value) {
  107898. if (this.particleEmitterType.maxEmitBox) {
  107899. this.particleEmitterType.maxEmitBox = value;
  107900. }
  107901. },
  107902. enumerable: true,
  107903. configurable: true
  107904. });
  107905. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  107906. /**
  107907. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  107908. */
  107909. get: function () {
  107910. return this._isBillboardBased;
  107911. },
  107912. set: function (value) {
  107913. if (this._isBillboardBased === value) {
  107914. return;
  107915. }
  107916. this._isBillboardBased = value;
  107917. this._reset();
  107918. },
  107919. enumerable: true,
  107920. configurable: true
  107921. });
  107922. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  107923. /**
  107924. * Gets the image processing configuration used either in this material.
  107925. */
  107926. get: function () {
  107927. return this._imageProcessingConfiguration;
  107928. },
  107929. /**
  107930. * Sets the Default image processing configuration used either in the this material.
  107931. *
  107932. * If sets to null, the scene one is in use.
  107933. */
  107934. set: function (value) {
  107935. this._attachImageProcessingConfiguration(value);
  107936. },
  107937. enumerable: true,
  107938. configurable: true
  107939. });
  107940. /**
  107941. * Attaches a new image processing configuration to the Standard Material.
  107942. * @param configuration
  107943. */
  107944. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  107945. if (configuration === this._imageProcessingConfiguration) {
  107946. return;
  107947. }
  107948. // Pick the scene configuration if needed.
  107949. if (!configuration) {
  107950. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  107951. }
  107952. else {
  107953. this._imageProcessingConfiguration = configuration;
  107954. }
  107955. };
  107956. /** @hidden */
  107957. BaseParticleSystem.prototype._reset = function () {
  107958. };
  107959. /** @hidden */
  107960. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  107961. if (!gradients) {
  107962. return this;
  107963. }
  107964. var index = 0;
  107965. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  107966. var valueGradient = gradients_1[_i];
  107967. if (valueGradient.gradient === gradient) {
  107968. gradients.splice(index, 1);
  107969. break;
  107970. }
  107971. index++;
  107972. }
  107973. if (texture) {
  107974. texture.dispose();
  107975. }
  107976. return this;
  107977. };
  107978. /**
  107979. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  107980. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  107981. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  107982. * @returns the emitter
  107983. */
  107984. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  107985. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  107986. particleEmitter.direction1 = direction1;
  107987. particleEmitter.direction2 = direction2;
  107988. this.particleEmitterType = particleEmitter;
  107989. return particleEmitter;
  107990. };
  107991. /**
  107992. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  107993. * @param radius The radius of the hemisphere to emit from
  107994. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  107995. * @returns the emitter
  107996. */
  107997. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  107998. if (radius === void 0) { radius = 1; }
  107999. if (radiusRange === void 0) { radiusRange = 1; }
  108000. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  108001. this.particleEmitterType = particleEmitter;
  108002. return particleEmitter;
  108003. };
  108004. /**
  108005. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  108006. * @param radius The radius of the sphere to emit from
  108007. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  108008. * @returns the emitter
  108009. */
  108010. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  108011. if (radius === void 0) { radius = 1; }
  108012. if (radiusRange === void 0) { radiusRange = 1; }
  108013. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  108014. this.particleEmitterType = particleEmitter;
  108015. return particleEmitter;
  108016. };
  108017. /**
  108018. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  108019. * @param radius The radius of the sphere to emit from
  108020. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  108021. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  108022. * @returns the emitter
  108023. */
  108024. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  108025. if (radius === void 0) { radius = 1; }
  108026. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  108027. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  108028. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  108029. this.particleEmitterType = particleEmitter;
  108030. return particleEmitter;
  108031. };
  108032. /**
  108033. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  108034. * @param radius The radius of the emission cylinder
  108035. * @param height The height of the emission cylinder
  108036. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  108037. * @param directionRandomizer How much to randomize the particle direction [0-1]
  108038. * @returns the emitter
  108039. */
  108040. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  108041. if (radius === void 0) { radius = 1; }
  108042. if (height === void 0) { height = 1; }
  108043. if (radiusRange === void 0) { radiusRange = 1; }
  108044. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  108045. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  108046. this.particleEmitterType = particleEmitter;
  108047. return particleEmitter;
  108048. };
  108049. /**
  108050. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  108051. * @param radius The radius of the cylinder to emit from
  108052. * @param height The height of the emission cylinder
  108053. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  108054. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  108055. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  108056. * @returns the emitter
  108057. */
  108058. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  108059. if (radius === void 0) { radius = 1; }
  108060. if (height === void 0) { height = 1; }
  108061. if (radiusRange === void 0) { radiusRange = 1; }
  108062. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  108063. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  108064. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  108065. this.particleEmitterType = particleEmitter;
  108066. return particleEmitter;
  108067. };
  108068. /**
  108069. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  108070. * @param radius The radius of the cone to emit from
  108071. * @param angle The base angle of the cone
  108072. * @returns the emitter
  108073. */
  108074. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  108075. if (radius === void 0) { radius = 1; }
  108076. if (angle === void 0) { angle = Math.PI / 4; }
  108077. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  108078. this.particleEmitterType = particleEmitter;
  108079. return particleEmitter;
  108080. };
  108081. /**
  108082. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  108083. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  108084. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  108085. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  108086. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  108087. * @returns the emitter
  108088. */
  108089. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  108090. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  108091. this.particleEmitterType = particleEmitter;
  108092. this.direction1 = direction1;
  108093. this.direction2 = direction2;
  108094. this.minEmitBox = minEmitBox;
  108095. this.maxEmitBox = maxEmitBox;
  108096. return particleEmitter;
  108097. };
  108098. /**
  108099. * Source color is added to the destination color without alpha affecting the result
  108100. */
  108101. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  108102. /**
  108103. * Blend current color and particle color using particle’s alpha
  108104. */
  108105. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  108106. /**
  108107. * Add current color and particle color multiplied by particle’s alpha
  108108. */
  108109. BaseParticleSystem.BLENDMODE_ADD = 2;
  108110. /**
  108111. * Multiply current color with particle color
  108112. */
  108113. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  108114. /**
  108115. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  108116. */
  108117. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  108118. return BaseParticleSystem;
  108119. }());
  108120. /***/ }),
  108121. /***/ "./Particles/gpuParticleSystem.ts":
  108122. /*!****************************************!*\
  108123. !*** ./Particles/gpuParticleSystem.ts ***!
  108124. \****************************************/
  108125. /*! exports provided: GPUParticleSystem */
  108126. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108127. "use strict";
  108128. __webpack_require__.r(__webpack_exports__);
  108129. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  108130. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  108131. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  108132. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  108133. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  108134. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  108135. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  108136. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  108137. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  108138. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  108139. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  108140. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  108141. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  108142. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  108143. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  108144. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  108145. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  108146. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  108147. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  108148. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  108149. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  108150. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  108151. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  108152. /**
  108153. * This represents a GPU particle system in Babylon
  108154. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  108155. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  108156. */
  108157. var GPUParticleSystem = /** @class */ (function (_super) {
  108158. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  108159. /**
  108160. * Instantiates a GPU particle system.
  108161. * 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.
  108162. * @param name The name of the particle system
  108163. * @param options The options used to create the system
  108164. * @param scene The scene the particle system belongs to
  108165. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  108166. */
  108167. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  108168. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  108169. var _this = _super.call(this, name) || this;
  108170. /**
  108171. * The layer mask we are rendering the particles through.
  108172. */
  108173. _this.layerMask = 0x0FFFFFFF;
  108174. _this._accumulatedCount = 0;
  108175. _this._targetIndex = 0;
  108176. _this._currentRenderId = -1;
  108177. _this._started = false;
  108178. _this._stopped = false;
  108179. _this._timeDelta = 0;
  108180. _this._actualFrame = 0;
  108181. _this._rawTextureWidth = 256;
  108182. /**
  108183. * An event triggered when the system is disposed.
  108184. */
  108185. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  108186. /**
  108187. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  108188. * to override the particles.
  108189. */
  108190. _this.forceDepthWrite = false;
  108191. _this._preWarmDone = false;
  108192. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  108193. // Setup the default processing configuration to the scene.
  108194. _this._attachImageProcessingConfiguration(null);
  108195. _this._engine = _this._scene.getEngine();
  108196. if (!options.randomTextureSize) {
  108197. delete options.randomTextureSize;
  108198. }
  108199. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  108200. var optionsAsNumber = options;
  108201. if (isFinite(optionsAsNumber)) {
  108202. fullOptions.capacity = optionsAsNumber;
  108203. }
  108204. _this._capacity = fullOptions.capacity;
  108205. _this._activeCount = fullOptions.capacity;
  108206. _this._currentActiveCount = 0;
  108207. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  108208. _this._scene.particleSystems.push(_this);
  108209. _this._updateEffectOptions = {
  108210. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  108211. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  108212. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  108213. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  108214. uniformBuffersNames: [],
  108215. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  108216. defines: "",
  108217. fallbacks: null,
  108218. onCompiled: null,
  108219. onError: null,
  108220. indexParameters: null,
  108221. maxSimultaneousLights: 0,
  108222. transformFeedbackVaryings: []
  108223. };
  108224. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__["BoxParticleEmitter"]();
  108225. // Random data
  108226. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  108227. var d = [];
  108228. for (var i = 0; i < maxTextureSize; ++i) {
  108229. d.push(Math.random());
  108230. d.push(Math.random());
  108231. d.push(Math.random());
  108232. d.push(Math.random());
  108233. }
  108234. _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);
  108235. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  108236. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  108237. d = [];
  108238. for (var i = 0; i < maxTextureSize; ++i) {
  108239. d.push(Math.random());
  108240. d.push(Math.random());
  108241. d.push(Math.random());
  108242. d.push(Math.random());
  108243. }
  108244. _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);
  108245. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  108246. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  108247. _this._randomTextureSize = maxTextureSize;
  108248. return _this;
  108249. }
  108250. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  108251. /**
  108252. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  108253. */
  108254. get: function () {
  108255. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine) {
  108256. return false;
  108257. }
  108258. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  108259. },
  108260. enumerable: true,
  108261. configurable: true
  108262. });
  108263. /**
  108264. * Gets the maximum number of particles active at the same time.
  108265. * @returns The max number of active particles.
  108266. */
  108267. GPUParticleSystem.prototype.getCapacity = function () {
  108268. return this._capacity;
  108269. };
  108270. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  108271. /**
  108272. * Gets or set the number of active particles
  108273. */
  108274. get: function () {
  108275. return this._activeCount;
  108276. },
  108277. set: function (value) {
  108278. this._activeCount = Math.min(value, this._capacity);
  108279. },
  108280. enumerable: true,
  108281. configurable: true
  108282. });
  108283. /**
  108284. * Is this system ready to be used/rendered
  108285. * @return true if the system is ready
  108286. */
  108287. GPUParticleSystem.prototype.isReady = function () {
  108288. if (!this._updateEffect) {
  108289. this._recreateUpdateEffect();
  108290. this._recreateRenderEffect();
  108291. return false;
  108292. }
  108293. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  108294. return false;
  108295. }
  108296. return true;
  108297. };
  108298. /**
  108299. * Gets if the system has been started. (Note: this will still be true after stop is called)
  108300. * @returns True if it has been started, otherwise false.
  108301. */
  108302. GPUParticleSystem.prototype.isStarted = function () {
  108303. return this._started;
  108304. };
  108305. /**
  108306. * Starts the particle system and begins to emit
  108307. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  108308. */
  108309. GPUParticleSystem.prototype.start = function (delay) {
  108310. var _this = this;
  108311. if (delay === void 0) { delay = this.startDelay; }
  108312. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  108313. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  108314. }
  108315. if (delay) {
  108316. setTimeout(function () {
  108317. _this.start(0);
  108318. }, delay);
  108319. return;
  108320. }
  108321. this._started = true;
  108322. this._stopped = false;
  108323. this._preWarmDone = false;
  108324. // Animations
  108325. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  108326. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  108327. }
  108328. };
  108329. /**
  108330. * Stops the particle system.
  108331. */
  108332. GPUParticleSystem.prototype.stop = function () {
  108333. this._stopped = true;
  108334. };
  108335. /**
  108336. * Remove all active particles
  108337. */
  108338. GPUParticleSystem.prototype.reset = function () {
  108339. this._releaseBuffers();
  108340. this._releaseVAOs();
  108341. this._currentActiveCount = 0;
  108342. this._targetIndex = 0;
  108343. };
  108344. /**
  108345. * Returns the string "GPUParticleSystem"
  108346. * @returns a string containing the class name
  108347. */
  108348. GPUParticleSystem.prototype.getClassName = function () {
  108349. return "GPUParticleSystem";
  108350. };
  108351. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  108352. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  108353. this._releaseBuffers();
  108354. return this;
  108355. };
  108356. /**
  108357. * Adds a new color gradient
  108358. * @param gradient defines the gradient to use (between 0 and 1)
  108359. * @param color1 defines the color to affect to the specified gradient
  108360. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  108361. * @returns the current particle system
  108362. */
  108363. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  108364. if (!this._colorGradients) {
  108365. this._colorGradients = [];
  108366. }
  108367. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  108368. colorGradient.gradient = gradient;
  108369. colorGradient.color1 = color1;
  108370. this._colorGradients.push(colorGradient);
  108371. this._colorGradients.sort(function (a, b) {
  108372. if (a.gradient < b.gradient) {
  108373. return -1;
  108374. }
  108375. else if (a.gradient > b.gradient) {
  108376. return 1;
  108377. }
  108378. return 0;
  108379. });
  108380. if (this._colorGradientsTexture) {
  108381. this._colorGradientsTexture.dispose();
  108382. this._colorGradientsTexture = null;
  108383. }
  108384. this._releaseBuffers();
  108385. return this;
  108386. };
  108387. /**
  108388. * Remove a specific color gradient
  108389. * @param gradient defines the gradient to remove
  108390. * @returns the current particle system
  108391. */
  108392. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  108393. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  108394. this._colorGradientsTexture = null;
  108395. return this;
  108396. };
  108397. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  108398. var valueGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  108399. valueGradient.gradient = gradient;
  108400. valueGradient.factor1 = factor;
  108401. factorGradients.push(valueGradient);
  108402. factorGradients.sort(function (a, b) {
  108403. if (a.gradient < b.gradient) {
  108404. return -1;
  108405. }
  108406. else if (a.gradient > b.gradient) {
  108407. return 1;
  108408. }
  108409. return 0;
  108410. });
  108411. this._releaseBuffers();
  108412. };
  108413. /**
  108414. * Adds a new size gradient
  108415. * @param gradient defines the gradient to use (between 0 and 1)
  108416. * @param factor defines the size factor to affect to the specified gradient
  108417. * @returns the current particle system
  108418. */
  108419. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  108420. if (!this._sizeGradients) {
  108421. this._sizeGradients = [];
  108422. }
  108423. this._addFactorGradient(this._sizeGradients, gradient, factor);
  108424. if (this._sizeGradientsTexture) {
  108425. this._sizeGradientsTexture.dispose();
  108426. this._sizeGradientsTexture = null;
  108427. }
  108428. this._releaseBuffers();
  108429. return this;
  108430. };
  108431. /**
  108432. * Remove a specific size gradient
  108433. * @param gradient defines the gradient to remove
  108434. * @returns the current particle system
  108435. */
  108436. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  108437. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  108438. this._sizeGradientsTexture = null;
  108439. return this;
  108440. };
  108441. /**
  108442. * Adds a new angular speed gradient
  108443. * @param gradient defines the gradient to use (between 0 and 1)
  108444. * @param factor defines the angular speed to affect to the specified gradient
  108445. * @returns the current particle system
  108446. */
  108447. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  108448. if (!this._angularSpeedGradients) {
  108449. this._angularSpeedGradients = [];
  108450. }
  108451. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  108452. if (this._angularSpeedGradientsTexture) {
  108453. this._angularSpeedGradientsTexture.dispose();
  108454. this._angularSpeedGradientsTexture = null;
  108455. }
  108456. this._releaseBuffers();
  108457. return this;
  108458. };
  108459. /**
  108460. * Remove a specific angular speed gradient
  108461. * @param gradient defines the gradient to remove
  108462. * @returns the current particle system
  108463. */
  108464. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  108465. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  108466. this._angularSpeedGradientsTexture = null;
  108467. return this;
  108468. };
  108469. /**
  108470. * Adds a new velocity gradient
  108471. * @param gradient defines the gradient to use (between 0 and 1)
  108472. * @param factor defines the velocity to affect to the specified gradient
  108473. * @returns the current particle system
  108474. */
  108475. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  108476. if (!this._velocityGradients) {
  108477. this._velocityGradients = [];
  108478. }
  108479. this._addFactorGradient(this._velocityGradients, gradient, factor);
  108480. if (this._velocityGradientsTexture) {
  108481. this._velocityGradientsTexture.dispose();
  108482. this._velocityGradientsTexture = null;
  108483. }
  108484. this._releaseBuffers();
  108485. return this;
  108486. };
  108487. /**
  108488. * Remove a specific velocity gradient
  108489. * @param gradient defines the gradient to remove
  108490. * @returns the current particle system
  108491. */
  108492. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  108493. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  108494. this._velocityGradientsTexture = null;
  108495. return this;
  108496. };
  108497. /**
  108498. * Adds a new limit velocity gradient
  108499. * @param gradient defines the gradient to use (between 0 and 1)
  108500. * @param factor defines the limit velocity value to affect to the specified gradient
  108501. * @returns the current particle system
  108502. */
  108503. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  108504. if (!this._limitVelocityGradients) {
  108505. this._limitVelocityGradients = [];
  108506. }
  108507. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  108508. if (this._limitVelocityGradientsTexture) {
  108509. this._limitVelocityGradientsTexture.dispose();
  108510. this._limitVelocityGradientsTexture = null;
  108511. }
  108512. this._releaseBuffers();
  108513. return this;
  108514. };
  108515. /**
  108516. * Remove a specific limit velocity gradient
  108517. * @param gradient defines the gradient to remove
  108518. * @returns the current particle system
  108519. */
  108520. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  108521. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  108522. this._limitVelocityGradientsTexture = null;
  108523. return this;
  108524. };
  108525. /**
  108526. * Adds a new drag gradient
  108527. * @param gradient defines the gradient to use (between 0 and 1)
  108528. * @param factor defines the drag value to affect to the specified gradient
  108529. * @returns the current particle system
  108530. */
  108531. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  108532. if (!this._dragGradients) {
  108533. this._dragGradients = [];
  108534. }
  108535. this._addFactorGradient(this._dragGradients, gradient, factor);
  108536. if (this._dragGradientsTexture) {
  108537. this._dragGradientsTexture.dispose();
  108538. this._dragGradientsTexture = null;
  108539. }
  108540. this._releaseBuffers();
  108541. return this;
  108542. };
  108543. /**
  108544. * Remove a specific drag gradient
  108545. * @param gradient defines the gradient to remove
  108546. * @returns the current particle system
  108547. */
  108548. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  108549. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  108550. this._dragGradientsTexture = null;
  108551. return this;
  108552. };
  108553. /**
  108554. * Not supported by GPUParticleSystem
  108555. * @param gradient defines the gradient to use (between 0 and 1)
  108556. * @param factor defines the emit rate value to affect to the specified gradient
  108557. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108558. * @returns the current particle system
  108559. */
  108560. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  108561. // Do nothing as emit rate is not supported by GPUParticleSystem
  108562. return this;
  108563. };
  108564. /**
  108565. * Not supported by GPUParticleSystem
  108566. * @param gradient defines the gradient to remove
  108567. * @returns the current particle system
  108568. */
  108569. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  108570. // Do nothing as emit rate is not supported by GPUParticleSystem
  108571. return this;
  108572. };
  108573. /**
  108574. * Not supported by GPUParticleSystem
  108575. * @param gradient defines the gradient to use (between 0 and 1)
  108576. * @param factor defines the start size value to affect to the specified gradient
  108577. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108578. * @returns the current particle system
  108579. */
  108580. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  108581. // Do nothing as start size is not supported by GPUParticleSystem
  108582. return this;
  108583. };
  108584. /**
  108585. * Not supported by GPUParticleSystem
  108586. * @param gradient defines the gradient to remove
  108587. * @returns the current particle system
  108588. */
  108589. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  108590. // Do nothing as start size is not supported by GPUParticleSystem
  108591. return this;
  108592. };
  108593. /**
  108594. * Not supported by GPUParticleSystem
  108595. * @param gradient defines the gradient to use (between 0 and 1)
  108596. * @param min defines the color remap minimal range
  108597. * @param max defines the color remap maximal range
  108598. * @returns the current particle system
  108599. */
  108600. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  108601. // Do nothing as start size is not supported by GPUParticleSystem
  108602. return this;
  108603. };
  108604. /**
  108605. * Not supported by GPUParticleSystem
  108606. * @param gradient defines the gradient to remove
  108607. * @returns the current particle system
  108608. */
  108609. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  108610. // Do nothing as start size is not supported by GPUParticleSystem
  108611. return this;
  108612. };
  108613. /**
  108614. * Not supported by GPUParticleSystem
  108615. * @param gradient defines the gradient to use (between 0 and 1)
  108616. * @param min defines the alpha remap minimal range
  108617. * @param max defines the alpha remap maximal range
  108618. * @returns the current particle system
  108619. */
  108620. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  108621. // Do nothing as start size is not supported by GPUParticleSystem
  108622. return this;
  108623. };
  108624. /**
  108625. * Not supported by GPUParticleSystem
  108626. * @param gradient defines the gradient to remove
  108627. * @returns the current particle system
  108628. */
  108629. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  108630. // Do nothing as start size is not supported by GPUParticleSystem
  108631. return this;
  108632. };
  108633. /**
  108634. * Not supported by GPUParticleSystem
  108635. * @param gradient defines the gradient to use (between 0 and 1)
  108636. * @param color defines the color to affect to the specified gradient
  108637. * @returns the current particle system
  108638. */
  108639. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  108640. //Not supported by GPUParticleSystem
  108641. return this;
  108642. };
  108643. /**
  108644. * Not supported by GPUParticleSystem
  108645. * @param gradient defines the gradient to remove
  108646. * @returns the current particle system
  108647. */
  108648. GPUParticleSystem.prototype.removeRampGradient = function () {
  108649. //Not supported by GPUParticleSystem
  108650. return this;
  108651. };
  108652. /**
  108653. * Not supported by GPUParticleSystem
  108654. * @returns the list of ramp gradients
  108655. */
  108656. GPUParticleSystem.prototype.getRampGradients = function () {
  108657. return null;
  108658. };
  108659. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  108660. /**
  108661. * Not supported by GPUParticleSystem
  108662. * Gets or sets a boolean indicating that ramp gradients must be used
  108663. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  108664. */
  108665. get: function () {
  108666. //Not supported by GPUParticleSystem
  108667. return false;
  108668. },
  108669. set: function (value) {
  108670. //Not supported by GPUParticleSystem
  108671. },
  108672. enumerable: true,
  108673. configurable: true
  108674. });
  108675. /**
  108676. * Not supported by GPUParticleSystem
  108677. * @param gradient defines the gradient to use (between 0 and 1)
  108678. * @param factor defines the life time factor to affect to the specified gradient
  108679. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  108680. * @returns the current particle system
  108681. */
  108682. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  108683. //Not supported by GPUParticleSystem
  108684. return this;
  108685. };
  108686. /**
  108687. * Not supported by GPUParticleSystem
  108688. * @param gradient defines the gradient to remove
  108689. * @returns the current particle system
  108690. */
  108691. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  108692. //Not supported by GPUParticleSystem
  108693. return this;
  108694. };
  108695. GPUParticleSystem.prototype._reset = function () {
  108696. this._releaseBuffers();
  108697. };
  108698. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  108699. var updateVertexBuffers = {};
  108700. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  108701. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  108702. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  108703. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  108704. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  108705. var offset = 12;
  108706. if (!this._colorGradientsTexture) {
  108707. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  108708. offset += 4;
  108709. }
  108710. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  108711. offset += 3;
  108712. if (!this._isBillboardBased) {
  108713. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  108714. offset += 3;
  108715. }
  108716. if (this._angularSpeedGradientsTexture) {
  108717. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  108718. offset += 1;
  108719. }
  108720. else {
  108721. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  108722. offset += 2;
  108723. }
  108724. if (this._isAnimationSheetEnabled) {
  108725. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  108726. offset += 1;
  108727. if (this.spriteRandomStartCell) {
  108728. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  108729. offset += 1;
  108730. }
  108731. }
  108732. if (this.noiseTexture) {
  108733. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  108734. offset += 3;
  108735. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  108736. offset += 3;
  108737. }
  108738. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  108739. this._engine.bindArrayBuffer(null);
  108740. return vao;
  108741. };
  108742. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  108743. var renderVertexBuffers = {};
  108744. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  108745. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  108746. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  108747. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  108748. var offset = 12;
  108749. if (!this._colorGradientsTexture) {
  108750. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  108751. offset += 4;
  108752. }
  108753. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  108754. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  108755. }
  108756. offset += 3; // Direction
  108757. if (!this._isBillboardBased) {
  108758. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  108759. offset += 3;
  108760. }
  108761. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  108762. if (this._angularSpeedGradientsTexture) {
  108763. offset++;
  108764. }
  108765. else {
  108766. offset += 2;
  108767. }
  108768. if (this._isAnimationSheetEnabled) {
  108769. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  108770. offset += 1;
  108771. if (this.spriteRandomStartCell) {
  108772. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  108773. offset += 1;
  108774. }
  108775. }
  108776. if (this.noiseTexture) {
  108777. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  108778. offset += 3;
  108779. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  108780. offset += 3;
  108781. }
  108782. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  108783. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  108784. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  108785. this._engine.bindArrayBuffer(null);
  108786. return vao;
  108787. };
  108788. GPUParticleSystem.prototype._initialize = function (force) {
  108789. if (force === void 0) { force = false; }
  108790. if (this._buffer0 && !force) {
  108791. return;
  108792. }
  108793. var engine = this._scene.getEngine();
  108794. var data = new Array();
  108795. this._attributesStrideSize = 21;
  108796. this._targetIndex = 0;
  108797. if (!this.isBillboardBased) {
  108798. this._attributesStrideSize += 3;
  108799. }
  108800. if (this._colorGradientsTexture) {
  108801. this._attributesStrideSize -= 4;
  108802. }
  108803. if (this._angularSpeedGradientsTexture) {
  108804. this._attributesStrideSize -= 1;
  108805. }
  108806. if (this._isAnimationSheetEnabled) {
  108807. this._attributesStrideSize += 1;
  108808. if (this.spriteRandomStartCell) {
  108809. this._attributesStrideSize += 1;
  108810. }
  108811. }
  108812. if (this.noiseTexture) {
  108813. this._attributesStrideSize += 6;
  108814. }
  108815. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  108816. // position
  108817. data.push(0.0);
  108818. data.push(0.0);
  108819. data.push(0.0);
  108820. // Age and life
  108821. data.push(0.0); // create the particle as a dead one to create a new one at start
  108822. data.push(0.0);
  108823. // Seed
  108824. data.push(Math.random());
  108825. data.push(Math.random());
  108826. data.push(Math.random());
  108827. data.push(Math.random());
  108828. // Size
  108829. data.push(0.0);
  108830. data.push(0.0);
  108831. data.push(0.0);
  108832. if (!this._colorGradientsTexture) {
  108833. // color
  108834. data.push(0.0);
  108835. data.push(0.0);
  108836. data.push(0.0);
  108837. data.push(0.0);
  108838. }
  108839. // direction
  108840. data.push(0.0);
  108841. data.push(0.0);
  108842. data.push(0.0);
  108843. if (!this.isBillboardBased) {
  108844. // initialDirection
  108845. data.push(0.0);
  108846. data.push(0.0);
  108847. data.push(0.0);
  108848. }
  108849. // angle
  108850. data.push(0.0);
  108851. if (!this._angularSpeedGradientsTexture) {
  108852. data.push(0.0);
  108853. }
  108854. if (this._isAnimationSheetEnabled) {
  108855. data.push(0.0);
  108856. if (this.spriteRandomStartCell) {
  108857. data.push(0.0);
  108858. }
  108859. }
  108860. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  108861. data.push(Math.random());
  108862. data.push(Math.random());
  108863. data.push(Math.random());
  108864. data.push(Math.random());
  108865. data.push(Math.random());
  108866. data.push(Math.random());
  108867. }
  108868. }
  108869. // Sprite data
  108870. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  108871. -0.5, 0.5, 0, 1,
  108872. -0.5, -0.5, 0, 0,
  108873. 0.5, -0.5, 1, 0]);
  108874. // Buffers
  108875. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  108876. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  108877. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 4);
  108878. // Update VAO
  108879. this._updateVAO = [];
  108880. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  108881. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  108882. // Render VAO
  108883. this._renderVAO = [];
  108884. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  108885. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  108886. // Links
  108887. this._sourceBuffer = this._buffer0;
  108888. this._targetBuffer = this._buffer1;
  108889. };
  108890. /** @hidden */
  108891. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  108892. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  108893. if (this._isBillboardBased) {
  108894. defines += "\n#define BILLBOARD";
  108895. }
  108896. if (this._colorGradientsTexture) {
  108897. defines += "\n#define COLORGRADIENTS";
  108898. }
  108899. if (this._sizeGradientsTexture) {
  108900. defines += "\n#define SIZEGRADIENTS";
  108901. }
  108902. if (this._angularSpeedGradientsTexture) {
  108903. defines += "\n#define ANGULARSPEEDGRADIENTS";
  108904. }
  108905. if (this._velocityGradientsTexture) {
  108906. defines += "\n#define VELOCITYGRADIENTS";
  108907. }
  108908. if (this._limitVelocityGradientsTexture) {
  108909. defines += "\n#define LIMITVELOCITYGRADIENTS";
  108910. }
  108911. if (this._dragGradientsTexture) {
  108912. defines += "\n#define DRAGGRADIENTS";
  108913. }
  108914. if (this.isAnimationSheetEnabled) {
  108915. defines += "\n#define ANIMATESHEET";
  108916. if (this.spriteRandomStartCell) {
  108917. defines += "\n#define ANIMATESHEETRANDOMSTART";
  108918. }
  108919. }
  108920. if (this.noiseTexture) {
  108921. defines += "\n#define NOISE";
  108922. }
  108923. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  108924. return;
  108925. }
  108926. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  108927. if (!this._colorGradientsTexture) {
  108928. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  108929. }
  108930. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  108931. if (!this._isBillboardBased) {
  108932. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  108933. }
  108934. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  108935. if (this.isAnimationSheetEnabled) {
  108936. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  108937. if (this.spriteRandomStartCell) {
  108938. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  108939. }
  108940. }
  108941. if (this.noiseTexture) {
  108942. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  108943. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  108944. }
  108945. this._updateEffectOptions.defines = defines;
  108946. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  108947. };
  108948. /** @hidden */
  108949. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  108950. var defines = "";
  108951. if (this._scene.clipPlane) {
  108952. defines = "\n#define CLIPPLANE";
  108953. }
  108954. if (this._scene.clipPlane2) {
  108955. defines = "\n#define CLIPPLANE2";
  108956. }
  108957. if (this._scene.clipPlane3) {
  108958. defines = "\n#define CLIPPLANE3";
  108959. }
  108960. if (this._scene.clipPlane4) {
  108961. defines = "\n#define CLIPPLANE4";
  108962. }
  108963. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  108964. defines = "\n#define BLENDMULTIPLYMODE";
  108965. }
  108966. if (this._isBillboardBased) {
  108967. defines += "\n#define BILLBOARD";
  108968. switch (this.billboardMode) {
  108969. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_Y:
  108970. defines += "\n#define BILLBOARDY";
  108971. break;
  108972. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  108973. defines += "\n#define BILLBOARDSTRETCHED";
  108974. break;
  108975. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_ALL:
  108976. default:
  108977. break;
  108978. }
  108979. }
  108980. if (this._colorGradientsTexture) {
  108981. defines += "\n#define COLORGRADIENTS";
  108982. }
  108983. if (this.isAnimationSheetEnabled) {
  108984. defines += "\n#define ANIMATESHEET";
  108985. }
  108986. if (this._imageProcessingConfiguration) {
  108987. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  108988. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  108989. }
  108990. if (this._renderEffect && this._renderEffect.defines === defines) {
  108991. return;
  108992. }
  108993. var uniforms = ["worldOffset", "view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  108994. var samplers = ["textureSampler", "colorGradientSampler"];
  108995. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  108996. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  108997. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  108998. }
  108999. 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);
  109000. };
  109001. /**
  109002. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  109003. * @param preWarm defines if we are in the pre-warmimg phase
  109004. */
  109005. GPUParticleSystem.prototype.animate = function (preWarm) {
  109006. if (preWarm === void 0) { preWarm = false; }
  109007. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  109008. this._actualFrame += this._timeDelta;
  109009. if (!this._stopped) {
  109010. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  109011. this.stop();
  109012. }
  109013. }
  109014. };
  109015. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  109016. var texture = this[textureName];
  109017. if (!factorGradients || !factorGradients.length || texture) {
  109018. return;
  109019. }
  109020. var data = new Float32Array(this._rawTextureWidth);
  109021. for (var x = 0; x < this._rawTextureWidth; x++) {
  109022. var ratio = x / this._rawTextureWidth;
  109023. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  109024. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  109025. });
  109026. }
  109027. 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);
  109028. };
  109029. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  109030. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  109031. };
  109032. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  109033. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  109034. };
  109035. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  109036. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  109037. };
  109038. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  109039. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  109040. };
  109041. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  109042. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  109043. };
  109044. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  109045. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  109046. return;
  109047. }
  109048. var data = new Uint8Array(this._rawTextureWidth * 4);
  109049. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color4[0];
  109050. for (var x = 0; x < this._rawTextureWidth; x++) {
  109051. var ratio = x / this._rawTextureWidth;
  109052. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  109053. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  109054. data[x * 4] = tmpColor.r * 255;
  109055. data[x * 4 + 1] = tmpColor.g * 255;
  109056. data[x * 4 + 2] = tmpColor.b * 255;
  109057. data[x * 4 + 3] = tmpColor.a * 255;
  109058. });
  109059. }
  109060. 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);
  109061. };
  109062. /**
  109063. * Renders the particle system in its current state
  109064. * @param preWarm defines if the system should only update the particles but not render them
  109065. * @returns the current number of particles
  109066. */
  109067. GPUParticleSystem.prototype.render = function (preWarm) {
  109068. if (preWarm === void 0) { preWarm = false; }
  109069. if (!this._started) {
  109070. return 0;
  109071. }
  109072. this._createColorGradientTexture();
  109073. this._createSizeGradientTexture();
  109074. this._createAngularSpeedGradientTexture();
  109075. this._createVelocityGradientTexture();
  109076. this._createLimitVelocityGradientTexture();
  109077. this._createDragGradientTexture();
  109078. this._recreateUpdateEffect();
  109079. this._recreateRenderEffect();
  109080. if (!this.isReady()) {
  109081. return 0;
  109082. }
  109083. if (!preWarm) {
  109084. if (!this._preWarmDone && this.preWarmCycles) {
  109085. for (var index = 0; index < this.preWarmCycles; index++) {
  109086. this.animate(true);
  109087. this.render(true);
  109088. }
  109089. this._preWarmDone = true;
  109090. }
  109091. if (this._currentRenderId === this._scene.getFrameId()) {
  109092. return 0;
  109093. }
  109094. this._currentRenderId = this._scene.getFrameId();
  109095. }
  109096. // Get everything ready to render
  109097. this._initialize();
  109098. this._accumulatedCount += this.emitRate * this._timeDelta;
  109099. if (this._accumulatedCount > 1) {
  109100. var intPart = this._accumulatedCount | 0;
  109101. this._accumulatedCount -= intPart;
  109102. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  109103. }
  109104. if (!this._currentActiveCount) {
  109105. return 0;
  109106. }
  109107. // Enable update effect
  109108. this._engine.enableEffect(this._updateEffect);
  109109. this._engine.setState(false);
  109110. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  109111. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  109112. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  109113. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  109114. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  109115. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  109116. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  109117. if (!this._colorGradientsTexture) {
  109118. this._updateEffect.setDirectColor4("color1", this.color1);
  109119. this._updateEffect.setDirectColor4("color2", this.color2);
  109120. }
  109121. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  109122. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  109123. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  109124. this._updateEffect.setVector3("gravity", this.gravity);
  109125. if (this._sizeGradientsTexture) {
  109126. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  109127. }
  109128. if (this._angularSpeedGradientsTexture) {
  109129. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  109130. }
  109131. if (this._velocityGradientsTexture) {
  109132. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  109133. }
  109134. if (this._limitVelocityGradientsTexture) {
  109135. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  109136. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  109137. }
  109138. if (this._dragGradientsTexture) {
  109139. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  109140. }
  109141. if (this.particleEmitterType) {
  109142. this.particleEmitterType.applyToShader(this._updateEffect);
  109143. }
  109144. if (this._isAnimationSheetEnabled) {
  109145. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  109146. }
  109147. if (this.noiseTexture) {
  109148. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  109149. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  109150. }
  109151. var emitterWM;
  109152. if (this.emitter.position) {
  109153. var emitterMesh = this.emitter;
  109154. emitterWM = emitterMesh.getWorldMatrix();
  109155. }
  109156. else {
  109157. var emitterPosition = this.emitter;
  109158. emitterWM = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  109159. }
  109160. this._updateEffect.setMatrix("emitterWM", emitterWM);
  109161. // Bind source VAO
  109162. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  109163. // Update
  109164. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  109165. this._engine.setRasterizerState(false);
  109166. this._engine.beginTransformFeedback(true);
  109167. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  109168. this._engine.endTransformFeedback();
  109169. this._engine.setRasterizerState(true);
  109170. this._engine.bindTransformFeedbackBuffer(null);
  109171. if (!preWarm) {
  109172. // Enable render effect
  109173. this._engine.enableEffect(this._renderEffect);
  109174. var viewMatrix = this._scene.getViewMatrix();
  109175. this._renderEffect.setMatrix("view", viewMatrix);
  109176. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  109177. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  109178. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  109179. this._renderEffect.setVector3("worldOffset", this.worldOffset);
  109180. if (this._colorGradientsTexture) {
  109181. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  109182. }
  109183. else {
  109184. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  109185. }
  109186. if (this._isAnimationSheetEnabled && this.particleTexture) {
  109187. var baseSize = this.particleTexture.getBaseSize();
  109188. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  109189. }
  109190. if (this._isBillboardBased) {
  109191. var camera = this._scene.activeCamera;
  109192. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  109193. }
  109194. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  109195. var invView = viewMatrix.clone();
  109196. invView.invert();
  109197. this._renderEffect.setMatrix("invView", invView);
  109198. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  109199. }
  109200. // image processing
  109201. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  109202. this._imageProcessingConfiguration.bind(this._renderEffect);
  109203. }
  109204. // Draw order
  109205. switch (this.blendMode) {
  109206. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ADD:
  109207. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ADD);
  109208. break;
  109209. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ONEONE:
  109210. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ONEONE);
  109211. break;
  109212. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_STANDARD:
  109213. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_COMBINE);
  109214. break;
  109215. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY:
  109216. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_MULTIPLY);
  109217. break;
  109218. }
  109219. if (this.forceDepthWrite) {
  109220. this._engine.setDepthWrite(true);
  109221. }
  109222. // Bind source VAO
  109223. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  109224. // Render
  109225. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  109226. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_DISABLE);
  109227. }
  109228. // Switch VAOs
  109229. this._targetIndex++;
  109230. if (this._targetIndex === 2) {
  109231. this._targetIndex = 0;
  109232. }
  109233. // Switch buffers
  109234. var tmpBuffer = this._sourceBuffer;
  109235. this._sourceBuffer = this._targetBuffer;
  109236. this._targetBuffer = tmpBuffer;
  109237. return this._currentActiveCount;
  109238. };
  109239. /**
  109240. * Rebuilds the particle system
  109241. */
  109242. GPUParticleSystem.prototype.rebuild = function () {
  109243. this._initialize(true);
  109244. };
  109245. GPUParticleSystem.prototype._releaseBuffers = function () {
  109246. if (this._buffer0) {
  109247. this._buffer0.dispose();
  109248. this._buffer0 = null;
  109249. }
  109250. if (this._buffer1) {
  109251. this._buffer1.dispose();
  109252. this._buffer1 = null;
  109253. }
  109254. if (this._spriteBuffer) {
  109255. this._spriteBuffer.dispose();
  109256. this._spriteBuffer = null;
  109257. }
  109258. };
  109259. GPUParticleSystem.prototype._releaseVAOs = function () {
  109260. if (!this._updateVAO) {
  109261. return;
  109262. }
  109263. for (var index = 0; index < this._updateVAO.length; index++) {
  109264. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  109265. }
  109266. this._updateVAO = [];
  109267. for (var index = 0; index < this._renderVAO.length; index++) {
  109268. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  109269. }
  109270. this._renderVAO = [];
  109271. };
  109272. /**
  109273. * Disposes the particle system and free the associated resources
  109274. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  109275. */
  109276. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  109277. if (disposeTexture === void 0) { disposeTexture = true; }
  109278. var index = this._scene.particleSystems.indexOf(this);
  109279. if (index > -1) {
  109280. this._scene.particleSystems.splice(index, 1);
  109281. }
  109282. this._releaseBuffers();
  109283. this._releaseVAOs();
  109284. if (this._colorGradientsTexture) {
  109285. this._colorGradientsTexture.dispose();
  109286. this._colorGradientsTexture = null;
  109287. }
  109288. if (this._sizeGradientsTexture) {
  109289. this._sizeGradientsTexture.dispose();
  109290. this._sizeGradientsTexture = null;
  109291. }
  109292. if (this._angularSpeedGradientsTexture) {
  109293. this._angularSpeedGradientsTexture.dispose();
  109294. this._angularSpeedGradientsTexture = null;
  109295. }
  109296. if (this._velocityGradientsTexture) {
  109297. this._velocityGradientsTexture.dispose();
  109298. this._velocityGradientsTexture = null;
  109299. }
  109300. if (this._limitVelocityGradientsTexture) {
  109301. this._limitVelocityGradientsTexture.dispose();
  109302. this._limitVelocityGradientsTexture = null;
  109303. }
  109304. if (this._dragGradientsTexture) {
  109305. this._dragGradientsTexture.dispose();
  109306. this._dragGradientsTexture = null;
  109307. }
  109308. if (this._randomTexture) {
  109309. this._randomTexture.dispose();
  109310. this._randomTexture = null;
  109311. }
  109312. if (this._randomTexture2) {
  109313. this._randomTexture2.dispose();
  109314. this._randomTexture2 = null;
  109315. }
  109316. if (disposeTexture && this.particleTexture) {
  109317. this.particleTexture.dispose();
  109318. this.particleTexture = null;
  109319. }
  109320. if (disposeTexture && this.noiseTexture) {
  109321. this.noiseTexture.dispose();
  109322. this.noiseTexture = null;
  109323. }
  109324. // Callback
  109325. this.onDisposeObservable.notifyObservers(this);
  109326. this.onDisposeObservable.clear();
  109327. };
  109328. /**
  109329. * Clones the particle system.
  109330. * @param name The name of the cloned object
  109331. * @param newEmitter The new emitter to use
  109332. * @returns the cloned particle system
  109333. */
  109334. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  109335. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  109336. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__["DeepCopier"].DeepCopy(this, result);
  109337. if (newEmitter === undefined) {
  109338. newEmitter = this.emitter;
  109339. }
  109340. result.emitter = newEmitter;
  109341. if (this.particleTexture) {
  109342. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"](this.particleTexture.url, this._scene);
  109343. }
  109344. return result;
  109345. };
  109346. /**
  109347. * Serializes the particle system to a JSON object.
  109348. * @returns the JSON object
  109349. */
  109350. GPUParticleSystem.prototype.serialize = function () {
  109351. var serializationObject = {};
  109352. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Serialize(serializationObject, this);
  109353. serializationObject.activeParticleCount = this.activeParticleCount;
  109354. return serializationObject;
  109355. };
  109356. /**
  109357. * Parses a JSON object to create a GPU particle system.
  109358. * @param parsedParticleSystem The JSON object to parse
  109359. * @param scene The scene to create the particle system in
  109360. * @param rootUrl The root url to use to load external dependencies like texture
  109361. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  109362. * @returns the parsed GPU particle system
  109363. */
  109364. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  109365. if (doNotStart === void 0) { doNotStart = false; }
  109366. var name = parsedParticleSystem.name;
  109367. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  109368. if (parsedParticleSystem.activeParticleCount) {
  109369. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  109370. }
  109371. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  109372. // Auto start
  109373. if (parsedParticleSystem.preventAutoStart) {
  109374. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  109375. }
  109376. if (!doNotStart && !particleSystem.preventAutoStart) {
  109377. particleSystem.start();
  109378. }
  109379. return particleSystem;
  109380. };
  109381. return GPUParticleSystem;
  109382. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__["BaseParticleSystem"]));
  109383. /***/ }),
  109384. /***/ "./Particles/index.ts":
  109385. /*!****************************!*\
  109386. !*** ./Particles/index.ts ***!
  109387. \****************************/
  109388. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  109389. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109390. "use strict";
  109391. __webpack_require__.r(__webpack_exports__);
  109392. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  109393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  109394. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  109395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  109396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  109397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  109398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  109399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  109400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  109401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  109402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  109403. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  109404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  109405. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  109406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  109407. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  109408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  109409. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  109410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  109411. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  109412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  109413. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  109414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  109415. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  109416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  109417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  109418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  109419. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  109420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  109421. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  109422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  109423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  109424. /***/ }),
  109425. /***/ "./Particles/particle.ts":
  109426. /*!*******************************!*\
  109427. !*** ./Particles/particle.ts ***!
  109428. \*******************************/
  109429. /*! exports provided: Particle */
  109430. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109431. "use strict";
  109432. __webpack_require__.r(__webpack_exports__);
  109433. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  109434. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109435. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  109436. /**
  109437. * A particle represents one of the element emitted by a particle system.
  109438. * This is mainly define by its coordinates, direction, velocity and age.
  109439. */
  109440. var Particle = /** @class */ (function () {
  109441. /**
  109442. * Creates a new instance Particle
  109443. * @param particleSystem the particle system the particle belongs to
  109444. */
  109445. function Particle(
  109446. /**
  109447. * The particle system the particle belongs to.
  109448. */
  109449. particleSystem) {
  109450. this.particleSystem = particleSystem;
  109451. /**
  109452. * The world position of the particle in the scene.
  109453. */
  109454. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  109455. /**
  109456. * The world direction of the particle in the scene.
  109457. */
  109458. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  109459. /**
  109460. * The color of the particle.
  109461. */
  109462. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  109463. /**
  109464. * The color change of the particle per step.
  109465. */
  109466. this.colorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  109467. /**
  109468. * Defines how long will the life of the particle be.
  109469. */
  109470. this.lifeTime = 1.0;
  109471. /**
  109472. * The current age of the particle.
  109473. */
  109474. this.age = 0;
  109475. /**
  109476. * The current size of the particle.
  109477. */
  109478. this.size = 0;
  109479. /**
  109480. * The current scale of the particle.
  109481. */
  109482. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  109483. /**
  109484. * The current angle of the particle.
  109485. */
  109486. this.angle = 0;
  109487. /**
  109488. * Defines how fast is the angle changing.
  109489. */
  109490. this.angularSpeed = 0;
  109491. /**
  109492. * Defines the cell index used by the particle to be rendered from a sprite.
  109493. */
  109494. this.cellIndex = 0;
  109495. /** @hidden */
  109496. this._attachedSubEmitters = null;
  109497. /** @hidden */
  109498. this._currentColor1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  109499. /** @hidden */
  109500. this._currentColor2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  109501. /** @hidden */
  109502. this._currentSize1 = 0;
  109503. /** @hidden */
  109504. this._currentSize2 = 0;
  109505. /** @hidden */
  109506. this._currentAngularSpeed1 = 0;
  109507. /** @hidden */
  109508. this._currentAngularSpeed2 = 0;
  109509. /** @hidden */
  109510. this._currentVelocity1 = 0;
  109511. /** @hidden */
  109512. this._currentVelocity2 = 0;
  109513. /** @hidden */
  109514. this._currentLimitVelocity1 = 0;
  109515. /** @hidden */
  109516. this._currentLimitVelocity2 = 0;
  109517. /** @hidden */
  109518. this._currentDrag1 = 0;
  109519. /** @hidden */
  109520. this._currentDrag2 = 0;
  109521. this.id = Particle._Count++;
  109522. if (!this.particleSystem.isAnimationSheetEnabled) {
  109523. return;
  109524. }
  109525. this.updateCellInfoFromSystem();
  109526. }
  109527. Particle.prototype.updateCellInfoFromSystem = function () {
  109528. this.cellIndex = this.particleSystem.startSpriteCellID;
  109529. };
  109530. /**
  109531. * Defines how the sprite cell index is updated for the particle
  109532. */
  109533. Particle.prototype.updateCellIndex = function () {
  109534. var offsetAge = this.age;
  109535. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  109536. if (this.particleSystem.spriteRandomStartCell) {
  109537. if (this._randomCellOffset === undefined) {
  109538. this._randomCellOffset = Math.random() * this.lifeTime;
  109539. }
  109540. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  109541. changeSpeed = 1;
  109542. offsetAge = this._randomCellOffset;
  109543. }
  109544. else {
  109545. offsetAge += this._randomCellOffset;
  109546. }
  109547. }
  109548. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  109549. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  109550. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  109551. };
  109552. /** @hidden */
  109553. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  109554. if (subEmitter.particleSystem.emitter.position) {
  109555. var emitterMesh = subEmitter.particleSystem.emitter;
  109556. emitterMesh.position.copyFrom(this.position);
  109557. if (subEmitter.inheritDirection) {
  109558. emitterMesh.position.subtractToRef(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  109559. // Look at using Y as forward
  109560. emitterMesh.lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0], 0, Math.PI / 2);
  109561. }
  109562. }
  109563. else {
  109564. var emitterPosition = subEmitter.particleSystem.emitter;
  109565. emitterPosition.copyFrom(this.position);
  109566. }
  109567. // Set inheritedVelocityOffset to be used when new particles are created
  109568. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  109569. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  109570. };
  109571. /** @hidden */
  109572. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  109573. var _this = this;
  109574. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  109575. this._attachedSubEmitters.forEach(function (subEmitter) {
  109576. _this._inheritParticleInfoToSubEmitter(subEmitter);
  109577. });
  109578. }
  109579. };
  109580. /** @hidden */
  109581. Particle.prototype._reset = function () {
  109582. this.age = 0;
  109583. this._currentColorGradient = null;
  109584. this._currentSizeGradient = null;
  109585. this._currentAngularSpeedGradient = null;
  109586. this._currentVelocityGradient = null;
  109587. this._currentLimitVelocityGradient = null;
  109588. this._currentDragGradient = null;
  109589. this.cellIndex = this.particleSystem.startSpriteCellID;
  109590. this._randomCellOffset = undefined;
  109591. };
  109592. /**
  109593. * Copy the properties of particle to another one.
  109594. * @param other the particle to copy the information to.
  109595. */
  109596. Particle.prototype.copyTo = function (other) {
  109597. other.position.copyFrom(this.position);
  109598. if (this._initialDirection) {
  109599. if (other._initialDirection) {
  109600. other._initialDirection.copyFrom(this._initialDirection);
  109601. }
  109602. else {
  109603. other._initialDirection = this._initialDirection.clone();
  109604. }
  109605. }
  109606. else {
  109607. other._initialDirection = null;
  109608. }
  109609. other.direction.copyFrom(this.direction);
  109610. other.color.copyFrom(this.color);
  109611. other.colorStep.copyFrom(this.colorStep);
  109612. other.lifeTime = this.lifeTime;
  109613. other.age = this.age;
  109614. other._randomCellOffset = this._randomCellOffset;
  109615. other.size = this.size;
  109616. other.scale.copyFrom(this.scale);
  109617. other.angle = this.angle;
  109618. other.angularSpeed = this.angularSpeed;
  109619. other.particleSystem = this.particleSystem;
  109620. other.cellIndex = this.cellIndex;
  109621. other.id = this.id;
  109622. other._attachedSubEmitters = this._attachedSubEmitters;
  109623. if (this._currentColorGradient) {
  109624. other._currentColorGradient = this._currentColorGradient;
  109625. other._currentColor1.copyFrom(this._currentColor1);
  109626. other._currentColor2.copyFrom(this._currentColor2);
  109627. }
  109628. if (this._currentSizeGradient) {
  109629. other._currentSizeGradient = this._currentSizeGradient;
  109630. other._currentSize1 = this._currentSize1;
  109631. other._currentSize2 = this._currentSize2;
  109632. }
  109633. if (this._currentAngularSpeedGradient) {
  109634. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  109635. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  109636. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  109637. }
  109638. if (this._currentVelocityGradient) {
  109639. other._currentVelocityGradient = this._currentVelocityGradient;
  109640. other._currentVelocity1 = this._currentVelocity1;
  109641. other._currentVelocity2 = this._currentVelocity2;
  109642. }
  109643. if (this._currentLimitVelocityGradient) {
  109644. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  109645. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  109646. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  109647. }
  109648. if (this._currentDragGradient) {
  109649. other._currentDragGradient = this._currentDragGradient;
  109650. other._currentDrag1 = this._currentDrag1;
  109651. other._currentDrag2 = this._currentDrag2;
  109652. }
  109653. if (this.particleSystem.isAnimationSheetEnabled) {
  109654. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  109655. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  109656. }
  109657. if (this.particleSystem.useRampGradients) {
  109658. other.remapData.copyFrom(this.remapData);
  109659. }
  109660. if (this._randomNoiseCoordinates1) {
  109661. if (other._randomNoiseCoordinates1) {
  109662. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  109663. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  109664. }
  109665. else {
  109666. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  109667. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  109668. }
  109669. }
  109670. };
  109671. Particle._Count = 0;
  109672. return Particle;
  109673. }());
  109674. /***/ }),
  109675. /***/ "./Particles/particleHelper.ts":
  109676. /*!*************************************!*\
  109677. !*** ./Particles/particleHelper.ts ***!
  109678. \*************************************/
  109679. /*! exports provided: ParticleHelper */
  109680. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109681. "use strict";
  109682. __webpack_require__.r(__webpack_exports__);
  109683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  109684. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  109685. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109686. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  109687. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  109688. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  109689. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  109690. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  109691. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  109692. /**
  109693. * This class is made for on one-liner static method to help creating particle system set.
  109694. */
  109695. var ParticleHelper = /** @class */ (function () {
  109696. function ParticleHelper() {
  109697. }
  109698. /**
  109699. * Create a default particle system that you can tweak
  109700. * @param emitter defines the emitter to use
  109701. * @param capacity defines the system capacity (default is 500 particles)
  109702. * @param scene defines the hosting scene
  109703. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  109704. * @returns the new Particle system
  109705. */
  109706. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  109707. if (capacity === void 0) { capacity = 500; }
  109708. if (useGPU === void 0) { useGPU = false; }
  109709. var system;
  109710. if (useGPU) {
  109711. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  109712. }
  109713. else {
  109714. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  109715. }
  109716. system.emitter = emitter;
  109717. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  109718. system.createConeEmitter(0.1, Math.PI / 4);
  109719. // Particle color
  109720. system.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  109721. system.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  109722. system.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  109723. // Particle Size
  109724. system.minSize = 0.1;
  109725. system.maxSize = 0.1;
  109726. // Emission speed
  109727. system.minEmitPower = 2;
  109728. system.maxEmitPower = 2;
  109729. // Update speed
  109730. system.updateSpeed = 1 / 60;
  109731. system.emitRate = 30;
  109732. return system;
  109733. };
  109734. /**
  109735. * This is the main static method (one-liner) of this helper to create different particle systems
  109736. * @param type This string represents the type to the particle system to create
  109737. * @param scene The scene where the particle system should live
  109738. * @param gpu If the system will use gpu
  109739. * @returns the ParticleSystemSet created
  109740. */
  109741. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  109742. if (gpu === void 0) { gpu = false; }
  109743. if (!scene) {
  109744. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  109745. }
  109746. var token = {};
  109747. scene._addPendingData(token);
  109748. return new Promise(function (resolve, reject) {
  109749. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  109750. scene._removePendingData(token);
  109751. return reject("Particle system with GPU is not supported.");
  109752. }
  109753. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  109754. scene._removePendingData(token);
  109755. var newData = JSON.parse(data.toString());
  109756. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  109757. }, undefined, undefined, undefined, function () {
  109758. scene._removePendingData(token);
  109759. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  109760. });
  109761. });
  109762. };
  109763. /**
  109764. * Static function used to export a particle system to a ParticleSystemSet variable.
  109765. * Please note that the emitter shape is not exported
  109766. * @param systems defines the particle systems to export
  109767. * @returns the created particle system set
  109768. */
  109769. ParticleHelper.ExportSet = function (systems) {
  109770. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  109771. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  109772. var system = systems_1[_i];
  109773. set.systems.push(system);
  109774. }
  109775. return set;
  109776. };
  109777. /**
  109778. * Gets or sets base Assets URL
  109779. */
  109780. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  109781. return ParticleHelper;
  109782. }());
  109783. /***/ }),
  109784. /***/ "./Particles/particleSystem.ts":
  109785. /*!*************************************!*\
  109786. !*** ./Particles/particleSystem.ts ***!
  109787. \*************************************/
  109788. /*! exports provided: ParticleSystem */
  109789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109790. "use strict";
  109791. __webpack_require__.r(__webpack_exports__);
  109792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  109793. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  109794. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  109795. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  109796. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109797. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  109798. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  109799. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  109800. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  109801. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  109802. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  109803. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  109804. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  109805. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  109806. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  109807. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  109808. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  109809. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  109810. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  109811. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  109812. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  109813. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  109814. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  109815. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  109816. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  109817. /**
  109818. * This represents a particle system in Babylon.
  109819. * 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.
  109820. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  109821. * @example https://doc.babylonjs.com/babylon101/particles
  109822. */
  109823. var ParticleSystem = /** @class */ (function (_super) {
  109824. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  109825. /**
  109826. * Instantiates a particle system.
  109827. * 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.
  109828. * @param name The name of the particle system
  109829. * @param capacity The max number of particles alive at the same time
  109830. * @param scene The scene the particle system belongs to
  109831. * @param customEffect a custom effect used to change the way particles are rendered by default
  109832. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  109833. * @param epsilon Offset used to render the particles
  109834. */
  109835. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  109836. if (customEffect === void 0) { customEffect = null; }
  109837. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  109838. if (epsilon === void 0) { epsilon = 0.01; }
  109839. var _this = _super.call(this, name) || this;
  109840. /**
  109841. * @hidden
  109842. */
  109843. _this._inheritedVelocityOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  109844. /**
  109845. * An event triggered when the system is disposed
  109846. */
  109847. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  109848. _this._particles = new Array();
  109849. _this._stockParticles = new Array();
  109850. _this._newPartsExcess = 0;
  109851. _this._vertexBuffers = {};
  109852. _this._scaledColorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  109853. _this._colorDiff = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  109854. _this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  109855. _this._scaledGravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  109856. _this._currentRenderId = -1;
  109857. _this._useInstancing = false;
  109858. _this._started = false;
  109859. _this._stopped = false;
  109860. _this._actualFrame = 0;
  109861. /** @hidden */
  109862. _this._currentEmitRate1 = 0;
  109863. /** @hidden */
  109864. _this._currentEmitRate2 = 0;
  109865. /** @hidden */
  109866. _this._currentStartSize1 = 0;
  109867. /** @hidden */
  109868. _this._currentStartSize2 = 0;
  109869. _this._rawTextureWidth = 256;
  109870. _this._useRampGradients = false;
  109871. /**
  109872. * @hidden
  109873. * If the particle systems emitter should be disposed when the particle system is disposed
  109874. */
  109875. _this._disposeEmitterOnDispose = false;
  109876. // start of sub system methods
  109877. /**
  109878. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  109879. * Its lifetime will start back at 0.
  109880. */
  109881. _this.recycleParticle = function (particle) {
  109882. // move particle from activeParticle list to stock particles
  109883. var lastParticle = _this._particles.pop();
  109884. if (lastParticle !== particle) {
  109885. lastParticle.copyTo(particle);
  109886. }
  109887. _this._stockParticles.push(lastParticle);
  109888. };
  109889. _this._createParticle = function () {
  109890. var particle;
  109891. if (_this._stockParticles.length !== 0) {
  109892. particle = _this._stockParticles.pop();
  109893. particle._reset();
  109894. }
  109895. else {
  109896. particle = new _particle__WEBPACK_IMPORTED_MODULE_16__["Particle"](_this);
  109897. }
  109898. // Attach emitters
  109899. if (_this._subEmitters && _this._subEmitters.length > 0) {
  109900. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  109901. particle._attachedSubEmitters = [];
  109902. subEmitters.forEach(function (subEmitter) {
  109903. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].ATTACHED) {
  109904. var newEmitter = subEmitter.clone();
  109905. particle._attachedSubEmitters.push(newEmitter);
  109906. newEmitter.particleSystem.start();
  109907. }
  109908. });
  109909. }
  109910. return particle;
  109911. };
  109912. _this._emitFromParticle = function (particle) {
  109913. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  109914. return;
  109915. }
  109916. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  109917. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  109918. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].END) {
  109919. var subSystem = subEmitter.clone();
  109920. particle._inheritParticleInfoToSubEmitter(subSystem);
  109921. subSystem.particleSystem._rootParticleSystem = _this;
  109922. _this.activeSubSystems.push(subSystem.particleSystem);
  109923. subSystem.particleSystem.start();
  109924. }
  109925. });
  109926. };
  109927. _this._capacity = capacity;
  109928. _this._epsilon = epsilon;
  109929. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  109930. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  109931. // Setup the default processing configuration to the scene.
  109932. _this._attachImageProcessingConfiguration(null);
  109933. _this._customEffect = customEffect;
  109934. _this._scene.particleSystems.push(_this);
  109935. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  109936. _this._createIndexBuffer();
  109937. _this._createVertexBuffers();
  109938. // Default emitter type
  109939. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  109940. // Update
  109941. _this.updateFunction = function (particles) {
  109942. var noiseTextureSize = null;
  109943. var noiseTextureData = null;
  109944. if (_this.noiseTexture) { // We need to get texture data back to CPU
  109945. noiseTextureSize = _this.noiseTexture.getSize();
  109946. noiseTextureData = (_this.noiseTexture.getContent());
  109947. }
  109948. var _loop_1 = function () {
  109949. particle = particles[index];
  109950. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  109951. var previousAge = particle.age;
  109952. particle.age += scaledUpdateSpeed;
  109953. // Evaluate step to death
  109954. if (particle.age > particle.lifeTime) {
  109955. var diff = particle.age - previousAge;
  109956. var oldDiff = particle.lifeTime - previousAge;
  109957. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  109958. particle.age = particle.lifeTime;
  109959. }
  109960. var ratio = particle.age / particle.lifeTime;
  109961. // Color
  109962. if (_this._colorGradients && _this._colorGradients.length > 0) {
  109963. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  109964. if (currentGradient !== particle._currentColorGradient) {
  109965. particle._currentColor1.copyFrom(particle._currentColor2);
  109966. nextGradient.getColorToRef(particle._currentColor2);
  109967. particle._currentColorGradient = currentGradient;
  109968. }
  109969. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  109970. });
  109971. }
  109972. else {
  109973. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  109974. particle.color.addInPlace(_this._scaledColorStep);
  109975. if (particle.color.a < 0) {
  109976. particle.color.a = 0;
  109977. }
  109978. }
  109979. // Angular speed
  109980. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  109981. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  109982. if (currentGradient !== particle._currentAngularSpeedGradient) {
  109983. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  109984. particle._currentAngularSpeed2 = nextGradient.getFactor();
  109985. particle._currentAngularSpeedGradient = currentGradient;
  109986. }
  109987. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  109988. });
  109989. }
  109990. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  109991. // Direction
  109992. var directionScale = scaledUpdateSpeed;
  109993. /// Velocity
  109994. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  109995. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  109996. if (currentGradient !== particle._currentVelocityGradient) {
  109997. particle._currentVelocity1 = particle._currentVelocity2;
  109998. particle._currentVelocity2 = nextGradient.getFactor();
  109999. particle._currentVelocityGradient = currentGradient;
  110000. }
  110001. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  110002. });
  110003. }
  110004. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  110005. /// Limit velocity
  110006. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  110007. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  110008. if (currentGradient !== particle._currentLimitVelocityGradient) {
  110009. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  110010. particle._currentLimitVelocity2 = nextGradient.getFactor();
  110011. particle._currentLimitVelocityGradient = currentGradient;
  110012. }
  110013. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  110014. var currentVelocity = particle.direction.length();
  110015. if (currentVelocity > limitVelocity) {
  110016. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  110017. }
  110018. });
  110019. }
  110020. /// Drag
  110021. if (_this._dragGradients && _this._dragGradients.length > 0) {
  110022. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  110023. if (currentGradient !== particle._currentDragGradient) {
  110024. particle._currentDrag1 = particle._currentDrag2;
  110025. particle._currentDrag2 = nextGradient.getFactor();
  110026. particle._currentDragGradient = currentGradient;
  110027. }
  110028. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  110029. _this._scaledDirection.scaleInPlace(1.0 - drag);
  110030. });
  110031. }
  110032. particle.position.addInPlace(_this._scaledDirection);
  110033. // Noise
  110034. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  110035. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  110036. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  110037. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  110038. var force = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  110039. var scaledForce = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  110040. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  110041. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  110042. particle.direction.addInPlace(scaledForce);
  110043. }
  110044. // Gravity
  110045. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  110046. particle.direction.addInPlace(_this._scaledGravity);
  110047. // Size
  110048. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  110049. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  110050. if (currentGradient !== particle._currentSizeGradient) {
  110051. particle._currentSize1 = particle._currentSize2;
  110052. particle._currentSize2 = nextGradient.getFactor();
  110053. particle._currentSizeGradient = currentGradient;
  110054. }
  110055. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  110056. });
  110057. }
  110058. // Remap data
  110059. if (_this._useRampGradients) {
  110060. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  110061. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  110062. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  110063. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  110064. particle.remapData.x = min;
  110065. particle.remapData.y = max - min;
  110066. });
  110067. }
  110068. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  110069. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  110070. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  110071. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  110072. particle.remapData.z = min;
  110073. particle.remapData.w = max - min;
  110074. });
  110075. }
  110076. }
  110077. if (_this._isAnimationSheetEnabled) {
  110078. particle.updateCellIndex();
  110079. }
  110080. // Update the position of the attached sub-emitters to match their attached particle
  110081. particle._inheritParticleInfoToSubEmitters();
  110082. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  110083. _this._emitFromParticle(particle);
  110084. if (particle._attachedSubEmitters) {
  110085. particle._attachedSubEmitters.forEach(function (subEmitter) {
  110086. subEmitter.particleSystem.disposeOnStop = true;
  110087. subEmitter.particleSystem.stop();
  110088. });
  110089. particle._attachedSubEmitters = null;
  110090. }
  110091. _this.recycleParticle(particle);
  110092. index--;
  110093. return "continue";
  110094. }
  110095. };
  110096. var particle;
  110097. for (var index = 0; index < particles.length; index++) {
  110098. _loop_1();
  110099. }
  110100. };
  110101. return _this;
  110102. }
  110103. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  110104. /**
  110105. * Sets a callback that will be triggered when the system is disposed
  110106. */
  110107. set: function (callback) {
  110108. if (this._onDisposeObserver) {
  110109. this.onDisposeObservable.remove(this._onDisposeObserver);
  110110. }
  110111. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  110112. },
  110113. enumerable: true,
  110114. configurable: true
  110115. });
  110116. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  110117. /** Gets or sets a boolean indicating that ramp gradients must be used
  110118. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  110119. */
  110120. get: function () {
  110121. return this._useRampGradients;
  110122. },
  110123. set: function (value) {
  110124. if (this._useRampGradients === value) {
  110125. return;
  110126. }
  110127. this._useRampGradients = value;
  110128. this._resetEffect();
  110129. },
  110130. enumerable: true,
  110131. configurable: true
  110132. });
  110133. Object.defineProperty(ParticleSystem.prototype, "particles", {
  110134. //end of Sub-emitter
  110135. /**
  110136. * Gets the current list of active particles
  110137. */
  110138. get: function () {
  110139. return this._particles;
  110140. },
  110141. enumerable: true,
  110142. configurable: true
  110143. });
  110144. /**
  110145. * Returns the string "ParticleSystem"
  110146. * @returns a string containing the class name
  110147. */
  110148. ParticleSystem.prototype.getClassName = function () {
  110149. return "ParticleSystem";
  110150. };
  110151. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  110152. var newGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  110153. newGradient.gradient = gradient;
  110154. newGradient.factor1 = factor;
  110155. newGradient.factor2 = factor2;
  110156. factorGradients.push(newGradient);
  110157. factorGradients.sort(function (a, b) {
  110158. if (a.gradient < b.gradient) {
  110159. return -1;
  110160. }
  110161. else if (a.gradient > b.gradient) {
  110162. return 1;
  110163. }
  110164. return 0;
  110165. });
  110166. };
  110167. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  110168. if (!factorGradients) {
  110169. return;
  110170. }
  110171. var index = 0;
  110172. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  110173. var factorGradient = factorGradients_1[_i];
  110174. if (factorGradient.gradient === gradient) {
  110175. factorGradients.splice(index, 1);
  110176. break;
  110177. }
  110178. index++;
  110179. }
  110180. };
  110181. /**
  110182. * Adds a new life time gradient
  110183. * @param gradient defines the gradient to use (between 0 and 1)
  110184. * @param factor defines the life time factor to affect to the specified gradient
  110185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110186. * @returns the current particle system
  110187. */
  110188. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  110189. if (!this._lifeTimeGradients) {
  110190. this._lifeTimeGradients = [];
  110191. }
  110192. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  110193. return this;
  110194. };
  110195. /**
  110196. * Remove a specific life time gradient
  110197. * @param gradient defines the gradient to remove
  110198. * @returns the current particle system
  110199. */
  110200. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  110201. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  110202. return this;
  110203. };
  110204. /**
  110205. * Adds a new size gradient
  110206. * @param gradient defines the gradient to use (between 0 and 1)
  110207. * @param factor defines the size factor to affect to the specified gradient
  110208. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110209. * @returns the current particle system
  110210. */
  110211. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  110212. if (!this._sizeGradients) {
  110213. this._sizeGradients = [];
  110214. }
  110215. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  110216. return this;
  110217. };
  110218. /**
  110219. * Remove a specific size gradient
  110220. * @param gradient defines the gradient to remove
  110221. * @returns the current particle system
  110222. */
  110223. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  110224. this._removeFactorGradient(this._sizeGradients, gradient);
  110225. return this;
  110226. };
  110227. /**
  110228. * Adds a new color remap gradient
  110229. * @param gradient defines the gradient to use (between 0 and 1)
  110230. * @param min defines the color remap minimal range
  110231. * @param max defines the color remap maximal range
  110232. * @returns the current particle system
  110233. */
  110234. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  110235. if (!this._colorRemapGradients) {
  110236. this._colorRemapGradients = [];
  110237. }
  110238. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  110239. return this;
  110240. };
  110241. /**
  110242. * Remove a specific color remap gradient
  110243. * @param gradient defines the gradient to remove
  110244. * @returns the current particle system
  110245. */
  110246. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  110247. this._removeFactorGradient(this._colorRemapGradients, gradient);
  110248. return this;
  110249. };
  110250. /**
  110251. * Adds a new alpha remap gradient
  110252. * @param gradient defines the gradient to use (between 0 and 1)
  110253. * @param min defines the alpha remap minimal range
  110254. * @param max defines the alpha remap maximal range
  110255. * @returns the current particle system
  110256. */
  110257. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  110258. if (!this._alphaRemapGradients) {
  110259. this._alphaRemapGradients = [];
  110260. }
  110261. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  110262. return this;
  110263. };
  110264. /**
  110265. * Remove a specific alpha remap gradient
  110266. * @param gradient defines the gradient to remove
  110267. * @returns the current particle system
  110268. */
  110269. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  110270. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  110271. return this;
  110272. };
  110273. /**
  110274. * Adds a new angular speed gradient
  110275. * @param gradient defines the gradient to use (between 0 and 1)
  110276. * @param factor defines the angular speed to affect to the specified gradient
  110277. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110278. * @returns the current particle system
  110279. */
  110280. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  110281. if (!this._angularSpeedGradients) {
  110282. this._angularSpeedGradients = [];
  110283. }
  110284. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  110285. return this;
  110286. };
  110287. /**
  110288. * Remove a specific angular speed gradient
  110289. * @param gradient defines the gradient to remove
  110290. * @returns the current particle system
  110291. */
  110292. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  110293. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  110294. return this;
  110295. };
  110296. /**
  110297. * Adds a new velocity gradient
  110298. * @param gradient defines the gradient to use (between 0 and 1)
  110299. * @param factor defines the velocity to affect to the specified gradient
  110300. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110301. * @returns the current particle system
  110302. */
  110303. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  110304. if (!this._velocityGradients) {
  110305. this._velocityGradients = [];
  110306. }
  110307. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  110308. return this;
  110309. };
  110310. /**
  110311. * Remove a specific velocity gradient
  110312. * @param gradient defines the gradient to remove
  110313. * @returns the current particle system
  110314. */
  110315. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  110316. this._removeFactorGradient(this._velocityGradients, gradient);
  110317. return this;
  110318. };
  110319. /**
  110320. * Adds a new limit velocity gradient
  110321. * @param gradient defines the gradient to use (between 0 and 1)
  110322. * @param factor defines the limit velocity value to affect to the specified gradient
  110323. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110324. * @returns the current particle system
  110325. */
  110326. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  110327. if (!this._limitVelocityGradients) {
  110328. this._limitVelocityGradients = [];
  110329. }
  110330. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  110331. return this;
  110332. };
  110333. /**
  110334. * Remove a specific limit velocity gradient
  110335. * @param gradient defines the gradient to remove
  110336. * @returns the current particle system
  110337. */
  110338. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  110339. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  110340. return this;
  110341. };
  110342. /**
  110343. * Adds a new drag gradient
  110344. * @param gradient defines the gradient to use (between 0 and 1)
  110345. * @param factor defines the drag value to affect to the specified gradient
  110346. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110347. * @returns the current particle system
  110348. */
  110349. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  110350. if (!this._dragGradients) {
  110351. this._dragGradients = [];
  110352. }
  110353. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  110354. return this;
  110355. };
  110356. /**
  110357. * Remove a specific drag gradient
  110358. * @param gradient defines the gradient to remove
  110359. * @returns the current particle system
  110360. */
  110361. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  110362. this._removeFactorGradient(this._dragGradients, gradient);
  110363. return this;
  110364. };
  110365. /**
  110366. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  110367. * @param gradient defines the gradient to use (between 0 and 1)
  110368. * @param factor defines the emit rate value to affect to the specified gradient
  110369. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110370. * @returns the current particle system
  110371. */
  110372. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  110373. if (!this._emitRateGradients) {
  110374. this._emitRateGradients = [];
  110375. }
  110376. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  110377. return this;
  110378. };
  110379. /**
  110380. * Remove a specific emit rate gradient
  110381. * @param gradient defines the gradient to remove
  110382. * @returns the current particle system
  110383. */
  110384. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  110385. this._removeFactorGradient(this._emitRateGradients, gradient);
  110386. return this;
  110387. };
  110388. /**
  110389. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  110390. * @param gradient defines the gradient to use (between 0 and 1)
  110391. * @param factor defines the start size value to affect to the specified gradient
  110392. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110393. * @returns the current particle system
  110394. */
  110395. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  110396. if (!this._startSizeGradients) {
  110397. this._startSizeGradients = [];
  110398. }
  110399. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  110400. return this;
  110401. };
  110402. /**
  110403. * Remove a specific start size gradient
  110404. * @param gradient defines the gradient to remove
  110405. * @returns the current particle system
  110406. */
  110407. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  110408. this._removeFactorGradient(this._emitRateGradients, gradient);
  110409. return this;
  110410. };
  110411. ParticleSystem.prototype._createRampGradientTexture = function () {
  110412. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  110413. return;
  110414. }
  110415. var data = new Uint8Array(this._rawTextureWidth * 4);
  110416. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color3[0];
  110417. for (var x = 0; x < this._rawTextureWidth; x++) {
  110418. var ratio = x / this._rawTextureWidth;
  110419. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  110420. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  110421. data[x * 4] = tmpColor.r * 255;
  110422. data[x * 4 + 1] = tmpColor.g * 255;
  110423. data[x * 4 + 2] = tmpColor.b * 255;
  110424. data[x * 4 + 3] = 255;
  110425. });
  110426. }
  110427. 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);
  110428. };
  110429. /**
  110430. * Gets the current list of ramp gradients.
  110431. * You must use addRampGradient and removeRampGradient to udpate this list
  110432. * @returns the list of ramp gradients
  110433. */
  110434. ParticleSystem.prototype.getRampGradients = function () {
  110435. return this._rampGradients;
  110436. };
  110437. /**
  110438. * Adds a new ramp gradient used to remap particle colors
  110439. * @param gradient defines the gradient to use (between 0 and 1)
  110440. * @param color defines the color to affect to the specified gradient
  110441. * @returns the current particle system
  110442. */
  110443. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  110444. if (!this._rampGradients) {
  110445. this._rampGradients = [];
  110446. }
  110447. var rampGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  110448. rampGradient.gradient = gradient;
  110449. rampGradient.color = color;
  110450. this._rampGradients.push(rampGradient);
  110451. this._rampGradients.sort(function (a, b) {
  110452. if (a.gradient < b.gradient) {
  110453. return -1;
  110454. }
  110455. else if (a.gradient > b.gradient) {
  110456. return 1;
  110457. }
  110458. return 0;
  110459. });
  110460. if (this._rampGradientsTexture) {
  110461. this._rampGradientsTexture.dispose();
  110462. this._rampGradientsTexture = null;
  110463. }
  110464. this._createRampGradientTexture();
  110465. return this;
  110466. };
  110467. /**
  110468. * Remove a specific ramp gradient
  110469. * @param gradient defines the gradient to remove
  110470. * @returns the current particle system
  110471. */
  110472. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  110473. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  110474. this._rampGradientsTexture = null;
  110475. if (this._rampGradients && this._rampGradients.length > 0) {
  110476. this._createRampGradientTexture();
  110477. }
  110478. return this;
  110479. };
  110480. /**
  110481. * Adds a new color gradient
  110482. * @param gradient defines the gradient to use (between 0 and 1)
  110483. * @param color1 defines the color to affect to the specified gradient
  110484. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  110485. * @returns this particle system
  110486. */
  110487. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  110488. if (!this._colorGradients) {
  110489. this._colorGradients = [];
  110490. }
  110491. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  110492. colorGradient.gradient = gradient;
  110493. colorGradient.color1 = color1;
  110494. colorGradient.color2 = color2;
  110495. this._colorGradients.push(colorGradient);
  110496. this._colorGradients.sort(function (a, b) {
  110497. if (a.gradient < b.gradient) {
  110498. return -1;
  110499. }
  110500. else if (a.gradient > b.gradient) {
  110501. return 1;
  110502. }
  110503. return 0;
  110504. });
  110505. return this;
  110506. };
  110507. /**
  110508. * Remove a specific color gradient
  110509. * @param gradient defines the gradient to remove
  110510. * @returns this particle system
  110511. */
  110512. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  110513. if (!this._colorGradients) {
  110514. return this;
  110515. }
  110516. var index = 0;
  110517. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  110518. var colorGradient = _a[_i];
  110519. if (colorGradient.gradient === gradient) {
  110520. this._colorGradients.splice(index, 1);
  110521. break;
  110522. }
  110523. index++;
  110524. }
  110525. return this;
  110526. };
  110527. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  110528. u = Math.abs(u) * 0.5 + 0.5;
  110529. v = Math.abs(v) * 0.5 + 0.5;
  110530. var wrappedU = ((u * width) % width) | 0;
  110531. var wrappedV = ((v * height) % height) | 0;
  110532. var position = (wrappedU + wrappedV * width) * 4;
  110533. return pixels[position] / 255;
  110534. };
  110535. ParticleSystem.prototype._reset = function () {
  110536. this._resetEffect();
  110537. };
  110538. ParticleSystem.prototype._resetEffect = function () {
  110539. if (this._vertexBuffer) {
  110540. this._vertexBuffer.dispose();
  110541. this._vertexBuffer = null;
  110542. }
  110543. if (this._spriteBuffer) {
  110544. this._spriteBuffer.dispose();
  110545. this._spriteBuffer = null;
  110546. }
  110547. this._createVertexBuffers();
  110548. };
  110549. ParticleSystem.prototype._createVertexBuffers = function () {
  110550. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  110551. if (this._isAnimationSheetEnabled) {
  110552. this._vertexBufferSize += 1;
  110553. }
  110554. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  110555. this._vertexBufferSize += 3;
  110556. }
  110557. if (this._useRampGradients) {
  110558. this._vertexBufferSize += 4;
  110559. }
  110560. var engine = this._scene.getEngine();
  110561. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  110562. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  110563. var dataOffset = 0;
  110564. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  110565. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  110566. dataOffset += 3;
  110567. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  110568. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  110569. dataOffset += 4;
  110570. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  110571. this._vertexBuffers["angle"] = options;
  110572. dataOffset += 1;
  110573. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  110574. this._vertexBuffers["size"] = size;
  110575. dataOffset += 2;
  110576. if (this._isAnimationSheetEnabled) {
  110577. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  110578. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  110579. dataOffset += 1;
  110580. }
  110581. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  110582. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  110583. this._vertexBuffers["direction"] = directionBuffer;
  110584. dataOffset += 3;
  110585. }
  110586. if (this._useRampGradients) {
  110587. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  110588. this._vertexBuffers["remapData"] = rampDataBuffer;
  110589. dataOffset += 4;
  110590. }
  110591. var offsets;
  110592. if (this._useInstancing) {
  110593. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  110594. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  110595. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  110596. }
  110597. else {
  110598. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  110599. dataOffset += 2;
  110600. }
  110601. this._vertexBuffers["offset"] = offsets;
  110602. };
  110603. ParticleSystem.prototype._createIndexBuffer = function () {
  110604. if (this._useInstancing) {
  110605. return;
  110606. }
  110607. var indices = [];
  110608. var index = 0;
  110609. for (var count = 0; count < this._capacity; count++) {
  110610. indices.push(index);
  110611. indices.push(index + 1);
  110612. indices.push(index + 2);
  110613. indices.push(index);
  110614. indices.push(index + 2);
  110615. indices.push(index + 3);
  110616. index += 4;
  110617. }
  110618. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  110619. };
  110620. /**
  110621. * Gets the maximum number of particles active at the same time.
  110622. * @returns The max number of active particles.
  110623. */
  110624. ParticleSystem.prototype.getCapacity = function () {
  110625. return this._capacity;
  110626. };
  110627. /**
  110628. * Gets whether there are still active particles in the system.
  110629. * @returns True if it is alive, otherwise false.
  110630. */
  110631. ParticleSystem.prototype.isAlive = function () {
  110632. return this._alive;
  110633. };
  110634. /**
  110635. * Gets if the system has been started. (Note: this will still be true after stop is called)
  110636. * @returns True if it has been started, otherwise false.
  110637. */
  110638. ParticleSystem.prototype.isStarted = function () {
  110639. return this._started;
  110640. };
  110641. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  110642. var _this = this;
  110643. this._subEmitters = new Array();
  110644. if (this.subEmitters) {
  110645. this.subEmitters.forEach(function (subEmitter) {
  110646. if (subEmitter instanceof ParticleSystem) {
  110647. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"](subEmitter)]);
  110648. }
  110649. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]) {
  110650. _this._subEmitters.push([subEmitter]);
  110651. }
  110652. else if (subEmitter instanceof Array) {
  110653. _this._subEmitters.push(subEmitter);
  110654. }
  110655. });
  110656. }
  110657. };
  110658. /**
  110659. * Starts the particle system and begins to emit
  110660. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  110661. */
  110662. ParticleSystem.prototype.start = function (delay) {
  110663. var _this = this;
  110664. if (delay === void 0) { delay = this.startDelay; }
  110665. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  110666. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  110667. }
  110668. if (delay) {
  110669. setTimeout(function () {
  110670. _this.start(0);
  110671. }, delay);
  110672. return;
  110673. }
  110674. // Convert the subEmitters field to the constant type field _subEmitters
  110675. this._prepareSubEmitterInternalArray();
  110676. this._started = true;
  110677. this._stopped = false;
  110678. this._actualFrame = 0;
  110679. if (this._subEmitters && this._subEmitters.length != 0) {
  110680. this.activeSubSystems = new Array();
  110681. }
  110682. // Reset emit gradient so it acts the same on every start
  110683. if (this._emitRateGradients) {
  110684. if (this._emitRateGradients.length > 0) {
  110685. this._currentEmitRateGradient = this._emitRateGradients[0];
  110686. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  110687. this._currentEmitRate2 = this._currentEmitRate1;
  110688. }
  110689. if (this._emitRateGradients.length > 1) {
  110690. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  110691. }
  110692. }
  110693. // Reset start size gradient so it acts the same on every start
  110694. if (this._startSizeGradients) {
  110695. if (this._startSizeGradients.length > 0) {
  110696. this._currentStartSizeGradient = this._startSizeGradients[0];
  110697. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  110698. this._currentStartSize2 = this._currentStartSize1;
  110699. }
  110700. if (this._startSizeGradients.length > 1) {
  110701. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  110702. }
  110703. }
  110704. if (this.preWarmCycles) {
  110705. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  110706. this.emitter.computeWorldMatrix(true);
  110707. }
  110708. var noiseTextureAsProcedural_1 = this.noiseTexture;
  110709. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  110710. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  110711. setTimeout(function () {
  110712. for (var index = 0; index < _this.preWarmCycles; index++) {
  110713. _this.animate(true);
  110714. noiseTextureAsProcedural_1.render();
  110715. }
  110716. });
  110717. });
  110718. }
  110719. else {
  110720. for (var index = 0; index < this.preWarmCycles; index++) {
  110721. this.animate(true);
  110722. }
  110723. }
  110724. }
  110725. // Animations
  110726. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  110727. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  110728. }
  110729. };
  110730. /**
  110731. * Stops the particle system.
  110732. * @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.
  110733. */
  110734. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  110735. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  110736. this._stopped = true;
  110737. if (stopSubEmitters) {
  110738. this._stopSubEmitters();
  110739. }
  110740. };
  110741. // animation sheet
  110742. /**
  110743. * Remove all active particles
  110744. */
  110745. ParticleSystem.prototype.reset = function () {
  110746. this._stockParticles = [];
  110747. this._particles = [];
  110748. };
  110749. /**
  110750. * @hidden (for internal use only)
  110751. */
  110752. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  110753. var offset = index * this._vertexBufferSize;
  110754. this._vertexData[offset++] = particle.position.x + this.worldOffset.x;
  110755. this._vertexData[offset++] = particle.position.y + this.worldOffset.y;
  110756. this._vertexData[offset++] = particle.position.z + this.worldOffset.z;
  110757. this._vertexData[offset++] = particle.color.r;
  110758. this._vertexData[offset++] = particle.color.g;
  110759. this._vertexData[offset++] = particle.color.b;
  110760. this._vertexData[offset++] = particle.color.a;
  110761. this._vertexData[offset++] = particle.angle;
  110762. this._vertexData[offset++] = particle.scale.x * particle.size;
  110763. this._vertexData[offset++] = particle.scale.y * particle.size;
  110764. if (this._isAnimationSheetEnabled) {
  110765. this._vertexData[offset++] = particle.cellIndex;
  110766. }
  110767. if (!this._isBillboardBased) {
  110768. if (particle._initialDirection) {
  110769. this._vertexData[offset++] = particle._initialDirection.x;
  110770. this._vertexData[offset++] = particle._initialDirection.y;
  110771. this._vertexData[offset++] = particle._initialDirection.z;
  110772. }
  110773. else {
  110774. this._vertexData[offset++] = particle.direction.x;
  110775. this._vertexData[offset++] = particle.direction.y;
  110776. this._vertexData[offset++] = particle.direction.z;
  110777. }
  110778. }
  110779. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  110780. this._vertexData[offset++] = particle.direction.x;
  110781. this._vertexData[offset++] = particle.direction.y;
  110782. this._vertexData[offset++] = particle.direction.z;
  110783. }
  110784. if (this._useRampGradients) {
  110785. this._vertexData[offset++] = particle.remapData.x;
  110786. this._vertexData[offset++] = particle.remapData.y;
  110787. this._vertexData[offset++] = particle.remapData.z;
  110788. this._vertexData[offset++] = particle.remapData.w;
  110789. }
  110790. if (!this._useInstancing) {
  110791. if (this._isAnimationSheetEnabled) {
  110792. if (offsetX === 0) {
  110793. offsetX = this._epsilon;
  110794. }
  110795. else if (offsetX === 1) {
  110796. offsetX = 1 - this._epsilon;
  110797. }
  110798. if (offsetY === 0) {
  110799. offsetY = this._epsilon;
  110800. }
  110801. else if (offsetY === 1) {
  110802. offsetY = 1 - this._epsilon;
  110803. }
  110804. }
  110805. this._vertexData[offset++] = offsetX;
  110806. this._vertexData[offset++] = offsetY;
  110807. }
  110808. };
  110809. ParticleSystem.prototype._stopSubEmitters = function () {
  110810. if (!this.activeSubSystems) {
  110811. return;
  110812. }
  110813. this.activeSubSystems.forEach(function (subSystem) {
  110814. subSystem.stop(true);
  110815. });
  110816. this.activeSubSystems = new Array();
  110817. };
  110818. ParticleSystem.prototype._removeFromRoot = function () {
  110819. if (!this._rootParticleSystem) {
  110820. return;
  110821. }
  110822. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  110823. if (index !== -1) {
  110824. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  110825. }
  110826. this._rootParticleSystem = null;
  110827. };
  110828. // End of sub system methods
  110829. ParticleSystem.prototype._update = function (newParticles) {
  110830. var _this = this;
  110831. // Update current
  110832. this._alive = this._particles.length > 0;
  110833. if (this.emitter.position) {
  110834. var emitterMesh = this.emitter;
  110835. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  110836. }
  110837. else {
  110838. var emitterPosition = this.emitter;
  110839. this._emitterWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  110840. }
  110841. this.updateFunction(this._particles);
  110842. // Add new ones
  110843. var particle;
  110844. var _loop_2 = function () {
  110845. if (this_1._particles.length === this_1._capacity) {
  110846. return "break";
  110847. }
  110848. particle = this_1._createParticle();
  110849. this_1._particles.push(particle);
  110850. // Emitter
  110851. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  110852. if (this_1.startPositionFunction) {
  110853. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  110854. }
  110855. else {
  110856. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  110857. }
  110858. if (this_1.startDirectionFunction) {
  110859. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  110860. }
  110861. else {
  110862. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  110863. }
  110864. if (emitPower === 0) {
  110865. if (!particle._initialDirection) {
  110866. particle._initialDirection = particle.direction.clone();
  110867. }
  110868. else {
  110869. particle._initialDirection.copyFrom(particle.direction);
  110870. }
  110871. }
  110872. else {
  110873. particle._initialDirection = null;
  110874. }
  110875. particle.direction.scaleInPlace(emitPower);
  110876. // Life time
  110877. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  110878. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  110879. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  110880. var factorGradient1 = currentGradient;
  110881. var factorGradient2 = nextGradient;
  110882. var lifeTime1 = factorGradient1.getFactor();
  110883. var lifeTime2 = factorGradient2.getFactor();
  110884. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  110885. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  110886. });
  110887. }
  110888. else {
  110889. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  110890. }
  110891. // Size
  110892. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  110893. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  110894. }
  110895. else {
  110896. particle._currentSizeGradient = this_1._sizeGradients[0];
  110897. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  110898. particle.size = particle._currentSize1;
  110899. if (this_1._sizeGradients.length > 1) {
  110900. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  110901. }
  110902. else {
  110903. particle._currentSize2 = particle._currentSize1;
  110904. }
  110905. }
  110906. // Size and scale
  110907. 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));
  110908. // Adjust scale by start size
  110909. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  110910. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  110911. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  110912. if (currentGradient !== _this._currentStartSizeGradient) {
  110913. _this._currentStartSize1 = _this._currentStartSize2;
  110914. _this._currentStartSize2 = nextGradient.getFactor();
  110915. _this._currentStartSizeGradient = currentGradient;
  110916. }
  110917. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  110918. particle.scale.scaleInPlace(value);
  110919. });
  110920. }
  110921. // Angle
  110922. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  110923. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  110924. }
  110925. else {
  110926. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  110927. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  110928. particle._currentAngularSpeed1 = particle.angularSpeed;
  110929. if (this_1._angularSpeedGradients.length > 1) {
  110930. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  110931. }
  110932. else {
  110933. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  110934. }
  110935. }
  110936. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  110937. // Velocity
  110938. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  110939. particle._currentVelocityGradient = this_1._velocityGradients[0];
  110940. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  110941. if (this_1._velocityGradients.length > 1) {
  110942. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  110943. }
  110944. else {
  110945. particle._currentVelocity2 = particle._currentVelocity1;
  110946. }
  110947. }
  110948. // Limit velocity
  110949. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  110950. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  110951. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  110952. if (this_1._limitVelocityGradients.length > 1) {
  110953. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  110954. }
  110955. else {
  110956. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  110957. }
  110958. }
  110959. // Drag
  110960. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  110961. particle._currentDragGradient = this_1._dragGradients[0];
  110962. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  110963. if (this_1._dragGradients.length > 1) {
  110964. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  110965. }
  110966. else {
  110967. particle._currentDrag2 = particle._currentDrag1;
  110968. }
  110969. }
  110970. // Color
  110971. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  110972. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  110973. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  110974. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  110975. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  110976. }
  110977. else {
  110978. particle._currentColorGradient = this_1._colorGradients[0];
  110979. particle._currentColorGradient.getColorToRef(particle.color);
  110980. particle._currentColor1.copyFrom(particle.color);
  110981. if (this_1._colorGradients.length > 1) {
  110982. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  110983. }
  110984. else {
  110985. particle._currentColor2.copyFrom(particle.color);
  110986. }
  110987. }
  110988. // Sheet
  110989. if (this_1._isAnimationSheetEnabled) {
  110990. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  110991. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  110992. }
  110993. // Inherited Velocity
  110994. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  110995. // Ramp
  110996. if (this_1._useRampGradients) {
  110997. particle.remapData = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  110998. }
  110999. // Noise texture coordinates
  111000. if (this_1.noiseTexture) {
  111001. if (particle._randomNoiseCoordinates1) {
  111002. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  111003. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  111004. }
  111005. else {
  111006. particle._randomNoiseCoordinates1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  111007. particle._randomNoiseCoordinates2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  111008. }
  111009. }
  111010. // Update the position of the attached sub-emitters to match their attached particle
  111011. particle._inheritParticleInfoToSubEmitters();
  111012. };
  111013. var this_1 = this, step;
  111014. for (var index = 0; index < newParticles; index++) {
  111015. var state_1 = _loop_2();
  111016. if (state_1 === "break")
  111017. break;
  111018. }
  111019. };
  111020. /** @hidden */
  111021. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  111022. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  111023. if (isBillboardBased === void 0) { isBillboardBased = false; }
  111024. if (useRampGradients === void 0) { useRampGradients = false; }
  111025. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  111026. if (isAnimationSheetEnabled) {
  111027. attributeNamesOrOptions.push("cellIndex");
  111028. }
  111029. if (!isBillboardBased) {
  111030. attributeNamesOrOptions.push("direction");
  111031. }
  111032. if (useRampGradients) {
  111033. attributeNamesOrOptions.push("remapData");
  111034. }
  111035. return attributeNamesOrOptions;
  111036. };
  111037. /** @hidden */
  111038. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  111039. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  111040. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  111041. if (isAnimationSheetEnabled) {
  111042. effectCreationOption.push("particlesInfos");
  111043. }
  111044. return effectCreationOption;
  111045. };
  111046. /** @hidden */
  111047. ParticleSystem.prototype._getEffect = function (blendMode) {
  111048. if (this._customEffect) {
  111049. return this._customEffect;
  111050. }
  111051. var defines = [];
  111052. if (this._scene.clipPlane) {
  111053. defines.push("#define CLIPPLANE");
  111054. }
  111055. if (this._scene.clipPlane2) {
  111056. defines.push("#define CLIPPLANE2");
  111057. }
  111058. if (this._scene.clipPlane3) {
  111059. defines.push("#define CLIPPLANE3");
  111060. }
  111061. if (this._scene.clipPlane4) {
  111062. defines.push("#define CLIPPLANE4");
  111063. }
  111064. if (this._isAnimationSheetEnabled) {
  111065. defines.push("#define ANIMATESHEET");
  111066. }
  111067. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  111068. defines.push("#define BLENDMULTIPLYMODE");
  111069. }
  111070. if (this._useRampGradients) {
  111071. defines.push("#define RAMPGRADIENT");
  111072. }
  111073. if (this._isBillboardBased) {
  111074. defines.push("#define BILLBOARD");
  111075. switch (this.billboardMode) {
  111076. case ParticleSystem.BILLBOARDMODE_Y:
  111077. defines.push("#define BILLBOARDY");
  111078. break;
  111079. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  111080. defines.push("#define BILLBOARDSTRETCHED");
  111081. break;
  111082. case ParticleSystem.BILLBOARDMODE_ALL:
  111083. default:
  111084. break;
  111085. }
  111086. }
  111087. if (this._imageProcessingConfiguration) {
  111088. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  111089. defines.push(this._imageProcessingConfigurationDefines.toString());
  111090. }
  111091. // Effect
  111092. var join = defines.join("\n");
  111093. if (this._cachedDefines !== join) {
  111094. this._cachedDefines = join;
  111095. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  111096. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  111097. var samplers = ["diffuseSampler", "rampSampler"];
  111098. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  111099. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  111100. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  111101. }
  111102. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  111103. }
  111104. return this._effect;
  111105. };
  111106. /**
  111107. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  111108. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  111109. */
  111110. ParticleSystem.prototype.animate = function (preWarmOnly) {
  111111. var _this = this;
  111112. if (preWarmOnly === void 0) { preWarmOnly = false; }
  111113. if (!this._started) {
  111114. return;
  111115. }
  111116. if (!preWarmOnly) {
  111117. // Check
  111118. if (!this.isReady()) {
  111119. return;
  111120. }
  111121. if (this._currentRenderId === this._scene.getFrameId()) {
  111122. return;
  111123. }
  111124. this._currentRenderId = this._scene.getFrameId();
  111125. }
  111126. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  111127. // Determine the number of particles we need to create
  111128. var newParticles;
  111129. if (this.manualEmitCount > -1) {
  111130. newParticles = this.manualEmitCount;
  111131. this._newPartsExcess = 0;
  111132. this.manualEmitCount = 0;
  111133. }
  111134. else {
  111135. var rate_1 = this.emitRate;
  111136. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  111137. var ratio = this._actualFrame / this.targetStopDuration;
  111138. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  111139. if (currentGradient !== _this._currentEmitRateGradient) {
  111140. _this._currentEmitRate1 = _this._currentEmitRate2;
  111141. _this._currentEmitRate2 = nextGradient.getFactor();
  111142. _this._currentEmitRateGradient = currentGradient;
  111143. }
  111144. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  111145. });
  111146. }
  111147. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  111148. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  111149. }
  111150. if (this._newPartsExcess > 1.0) {
  111151. newParticles += this._newPartsExcess >> 0;
  111152. this._newPartsExcess -= this._newPartsExcess >> 0;
  111153. }
  111154. this._alive = false;
  111155. if (!this._stopped) {
  111156. this._actualFrame += this._scaledUpdateSpeed;
  111157. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  111158. this.stop();
  111159. }
  111160. }
  111161. else {
  111162. newParticles = 0;
  111163. }
  111164. this._update(newParticles);
  111165. // Stopped?
  111166. if (this._stopped) {
  111167. if (!this._alive) {
  111168. this._started = false;
  111169. if (this.onAnimationEnd) {
  111170. this.onAnimationEnd();
  111171. }
  111172. if (this.disposeOnStop) {
  111173. this._scene._toBeDisposed.push(this);
  111174. }
  111175. }
  111176. }
  111177. if (!preWarmOnly) {
  111178. // Update VBO
  111179. var offset = 0;
  111180. for (var index = 0; index < this._particles.length; index++) {
  111181. var particle = this._particles[index];
  111182. this._appendParticleVertices(offset, particle);
  111183. offset += this._useInstancing ? 1 : 4;
  111184. }
  111185. if (this._vertexBuffer) {
  111186. this._vertexBuffer.update(this._vertexData);
  111187. }
  111188. }
  111189. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  111190. this.stop();
  111191. }
  111192. };
  111193. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  111194. this._appendParticleVertex(offset++, particle, 0, 0);
  111195. if (!this._useInstancing) {
  111196. this._appendParticleVertex(offset++, particle, 1, 0);
  111197. this._appendParticleVertex(offset++, particle, 1, 1);
  111198. this._appendParticleVertex(offset++, particle, 0, 1);
  111199. }
  111200. };
  111201. /**
  111202. * Rebuilds the particle system.
  111203. */
  111204. ParticleSystem.prototype.rebuild = function () {
  111205. this._createIndexBuffer();
  111206. if (this._vertexBuffer) {
  111207. this._vertexBuffer._rebuild();
  111208. }
  111209. };
  111210. /**
  111211. * Is this system ready to be used/rendered
  111212. * @return true if the system is ready
  111213. */
  111214. ParticleSystem.prototype.isReady = function () {
  111215. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  111216. return false;
  111217. }
  111218. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  111219. if (!this._getEffect(this.blendMode).isReady()) {
  111220. return false;
  111221. }
  111222. }
  111223. else {
  111224. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  111225. return false;
  111226. }
  111227. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  111228. return false;
  111229. }
  111230. }
  111231. return true;
  111232. };
  111233. ParticleSystem.prototype._render = function (blendMode) {
  111234. var effect = this._getEffect(blendMode);
  111235. var engine = this._scene.getEngine();
  111236. // Render
  111237. engine.enableEffect(effect);
  111238. var viewMatrix = this._scene.getViewMatrix();
  111239. effect.setTexture("diffuseSampler", this.particleTexture);
  111240. effect.setMatrix("view", viewMatrix);
  111241. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  111242. if (this._isAnimationSheetEnabled && this.particleTexture) {
  111243. var baseSize = this.particleTexture.getBaseSize();
  111244. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  111245. }
  111246. effect.setVector2("translationPivot", this.translationPivot);
  111247. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  111248. if (this._isBillboardBased) {
  111249. var camera = this._scene.activeCamera;
  111250. effect.setVector3("eyePosition", camera.globalPosition);
  111251. }
  111252. if (this._rampGradientsTexture) {
  111253. effect.setTexture("rampSampler", this._rampGradientsTexture);
  111254. }
  111255. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  111256. var invView = viewMatrix.clone();
  111257. invView.invert();
  111258. effect.setMatrix("invView", invView);
  111259. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  111260. }
  111261. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  111262. // image processing
  111263. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  111264. this._imageProcessingConfiguration.bind(effect);
  111265. }
  111266. // Draw order
  111267. switch (blendMode) {
  111268. case ParticleSystem.BLENDMODE_ADD:
  111269. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ADD);
  111270. break;
  111271. case ParticleSystem.BLENDMODE_ONEONE:
  111272. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ONEONE);
  111273. break;
  111274. case ParticleSystem.BLENDMODE_STANDARD:
  111275. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_COMBINE);
  111276. break;
  111277. case ParticleSystem.BLENDMODE_MULTIPLY:
  111278. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_MULTIPLY);
  111279. break;
  111280. }
  111281. if (this._useInstancing) {
  111282. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  111283. }
  111284. else {
  111285. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  111286. }
  111287. return this._particles.length;
  111288. };
  111289. /**
  111290. * Renders the particle system in its current state.
  111291. * @returns the current number of particles
  111292. */
  111293. ParticleSystem.prototype.render = function () {
  111294. // Check
  111295. if (!this.isReady() || !this._particles.length) {
  111296. return 0;
  111297. }
  111298. var engine = this._scene.getEngine();
  111299. engine.setState(false);
  111300. if (this.forceDepthWrite) {
  111301. engine.setDepthWrite(true);
  111302. }
  111303. var outparticles = 0;
  111304. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  111305. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  111306. }
  111307. outparticles = this._render(this.blendMode);
  111308. engine.unbindInstanceAttributes();
  111309. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_DISABLE);
  111310. return outparticles;
  111311. };
  111312. /**
  111313. * Disposes the particle system and free the associated resources
  111314. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  111315. */
  111316. ParticleSystem.prototype.dispose = function (disposeTexture) {
  111317. if (disposeTexture === void 0) { disposeTexture = true; }
  111318. if (this._vertexBuffer) {
  111319. this._vertexBuffer.dispose();
  111320. this._vertexBuffer = null;
  111321. }
  111322. if (this._spriteBuffer) {
  111323. this._spriteBuffer.dispose();
  111324. this._spriteBuffer = null;
  111325. }
  111326. if (this._indexBuffer) {
  111327. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  111328. this._indexBuffer = null;
  111329. }
  111330. if (disposeTexture && this.particleTexture) {
  111331. this.particleTexture.dispose();
  111332. this.particleTexture = null;
  111333. }
  111334. if (disposeTexture && this.noiseTexture) {
  111335. this.noiseTexture.dispose();
  111336. this.noiseTexture = null;
  111337. }
  111338. if (this._rampGradientsTexture) {
  111339. this._rampGradientsTexture.dispose();
  111340. this._rampGradientsTexture = null;
  111341. }
  111342. this._removeFromRoot();
  111343. if (this._subEmitters && this._subEmitters.length) {
  111344. for (var index = 0; index < this._subEmitters.length; index++) {
  111345. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  111346. var subEmitter = _a[_i];
  111347. subEmitter.dispose();
  111348. }
  111349. }
  111350. this._subEmitters = [];
  111351. this.subEmitters = [];
  111352. }
  111353. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  111354. this.emitter.dispose(true);
  111355. }
  111356. // Remove from scene
  111357. var index = this._scene.particleSystems.indexOf(this);
  111358. if (index > -1) {
  111359. this._scene.particleSystems.splice(index, 1);
  111360. }
  111361. this._scene._activeParticleSystems.dispose();
  111362. // Callback
  111363. this.onDisposeObservable.notifyObservers(this);
  111364. this.onDisposeObservable.clear();
  111365. this.reset();
  111366. };
  111367. // Clone
  111368. /**
  111369. * Clones the particle system.
  111370. * @param name The name of the cloned object
  111371. * @param newEmitter The new emitter to use
  111372. * @returns the cloned particle system
  111373. */
  111374. ParticleSystem.prototype.clone = function (name, newEmitter) {
  111375. var custom = null;
  111376. var program = null;
  111377. if (this.customShader != null) {
  111378. program = this.customShader;
  111379. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  111380. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  111381. }
  111382. else if (this._customEffect) {
  111383. custom = this._customEffect;
  111384. }
  111385. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  111386. result.customShader = program;
  111387. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture"]);
  111388. if (newEmitter === undefined) {
  111389. newEmitter = this.emitter;
  111390. }
  111391. result.noiseTexture = this.noiseTexture;
  111392. result.emitter = newEmitter;
  111393. if (this.particleTexture) {
  111394. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  111395. }
  111396. // Clone gradients
  111397. if (this._colorGradients) {
  111398. this._colorGradients.forEach(function (v) {
  111399. result.addColorGradient(v.gradient, v.color1, v.color2);
  111400. });
  111401. }
  111402. if (this._dragGradients) {
  111403. this._dragGradients.forEach(function (v) {
  111404. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  111405. });
  111406. }
  111407. if (this._angularSpeedGradients) {
  111408. this._angularSpeedGradients.forEach(function (v) {
  111409. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  111410. });
  111411. }
  111412. if (this._emitRateGradients) {
  111413. this._emitRateGradients.forEach(function (v) {
  111414. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  111415. });
  111416. }
  111417. if (this._lifeTimeGradients) {
  111418. this._lifeTimeGradients.forEach(function (v) {
  111419. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  111420. });
  111421. }
  111422. if (this._limitVelocityGradients) {
  111423. this._limitVelocityGradients.forEach(function (v) {
  111424. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  111425. });
  111426. }
  111427. if (this._sizeGradients) {
  111428. this._sizeGradients.forEach(function (v) {
  111429. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  111430. });
  111431. }
  111432. if (this._startSizeGradients) {
  111433. this._startSizeGradients.forEach(function (v) {
  111434. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  111435. });
  111436. }
  111437. if (this._velocityGradients) {
  111438. this._velocityGradients.forEach(function (v) {
  111439. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  111440. });
  111441. }
  111442. if (this._rampGradients) {
  111443. this._rampGradients.forEach(function (v) {
  111444. result.addRampGradient(v.gradient, v.color);
  111445. });
  111446. }
  111447. if (this._colorRemapGradients) {
  111448. this._colorRemapGradients.forEach(function (v) {
  111449. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  111450. });
  111451. }
  111452. if (this._alphaRemapGradients) {
  111453. this._alphaRemapGradients.forEach(function (v) {
  111454. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  111455. });
  111456. }
  111457. if (!this.preventAutoStart) {
  111458. result.start();
  111459. }
  111460. return result;
  111461. };
  111462. /**
  111463. * Serializes the particle system to a JSON object.
  111464. * @returns the JSON object
  111465. */
  111466. ParticleSystem.prototype.serialize = function () {
  111467. var serializationObject = {};
  111468. ParticleSystem._Serialize(serializationObject, this);
  111469. serializationObject.textureMask = this.textureMask.asArray();
  111470. serializationObject.customShader = this.customShader;
  111471. serializationObject.preventAutoStart = this.preventAutoStart;
  111472. // SubEmitters
  111473. if (this.subEmitters) {
  111474. serializationObject.subEmitters = [];
  111475. if (!this._subEmitters) {
  111476. this._prepareSubEmitterInternalArray();
  111477. }
  111478. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  111479. var subs = _a[_i];
  111480. var cell = [];
  111481. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  111482. var sub = subs_1[_b];
  111483. cell.push(sub.serialize());
  111484. }
  111485. serializationObject.subEmitters.push(cell);
  111486. }
  111487. }
  111488. return serializationObject;
  111489. };
  111490. /** @hidden */
  111491. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  111492. serializationObject.name = particleSystem.name;
  111493. serializationObject.id = particleSystem.id;
  111494. serializationObject.capacity = particleSystem.getCapacity();
  111495. // Emitter
  111496. if (particleSystem.emitter.position) {
  111497. var emitterMesh = particleSystem.emitter;
  111498. serializationObject.emitterId = emitterMesh.id;
  111499. }
  111500. else {
  111501. var emitterPosition = particleSystem.emitter;
  111502. serializationObject.emitter = emitterPosition.asArray();
  111503. }
  111504. // Emitter
  111505. if (particleSystem.particleEmitterType) {
  111506. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  111507. }
  111508. if (particleSystem.particleTexture) {
  111509. serializationObject.textureName = particleSystem.particleTexture.name;
  111510. serializationObject.invertY = particleSystem.particleTexture._invertY;
  111511. }
  111512. // Animations
  111513. _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  111514. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  111515. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  111516. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  111517. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  111518. // Particle system
  111519. serializationObject.startDelay = particleSystem.startDelay;
  111520. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  111521. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  111522. serializationObject.billboardMode = particleSystem.billboardMode;
  111523. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  111524. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  111525. serializationObject.minSize = particleSystem.minSize;
  111526. serializationObject.maxSize = particleSystem.maxSize;
  111527. serializationObject.minScaleX = particleSystem.minScaleX;
  111528. serializationObject.maxScaleX = particleSystem.maxScaleX;
  111529. serializationObject.minScaleY = particleSystem.minScaleY;
  111530. serializationObject.maxScaleY = particleSystem.maxScaleY;
  111531. serializationObject.minEmitPower = particleSystem.minEmitPower;
  111532. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  111533. serializationObject.minLifeTime = particleSystem.minLifeTime;
  111534. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  111535. serializationObject.emitRate = particleSystem.emitRate;
  111536. serializationObject.gravity = particleSystem.gravity.asArray();
  111537. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  111538. serializationObject.color1 = particleSystem.color1.asArray();
  111539. serializationObject.color2 = particleSystem.color2.asArray();
  111540. serializationObject.colorDead = particleSystem.colorDead.asArray();
  111541. serializationObject.updateSpeed = particleSystem.updateSpeed;
  111542. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  111543. serializationObject.blendMode = particleSystem.blendMode;
  111544. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  111545. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  111546. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  111547. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  111548. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  111549. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  111550. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  111551. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  111552. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  111553. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  111554. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  111555. var colorGradients = particleSystem.getColorGradients();
  111556. if (colorGradients) {
  111557. serializationObject.colorGradients = [];
  111558. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  111559. var colorGradient = colorGradients_1[_i];
  111560. var serializedGradient = {
  111561. gradient: colorGradient.gradient,
  111562. color1: colorGradient.color1.asArray()
  111563. };
  111564. if (colorGradient.color2) {
  111565. serializedGradient.color2 = colorGradient.color2.asArray();
  111566. }
  111567. serializationObject.colorGradients.push(serializedGradient);
  111568. }
  111569. }
  111570. var rampGradients = particleSystem.getRampGradients();
  111571. if (rampGradients) {
  111572. serializationObject.rampGradients = [];
  111573. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  111574. var rampGradient = rampGradients_1[_a];
  111575. var serializedGradient = {
  111576. gradient: rampGradient.gradient,
  111577. color: rampGradient.color.asArray()
  111578. };
  111579. serializationObject.rampGradients.push(serializedGradient);
  111580. }
  111581. serializationObject.useRampGradients = particleSystem.useRampGradients;
  111582. }
  111583. var colorRemapGradients = particleSystem.getColorRemapGradients();
  111584. if (colorRemapGradients) {
  111585. serializationObject.colorRemapGradients = [];
  111586. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  111587. var colorRemapGradient = colorRemapGradients_1[_b];
  111588. var serializedGradient = {
  111589. gradient: colorRemapGradient.gradient,
  111590. factor1: colorRemapGradient.factor1
  111591. };
  111592. if (colorRemapGradient.factor2 !== undefined) {
  111593. serializedGradient.factor2 = colorRemapGradient.factor2;
  111594. }
  111595. serializationObject.colorRemapGradients.push(serializedGradient);
  111596. }
  111597. }
  111598. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  111599. if (alphaRemapGradients) {
  111600. serializationObject.alphaRemapGradients = [];
  111601. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  111602. var alphaRemapGradient = alphaRemapGradients_1[_c];
  111603. var serializedGradient = {
  111604. gradient: alphaRemapGradient.gradient,
  111605. factor1: alphaRemapGradient.factor1
  111606. };
  111607. if (alphaRemapGradient.factor2 !== undefined) {
  111608. serializedGradient.factor2 = alphaRemapGradient.factor2;
  111609. }
  111610. serializationObject.alphaRemapGradients.push(serializedGradient);
  111611. }
  111612. }
  111613. var sizeGradients = particleSystem.getSizeGradients();
  111614. if (sizeGradients) {
  111615. serializationObject.sizeGradients = [];
  111616. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  111617. var sizeGradient = sizeGradients_1[_d];
  111618. var serializedGradient = {
  111619. gradient: sizeGradient.gradient,
  111620. factor1: sizeGradient.factor1
  111621. };
  111622. if (sizeGradient.factor2 !== undefined) {
  111623. serializedGradient.factor2 = sizeGradient.factor2;
  111624. }
  111625. serializationObject.sizeGradients.push(serializedGradient);
  111626. }
  111627. }
  111628. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  111629. if (angularSpeedGradients) {
  111630. serializationObject.angularSpeedGradients = [];
  111631. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  111632. var angularSpeedGradient = angularSpeedGradients_1[_e];
  111633. var serializedGradient = {
  111634. gradient: angularSpeedGradient.gradient,
  111635. factor1: angularSpeedGradient.factor1
  111636. };
  111637. if (angularSpeedGradient.factor2 !== undefined) {
  111638. serializedGradient.factor2 = angularSpeedGradient.factor2;
  111639. }
  111640. serializationObject.angularSpeedGradients.push(serializedGradient);
  111641. }
  111642. }
  111643. var velocityGradients = particleSystem.getVelocityGradients();
  111644. if (velocityGradients) {
  111645. serializationObject.velocityGradients = [];
  111646. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  111647. var velocityGradient = velocityGradients_1[_f];
  111648. var serializedGradient = {
  111649. gradient: velocityGradient.gradient,
  111650. factor1: velocityGradient.factor1
  111651. };
  111652. if (velocityGradient.factor2 !== undefined) {
  111653. serializedGradient.factor2 = velocityGradient.factor2;
  111654. }
  111655. serializationObject.velocityGradients.push(serializedGradient);
  111656. }
  111657. }
  111658. var dragGradients = particleSystem.getDragGradients();
  111659. if (dragGradients) {
  111660. serializationObject.dragyGradients = [];
  111661. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  111662. var dragGradient = dragGradients_1[_g];
  111663. var serializedGradient = {
  111664. gradient: dragGradient.gradient,
  111665. factor1: dragGradient.factor1
  111666. };
  111667. if (dragGradient.factor2 !== undefined) {
  111668. serializedGradient.factor2 = dragGradient.factor2;
  111669. }
  111670. serializationObject.dragGradients.push(serializedGradient);
  111671. }
  111672. }
  111673. var emitRateGradients = particleSystem.getEmitRateGradients();
  111674. if (emitRateGradients) {
  111675. serializationObject.emitRateGradients = [];
  111676. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  111677. var emitRateGradient = emitRateGradients_1[_h];
  111678. var serializedGradient = {
  111679. gradient: emitRateGradient.gradient,
  111680. factor1: emitRateGradient.factor1
  111681. };
  111682. if (emitRateGradient.factor2 !== undefined) {
  111683. serializedGradient.factor2 = emitRateGradient.factor2;
  111684. }
  111685. serializationObject.emitRateGradients.push(serializedGradient);
  111686. }
  111687. }
  111688. var startSizeGradients = particleSystem.getStartSizeGradients();
  111689. if (startSizeGradients) {
  111690. serializationObject.startSizeGradients = [];
  111691. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  111692. var startSizeGradient = startSizeGradients_1[_j];
  111693. var serializedGradient = {
  111694. gradient: startSizeGradient.gradient,
  111695. factor1: startSizeGradient.factor1
  111696. };
  111697. if (startSizeGradient.factor2 !== undefined) {
  111698. serializedGradient.factor2 = startSizeGradient.factor2;
  111699. }
  111700. serializationObject.startSizeGradients.push(serializedGradient);
  111701. }
  111702. }
  111703. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  111704. if (lifeTimeGradients) {
  111705. serializationObject.lifeTimeGradients = [];
  111706. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  111707. var lifeTimeGradient = lifeTimeGradients_1[_k];
  111708. var serializedGradient = {
  111709. gradient: lifeTimeGradient.gradient,
  111710. factor1: lifeTimeGradient.factor1
  111711. };
  111712. if (lifeTimeGradient.factor2 !== undefined) {
  111713. serializedGradient.factor2 = lifeTimeGradient.factor2;
  111714. }
  111715. serializationObject.lifeTimeGradients.push(serializedGradient);
  111716. }
  111717. }
  111718. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  111719. if (limitVelocityGradients) {
  111720. serializationObject.limitVelocityGradients = [];
  111721. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  111722. var limitVelocityGradient = limitVelocityGradients_1[_l];
  111723. var serializedGradient = {
  111724. gradient: limitVelocityGradient.gradient,
  111725. factor1: limitVelocityGradient.factor1
  111726. };
  111727. if (limitVelocityGradient.factor2 !== undefined) {
  111728. serializedGradient.factor2 = limitVelocityGradient.factor2;
  111729. }
  111730. serializationObject.limitVelocityGradients.push(serializedGradient);
  111731. }
  111732. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  111733. }
  111734. if (particleSystem.noiseTexture) {
  111735. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  111736. }
  111737. };
  111738. /** @hidden */
  111739. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  111740. // Texture
  111741. if (parsedParticleSystem.textureName) {
  111742. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  111743. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  111744. }
  111745. // Emitter
  111746. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  111747. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  111748. }
  111749. else if (parsedParticleSystem.emitterId) {
  111750. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  111751. }
  111752. else {
  111753. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  111754. }
  111755. // Misc.
  111756. if (parsedParticleSystem.renderingGroupId !== undefined) {
  111757. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  111758. }
  111759. if (parsedParticleSystem.isBillboardBased !== undefined) {
  111760. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  111761. }
  111762. if (parsedParticleSystem.billboardMode !== undefined) {
  111763. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  111764. }
  111765. // Animations
  111766. if (parsedParticleSystem.animations) {
  111767. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  111768. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  111769. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__["_TypeStore"].GetClass("BABYLON.Animation");
  111770. if (internalClass) {
  111771. particleSystem.animations.push(internalClass.Parse(parsedAnimation));
  111772. }
  111773. }
  111774. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  111775. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  111776. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  111777. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  111778. }
  111779. if (parsedParticleSystem.autoAnimate) {
  111780. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  111781. }
  111782. // Particle system
  111783. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  111784. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  111785. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  111786. particleSystem.minSize = parsedParticleSystem.minSize;
  111787. particleSystem.maxSize = parsedParticleSystem.maxSize;
  111788. if (parsedParticleSystem.minScaleX) {
  111789. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  111790. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  111791. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  111792. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  111793. }
  111794. if (parsedParticleSystem.preWarmCycles !== undefined) {
  111795. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  111796. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  111797. }
  111798. if (parsedParticleSystem.minInitialRotation !== undefined) {
  111799. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  111800. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  111801. }
  111802. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  111803. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  111804. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  111805. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  111806. particleSystem.emitRate = parsedParticleSystem.emitRate;
  111807. particleSystem.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  111808. if (parsedParticleSystem.noiseStrength) {
  111809. particleSystem.noiseStrength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  111810. }
  111811. particleSystem.color1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color1);
  111812. particleSystem.color2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color2);
  111813. particleSystem.colorDead = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.colorDead);
  111814. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  111815. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  111816. particleSystem.blendMode = parsedParticleSystem.blendMode;
  111817. if (parsedParticleSystem.colorGradients) {
  111818. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  111819. var colorGradient = _a[_i];
  111820. 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);
  111821. }
  111822. }
  111823. if (parsedParticleSystem.rampGradients) {
  111824. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  111825. var rampGradient = _c[_b];
  111826. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(rampGradient.color));
  111827. }
  111828. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  111829. }
  111830. if (parsedParticleSystem.colorRemapGradients) {
  111831. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  111832. var colorRemapGradient = _e[_d];
  111833. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  111834. }
  111835. }
  111836. if (parsedParticleSystem.alphaRemapGradients) {
  111837. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  111838. var alphaRemapGradient = _g[_f];
  111839. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  111840. }
  111841. }
  111842. if (parsedParticleSystem.sizeGradients) {
  111843. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  111844. var sizeGradient = _j[_h];
  111845. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  111846. }
  111847. }
  111848. if (parsedParticleSystem.sizeGradients) {
  111849. for (var _k = 0, _l = parsedParticleSystem.sizeGradients; _k < _l.length; _k++) {
  111850. var sizeGradient = _l[_k];
  111851. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  111852. }
  111853. }
  111854. if (parsedParticleSystem.angularSpeedGradients) {
  111855. for (var _m = 0, _o = parsedParticleSystem.angularSpeedGradients; _m < _o.length; _m++) {
  111856. var angularSpeedGradient = _o[_m];
  111857. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  111858. }
  111859. }
  111860. if (parsedParticleSystem.velocityGradients) {
  111861. for (var _p = 0, _q = parsedParticleSystem.velocityGradients; _p < _q.length; _p++) {
  111862. var velocityGradient = _q[_p];
  111863. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  111864. }
  111865. }
  111866. if (parsedParticleSystem.dragGradients) {
  111867. for (var _r = 0, _s = parsedParticleSystem.dragGradients; _r < _s.length; _r++) {
  111868. var dragGradient = _s[_r];
  111869. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  111870. }
  111871. }
  111872. if (parsedParticleSystem.emitRateGradients) {
  111873. for (var _t = 0, _u = parsedParticleSystem.emitRateGradients; _t < _u.length; _t++) {
  111874. var emitRateGradient = _u[_t];
  111875. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  111876. }
  111877. }
  111878. if (parsedParticleSystem.startSizeGradients) {
  111879. for (var _v = 0, _w = parsedParticleSystem.startSizeGradients; _v < _w.length; _v++) {
  111880. var startSizeGradient = _w[_v];
  111881. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  111882. }
  111883. }
  111884. if (parsedParticleSystem.lifeTimeGradients) {
  111885. for (var _x = 0, _y = parsedParticleSystem.lifeTimeGradients; _x < _y.length; _x++) {
  111886. var lifeTimeGradient = _y[_x];
  111887. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  111888. }
  111889. }
  111890. if (parsedParticleSystem.limitVelocityGradients) {
  111891. for (var _z = 0, _0 = parsedParticleSystem.limitVelocityGradients; _z < _0.length; _z++) {
  111892. var limitVelocityGradient = _0[_z];
  111893. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  111894. }
  111895. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  111896. }
  111897. if (parsedParticleSystem.noiseTexture) {
  111898. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  111899. }
  111900. // Emitter
  111901. var emitterType;
  111902. if (parsedParticleSystem.particleEmitterType) {
  111903. switch (parsedParticleSystem.particleEmitterType.type) {
  111904. case "SphereParticleEmitter":
  111905. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereParticleEmitter"]();
  111906. break;
  111907. case "SphereDirectedParticleEmitter":
  111908. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereDirectedParticleEmitter"]();
  111909. break;
  111910. case "ConeEmitter":
  111911. case "ConeParticleEmitter":
  111912. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["ConeParticleEmitter"]();
  111913. break;
  111914. case "CylinderParticleEmitter":
  111915. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["CylinderParticleEmitter"]();
  111916. break;
  111917. case "HemisphericParticleEmitter":
  111918. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["HemisphericParticleEmitter"]();
  111919. break;
  111920. case "BoxEmitter":
  111921. case "BoxParticleEmitter":
  111922. default:
  111923. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  111924. break;
  111925. }
  111926. emitterType.parse(parsedParticleSystem.particleEmitterType);
  111927. }
  111928. else {
  111929. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  111930. emitterType.parse(parsedParticleSystem);
  111931. }
  111932. particleSystem.particleEmitterType = emitterType;
  111933. // Animation sheet
  111934. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  111935. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  111936. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  111937. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  111938. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  111939. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  111940. };
  111941. /**
  111942. * Parses a JSON object to create a particle system.
  111943. * @param parsedParticleSystem The JSON object to parse
  111944. * @param scene The scene to create the particle system in
  111945. * @param rootUrl The root url to use to load external dependencies like texture
  111946. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  111947. * @returns the Parsed particle system
  111948. */
  111949. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  111950. if (doNotStart === void 0) { doNotStart = false; }
  111951. var name = parsedParticleSystem.name;
  111952. var custom = null;
  111953. var program = null;
  111954. if (parsedParticleSystem.customShader) {
  111955. program = parsedParticleSystem.customShader;
  111956. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  111957. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  111958. }
  111959. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  111960. particleSystem.customShader = program;
  111961. if (parsedParticleSystem.id) {
  111962. particleSystem.id = parsedParticleSystem.id;
  111963. }
  111964. // SubEmitters
  111965. if (parsedParticleSystem.subEmitters) {
  111966. particleSystem.subEmitters = [];
  111967. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  111968. var cell = _a[_i];
  111969. var cellArray = [];
  111970. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  111971. var sub = cell_1[_b];
  111972. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"].Parse(sub, scene, rootUrl));
  111973. }
  111974. particleSystem.subEmitters.push(cellArray);
  111975. }
  111976. }
  111977. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  111978. particleSystem.textureMask = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.textureMask);
  111979. // Auto start
  111980. if (parsedParticleSystem.preventAutoStart) {
  111981. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  111982. }
  111983. if (!doNotStart && !particleSystem.preventAutoStart) {
  111984. particleSystem.start();
  111985. }
  111986. return particleSystem;
  111987. };
  111988. /**
  111989. * Billboard mode will only apply to Y axis
  111990. */
  111991. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  111992. /**
  111993. * Billboard mode will apply to all axes
  111994. */
  111995. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  111996. /**
  111997. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  111998. */
  111999. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  112000. return ParticleSystem;
  112001. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__["BaseParticleSystem"]));
  112002. _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  112003. /***/ }),
  112004. /***/ "./Particles/particleSystemComponent.ts":
  112005. /*!**********************************************!*\
  112006. !*** ./Particles/particleSystemComponent.ts ***!
  112007. \**********************************************/
  112008. /*! exports provided: _IDoNeedToBeInTheBuild */
  112009. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112010. "use strict";
  112011. __webpack_require__.r(__webpack_exports__);
  112012. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  112013. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  112014. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  112015. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  112016. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  112017. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  112018. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  112019. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  112020. // Adds the parsers to the scene parsers.
  112021. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  112022. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  112023. if (!individualParser) {
  112024. return;
  112025. }
  112026. // Particles Systems
  112027. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  112028. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  112029. var parsedParticleSystem = parsedData.particleSystems[index];
  112030. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  112031. }
  112032. }
  112033. });
  112034. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  112035. if (parsedParticleSystem.activeParticleCount) {
  112036. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  112037. return ps;
  112038. }
  112039. else {
  112040. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  112041. return ps;
  112042. }
  112043. });
  112044. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  112045. if (uniformsNames === void 0) { uniformsNames = []; }
  112046. if (samplers === void 0) { samplers = []; }
  112047. if (defines === void 0) { defines = ""; }
  112048. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  112049. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  112050. if (defines.indexOf(" BILLBOARD") === -1) {
  112051. defines += "\n#define BILLBOARD\n";
  112052. }
  112053. if (samplers.indexOf("diffuseSampler") === -1) {
  112054. samplers.push("diffuseSampler");
  112055. }
  112056. return this.createEffect({
  112057. vertex: "particles",
  112058. fragmentElement: fragmentName
  112059. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  112060. };
  112061. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  112062. var results = new Array();
  112063. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  112064. var particleSystem = this.getScene().particleSystems[index];
  112065. if (particleSystem.emitter === this) {
  112066. results.push(particleSystem);
  112067. }
  112068. }
  112069. return results;
  112070. };
  112071. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  112072. var results = new Array();
  112073. var descendants = this.getDescendants();
  112074. descendants.push(this);
  112075. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  112076. var particleSystem = this.getScene().particleSystems[index];
  112077. var emitter = particleSystem.emitter;
  112078. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  112079. results.push(particleSystem);
  112080. }
  112081. }
  112082. return results;
  112083. };
  112084. /**
  112085. * @hidden
  112086. */
  112087. var _IDoNeedToBeInTheBuild = 42;
  112088. /***/ }),
  112089. /***/ "./Particles/particleSystemSet.ts":
  112090. /*!****************************************!*\
  112091. !*** ./Particles/particleSystemSet.ts ***!
  112092. \****************************************/
  112093. /*! exports provided: ParticleSystemSet */
  112094. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112095. "use strict";
  112096. __webpack_require__.r(__webpack_exports__);
  112097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  112098. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  112099. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  112100. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  112101. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  112102. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  112103. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  112104. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  112105. /** Internal class used to store shapes for emitters */
  112106. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  112107. function ParticleSystemSetEmitterCreationOptions() {
  112108. }
  112109. return ParticleSystemSetEmitterCreationOptions;
  112110. }());
  112111. /**
  112112. * Represents a set of particle systems working together to create a specific effect
  112113. */
  112114. var ParticleSystemSet = /** @class */ (function () {
  112115. function ParticleSystemSet() {
  112116. /**
  112117. * Gets the particle system list
  112118. */
  112119. this.systems = new Array();
  112120. }
  112121. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  112122. /**
  112123. * Gets the emitter node used with this set
  112124. */
  112125. get: function () {
  112126. return this._emitterNode;
  112127. },
  112128. enumerable: true,
  112129. configurable: true
  112130. });
  112131. /**
  112132. * Creates a new emitter mesh as a sphere
  112133. * @param options defines the options used to create the sphere
  112134. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  112135. * @param scene defines the hosting scene
  112136. */
  112137. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  112138. if (this._emitterNode) {
  112139. this._emitterNode.dispose();
  112140. }
  112141. this._emitterCreationOptions = {
  112142. kind: "Sphere",
  112143. options: options,
  112144. renderingGroupId: renderingGroupId
  112145. };
  112146. var emitterMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  112147. emitterMesh.renderingGroupId = renderingGroupId;
  112148. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  112149. material.emissiveColor = options.color;
  112150. emitterMesh.material = material;
  112151. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  112152. var system = _a[_i];
  112153. system.emitter = emitterMesh;
  112154. }
  112155. this._emitterNode = emitterMesh;
  112156. };
  112157. /**
  112158. * Starts all particle systems of the set
  112159. * @param emitter defines an optional mesh to use as emitter for the particle systems
  112160. */
  112161. ParticleSystemSet.prototype.start = function (emitter) {
  112162. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  112163. var system = _a[_i];
  112164. if (emitter) {
  112165. system.emitter = emitter;
  112166. }
  112167. system.start();
  112168. }
  112169. };
  112170. /**
  112171. * Release all associated resources
  112172. */
  112173. ParticleSystemSet.prototype.dispose = function () {
  112174. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  112175. var system = _a[_i];
  112176. system.dispose();
  112177. }
  112178. this.systems = [];
  112179. if (this._emitterNode) {
  112180. this._emitterNode.dispose();
  112181. this._emitterNode = null;
  112182. }
  112183. };
  112184. /**
  112185. * Serialize the set into a JSON compatible object
  112186. * @returns a JSON compatible representation of the set
  112187. */
  112188. ParticleSystemSet.prototype.serialize = function () {
  112189. var result = {};
  112190. result.systems = [];
  112191. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  112192. var system = _a[_i];
  112193. result.systems.push(system.serialize());
  112194. }
  112195. if (this._emitterNode) {
  112196. result.emitter = this._emitterCreationOptions;
  112197. }
  112198. return result;
  112199. };
  112200. /**
  112201. * Parse a new ParticleSystemSet from a serialized source
  112202. * @param data defines a JSON compatible representation of the set
  112203. * @param scene defines the hosting scene
  112204. * @param gpu defines if we want GPU particles or CPU particles
  112205. * @returns a new ParticleSystemSet
  112206. */
  112207. ParticleSystemSet.Parse = function (data, scene, gpu) {
  112208. if (gpu === void 0) { gpu = false; }
  112209. var result = new ParticleSystemSet();
  112210. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  112211. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  112212. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  112213. var system = _a[_i];
  112214. 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));
  112215. }
  112216. if (data.emitter) {
  112217. var options = data.emitter.options;
  112218. switch (data.emitter.kind) {
  112219. case "Sphere":
  112220. result.setEmitterAsSphere({
  112221. diameter: options.diameter,
  112222. segments: options.segments,
  112223. color: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  112224. }, data.emitter.renderingGroupId, scene);
  112225. break;
  112226. }
  112227. }
  112228. return result;
  112229. };
  112230. return ParticleSystemSet;
  112231. }());
  112232. /***/ }),
  112233. /***/ "./Particles/solidParticle.ts":
  112234. /*!************************************!*\
  112235. !*** ./Particles/solidParticle.ts ***!
  112236. \************************************/
  112237. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  112238. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112239. "use strict";
  112240. __webpack_require__.r(__webpack_exports__);
  112241. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  112242. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  112243. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  112244. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  112245. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  112246. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  112247. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  112248. /**
  112249. * Represents one particle of a solid particle system.
  112250. */
  112251. var SolidParticle = /** @class */ (function () {
  112252. /**
  112253. * Creates a Solid Particle object.
  112254. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  112255. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  112256. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  112257. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  112258. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  112259. * @param shapeId (integer) is the model shape identifier in the SPS.
  112260. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  112261. * @param sps defines the sps it is associated to
  112262. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  112263. */
  112264. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  112265. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  112266. /**
  112267. * particle global index
  112268. */
  112269. this.idx = 0;
  112270. /**
  112271. * The color of the particle
  112272. */
  112273. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  112274. /**
  112275. * The world space position of the particle.
  112276. */
  112277. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112278. /**
  112279. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  112280. */
  112281. this.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112282. /**
  112283. * The scaling of the particle.
  112284. */
  112285. this.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  112286. /**
  112287. * The uvs of the particle.
  112288. */
  112289. this.uvs = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  112290. /**
  112291. * The current speed of the particle.
  112292. */
  112293. this.velocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112294. /**
  112295. * The pivot point in the particle local space.
  112296. */
  112297. this.pivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112298. /**
  112299. * Must the particle be translated from its pivot point in its local space ?
  112300. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  112301. * Default : false
  112302. */
  112303. this.translateFromPivot = false;
  112304. /**
  112305. * Is the particle active or not ?
  112306. */
  112307. this.alive = true;
  112308. /**
  112309. * Is the particle visible or not ?
  112310. */
  112311. this.isVisible = true;
  112312. /**
  112313. * Index of this particle in the global "positions" array (Internal use)
  112314. * @hidden
  112315. */
  112316. this._pos = 0;
  112317. /**
  112318. * @hidden Index of this particle in the global "indices" array (Internal use)
  112319. */
  112320. this._ind = 0;
  112321. /**
  112322. * ModelShape id of this particle
  112323. */
  112324. this.shapeId = 0;
  112325. /**
  112326. * Index of the particle in its shape id (Internal use)
  112327. */
  112328. this.idxInShape = 0;
  112329. /**
  112330. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  112331. */
  112332. this._stillInvisible = false;
  112333. /**
  112334. * @hidden Last computed particle rotation matrix
  112335. */
  112336. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  112337. /**
  112338. * Parent particle Id, if any.
  112339. * Default null.
  112340. */
  112341. this.parentId = null;
  112342. /**
  112343. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  112344. * The possible values are :
  112345. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112346. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112347. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112348. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112349. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112350. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  112351. * */
  112352. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  112353. /**
  112354. * @hidden Internal global position in the SPS.
  112355. */
  112356. this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112357. this.idx = particleIndex;
  112358. this._pos = positionIndex;
  112359. this._ind = indiceIndex;
  112360. this._model = model;
  112361. this.shapeId = shapeId;
  112362. this.idxInShape = idxInShape;
  112363. this._sps = sps;
  112364. if (modelBoundingInfo) {
  112365. this._modelBoundingInfo = modelBoundingInfo;
  112366. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  112367. }
  112368. }
  112369. Object.defineProperty(SolidParticle.prototype, "scale", {
  112370. /**
  112371. * Legacy support, changed scale to scaling
  112372. */
  112373. get: function () {
  112374. return this.scaling;
  112375. },
  112376. /**
  112377. * Legacy support, changed scale to scaling
  112378. */
  112379. set: function (scale) {
  112380. this.scaling = scale;
  112381. },
  112382. enumerable: true,
  112383. configurable: true
  112384. });
  112385. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  112386. /**
  112387. * Legacy support, changed quaternion to rotationQuaternion
  112388. */
  112389. get: function () {
  112390. return this.rotationQuaternion;
  112391. },
  112392. /**
  112393. * Legacy support, changed quaternion to rotationQuaternion
  112394. */
  112395. set: function (q) {
  112396. this.rotationQuaternion = q;
  112397. },
  112398. enumerable: true,
  112399. configurable: true
  112400. });
  112401. /**
  112402. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  112403. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  112404. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  112405. * @returns true if it intersects
  112406. */
  112407. SolidParticle.prototype.intersectsMesh = function (target) {
  112408. if (!this._boundingInfo || !target._boundingInfo) {
  112409. return false;
  112410. }
  112411. if (this._sps._bSphereOnly) {
  112412. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  112413. }
  112414. return this._boundingInfo.intersects(target._boundingInfo, false);
  112415. };
  112416. /**
  112417. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  112418. * A particle is in the frustum if its bounding box intersects the frustum
  112419. * @param frustumPlanes defines the frustum to test
  112420. * @returns true if the particle is in the frustum planes
  112421. */
  112422. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  112423. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  112424. };
  112425. /**
  112426. * get the rotation matrix of the particle
  112427. * @hidden
  112428. */
  112429. SolidParticle.prototype.getRotationMatrix = function (m) {
  112430. var quaternion;
  112431. if (this.rotationQuaternion) {
  112432. quaternion = this.rotationQuaternion;
  112433. }
  112434. else {
  112435. quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  112436. var rotation = this.rotation;
  112437. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  112438. }
  112439. quaternion.toRotationMatrix(m);
  112440. };
  112441. return SolidParticle;
  112442. }());
  112443. /**
  112444. * Represents the shape of the model used by one particle of a solid particle system.
  112445. * SPS internal tool, don't use it manually.
  112446. */
  112447. var ModelShape = /** @class */ (function () {
  112448. /**
  112449. * 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.
  112450. * SPS internal tool, don't use it manually.
  112451. * @hidden
  112452. */
  112453. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  112454. /**
  112455. * length of the shape in the model indices array (internal use)
  112456. * @hidden
  112457. */
  112458. this._indicesLength = 0;
  112459. this.shapeID = id;
  112460. this._shape = shape;
  112461. this._indicesLength = indicesLength;
  112462. this._shapeUV = shapeUV;
  112463. this._positionFunction = posFunction;
  112464. this._vertexFunction = vtxFunction;
  112465. }
  112466. return ModelShape;
  112467. }());
  112468. /**
  112469. * Represents a Depth Sorted Particle in the solid particle system.
  112470. */
  112471. var DepthSortedParticle = /** @class */ (function () {
  112472. function DepthSortedParticle() {
  112473. /**
  112474. * Index of the particle in the "indices" array
  112475. */
  112476. this.ind = 0;
  112477. /**
  112478. * Length of the particle shape in the "indices" array
  112479. */
  112480. this.indicesLength = 0;
  112481. /**
  112482. * Squared distance from the particle to the camera
  112483. */
  112484. this.sqDistance = 0.0;
  112485. }
  112486. return DepthSortedParticle;
  112487. }());
  112488. /***/ }),
  112489. /***/ "./Particles/solidParticleSystem.ts":
  112490. /*!******************************************!*\
  112491. !*** ./Particles/solidParticleSystem.ts ***!
  112492. \******************************************/
  112493. /*! exports provided: SolidParticleSystem */
  112494. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112495. "use strict";
  112496. __webpack_require__.r(__webpack_exports__);
  112497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  112498. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  112499. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  112500. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  112501. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  112502. /* harmony import */ var _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  112503. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  112504. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  112505. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  112506. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  112507. /**
  112508. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  112509. *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.
  112510. * The SPS is also a particle system. It provides some methods to manage the particles.
  112511. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  112512. *
  112513. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  112514. */
  112515. var SolidParticleSystem = /** @class */ (function () {
  112516. /**
  112517. * Creates a SPS (Solid Particle System) object.
  112518. * @param name (String) is the SPS name, this will be the underlying mesh name.
  112519. * @param scene (Scene) is the scene in which the SPS is added.
  112520. * @param options defines the options of the sps e.g.
  112521. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  112522. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  112523. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  112524. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  112525. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  112526. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  112527. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  112528. */
  112529. function SolidParticleSystem(name, scene, options) {
  112530. /**
  112531. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  112532. * Example : var p = SPS.particles[i];
  112533. */
  112534. this.particles = new Array();
  112535. /**
  112536. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  112537. */
  112538. this.nbParticles = 0;
  112539. /**
  112540. * If the particles must ever face the camera (default false). Useful for planar particles.
  112541. */
  112542. this.billboard = false;
  112543. /**
  112544. * Recompute normals when adding a shape
  112545. */
  112546. this.recomputeNormals = true;
  112547. /**
  112548. * This a counter ofr your own usage. It's not set by any SPS functions.
  112549. */
  112550. this.counter = 0;
  112551. /**
  112552. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  112553. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  112554. */
  112555. this.vars = {};
  112556. /**
  112557. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  112558. * @hidden
  112559. */
  112560. this._bSphereOnly = false;
  112561. /**
  112562. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  112563. * @hidden
  112564. */
  112565. this._bSphereRadiusFactor = 1.0;
  112566. this._positions = new Array();
  112567. this._indices = new Array();
  112568. this._normals = new Array();
  112569. this._colors = new Array();
  112570. this._uvs = new Array();
  112571. this._index = 0; // indices index
  112572. this._updatable = true;
  112573. this._pickable = false;
  112574. this._isVisibilityBoxLocked = false;
  112575. this._alwaysVisible = false;
  112576. this._depthSort = false;
  112577. this._shapeCounter = 0;
  112578. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  112579. this._color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  112580. this._computeParticleColor = true;
  112581. this._computeParticleTexture = true;
  112582. this._computeParticleRotation = true;
  112583. this._computeParticleVertex = false;
  112584. this._computeBoundingBox = false;
  112585. this._depthSortParticles = true;
  112586. this._mustUnrotateFixedNormals = false;
  112587. this._particlesIntersect = false;
  112588. this._needs32Bits = false;
  112589. this.name = name;
  112590. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  112591. this._camera = scene.activeCamera;
  112592. this._pickable = options ? options.isPickable : false;
  112593. this._depthSort = options ? options.enableDepthSort : false;
  112594. this._particlesIntersect = options ? options.particleIntersection : false;
  112595. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  112596. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  112597. if (options && options.updatable !== undefined) {
  112598. this._updatable = options.updatable;
  112599. }
  112600. else {
  112601. this._updatable = true;
  112602. }
  112603. if (this._pickable) {
  112604. this.pickedParticles = [];
  112605. }
  112606. if (this._depthSort) {
  112607. this.depthSortedParticles = [];
  112608. }
  112609. }
  112610. /**
  112611. * Builds the SPS underlying mesh. Returns a standard Mesh.
  112612. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  112613. * @returns the created mesh
  112614. */
  112615. SolidParticleSystem.prototype.buildMesh = function () {
  112616. if (this.nbParticles === 0) {
  112617. var triangle = _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__["DiscBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  112618. this.addShape(triangle, 1);
  112619. triangle.dispose();
  112620. }
  112621. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  112622. this._positions32 = new Float32Array(this._positions);
  112623. this._uvs32 = new Float32Array(this._uvs);
  112624. this._colors32 = new Float32Array(this._colors);
  112625. if (this.recomputeNormals) {
  112626. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  112627. }
  112628. this._normals32 = new Float32Array(this._normals);
  112629. this._fixedNormal32 = new Float32Array(this._normals);
  112630. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  112631. this._unrotateFixedNormals();
  112632. }
  112633. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  112634. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  112635. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  112636. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  112637. if (this._uvs32.length > 0) {
  112638. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  112639. }
  112640. if (this._colors32.length > 0) {
  112641. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  112642. }
  112643. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this.name, this._scene);
  112644. vertexData.applyToMesh(mesh, this._updatable);
  112645. this.mesh = mesh;
  112646. this.mesh.isPickable = this._pickable;
  112647. // free memory
  112648. if (!this._depthSort) {
  112649. this._indices = null;
  112650. }
  112651. this._positions = null;
  112652. this._normals = null;
  112653. this._uvs = null;
  112654. this._colors = null;
  112655. if (!this._updatable) {
  112656. this.particles.length = 0;
  112657. }
  112658. return mesh;
  112659. };
  112660. /**
  112661. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  112662. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  112663. * Thus the particles generated from `digest()` have their property `position` set yet.
  112664. * @param mesh ( Mesh ) is the mesh to be digested
  112665. * @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
  112666. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  112667. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  112668. * @returns the current SPS
  112669. */
  112670. SolidParticleSystem.prototype.digest = function (mesh, options) {
  112671. var size = (options && options.facetNb) || 1;
  112672. var number = (options && options.number) || 0;
  112673. var delta = (options && options.delta) || 0;
  112674. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  112675. var meshInd = mesh.getIndices();
  112676. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  112677. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  112678. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  112679. var f = 0; // facet counter
  112680. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  112681. // compute size from number
  112682. if (number) {
  112683. number = (number > totalFacets) ? totalFacets : number;
  112684. size = Math.round(totalFacets / number);
  112685. delta = 0;
  112686. }
  112687. else {
  112688. size = (size > totalFacets) ? totalFacets : size;
  112689. }
  112690. var facetPos = []; // submesh positions
  112691. var facetInd = []; // submesh indices
  112692. var facetUV = []; // submesh UV
  112693. var facetCol = []; // submesh colors
  112694. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  112695. var sizeO = size;
  112696. while (f < totalFacets) {
  112697. size = sizeO + Math.floor((1 + delta) * Math.random());
  112698. if (f > totalFacets - size) {
  112699. size = totalFacets - f;
  112700. }
  112701. // reset temp arrays
  112702. facetPos.length = 0;
  112703. facetInd.length = 0;
  112704. facetUV.length = 0;
  112705. facetCol.length = 0;
  112706. // iterate over "size" facets
  112707. var fi = 0;
  112708. for (var j = f * 3; j < (f + size) * 3; j++) {
  112709. facetInd.push(fi);
  112710. var i = meshInd[j];
  112711. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  112712. if (meshUV) {
  112713. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  112714. }
  112715. if (meshCol) {
  112716. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  112717. }
  112718. fi++;
  112719. }
  112720. // create a model shape for each single particle
  112721. var idx = this.nbParticles;
  112722. var shape = this._posToShape(facetPos);
  112723. var shapeUV = this._uvsToShapeUV(facetUV);
  112724. // compute the barycenter of the shape
  112725. var v;
  112726. for (v = 0; v < shape.length; v++) {
  112727. barycenter.addInPlace(shape[v]);
  112728. }
  112729. barycenter.scaleInPlace(1 / shape.length);
  112730. // shift the shape from its barycenter to the origin
  112731. for (v = 0; v < shape.length; v++) {
  112732. shape[v].subtractInPlace(barycenter);
  112733. }
  112734. var bInfo;
  112735. if (this._particlesIntersect) {
  112736. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](barycenter, barycenter);
  112737. }
  112738. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  112739. // add the particle in the SPS
  112740. var currentPos = this._positions.length;
  112741. var currentInd = this._indices.length;
  112742. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  112743. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  112744. // initialize the particle position
  112745. this.particles[this.nbParticles].position.addInPlace(barycenter);
  112746. this._index += shape.length;
  112747. idx++;
  112748. this.nbParticles++;
  112749. this._shapeCounter++;
  112750. f += size;
  112751. }
  112752. return this;
  112753. };
  112754. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  112755. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  112756. var index = 0;
  112757. var idx = 0;
  112758. var tmpNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  112759. var quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  112760. var invertedRotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  112761. for (var p = 0; p < this.particles.length; p++) {
  112762. var particle = this.particles[p];
  112763. var shape = particle._model._shape;
  112764. // computing the inverse of the rotation matrix from the quaternion
  112765. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  112766. if (particle.rotationQuaternion) {
  112767. particle.rotationQuaternion.conjugateToRef(quaternion);
  112768. }
  112769. else {
  112770. var rotation = particle.rotation;
  112771. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  112772. quaternion.conjugateInPlace();
  112773. }
  112774. quaternion.toRotationMatrix(invertedRotMatrix);
  112775. for (var pt = 0; pt < shape.length; pt++) {
  112776. idx = index + pt * 3;
  112777. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  112778. tmpNormal.toArray(this._fixedNormal32, idx);
  112779. }
  112780. index = idx + 3;
  112781. }
  112782. };
  112783. //reset copy
  112784. SolidParticleSystem.prototype._resetCopy = function () {
  112785. var copy = this._copy;
  112786. copy.position.setAll(0);
  112787. copy.rotation.setAll(0);
  112788. copy.rotationQuaternion = null;
  112789. copy.scaling.setAll(1);
  112790. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  112791. copy.color = null;
  112792. copy.translateFromPivot = false;
  112793. };
  112794. // _meshBuilder : inserts the shape model in the global SPS mesh
  112795. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  112796. var i;
  112797. var u = 0;
  112798. var c = 0;
  112799. var n = 0;
  112800. this._resetCopy();
  112801. var copy = this._copy;
  112802. if (options && options.positionFunction) { // call to custom positionFunction
  112803. options.positionFunction(copy, idx, idxInShape);
  112804. this._mustUnrotateFixedNormals = true;
  112805. }
  112806. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  112807. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  112808. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  112809. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  112810. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  112811. copy.getRotationMatrix(rotMatrix);
  112812. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  112813. if (copy.translateFromPivot) {
  112814. pivotBackTranslation.setAll(0.0);
  112815. }
  112816. else {
  112817. pivotBackTranslation.copyFrom(scaledPivot);
  112818. }
  112819. for (i = 0; i < shape.length; i++) {
  112820. tmpVertex.copyFrom(shape[i]);
  112821. if (options && options.vertexFunction) {
  112822. options.vertexFunction(copy, tmpVertex, i);
  112823. }
  112824. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  112825. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  112826. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  112827. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  112828. if (meshUV) {
  112829. var copyUvs = copy.uvs;
  112830. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  112831. u += 2;
  112832. }
  112833. if (copy.color) {
  112834. this._color = copy.color;
  112835. }
  112836. else {
  112837. var color = this._color;
  112838. if (meshCol && meshCol[c] !== undefined) {
  112839. color.r = meshCol[c];
  112840. color.g = meshCol[c + 1];
  112841. color.b = meshCol[c + 2];
  112842. color.a = meshCol[c + 3];
  112843. }
  112844. else {
  112845. color.r = 1.0;
  112846. color.g = 1.0;
  112847. color.b = 1.0;
  112848. color.a = 1.0;
  112849. }
  112850. }
  112851. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  112852. c += 4;
  112853. if (!this.recomputeNormals && meshNor) {
  112854. tmpVertex.x = meshNor[n];
  112855. tmpVertex.y = meshNor[n + 1];
  112856. tmpVertex.z = meshNor[n + 2];
  112857. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  112858. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  112859. n += 3;
  112860. }
  112861. }
  112862. for (i = 0; i < meshInd.length; i++) {
  112863. var current_ind = p + meshInd[i];
  112864. indices.push(current_ind);
  112865. if (current_ind > 65535) {
  112866. this._needs32Bits = true;
  112867. }
  112868. }
  112869. if (this._pickable) {
  112870. var nbfaces = meshInd.length / 3;
  112871. for (i = 0; i < nbfaces; i++) {
  112872. this.pickedParticles.push({ idx: idx, faceId: i });
  112873. }
  112874. }
  112875. if (this._depthSort) {
  112876. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["DepthSortedParticle"]());
  112877. }
  112878. return copy;
  112879. };
  112880. // returns a shape array from positions array
  112881. SolidParticleSystem.prototype._posToShape = function (positions) {
  112882. var shape = [];
  112883. for (var i = 0; i < positions.length; i += 3) {
  112884. shape.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  112885. }
  112886. return shape;
  112887. };
  112888. // returns a shapeUV array from a Vector4 uvs
  112889. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  112890. var shapeUV = [];
  112891. if (uvs) {
  112892. for (var i = 0; i < uvs.length; i++) {
  112893. shapeUV.push(uvs[i]);
  112894. }
  112895. }
  112896. return shapeUV;
  112897. };
  112898. // adds a new particle object in the particles array
  112899. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  112900. if (bInfo === void 0) { bInfo = null; }
  112901. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  112902. this.particles.push(sp);
  112903. return sp;
  112904. };
  112905. /**
  112906. * Adds some particles to the SPS from the model shape. Returns the shape id.
  112907. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  112908. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  112909. * @param nb (positive integer) the number of particles to be created from this model
  112910. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  112911. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  112912. * @returns the number of shapes in the system
  112913. */
  112914. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  112915. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  112916. var meshInd = mesh.getIndices();
  112917. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  112918. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  112919. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  112920. var bbInfo;
  112921. if (this._particlesIntersect) {
  112922. bbInfo = mesh.getBoundingInfo();
  112923. }
  112924. var shape = this._posToShape(meshPos);
  112925. var shapeUV = this._uvsToShapeUV(meshUV);
  112926. var posfunc = options ? options.positionFunction : null;
  112927. var vtxfunc = options ? options.vertexFunction : null;
  112928. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  112929. // particles
  112930. var sp;
  112931. var currentCopy;
  112932. var idx = this.nbParticles;
  112933. for (var i = 0; i < nb; i++) {
  112934. var currentPos = this._positions.length;
  112935. var currentInd = this._indices.length;
  112936. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  112937. if (this._updatable) {
  112938. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  112939. sp.position.copyFrom(currentCopy.position);
  112940. sp.rotation.copyFrom(currentCopy.rotation);
  112941. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  112942. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  112943. }
  112944. if (currentCopy.color && sp.color) {
  112945. sp.color.copyFrom(currentCopy.color);
  112946. }
  112947. sp.scaling.copyFrom(currentCopy.scaling);
  112948. sp.uvs.copyFrom(currentCopy.uvs);
  112949. }
  112950. this._index += shape.length;
  112951. idx++;
  112952. }
  112953. this.nbParticles += nb;
  112954. this._shapeCounter++;
  112955. return this._shapeCounter - 1;
  112956. };
  112957. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  112958. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  112959. this._resetCopy();
  112960. var copy = this._copy;
  112961. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  112962. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  112963. }
  112964. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  112965. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  112966. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  112967. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  112968. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  112969. copy.getRotationMatrix(rotMatrix);
  112970. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  112971. if (copy.translateFromPivot) {
  112972. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  112973. }
  112974. else {
  112975. pivotBackTranslation.copyFrom(scaledPivot);
  112976. }
  112977. var shape = particle._model._shape;
  112978. for (var pt = 0; pt < shape.length; pt++) {
  112979. tmpVertex.copyFrom(shape[pt]);
  112980. if (particle._model._vertexFunction) {
  112981. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  112982. }
  112983. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  112984. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  112985. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  112986. }
  112987. particle.position.setAll(0.0);
  112988. particle.rotation.setAll(0.0);
  112989. particle.rotationQuaternion = null;
  112990. particle.scaling.setAll(1.0);
  112991. particle.uvs.setAll(0.0);
  112992. particle.pivot.setAll(0.0);
  112993. particle.translateFromPivot = false;
  112994. particle.parentId = null;
  112995. };
  112996. /**
  112997. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  112998. * @returns the SPS.
  112999. */
  113000. SolidParticleSystem.prototype.rebuildMesh = function () {
  113001. for (var p = 0; p < this.particles.length; p++) {
  113002. this._rebuildParticle(this.particles[p]);
  113003. }
  113004. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this._positions32, false, false);
  113005. return this;
  113006. };
  113007. /**
  113008. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  113009. * This method calls `updateParticle()` for each particle of the SPS.
  113010. * For an animated SPS, it is usually called within the render loop.
  113011. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  113012. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  113013. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  113014. * @returns the SPS.
  113015. */
  113016. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  113017. if (start === void 0) { start = 0; }
  113018. if (end === void 0) { end = this.nbParticles - 1; }
  113019. if (update === void 0) { update = true; }
  113020. if (!this._updatable) {
  113021. return this;
  113022. }
  113023. // custom beforeUpdate
  113024. this.beforeUpdateParticles(start, end, update);
  113025. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  113026. var invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  113027. var mesh = this.mesh;
  113028. var colors32 = this._colors32;
  113029. var positions32 = this._positions32;
  113030. var normals32 = this._normals32;
  113031. var uvs32 = this._uvs32;
  113032. var indices32 = this._indices32;
  113033. var indices = this._indices;
  113034. var fixedNormal32 = this._fixedNormal32;
  113035. var tempVectors = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3;
  113036. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  113037. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  113038. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  113039. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  113040. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  113041. var camInvertedPosition = tempVectors[10].setAll(0);
  113042. // cases when the World Matrix is to be computed first
  113043. if (this.billboard || this._depthSort) {
  113044. this.mesh.computeWorldMatrix(true);
  113045. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  113046. }
  113047. // if the particles will always face the camera
  113048. if (this.billboard) {
  113049. // compute the camera position and un-rotate it by the current mesh rotation
  113050. var tmpVertex = tempVectors[0];
  113051. this._camera.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Z, tmpVertex);
  113052. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  113053. camAxisZ.normalize();
  113054. // same for camera up vector extracted from the cam view matrix
  113055. var view = this._camera.getViewMatrix(true);
  113056. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  113057. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  113058. camAxisY.normalize();
  113059. camAxisX.normalize();
  113060. }
  113061. // if depthSort, compute the camera global position in the mesh local system
  113062. if (this._depthSort) {
  113063. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  113064. }
  113065. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  113066. var idx = 0; // current position index in the global array positions32
  113067. var index = 0; // position start index in the global array positions32 of the current particle
  113068. var colidx = 0; // current color index in the global array colors32
  113069. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  113070. var uvidx = 0; // current uv index in the global array uvs32
  113071. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  113072. var pt = 0; // current index in the particle model shape
  113073. if (this.mesh.isFacetDataEnabled) {
  113074. this._computeBoundingBox = true;
  113075. }
  113076. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  113077. if (this._computeBoundingBox) {
  113078. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  113079. var boundingInfo = this.mesh._boundingInfo;
  113080. if (boundingInfo) {
  113081. minimum.copyFrom(boundingInfo.minimum);
  113082. maximum.copyFrom(boundingInfo.maximum);
  113083. }
  113084. }
  113085. }
  113086. // particle loop
  113087. index = this.particles[start]._pos;
  113088. var vpos = (index / 3) | 0;
  113089. colorIndex = vpos * 4;
  113090. uvIndex = vpos * 2;
  113091. for (var p = start; p <= end; p++) {
  113092. var particle = this.particles[p];
  113093. // call to custom user function to update the particle properties
  113094. this.updateParticle(particle);
  113095. var shape = particle._model._shape;
  113096. var shapeUV = particle._model._shapeUV;
  113097. var particleRotationMatrix = particle._rotationMatrix;
  113098. var particlePosition = particle.position;
  113099. var particleRotation = particle.rotation;
  113100. var particleScaling = particle.scaling;
  113101. var particleGlobalPosition = particle._globalPosition;
  113102. // camera-particle distance for depth sorting
  113103. if (this._depthSort && this._depthSortParticles) {
  113104. var dsp = this.depthSortedParticles[p];
  113105. dsp.ind = particle._ind;
  113106. dsp.indicesLength = particle._model._indicesLength;
  113107. dsp.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  113108. }
  113109. // skip the computations for inactive or already invisible particles
  113110. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  113111. // increment indexes for the next particle
  113112. pt = shape.length;
  113113. index += pt * 3;
  113114. colorIndex += pt * 4;
  113115. uvIndex += pt * 2;
  113116. continue;
  113117. }
  113118. if (particle.isVisible) {
  113119. particle._stillInvisible = false; // un-mark permanent invisibility
  113120. var scaledPivot = tempVectors[12];
  113121. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  113122. // particle rotation matrix
  113123. if (this.billboard) {
  113124. particleRotation.x = 0.0;
  113125. particleRotation.y = 0.0;
  113126. }
  113127. if (this._computeParticleRotation || this.billboard) {
  113128. particle.getRotationMatrix(rotMatrix);
  113129. }
  113130. var particleHasParent = (particle.parentId !== null);
  113131. if (particleHasParent) {
  113132. var parent_1 = this.particles[particle.parentId];
  113133. var parentRotationMatrix = parent_1._rotationMatrix;
  113134. var parentGlobalPosition = parent_1._globalPosition;
  113135. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  113136. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  113137. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  113138. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  113139. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  113140. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  113141. if (this._computeParticleRotation || this.billboard) {
  113142. var rotMatrixValues = rotMatrix.m;
  113143. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  113144. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  113145. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  113146. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  113147. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  113148. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  113149. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  113150. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  113151. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  113152. }
  113153. }
  113154. else {
  113155. particleGlobalPosition.x = particlePosition.x;
  113156. particleGlobalPosition.y = particlePosition.y;
  113157. particleGlobalPosition.z = particlePosition.z;
  113158. if (this._computeParticleRotation || this.billboard) {
  113159. var rotMatrixValues = rotMatrix.m;
  113160. particleRotationMatrix[0] = rotMatrixValues[0];
  113161. particleRotationMatrix[1] = rotMatrixValues[1];
  113162. particleRotationMatrix[2] = rotMatrixValues[2];
  113163. particleRotationMatrix[3] = rotMatrixValues[4];
  113164. particleRotationMatrix[4] = rotMatrixValues[5];
  113165. particleRotationMatrix[5] = rotMatrixValues[6];
  113166. particleRotationMatrix[6] = rotMatrixValues[8];
  113167. particleRotationMatrix[7] = rotMatrixValues[9];
  113168. particleRotationMatrix[8] = rotMatrixValues[10];
  113169. }
  113170. }
  113171. var pivotBackTranslation = tempVectors[11];
  113172. if (particle.translateFromPivot) {
  113173. pivotBackTranslation.setAll(0.0);
  113174. }
  113175. else {
  113176. pivotBackTranslation.copyFrom(scaledPivot);
  113177. }
  113178. // particle vertex loop
  113179. for (pt = 0; pt < shape.length; pt++) {
  113180. idx = index + pt * 3;
  113181. colidx = colorIndex + pt * 4;
  113182. uvidx = uvIndex + pt * 2;
  113183. var tmpVertex = tempVectors[0];
  113184. tmpVertex.copyFrom(shape[pt]);
  113185. if (this._computeParticleVertex) {
  113186. this.updateParticleVertex(particle, tmpVertex, pt);
  113187. }
  113188. // positions
  113189. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  113190. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  113191. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  113192. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  113193. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  113194. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  113195. rotatedX += pivotBackTranslation.x;
  113196. rotatedY += pivotBackTranslation.y;
  113197. rotatedZ += pivotBackTranslation.z;
  113198. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  113199. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  113200. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  113201. if (this._computeBoundingBox) {
  113202. minimum.minimizeInPlaceFromFloats(px, py, pz);
  113203. maximum.maximizeInPlaceFromFloats(px, py, pz);
  113204. }
  113205. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  113206. if (!this._computeParticleVertex) {
  113207. var normalx = fixedNormal32[idx];
  113208. var normaly = fixedNormal32[idx + 1];
  113209. var normalz = fixedNormal32[idx + 2];
  113210. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  113211. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  113212. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  113213. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  113214. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  113215. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  113216. }
  113217. if (this._computeParticleColor && particle.color) {
  113218. var color = particle.color;
  113219. var colors32_1 = this._colors32;
  113220. colors32_1[colidx] = color.r;
  113221. colors32_1[colidx + 1] = color.g;
  113222. colors32_1[colidx + 2] = color.b;
  113223. colors32_1[colidx + 3] = color.a;
  113224. }
  113225. if (this._computeParticleTexture) {
  113226. var uvs = particle.uvs;
  113227. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  113228. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  113229. }
  113230. }
  113231. }
  113232. // particle just set invisible : scaled to zero and positioned at the origin
  113233. else {
  113234. particle._stillInvisible = true; // mark the particle as invisible
  113235. for (pt = 0; pt < shape.length; pt++) {
  113236. idx = index + pt * 3;
  113237. colidx = colorIndex + pt * 4;
  113238. uvidx = uvIndex + pt * 2;
  113239. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  113240. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  113241. if (this._computeParticleColor && particle.color) {
  113242. var color = particle.color;
  113243. colors32[colidx] = color.r;
  113244. colors32[colidx + 1] = color.g;
  113245. colors32[colidx + 2] = color.b;
  113246. colors32[colidx + 3] = color.a;
  113247. }
  113248. if (this._computeParticleTexture) {
  113249. var uvs = particle.uvs;
  113250. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  113251. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  113252. }
  113253. }
  113254. }
  113255. // if the particle intersections must be computed : update the bbInfo
  113256. if (this._particlesIntersect) {
  113257. var bInfo = particle._boundingInfo;
  113258. var bBox = bInfo.boundingBox;
  113259. var bSphere = bInfo.boundingSphere;
  113260. var modelBoundingInfo = particle._modelBoundingInfo;
  113261. if (!this._bSphereOnly) {
  113262. // place, scale and rotate the particle bbox within the SPS local system, then update it
  113263. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  113264. var tempMin = tempVectors[1];
  113265. var tempMax = tempVectors[2];
  113266. tempMin.setAll(Number.MAX_VALUE);
  113267. tempMax.setAll(-Number.MAX_VALUE);
  113268. for (var b = 0; b < 8; b++) {
  113269. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  113270. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  113271. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  113272. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  113273. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  113274. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  113275. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  113276. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  113277. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  113278. tempMin.minimizeInPlaceFromFloats(x, y, z);
  113279. tempMax.maximizeInPlaceFromFloats(x, y, z);
  113280. }
  113281. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  113282. }
  113283. // place and scale the particle bouding sphere in the SPS local system, then update it
  113284. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  113285. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  113286. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  113287. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  113288. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  113289. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  113290. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  113291. }
  113292. // increment indexes for the next particle
  113293. index = idx + 3;
  113294. colorIndex = colidx + 4;
  113295. uvIndex = uvidx + 2;
  113296. }
  113297. // if the VBO must be updated
  113298. if (update) {
  113299. if (this._computeParticleColor) {
  113300. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, colors32, false, false);
  113301. }
  113302. if (this._computeParticleTexture) {
  113303. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs32, false, false);
  113304. }
  113305. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, positions32, false, false);
  113306. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  113307. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  113308. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  113309. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  113310. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  113311. for (var i = 0; i < normals32.length; i++) {
  113312. fixedNormal32[i] = normals32[i];
  113313. }
  113314. }
  113315. if (!mesh.areNormalsFrozen) {
  113316. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals32, false, false);
  113317. }
  113318. }
  113319. if (this._depthSort && this._depthSortParticles) {
  113320. var depthSortedParticles = this.depthSortedParticles;
  113321. depthSortedParticles.sort(depthSortFunction);
  113322. var dspl = depthSortedParticles.length;
  113323. var sid = 0;
  113324. for (var sorted = 0; sorted < dspl; sorted++) {
  113325. var lind = depthSortedParticles[sorted].indicesLength;
  113326. var sind = depthSortedParticles[sorted].ind;
  113327. for (var i = 0; i < lind; i++) {
  113328. indices32[sid] = indices[sind + i];
  113329. sid++;
  113330. }
  113331. }
  113332. mesh.updateIndices(indices32);
  113333. }
  113334. }
  113335. if (this._computeBoundingBox) {
  113336. if (mesh._boundingInfo) {
  113337. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  113338. }
  113339. else {
  113340. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  113341. }
  113342. }
  113343. this.afterUpdateParticles(start, end, update);
  113344. return this;
  113345. };
  113346. /**
  113347. * Disposes the SPS.
  113348. */
  113349. SolidParticleSystem.prototype.dispose = function () {
  113350. this.mesh.dispose();
  113351. this.vars = null;
  113352. // drop references to internal big arrays for the GC
  113353. this._positions = null;
  113354. this._indices = null;
  113355. this._normals = null;
  113356. this._uvs = null;
  113357. this._colors = null;
  113358. this._indices32 = null;
  113359. this._positions32 = null;
  113360. this._normals32 = null;
  113361. this._fixedNormal32 = null;
  113362. this._uvs32 = null;
  113363. this._colors32 = null;
  113364. this.pickedParticles = null;
  113365. };
  113366. /**
  113367. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  113368. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  113369. * @returns the SPS.
  113370. */
  113371. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  113372. if (!this._isVisibilityBoxLocked) {
  113373. this.mesh.refreshBoundingInfo();
  113374. }
  113375. return this;
  113376. };
  113377. /**
  113378. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  113379. * @param size the size (float) of the visibility box
  113380. * note : this doesn't lock the SPS mesh bounding box.
  113381. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  113382. */
  113383. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  113384. var vis = size / 2;
  113385. 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));
  113386. };
  113387. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  113388. /**
  113389. * Gets whether the SPS as always visible or not
  113390. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  113391. */
  113392. get: function () {
  113393. return this._alwaysVisible;
  113394. },
  113395. /**
  113396. * Sets the SPS as always visible or not
  113397. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  113398. */
  113399. set: function (val) {
  113400. this._alwaysVisible = val;
  113401. this.mesh.alwaysSelectAsActiveMesh = val;
  113402. },
  113403. enumerable: true,
  113404. configurable: true
  113405. });
  113406. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  113407. /**
  113408. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  113409. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  113410. */
  113411. get: function () {
  113412. return this._isVisibilityBoxLocked;
  113413. },
  113414. /**
  113415. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  113416. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  113417. */
  113418. set: function (val) {
  113419. this._isVisibilityBoxLocked = val;
  113420. var boundingInfo = this.mesh.getBoundingInfo();
  113421. boundingInfo.isLocked = val;
  113422. },
  113423. enumerable: true,
  113424. configurable: true
  113425. });
  113426. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  113427. /**
  113428. * Gets if `setParticles()` computes the particle rotations or not.
  113429. * Default value : true. The SPS is faster when it's set to false.
  113430. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  113431. */
  113432. get: function () {
  113433. return this._computeParticleRotation;
  113434. },
  113435. /**
  113436. * Tells to `setParticles()` to compute the particle rotations or not.
  113437. * Default value : true. The SPS is faster when it's set to false.
  113438. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  113439. */
  113440. set: function (val) {
  113441. this._computeParticleRotation = val;
  113442. },
  113443. enumerable: true,
  113444. configurable: true
  113445. });
  113446. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  113447. /**
  113448. * Gets if `setParticles()` computes the particle colors or not.
  113449. * Default value : true. The SPS is faster when it's set to false.
  113450. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  113451. */
  113452. get: function () {
  113453. return this._computeParticleColor;
  113454. },
  113455. /**
  113456. * Tells to `setParticles()` to compute the particle colors or not.
  113457. * Default value : true. The SPS is faster when it's set to false.
  113458. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  113459. */
  113460. set: function (val) {
  113461. this._computeParticleColor = val;
  113462. },
  113463. enumerable: true,
  113464. configurable: true
  113465. });
  113466. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  113467. /**
  113468. * Gets if `setParticles()` computes the particle textures or not.
  113469. * Default value : true. The SPS is faster when it's set to false.
  113470. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  113471. */
  113472. get: function () {
  113473. return this._computeParticleTexture;
  113474. },
  113475. set: function (val) {
  113476. this._computeParticleTexture = val;
  113477. },
  113478. enumerable: true,
  113479. configurable: true
  113480. });
  113481. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  113482. /**
  113483. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  113484. * Default value : false. The SPS is faster when it's set to false.
  113485. * Note : the particle custom vertex positions aren't stored values.
  113486. */
  113487. get: function () {
  113488. return this._computeParticleVertex;
  113489. },
  113490. /**
  113491. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  113492. * Default value : false. The SPS is faster when it's set to false.
  113493. * Note : the particle custom vertex positions aren't stored values.
  113494. */
  113495. set: function (val) {
  113496. this._computeParticleVertex = val;
  113497. },
  113498. enumerable: true,
  113499. configurable: true
  113500. });
  113501. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  113502. /**
  113503. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  113504. */
  113505. get: function () {
  113506. return this._computeBoundingBox;
  113507. },
  113508. /**
  113509. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  113510. */
  113511. set: function (val) {
  113512. this._computeBoundingBox = val;
  113513. },
  113514. enumerable: true,
  113515. configurable: true
  113516. });
  113517. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  113518. /**
  113519. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  113520. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  113521. * Default : `true`
  113522. */
  113523. get: function () {
  113524. return this._depthSortParticles;
  113525. },
  113526. /**
  113527. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  113528. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  113529. * Default : `true`
  113530. */
  113531. set: function (val) {
  113532. this._depthSortParticles = val;
  113533. },
  113534. enumerable: true,
  113535. configurable: true
  113536. });
  113537. // =======================================================================
  113538. // Particle behavior logic
  113539. // these following methods may be overwritten by the user to fit his needs
  113540. /**
  113541. * This function does nothing. It may be overwritten to set all the particle first values.
  113542. * The SPS doesn't call this function, you may have to call it by your own.
  113543. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  113544. */
  113545. SolidParticleSystem.prototype.initParticles = function () {
  113546. };
  113547. /**
  113548. * This function does nothing. It may be overwritten to recycle a particle.
  113549. * The SPS doesn't call this function, you may have to call it by your own.
  113550. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  113551. * @param particle The particle to recycle
  113552. * @returns the recycled particle
  113553. */
  113554. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  113555. return particle;
  113556. };
  113557. /**
  113558. * Updates a particle : this function should be overwritten by the user.
  113559. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  113560. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  113561. * @example : just set a particle position or velocity and recycle conditions
  113562. * @param particle The particle to update
  113563. * @returns the updated particle
  113564. */
  113565. SolidParticleSystem.prototype.updateParticle = function (particle) {
  113566. return particle;
  113567. };
  113568. /**
  113569. * Updates a vertex of a particle : it can be overwritten by the user.
  113570. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  113571. * @param particle the current particle
  113572. * @param vertex the current index of the current particle
  113573. * @param pt the index of the current vertex in the particle shape
  113574. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  113575. * @example : just set a vertex particle position
  113576. * @returns the updated vertex
  113577. */
  113578. SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
  113579. return vertex;
  113580. };
  113581. /**
  113582. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  113583. * This does nothing and may be overwritten by the user.
  113584. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  113585. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  113586. * @param update the boolean update value actually passed to setParticles()
  113587. */
  113588. SolidParticleSystem.prototype.beforeUpdateParticles = function (start, stop, update) {
  113589. };
  113590. /**
  113591. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  113592. * This will be passed three parameters.
  113593. * This does nothing and may be overwritten by the user.
  113594. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  113595. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  113596. * @param update the boolean update value actually passed to setParticles()
  113597. */
  113598. SolidParticleSystem.prototype.afterUpdateParticles = function (start, stop, update) {
  113599. };
  113600. return SolidParticleSystem;
  113601. }());
  113602. /***/ }),
  113603. /***/ "./Particles/subEmitter.ts":
  113604. /*!*********************************!*\
  113605. !*** ./Particles/subEmitter.ts ***!
  113606. \*********************************/
  113607. /*! exports provided: SubEmitterType, SubEmitter */
  113608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113609. "use strict";
  113610. __webpack_require__.r(__webpack_exports__);
  113611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  113612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  113613. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  113614. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  113615. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  113616. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  113617. /**
  113618. * Type of sub emitter
  113619. */
  113620. var SubEmitterType;
  113621. (function (SubEmitterType) {
  113622. /**
  113623. * Attached to the particle over it's lifetime
  113624. */
  113625. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  113626. /**
  113627. * Created when the particle dies
  113628. */
  113629. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  113630. })(SubEmitterType || (SubEmitterType = {}));
  113631. /**
  113632. * Sub emitter class used to emit particles from an existing particle
  113633. */
  113634. var SubEmitter = /** @class */ (function () {
  113635. /**
  113636. * Creates a sub emitter
  113637. * @param particleSystem the particle system to be used by the sub emitter
  113638. */
  113639. function SubEmitter(
  113640. /**
  113641. * the particle system to be used by the sub emitter
  113642. */
  113643. particleSystem) {
  113644. this.particleSystem = particleSystem;
  113645. /**
  113646. * Type of the submitter (Default: END)
  113647. */
  113648. this.type = SubEmitterType.END;
  113649. /**
  113650. * 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)
  113651. * Note: This only is supported when using an emitter of type Mesh
  113652. */
  113653. this.inheritDirection = false;
  113654. /**
  113655. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  113656. */
  113657. this.inheritedVelocityAmount = 0;
  113658. // Create mesh as emitter to support rotation
  113659. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  113660. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  113661. }
  113662. // Automatically dispose of subemitter when system is disposed
  113663. particleSystem.onDisposeObservable.add(function () {
  113664. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  113665. particleSystem.emitter.dispose();
  113666. }
  113667. });
  113668. }
  113669. /**
  113670. * Clones the sub emitter
  113671. * @returns the cloned sub emitter
  113672. */
  113673. SubEmitter.prototype.clone = function () {
  113674. // Clone particle system
  113675. var emitter = this.particleSystem.emitter;
  113676. if (!emitter) {
  113677. emitter = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  113678. }
  113679. else if (emitter instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  113680. emitter = emitter.clone();
  113681. }
  113682. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  113683. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  113684. emitter.isVisible = false;
  113685. }
  113686. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  113687. // Clone properties
  113688. clone.type = this.type;
  113689. clone.inheritDirection = this.inheritDirection;
  113690. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  113691. clone.particleSystem._disposeEmitterOnDispose = true;
  113692. clone.particleSystem.disposeOnStop = true;
  113693. return clone;
  113694. };
  113695. /**
  113696. * Serialize current object to a JSON object
  113697. * @returns the serialized object
  113698. */
  113699. SubEmitter.prototype.serialize = function () {
  113700. var serializationObject = {};
  113701. serializationObject.type = this.type;
  113702. serializationObject.inheritDirection = this.inheritDirection;
  113703. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  113704. serializationObject.particleSystem = this.particleSystem.serialize();
  113705. return serializationObject;
  113706. };
  113707. /** @hidden */
  113708. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  113709. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("ParseParticle");
  113710. };
  113711. /**
  113712. * Creates a new SubEmitter from a serialized JSON version
  113713. * @param serializationObject defines the JSON object to read from
  113714. * @param scene defines the hosting scene
  113715. * @param rootUrl defines the rootUrl for data loading
  113716. * @returns a new SubEmitter
  113717. */
  113718. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  113719. var system = serializationObject.particleSystem;
  113720. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  113721. subEmitter.type = serializationObject.type;
  113722. subEmitter.inheritDirection = serializationObject.inheritDirection;
  113723. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  113724. subEmitter.particleSystem._isSubEmitter = true;
  113725. return subEmitter;
  113726. };
  113727. /** Release associated resources */
  113728. SubEmitter.prototype.dispose = function () {
  113729. this.particleSystem.dispose();
  113730. };
  113731. return SubEmitter;
  113732. }());
  113733. /***/ }),
  113734. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  113735. /*!*****************************************!*\
  113736. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  113737. \*****************************************/
  113738. /*! exports provided: AmmoJSPlugin */
  113739. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113740. "use strict";
  113741. __webpack_require__.r(__webpack_exports__);
  113742. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  113743. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  113744. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  113745. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  113746. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  113747. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  113748. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  113749. /* harmony import */ var _Meshes_Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Meshes/Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  113750. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  113751. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  113752. /**
  113753. * AmmoJS Physics plugin
  113754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113755. * @see https://github.com/kripken/ammo.js/
  113756. */
  113757. var AmmoJSPlugin = /** @class */ (function () {
  113758. /**
  113759. * Initializes the ammoJS plugin
  113760. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  113761. * @param ammoInjection can be used to inject your own ammo reference
  113762. */
  113763. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection) {
  113764. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  113765. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  113766. var _this = this;
  113767. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  113768. /**
  113769. * Reference to the Ammo library
  113770. */
  113771. this.bjsAMMO = {};
  113772. /**
  113773. * Name of the plugin
  113774. */
  113775. this.name = "AmmoJSPlugin";
  113776. this._timeStep = 1 / 60;
  113777. this._fixedTimeStep = 1 / 60;
  113778. this._maxSteps = 5;
  113779. this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  113780. this._tmpContactCallbackResult = false;
  113781. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  113782. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  113783. if (typeof ammoInjection === "function") {
  113784. ammoInjection(this.bjsAMMO);
  113785. }
  113786. else {
  113787. this.bjsAMMO = ammoInjection;
  113788. }
  113789. if (!this.isSupported()) {
  113790. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  113791. return;
  113792. }
  113793. // Initialize the physics world
  113794. this._collisionConfiguration = new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration();
  113795. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  113796. this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
  113797. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  113798. this._softBodySolver = new this.bjsAMMO.btDefaultSoftBodySolver();
  113799. this.world = new this.bjsAMMO.btSoftRigidDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration, this._softBodySolver);
  113800. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  113801. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  113802. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_8__["PhysicsRaycastResult"]();
  113803. // Create temp ammo variables
  113804. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  113805. this._tmpAmmoTransform.setIdentity();
  113806. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  113807. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  113808. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  113809. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  113810. this._tmpAmmoVectorD = new this.bjsAMMO.btVector3(0, 0, 0);
  113811. }
  113812. /**
  113813. * Sets the gravity of the physics world (m/(s^2))
  113814. * @param gravity Gravity to set
  113815. */
  113816. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  113817. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  113818. this.world.setGravity(this._tmpAmmoVectorA);
  113819. this.world.getWorldInfo().set_m_gravity(this._tmpAmmoVectorA);
  113820. };
  113821. /**
  113822. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  113823. * @param timeStep timestep to use in seconds
  113824. */
  113825. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  113826. this._timeStep = timeStep;
  113827. };
  113828. /**
  113829. * 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)
  113830. * @param fixedTimeStep fixedTimeStep to use in seconds
  113831. */
  113832. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  113833. this._fixedTimeStep = fixedTimeStep;
  113834. };
  113835. /**
  113836. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  113837. * @param maxSteps the maximum number of steps by the physics engine per frame
  113838. */
  113839. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  113840. this._maxSteps = maxSteps;
  113841. };
  113842. /**
  113843. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  113844. * @returns the current timestep in seconds
  113845. */
  113846. AmmoJSPlugin.prototype.getTimeStep = function () {
  113847. return this._timeStep;
  113848. };
  113849. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  113850. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  113851. this._tmpContactCallbackResult = false;
  113852. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  113853. return this._tmpContactCallbackResult;
  113854. };
  113855. // Ammo's collision events have some weird quirks
  113856. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  113857. // so only fire event if both contactTest and contactPairTest have a hit
  113858. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  113859. this._tmpContactCallbackResult = false;
  113860. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  113861. return this._tmpContactCallbackResult;
  113862. };
  113863. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  113864. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  113865. //
  113866. // When maxSteps is 0 do the entire simulation in one step
  113867. // 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)
  113868. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  113869. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  113870. if (timeStep === void 0) { timeStep = 1 / 60; }
  113871. if (maxSteps === void 0) { maxSteps = 10; }
  113872. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  113873. if (maxSteps == 0) {
  113874. this.world.stepSimulation(timeStep, 0);
  113875. }
  113876. else {
  113877. while (maxSteps > 0 && timeStep > 0) {
  113878. if (timeStep - fixedTimeStep < fixedTimeStep) {
  113879. this.world.stepSimulation(timeStep, 0);
  113880. timeStep = 0;
  113881. }
  113882. else {
  113883. timeStep -= fixedTimeStep;
  113884. this.world.stepSimulation(fixedTimeStep, 0);
  113885. }
  113886. maxSteps--;
  113887. }
  113888. }
  113889. };
  113890. /**
  113891. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  113892. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  113893. * After the step the babylon meshes are set to the position of the physics imposters
  113894. * @param delta amount of time to step forward
  113895. * @param impostors array of imposters to update before/after the step
  113896. */
  113897. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  113898. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  113899. var impostor = impostors_1[_i];
  113900. // Update physics world objects to match babylon world
  113901. if (!impostor.soft) {
  113902. impostor.beforeStep();
  113903. }
  113904. }
  113905. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  113906. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  113907. var mainImpostor = impostors_2[_a];
  113908. // After physics update make babylon world objects match physics world objects
  113909. if (mainImpostor.soft) {
  113910. this._afterSoftStep(mainImpostor);
  113911. }
  113912. else {
  113913. mainImpostor.afterStep();
  113914. }
  113915. // Handle collision event
  113916. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  113917. if (this._isImpostorInContact(mainImpostor)) {
  113918. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  113919. var collideCallback = _c[_b];
  113920. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  113921. var otherImpostor = _e[_d];
  113922. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  113923. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  113924. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  113925. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  113926. }
  113927. }
  113928. }
  113929. }
  113930. }
  113931. }
  113932. }
  113933. };
  113934. /**
  113935. * Update babylon mesh to match physics world object
  113936. * @param impostor imposter to match
  113937. */
  113938. AmmoJSPlugin.prototype._afterSoftStep = function (impostor) {
  113939. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].RopeImpostor) {
  113940. this._ropeStep(impostor);
  113941. }
  113942. else {
  113943. this._softbodyOrClothStep(impostor);
  113944. }
  113945. };
  113946. /**
  113947. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  113948. * @param impostor imposter to match
  113949. */
  113950. AmmoJSPlugin.prototype._ropeStep = function (impostor) {
  113951. var bodyVertices = impostor.physicsBody.get_m_nodes();
  113952. var nbVertices = bodyVertices.size();
  113953. var node;
  113954. var nodePositions;
  113955. var x, y, z;
  113956. var path = new Array();
  113957. for (var n = 0; n < nbVertices; n++) {
  113958. node = bodyVertices.at(n);
  113959. nodePositions = node.get_m_x();
  113960. x = nodePositions.x();
  113961. y = nodePositions.y();
  113962. z = nodePositions.z();
  113963. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](x, y, z));
  113964. }
  113965. var object = impostor.object;
  113966. var shape = impostor.getParam("shape");
  113967. if (impostor._isFromLine) {
  113968. impostor.object = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines("lines", { points: path, instance: object });
  113969. }
  113970. else {
  113971. impostor.object = _Meshes_Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_6__["ShapeBuilder"].ExtrudeShape("ext", { shape: shape, path: path, instance: object });
  113972. }
  113973. };
  113974. /**
  113975. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  113976. * @param impostor imposter to match
  113977. */
  113978. AmmoJSPlugin.prototype._softbodyOrClothStep = function (impostor) {
  113979. var normalDirection = (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ClothImpostor) ? 1 : -1;
  113980. var object = impostor.object;
  113981. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  113982. if (!vertexPositions) {
  113983. vertexPositions = [];
  113984. }
  113985. var vertexNormals = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  113986. if (!vertexNormals) {
  113987. vertexNormals = [];
  113988. }
  113989. var nbVertices = vertexPositions.length / 3;
  113990. var bodyVertices = impostor.physicsBody.get_m_nodes();
  113991. var node;
  113992. var nodePositions;
  113993. var nodeNormals;
  113994. var x, y, z;
  113995. var nx, ny, nz;
  113996. for (var n = 0; n < nbVertices; n++) {
  113997. node = bodyVertices.at(n);
  113998. nodePositions = node.get_m_x();
  113999. x = nodePositions.x();
  114000. y = nodePositions.y();
  114001. z = nodePositions.z() * normalDirection;
  114002. var nodeNormals = node.get_m_n();
  114003. nx = nodeNormals.x();
  114004. ny = nodeNormals.y();
  114005. nz = nodeNormals.z() * normalDirection;
  114006. vertexPositions[3 * n] = x;
  114007. vertexPositions[3 * n + 1] = y;
  114008. vertexPositions[3 * n + 2] = z;
  114009. vertexNormals[3 * n] = nx;
  114010. vertexNormals[3 * n + 1] = ny;
  114011. vertexNormals[3 * n + 2] = nz;
  114012. }
  114013. var vertex_data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  114014. vertex_data.positions = vertexPositions;
  114015. vertex_data.normals = vertexNormals;
  114016. vertex_data.uvs = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  114017. vertex_data.colors = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  114018. if (object && object.getIndices) {
  114019. vertex_data.indices = object.getIndices();
  114020. }
  114021. vertex_data.applyToMesh(object);
  114022. };
  114023. /**
  114024. * Applies an impulse on the imposter
  114025. * @param impostor imposter to apply impulse to
  114026. * @param force amount of force to be applied to the imposter
  114027. * @param contactPoint the location to apply the impulse on the imposter
  114028. */
  114029. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  114030. if (!impostor.soft) {
  114031. impostor.physicsBody.activate();
  114032. var worldPoint = this._tmpAmmoVectorA;
  114033. var impulse = this._tmpAmmoVectorB;
  114034. // Convert contactPoint into world space
  114035. if (impostor.object && impostor.object.getWorldMatrix) {
  114036. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  114037. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  114038. contactPoint = this._tmpVector;
  114039. }
  114040. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  114041. impulse.setValue(force.x, force.y, force.z);
  114042. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  114043. }
  114044. else {
  114045. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Cannot be applied to a soft body");
  114046. }
  114047. };
  114048. /**
  114049. * Applies a force on the imposter
  114050. * @param impostor imposter to apply force
  114051. * @param force amount of force to be applied to the imposter
  114052. * @param contactPoint the location to apply the force on the imposter
  114053. */
  114054. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  114055. if (!impostor.soft) {
  114056. impostor.physicsBody.activate();
  114057. var worldPoint = this._tmpAmmoVectorA;
  114058. var impulse = this._tmpAmmoVectorB;
  114059. // Convert contactPoint into world space
  114060. if (impostor.object && impostor.object.getWorldMatrix) {
  114061. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  114062. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  114063. contactPoint = this._tmpVector;
  114064. }
  114065. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  114066. impulse.setValue(force.x, force.y, force.z);
  114067. impostor.physicsBody.applyForce(impulse, worldPoint);
  114068. }
  114069. else {
  114070. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Cannot be applied to a soft body");
  114071. }
  114072. };
  114073. /**
  114074. * Creates a physics body using the plugin
  114075. * @param impostor the imposter to create the physics body on
  114076. */
  114077. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  114078. // Note: this method will not be called on child imposotrs for compound impostors
  114079. impostor._pluginData.toDispose = [];
  114080. //parent-child relationship
  114081. if (impostor.parent) {
  114082. if (impostor.physicsBody) {
  114083. this.removePhysicsBody(impostor);
  114084. impostor.forceUpdate();
  114085. }
  114086. return;
  114087. }
  114088. if (impostor.isBodyInitRequired()) {
  114089. var colShape = this._createShape(impostor);
  114090. var mass = impostor.getParam("mass");
  114091. impostor._pluginData.mass = mass;
  114092. if (impostor.soft) {
  114093. colShape.get_m_cfg().set_collisions(0x11);
  114094. colShape.get_m_cfg().set_kDP(impostor.getParam("damping"));
  114095. Ammo.castObject(colShape, Ammo.btCollisionObject).getCollisionShape().setMargin(impostor.getParam("margin"));
  114096. colShape.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  114097. this.world.addSoftBody(colShape, 1, -1);
  114098. impostor.physicsBody = colShape;
  114099. impostor._pluginData.toDispose.concat([colShape]);
  114100. this.setBodyPressure(impostor, 0);
  114101. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor) {
  114102. this.setBodyPressure(impostor, impostor.getParam("pressure"));
  114103. }
  114104. this.setBodyStiffness(impostor, impostor.getParam("stiffness"));
  114105. this.setBodyVelocityIterations(impostor, impostor.getParam("velocityIterations"));
  114106. this.setBodyPositionIterations(impostor, impostor.getParam("positionIterations"));
  114107. }
  114108. else {
  114109. var localInertia = new Ammo.btVector3(0, 0, 0);
  114110. var startTransform = new Ammo.btTransform();
  114111. startTransform.setIdentity();
  114112. if (mass !== 0) {
  114113. colShape.calculateLocalInertia(mass, localInertia);
  114114. }
  114115. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  114116. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  114117. startTransform.setOrigin(this._tmpAmmoVectorA);
  114118. startTransform.setRotation(this._tmpAmmoQuaternion);
  114119. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  114120. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  114121. var body = new Ammo.btRigidBody(rbInfo);
  114122. // Make objects kinematic if it's mass is 0
  114123. if (mass === 0) {
  114124. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  114125. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  114126. }
  114127. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  114128. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  114129. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  114130. }
  114131. this.world.addRigidBody(body);
  114132. impostor.physicsBody = body;
  114133. impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  114134. }
  114135. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  114136. this.setBodyFriction(impostor, impostor.getParam("friction"));
  114137. }
  114138. };
  114139. /**
  114140. * Removes the physics body from the imposter and disposes of the body's memory
  114141. * @param impostor imposter to remove the physics body from
  114142. */
  114143. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  114144. var _this = this;
  114145. if (this.world) {
  114146. this.world.removeRigidBody(impostor.physicsBody);
  114147. if (impostor._pluginData) {
  114148. impostor._pluginData.toDispose.forEach(function (d) {
  114149. _this.bjsAMMO.destroy(d);
  114150. });
  114151. }
  114152. }
  114153. };
  114154. /**
  114155. * Generates a joint
  114156. * @param impostorJoint the imposter joint to create the joint with
  114157. */
  114158. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  114159. var mainBody = impostorJoint.mainImpostor.physicsBody;
  114160. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  114161. if (!mainBody || !connectedBody) {
  114162. return;
  114163. }
  114164. var jointData = impostorJoint.joint.jointData;
  114165. if (!jointData.mainPivot) {
  114166. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  114167. }
  114168. if (!jointData.connectedPivot) {
  114169. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  114170. }
  114171. var joint;
  114172. switch (impostorJoint.joint.type) {
  114173. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  114174. var distance = jointData.maxDistance;
  114175. if (distance) {
  114176. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  114177. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  114178. }
  114179. 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));
  114180. break;
  114181. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  114182. if (!jointData.mainAxis) {
  114183. jointData.mainAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  114184. }
  114185. if (!jointData.connectedAxis) {
  114186. jointData.connectedAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  114187. }
  114188. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  114189. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  114190. 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);
  114191. break;
  114192. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  114193. 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));
  114194. break;
  114195. default:
  114196. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint");
  114197. 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));
  114198. break;
  114199. }
  114200. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  114201. impostorJoint.joint.physicsJoint = joint;
  114202. };
  114203. /**
  114204. * Removes a joint
  114205. * @param impostorJoint the imposter joint to remove the joint from
  114206. */
  114207. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  114208. if (this.world) {
  114209. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  114210. }
  114211. };
  114212. // adds all verticies (including child verticies) to the triangle mesh
  114213. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  114214. var _this = this;
  114215. var triangleCount = 0;
  114216. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  114217. var indices = object.getIndices();
  114218. if (!indices) {
  114219. indices = [];
  114220. }
  114221. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  114222. if (!vertexPositions) {
  114223. vertexPositions = [];
  114224. }
  114225. object.computeWorldMatrix(false);
  114226. var faceCount = indices.length / 3;
  114227. for (var i = 0; i < faceCount; i++) {
  114228. var triPoints = [];
  114229. for (var point = 0; point < 3; point++) {
  114230. 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]);
  114231. // Adjust for initial scaling
  114232. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].ScalingToRef(object.scaling.x, object.scaling.y, object.scaling.z, this._tmpMatrix);
  114233. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, this._tmpMatrix);
  114234. var vec;
  114235. if (point == 0) {
  114236. vec = this._tmpAmmoVectorA;
  114237. }
  114238. else if (point == 1) {
  114239. vec = this._tmpAmmoVectorB;
  114240. }
  114241. else {
  114242. vec = this._tmpAmmoVectorC;
  114243. }
  114244. vec.setValue(v.x, v.y, v.z);
  114245. triPoints.push(vec);
  114246. }
  114247. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  114248. triangleCount++;
  114249. }
  114250. object.getChildMeshes().forEach(function (m) {
  114251. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  114252. });
  114253. }
  114254. return triangleCount;
  114255. };
  114256. /**
  114257. * Initialise the soft body vertices to match its object's (mesh) vertices
  114258. * Softbody vertices (nodes) are in world space and to match this
  114259. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  114260. * @param impostor to create the softbody for
  114261. */
  114262. AmmoJSPlugin.prototype._softVertexData = function (impostor) {
  114263. var object = impostor.object;
  114264. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  114265. var indices = object.getIndices();
  114266. if (!indices) {
  114267. indices = [];
  114268. }
  114269. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  114270. if (!vertexPositions) {
  114271. vertexPositions = [];
  114272. }
  114273. var vertexNormals = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  114274. if (!vertexNormals) {
  114275. vertexNormals = [];
  114276. }
  114277. object.computeWorldMatrix(false);
  114278. var newPoints = [];
  114279. var newNorms = [];
  114280. for (var i = 0; i < vertexPositions.length; i += 3) {
  114281. var v = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[i], vertexPositions[i + 1], vertexPositions[i + 2]);
  114282. var n = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexNormals[i], vertexNormals[i + 1], vertexNormals[i + 2]);
  114283. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  114284. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(n, object.getWorldMatrix());
  114285. newPoints.push(v.x, v.y, v.z);
  114286. newNorms.push(n.x, n.y, n.z);
  114287. }
  114288. var vertex_data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"]();
  114289. vertex_data.positions = newPoints;
  114290. vertex_data.normals = newNorms;
  114291. vertex_data.uvs = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  114292. vertex_data.colors = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  114293. if (object && object.getIndices) {
  114294. vertex_data.indices = object.getIndices();
  114295. }
  114296. vertex_data.applyToMesh(object);
  114297. object.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  114298. object.rotationQuaternion = null;
  114299. object.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  114300. object.computeWorldMatrix(true);
  114301. return vertex_data;
  114302. }
  114303. return _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_5__["VertexData"].ExtractFromMesh(object);
  114304. };
  114305. /**
  114306. * Create an impostor's soft body
  114307. * @param impostor to create the softbody for
  114308. */
  114309. AmmoJSPlugin.prototype._createSoftbody = function (impostor) {
  114310. var object = impostor.object;
  114311. if (object && object.getIndices) {
  114312. var indices = object.getIndices();
  114313. if (!indices) {
  114314. indices = [];
  114315. }
  114316. var vertex_data = this._softVertexData(impostor);
  114317. var vertexPositions = vertex_data.positions;
  114318. var vertexNormals = vertex_data.normals;
  114319. if (vertexPositions === null || vertexNormals === null) {
  114320. return new Ammo.btCompoundShape();
  114321. }
  114322. else {
  114323. var triPoints = [];
  114324. var triNorms = [];
  114325. for (var i = 0; i < vertexPositions.length; i += 3) {
  114326. var v = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexPositions[i], vertexPositions[i + 1], vertexPositions[i + 2]);
  114327. var n = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](vertexNormals[i], vertexNormals[i + 1], vertexNormals[i + 2]);
  114328. triPoints.push(v.x, v.y, -v.z);
  114329. triNorms.push(n.x, n.y, -n.z);
  114330. }
  114331. var softBody = new Ammo.btSoftBodyHelpers().CreateFromTriMesh(this.world.getWorldInfo(), triPoints, object.getIndices(), indices.length / 3, true);
  114332. var nbVertices = vertexPositions.length / 3;
  114333. var bodyVertices = softBody.get_m_nodes();
  114334. var node;
  114335. var nodeNormals;
  114336. for (var i = 0; i < nbVertices; i++) {
  114337. node = bodyVertices.at(i);
  114338. var nodeNormals = node.get_m_n();
  114339. nodeNormals.setX(triNorms[3 * i]);
  114340. nodeNormals.setY(triNorms[3 * i + 1]);
  114341. nodeNormals.setZ(triNorms[3 * i + 2]);
  114342. }
  114343. return softBody;
  114344. }
  114345. }
  114346. };
  114347. /**
  114348. * Create cloth for an impostor
  114349. * @param impostor to create the softbody for
  114350. */
  114351. AmmoJSPlugin.prototype._createCloth = function (impostor) {
  114352. var object = impostor.object;
  114353. if (object && object.getIndices) {
  114354. var indices = object.getIndices();
  114355. if (!indices) {
  114356. indices = [];
  114357. }
  114358. var vertex_data = this._softVertexData(impostor);
  114359. var vertexPositions = vertex_data.positions;
  114360. var vertexNormals = vertex_data.normals;
  114361. if (vertexPositions === null || vertexNormals === null) {
  114362. return new Ammo.btCompoundShape();
  114363. }
  114364. else {
  114365. var len = vertexPositions.length;
  114366. var segments = Math.sqrt(len / 3);
  114367. impostor.segments = segments;
  114368. var segs = segments - 1;
  114369. this._tmpAmmoVectorA.setValue(vertexPositions[0], vertexPositions[1], vertexPositions[2]);
  114370. this._tmpAmmoVectorB.setValue(vertexPositions[3 * segs], vertexPositions[3 * segs + 1], vertexPositions[3 * segs + 2]);
  114371. this._tmpAmmoVectorD.setValue(vertexPositions[len - 3], vertexPositions[len - 2], vertexPositions[len - 1]);
  114372. this._tmpAmmoVectorC.setValue(vertexPositions[len - 3 - 3 * segs], vertexPositions[len - 2 - 3 * segs], vertexPositions[len - 1 - 3 * segs]);
  114373. var clothBody = new Ammo.btSoftBodyHelpers().CreatePatch(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, this._tmpAmmoVectorC, this._tmpAmmoVectorD, segments, segments, impostor.getParam("fixedPoints"), true);
  114374. return clothBody;
  114375. }
  114376. }
  114377. };
  114378. /**
  114379. * Create rope for an impostor
  114380. * @param impostor to create the softbody for
  114381. */
  114382. AmmoJSPlugin.prototype._createRope = function (impostor) {
  114383. var len;
  114384. var segments;
  114385. var vertex_data = this._softVertexData(impostor);
  114386. var vertexPositions = vertex_data.positions;
  114387. var vertexNormals = vertex_data.normals;
  114388. if (vertexPositions === null || vertexNormals === null) {
  114389. return new Ammo.btCompoundShape();
  114390. }
  114391. //force the mesh to be updatable
  114392. vertex_data.applyToMesh(impostor.object, true);
  114393. impostor._isFromLine = true;
  114394. // If in lines mesh all normals will be zero
  114395. var vertexSquared = vertexNormals.map(function (x) { return x * x; });
  114396. var reducer = function (accumulator, currentValue) { return accumulator + currentValue; };
  114397. var reduced = vertexSquared.reduce(reducer);
  114398. if (reduced === 0) { // line mesh
  114399. len = vertexPositions.length;
  114400. segments = len / 3 - 1;
  114401. this._tmpAmmoVectorA.setValue(vertexPositions[0], vertexPositions[1], vertexPositions[2]);
  114402. this._tmpAmmoVectorB.setValue(vertexPositions[len - 3], vertexPositions[len - 2], vertexPositions[len - 1]);
  114403. }
  114404. else { //extruded mesh
  114405. impostor._isFromLine = false;
  114406. var pathVectors = impostor.getParam("path");
  114407. var shape = impostor.getParam("shape");
  114408. if (shape === null) {
  114409. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("No shape available for extruded mesh");
  114410. return new Ammo.btCompoundShape();
  114411. }
  114412. if ((vertexPositions.length % (3 * pathVectors.length)) !== 0) {
  114413. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Path does not match extrusion");
  114414. return new Ammo.btCompoundShape();
  114415. }
  114416. len = pathVectors.length;
  114417. segments = len - 1;
  114418. this._tmpAmmoVectorA.setValue(pathVectors[0].x, pathVectors[0].y, pathVectors[0].z);
  114419. this._tmpAmmoVectorB.setValue(pathVectors[len - 1].x, pathVectors[len - 1].y, pathVectors[len - 1].z);
  114420. }
  114421. impostor.segments = segments;
  114422. var fixedPoints = impostor.getParam("fixedPoints");
  114423. fixedPoints = (fixedPoints > 3) ? 3 : fixedPoints;
  114424. var ropeBody = new Ammo.btSoftBodyHelpers().CreateRope(this.world.getWorldInfo(), this._tmpAmmoVectorA, this._tmpAmmoVectorB, segments - 1, fixedPoints);
  114425. ropeBody.get_m_cfg().set_collisions(0x11);
  114426. return ropeBody;
  114427. };
  114428. // adds all verticies (including child verticies) to the convex hull shape
  114429. AmmoJSPlugin.prototype._addHullVerts = function (btConvexHullShape, topLevelObject, object) {
  114430. var _this = this;
  114431. var triangleCount = 0;
  114432. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  114433. var indices = object.getIndices();
  114434. if (!indices) {
  114435. indices = [];
  114436. }
  114437. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  114438. if (!vertexPositions) {
  114439. vertexPositions = [];
  114440. }
  114441. object.computeWorldMatrix(false);
  114442. var faceCount = indices.length / 3;
  114443. for (var i = 0; i < faceCount; i++) {
  114444. var triPoints = [];
  114445. for (var point = 0; point < 3; point++) {
  114446. 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]);
  114447. // Adjust for initial scaling
  114448. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].ScalingToRef(object.scaling.x, object.scaling.y, object.scaling.z, this._tmpMatrix);
  114449. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, this._tmpMatrix);
  114450. var vec;
  114451. if (point == 0) {
  114452. vec = this._tmpAmmoVectorA;
  114453. }
  114454. else if (point == 1) {
  114455. vec = this._tmpAmmoVectorB;
  114456. }
  114457. else {
  114458. vec = this._tmpAmmoVectorC;
  114459. }
  114460. vec.setValue(v.x, v.y, v.z);
  114461. triPoints.push(vec);
  114462. }
  114463. btConvexHullShape.addPoint(triPoints[0], true);
  114464. btConvexHullShape.addPoint(triPoints[1], true);
  114465. btConvexHullShape.addPoint(triPoints[2], true);
  114466. triangleCount++;
  114467. }
  114468. object.getChildMeshes().forEach(function (m) {
  114469. triangleCount += _this._addHullVerts(btConvexHullShape, topLevelObject, m);
  114470. });
  114471. }
  114472. return triangleCount;
  114473. };
  114474. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  114475. var _this = this;
  114476. if (ignoreChildren === void 0) { ignoreChildren = false; }
  114477. var object = impostor.object;
  114478. var returnValue;
  114479. var extendSize = impostor.getObjectExtendSize();
  114480. if (!ignoreChildren) {
  114481. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  114482. returnValue = new Ammo.btCompoundShape();
  114483. // Add shape of all children to the compound shape
  114484. var childrenAdded = 0;
  114485. meshChildren.forEach(function (childMesh) {
  114486. var childImpostor = childMesh.getPhysicsImpostor();
  114487. if (childImpostor) {
  114488. if (childImpostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor) {
  114489. throw "A child MeshImpostor is not supported. Only primitive impostors are supported as children (eg. box or sphere)";
  114490. }
  114491. var shape = _this._createShape(childImpostor);
  114492. // Position needs to be scaled based on parent's scaling
  114493. var parentMat = childMesh.parent.getWorldMatrix().clone();
  114494. var s = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  114495. parentMat.decompose(s);
  114496. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  114497. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  114498. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  114499. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  114500. childImpostor.dispose();
  114501. childrenAdded++;
  114502. }
  114503. });
  114504. if (childrenAdded > 0) {
  114505. // Add parents shape as a child if present
  114506. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  114507. var shape = this._createShape(impostor, true);
  114508. if (shape) {
  114509. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  114510. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  114511. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  114512. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  114513. }
  114514. }
  114515. return returnValue;
  114516. }
  114517. else {
  114518. // If no children with impostors create the actual shape below instead
  114519. Ammo.destroy(returnValue);
  114520. returnValue = null;
  114521. }
  114522. }
  114523. switch (impostor.type) {
  114524. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  114525. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  114526. break;
  114527. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  114528. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  114529. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  114530. break;
  114531. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  114532. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  114533. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  114534. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  114535. break;
  114536. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  114537. if (impostor.getParam("mass") == 0) {
  114538. // Only create btBvhTriangleMeshShape impostor is static
  114539. // See https://pybullet.org/Bullet/phpBB3/viewtopic.php?t=7283
  114540. var tetraMesh = new Ammo.btTriangleMesh();
  114541. impostor._pluginData.toDispose.concat([tetraMesh]);
  114542. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  114543. if (triangeCount == 0) {
  114544. returnValue = new Ammo.btCompoundShape();
  114545. }
  114546. else {
  114547. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  114548. }
  114549. break;
  114550. }
  114551. // Otherwise create convexHullImpostor
  114552. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ConvexHullImpostor:
  114553. var convexMesh = new Ammo.btConvexHullShape();
  114554. var triangeCount = this._addHullVerts(convexMesh, object, object);
  114555. if (triangeCount == 0) {
  114556. // Cleanup Unused Convex Hull Shape
  114557. impostor._pluginData.toDispose.concat([convexMesh]);
  114558. returnValue = new Ammo.btCompoundShape();
  114559. }
  114560. else {
  114561. returnValue = convexMesh;
  114562. }
  114563. break;
  114564. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  114565. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  114566. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  114567. break;
  114568. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor:
  114569. // Only usable with a mesh that has sufficient and shared vertices
  114570. returnValue = this._createSoftbody(impostor);
  114571. break;
  114572. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].ClothImpostor:
  114573. // Only usable with a ground mesh that has sufficient and shared vertices
  114574. returnValue = this._createCloth(impostor);
  114575. break;
  114576. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].RopeImpostor:
  114577. // Only usable with a line mesh or an extruded mesh that is updatable
  114578. returnValue = this._createRope(impostor);
  114579. break;
  114580. default:
  114581. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  114582. break;
  114583. }
  114584. return returnValue;
  114585. };
  114586. /**
  114587. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  114588. * @param impostor imposter containing the physics body and babylon object
  114589. */
  114590. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  114591. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  114592. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  114593. if (!impostor.object.rotationQuaternion) {
  114594. if (impostor.object.rotation) {
  114595. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  114596. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  114597. }
  114598. }
  114599. else {
  114600. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  114601. }
  114602. };
  114603. /**
  114604. * Sets the babylon object's position/rotation from the physics body's position/rotation
  114605. * @param impostor imposter containing the physics body and babylon object
  114606. * @param newPosition new position
  114607. * @param newRotation new rotation
  114608. */
  114609. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  114610. var trans = impostor.physicsBody.getWorldTransform();
  114611. // If rotation/position has changed update and activate riged body
  114612. if (trans.getOrigin().x() != newPosition.x ||
  114613. trans.getOrigin().y() != newPosition.y ||
  114614. trans.getOrigin().z() != newPosition.z ||
  114615. trans.getRotation().x() != newRotation.x ||
  114616. trans.getRotation().y() != newRotation.y ||
  114617. trans.getRotation().z() != newRotation.z ||
  114618. trans.getRotation().w() != newRotation.w) {
  114619. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  114620. trans.setOrigin(this._tmpAmmoVectorA);
  114621. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  114622. trans.setRotation(this._tmpAmmoQuaternion);
  114623. impostor.physicsBody.setWorldTransform(trans);
  114624. if (impostor.mass == 0) {
  114625. // Kinematic objects must be updated using motion state
  114626. var motionState = impostor.physicsBody.getMotionState();
  114627. if (motionState) {
  114628. motionState.setWorldTransform(trans);
  114629. }
  114630. }
  114631. else {
  114632. impostor.physicsBody.activate();
  114633. }
  114634. }
  114635. };
  114636. /**
  114637. * If this plugin is supported
  114638. * @returns true if its supported
  114639. */
  114640. AmmoJSPlugin.prototype.isSupported = function () {
  114641. return this.bjsAMMO !== undefined;
  114642. };
  114643. /**
  114644. * Sets the linear velocity of the physics body
  114645. * @param impostor imposter to set the velocity on
  114646. * @param velocity velocity to set
  114647. */
  114648. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  114649. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  114650. if (impostor.soft) {
  114651. impostor.physicsBody.linearVelocity(this._tmpAmmoVectorA);
  114652. }
  114653. else {
  114654. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  114655. }
  114656. };
  114657. /**
  114658. * Sets the angular velocity of the physics body
  114659. * @param impostor imposter to set the velocity on
  114660. * @param velocity velocity to set
  114661. */
  114662. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  114663. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  114664. if (impostor.soft) {
  114665. impostor.physicsBody.angularVelocity(this._tmpAmmoVectorA);
  114666. }
  114667. else {
  114668. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  114669. }
  114670. };
  114671. /**
  114672. * gets the linear velocity
  114673. * @param impostor imposter to get linear velocity from
  114674. * @returns linear velocity
  114675. */
  114676. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  114677. if (impostor.soft) {
  114678. var v = impostor.physicsBody.linearVelocity();
  114679. }
  114680. else {
  114681. var v = impostor.physicsBody.getLinearVelocity();
  114682. }
  114683. if (!v) {
  114684. return null;
  114685. }
  114686. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  114687. };
  114688. /**
  114689. * gets the angular velocity
  114690. * @param impostor imposter to get angular velocity from
  114691. * @returns angular velocity
  114692. */
  114693. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  114694. if (impostor.soft) {
  114695. var v = impostor.physicsBody.angularVelocity();
  114696. }
  114697. else {
  114698. var v = impostor.physicsBody.getAngularVelocity();
  114699. }
  114700. if (!v) {
  114701. return null;
  114702. }
  114703. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  114704. };
  114705. /**
  114706. * Sets the mass of physics body
  114707. * @param impostor imposter to set the mass on
  114708. * @param mass mass to set
  114709. */
  114710. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  114711. if (impostor.soft) {
  114712. impostor.physicsBody.setTotalMass(mass, false);
  114713. }
  114714. else {
  114715. impostor.physicsBody.setMassProps(mass);
  114716. }
  114717. impostor._pluginData.mass = mass;
  114718. };
  114719. /**
  114720. * Gets the mass of the physics body
  114721. * @param impostor imposter to get the mass from
  114722. * @returns mass
  114723. */
  114724. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  114725. return impostor._pluginData.mass || 0;
  114726. };
  114727. /**
  114728. * Gets friction of the impostor
  114729. * @param impostor impostor to get friction from
  114730. * @returns friction value
  114731. */
  114732. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  114733. return impostor._pluginData.friction || 0;
  114734. };
  114735. /**
  114736. * Sets friction of the impostor
  114737. * @param impostor impostor to set friction on
  114738. * @param friction friction value
  114739. */
  114740. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  114741. if (impostor.soft) {
  114742. impostor.physicsBody.get_m_cfg().set_kDF(friction);
  114743. }
  114744. else {
  114745. impostor.physicsBody.setFriction(friction);
  114746. }
  114747. impostor._pluginData.friction = friction;
  114748. };
  114749. /**
  114750. * Gets restitution of the impostor
  114751. * @param impostor impostor to get restitution from
  114752. * @returns restitution value
  114753. */
  114754. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  114755. return impostor._pluginData.restitution || 0;
  114756. };
  114757. /**
  114758. * Sets resitution of the impostor
  114759. * @param impostor impostor to set resitution on
  114760. * @param restitution resitution value
  114761. */
  114762. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  114763. impostor.physicsBody.setRestitution(restitution);
  114764. impostor._pluginData.restitution = restitution;
  114765. };
  114766. /**
  114767. * Gets pressure inside the impostor
  114768. * @param impostor impostor to get pressure from
  114769. * @returns pressure value
  114770. */
  114771. AmmoJSPlugin.prototype.getBodyPressure = function (impostor) {
  114772. if (!impostor.soft) {
  114773. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Pressure is not a property of a rigid body");
  114774. return 0;
  114775. }
  114776. return impostor._pluginData.pressure || 0;
  114777. };
  114778. /**
  114779. * Sets pressure inside a soft body impostor
  114780. * Cloth and rope must remain 0 pressure
  114781. * @param impostor impostor to set pressure on
  114782. * @param pressure pressure value
  114783. */
  114784. AmmoJSPlugin.prototype.setBodyPressure = function (impostor, pressure) {
  114785. if (impostor.soft) {
  114786. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SoftbodyImpostor) {
  114787. impostor.physicsBody.get_m_cfg().set_kPR(pressure);
  114788. impostor._pluginData.pressure = pressure;
  114789. }
  114790. else {
  114791. impostor.physicsBody.get_m_cfg().set_kPR(0);
  114792. impostor._pluginData.pressure = 0;
  114793. }
  114794. }
  114795. else {
  114796. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Pressure can only be applied to a softbody");
  114797. }
  114798. };
  114799. /**
  114800. * Gets stiffness of the impostor
  114801. * @param impostor impostor to get stiffness from
  114802. * @returns pressure value
  114803. */
  114804. AmmoJSPlugin.prototype.getBodyStiffness = function (impostor) {
  114805. if (!impostor.soft) {
  114806. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Stiffness is not a property of a rigid body");
  114807. return 0;
  114808. }
  114809. return impostor._pluginData.stiffness || 0;
  114810. };
  114811. /**
  114812. * Sets stiffness of the impostor
  114813. * @param impostor impostor to set stiffness on
  114814. * @param stiffness stiffness value from 0 to 1
  114815. */
  114816. AmmoJSPlugin.prototype.setBodyStiffness = function (impostor, stiffness) {
  114817. if (impostor.soft) {
  114818. stiffness = stiffness < 0 ? 0 : stiffness;
  114819. stiffness = stiffness > 1 ? 1 : stiffness;
  114820. impostor.physicsBody.get_m_materials().at(0).set_m_kLST(stiffness);
  114821. impostor._pluginData.stiffness = stiffness;
  114822. }
  114823. else {
  114824. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Stiffness cannot be applied to a rigid body");
  114825. }
  114826. };
  114827. /**
  114828. * Gets velocityIterations of the impostor
  114829. * @param impostor impostor to get velocity iterations from
  114830. * @returns velocityIterations value
  114831. */
  114832. AmmoJSPlugin.prototype.getBodyVelocityIterations = function (impostor) {
  114833. if (!impostor.soft) {
  114834. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Velocity iterations is not a property of a rigid body");
  114835. return 0;
  114836. }
  114837. return impostor._pluginData.velocityIterations || 0;
  114838. };
  114839. /**
  114840. * Sets velocityIterations of the impostor
  114841. * @param impostor impostor to set velocity iterations on
  114842. * @param velocityIterations velocityIterations value
  114843. */
  114844. AmmoJSPlugin.prototype.setBodyVelocityIterations = function (impostor, velocityIterations) {
  114845. if (impostor.soft) {
  114846. velocityIterations = velocityIterations < 0 ? 0 : velocityIterations;
  114847. impostor.physicsBody.get_m_cfg().set_viterations(velocityIterations);
  114848. impostor._pluginData.velocityIterations = velocityIterations;
  114849. }
  114850. else {
  114851. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Velocity iterations cannot be applied to a rigid body");
  114852. }
  114853. };
  114854. /**
  114855. * Gets positionIterations of the impostor
  114856. * @param impostor impostor to get position iterations from
  114857. * @returns positionIterations value
  114858. */
  114859. AmmoJSPlugin.prototype.getBodyPositionIterations = function (impostor) {
  114860. if (!impostor.soft) {
  114861. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Position iterations is not a property of a rigid body");
  114862. return 0;
  114863. }
  114864. return impostor._pluginData.positionIterations || 0;
  114865. };
  114866. /**
  114867. * Sets positionIterations of the impostor
  114868. * @param impostor impostor to set position on
  114869. * @param positionIterations positionIterations value
  114870. */
  114871. AmmoJSPlugin.prototype.setBodyPositionIterations = function (impostor, positionIterations) {
  114872. if (impostor.soft) {
  114873. positionIterations = positionIterations < 0 ? 0 : positionIterations;
  114874. impostor.physicsBody.get_m_cfg().set_piterations(positionIterations);
  114875. impostor._pluginData.positionIterations = positionIterations;
  114876. }
  114877. else {
  114878. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Position iterations cannot be applied to a rigid body");
  114879. }
  114880. };
  114881. /**
  114882. * Append an anchor to a cloth object
  114883. * @param impostor is the cloth impostor to add anchor to
  114884. * @param otherImpostor is the rigid impostor to anchor to
  114885. * @param width ratio across width from 0 to 1
  114886. * @param height ratio up height from 0 to 1
  114887. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  114888. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  114889. */
  114890. AmmoJSPlugin.prototype.appendAnchor = function (impostor, otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies) {
  114891. if (influence === void 0) { influence = 1; }
  114892. if (noCollisionBetweenLinkedBodies === void 0) { noCollisionBetweenLinkedBodies = false; }
  114893. var segs = impostor.segments;
  114894. var nbAcross = Math.round((segs - 1) * width);
  114895. var nbUp = Math.round((segs - 1) * height);
  114896. var nbDown = segs - 1 - nbUp;
  114897. var node = nbAcross + segs * nbDown;
  114898. impostor.physicsBody.appendAnchor(node, otherImpostor.physicsBody, noCollisionBetweenLinkedBodies, influence);
  114899. };
  114900. /**
  114901. * Append an hook to a rope object
  114902. * @param impostor is the rope impostor to add hook to
  114903. * @param otherImpostor is the rigid impostor to hook to
  114904. * @param length ratio along the rope from 0 to 1
  114905. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  114906. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  114907. */
  114908. AmmoJSPlugin.prototype.appendHook = function (impostor, otherImpostor, length, influence, noCollisionBetweenLinkedBodies) {
  114909. if (influence === void 0) { influence = 1; }
  114910. if (noCollisionBetweenLinkedBodies === void 0) { noCollisionBetweenLinkedBodies = false; }
  114911. var node = Math.round(impostor.segments * length);
  114912. impostor.physicsBody.appendAnchor(node, otherImpostor.physicsBody, noCollisionBetweenLinkedBodies, influence);
  114913. };
  114914. /**
  114915. * Sleeps the physics body and stops it from being active
  114916. * @param impostor impostor to sleep
  114917. */
  114918. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  114919. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  114920. };
  114921. /**
  114922. * Activates the physics body
  114923. * @param impostor impostor to activate
  114924. */
  114925. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  114926. impostor.physicsBody.activate();
  114927. };
  114928. /**
  114929. * Updates the distance parameters of the joint
  114930. * @param joint joint to update
  114931. * @param maxDistance maximum distance of the joint
  114932. * @param minDistance minimum distance of the joint
  114933. */
  114934. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  114935. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  114936. };
  114937. /**
  114938. * Sets a motor on the joint
  114939. * @param joint joint to set motor on
  114940. * @param speed speed of the motor
  114941. * @param maxForce maximum force of the motor
  114942. * @param motorIndex index of the motor
  114943. */
  114944. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  114945. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  114946. };
  114947. /**
  114948. * Sets the motors limit
  114949. * @param joint joint to set limit on
  114950. * @param upperLimit upper limit
  114951. * @param lowerLimit lower limit
  114952. */
  114953. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  114954. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  114955. };
  114956. /**
  114957. * Syncs the position and rotation of a mesh with the impostor
  114958. * @param mesh mesh to sync
  114959. * @param impostor impostor to update the mesh with
  114960. */
  114961. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  114962. var body = impostor.physicsBody;
  114963. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  114964. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  114965. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  114966. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  114967. if (mesh.rotationQuaternion) {
  114968. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  114969. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  114970. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  114971. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  114972. }
  114973. };
  114974. /**
  114975. * Gets the radius of the impostor
  114976. * @param impostor impostor to get radius from
  114977. * @returns the radius
  114978. */
  114979. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  114980. var exntend = impostor.getObjectExtendSize();
  114981. return exntend.x / 2;
  114982. };
  114983. /**
  114984. * Gets the box size of the impostor
  114985. * @param impostor impostor to get box size from
  114986. * @param result the resulting box size
  114987. */
  114988. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  114989. var exntend = impostor.getObjectExtendSize();
  114990. result.x = exntend.x;
  114991. result.y = exntend.y;
  114992. result.z = exntend.z;
  114993. };
  114994. /**
  114995. * Disposes of the impostor
  114996. */
  114997. AmmoJSPlugin.prototype.dispose = function () {
  114998. // Dispose of world
  114999. Ammo.destroy(this.world);
  115000. Ammo.destroy(this._solver);
  115001. Ammo.destroy(this._overlappingPairCache);
  115002. Ammo.destroy(this._dispatcher);
  115003. Ammo.destroy(this._collisionConfiguration);
  115004. // Dispose of tmp variables
  115005. Ammo.destroy(this._tmpAmmoVectorA);
  115006. Ammo.destroy(this._tmpAmmoVectorB);
  115007. Ammo.destroy(this._tmpAmmoVectorC);
  115008. Ammo.destroy(this._tmpAmmoTransform);
  115009. Ammo.destroy(this._tmpAmmoQuaternion);
  115010. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  115011. this.world = null;
  115012. };
  115013. /**
  115014. * Does a raycast in the physics world
  115015. * @param from when should the ray start?
  115016. * @param to when should the ray end?
  115017. * @returns PhysicsRaycastResult
  115018. */
  115019. AmmoJSPlugin.prototype.raycast = function (from, to) {
  115020. this._tmpAmmoVectorRCA = new this.bjsAMMO.btVector3(from.x, from.y, from.z);
  115021. this._tmpAmmoVectorRCB = new this.bjsAMMO.btVector3(to.x, to.y, to.z);
  115022. var rayCallback = new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB);
  115023. this.world.rayTest(this._tmpAmmoVectorRCA, this._tmpAmmoVectorRCB, rayCallback);
  115024. this._raycastResult.reset(from, to);
  115025. if (rayCallback.hasHit()) {
  115026. // TODO: do we want/need the body? If so, set all the data
  115027. /*
  115028. var rigidBody = this.bjsAMMO.btRigidBody.prototype.upcast(
  115029. rayCallback.get_m_collisionObject()
  115030. );
  115031. var body = {};
  115032. */
  115033. this._raycastResult.setHitData({
  115034. x: rayCallback.get_m_hitNormalWorld().x(),
  115035. y: rayCallback.get_m_hitNormalWorld().y(),
  115036. z: rayCallback.get_m_hitNormalWorld().z(),
  115037. }, {
  115038. x: rayCallback.get_m_hitPointWorld().x(),
  115039. y: rayCallback.get_m_hitPointWorld().y(),
  115040. z: rayCallback.get_m_hitPointWorld().z(),
  115041. });
  115042. this._raycastResult.calculateHitDistance();
  115043. }
  115044. return this._raycastResult;
  115045. };
  115046. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  115047. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  115048. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  115049. return AmmoJSPlugin;
  115050. }());
  115051. /***/ }),
  115052. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  115053. /*!*******************************************!*\
  115054. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  115055. \*******************************************/
  115056. /*! exports provided: CannonJSPlugin */
  115057. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115058. "use strict";
  115059. __webpack_require__.r(__webpack_exports__);
  115060. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  115061. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  115062. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  115063. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  115064. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  115065. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  115066. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  115067. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  115068. /** @hidden */
  115069. var CannonJSPlugin = /** @class */ (function () {
  115070. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  115071. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  115072. if (iterations === void 0) { iterations = 10; }
  115073. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  115074. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  115075. this.name = "CannonJSPlugin";
  115076. this._physicsMaterials = new Array();
  115077. this._fixedTimeStep = 1 / 60;
  115078. this._removeAfterStep = new Array();
  115079. this._minus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  115080. this._plus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  115081. this._tmpPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  115082. this._tmpDeltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  115083. this._tmpUnityRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  115084. this.BJSCANNON = cannonInjection;
  115085. if (!this.isSupported()) {
  115086. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  115087. return;
  115088. }
  115089. this._extendNamespace();
  115090. this.world = new this.BJSCANNON.World();
  115091. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  115092. this.world.solver.iterations = iterations;
  115093. this._cannonRaycastResult = new this.BJSCANNON.RaycastResult();
  115094. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_6__["PhysicsRaycastResult"]();
  115095. }
  115096. CannonJSPlugin.prototype.setGravity = function (gravity) {
  115097. this.world.gravity.copy(gravity);
  115098. };
  115099. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  115100. this._fixedTimeStep = timeStep;
  115101. };
  115102. CannonJSPlugin.prototype.getTimeStep = function () {
  115103. return this._fixedTimeStep;
  115104. };
  115105. CannonJSPlugin.prototype.executeStep = function (delta) {
  115106. var _this = this;
  115107. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  115108. if (this._removeAfterStep.length > 0) {
  115109. this._removeAfterStep.forEach(function (impostor) {
  115110. _this.world.remove(impostor.physicsBody);
  115111. });
  115112. this._removeAfterStep = [];
  115113. }
  115114. };
  115115. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  115116. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  115117. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  115118. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  115119. };
  115120. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  115121. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  115122. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  115123. impostor.physicsBody.applyForce(impulse, worldPoint);
  115124. };
  115125. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  115126. //parent-child relationship. Does this impostor has a parent impostor?
  115127. if (impostor.parent) {
  115128. if (impostor.physicsBody) {
  115129. this.removePhysicsBody(impostor);
  115130. //TODO is that needed?
  115131. impostor.forceUpdate();
  115132. }
  115133. return;
  115134. }
  115135. //should a new body be created for this impostor?
  115136. if (impostor.isBodyInitRequired()) {
  115137. var shape = this._createShape(impostor);
  115138. //unregister events, if body is being changed
  115139. var oldBody = impostor.physicsBody;
  115140. if (oldBody) {
  115141. this.removePhysicsBody(impostor);
  115142. }
  115143. //create the body and material
  115144. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  115145. var bodyCreationObject = {
  115146. mass: impostor.getParam("mass"),
  115147. material: material
  115148. };
  115149. // A simple extend, in case native options were used.
  115150. var nativeOptions = impostor.getParam("nativeOptions");
  115151. for (var key in nativeOptions) {
  115152. if (nativeOptions.hasOwnProperty(key)) {
  115153. bodyCreationObject[key] = nativeOptions[key];
  115154. }
  115155. }
  115156. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  115157. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  115158. this.world.addEventListener("preStep", impostor.beforeStep);
  115159. this.world.addEventListener("postStep", impostor.afterStep);
  115160. impostor.physicsBody.addShape(shape);
  115161. this.world.add(impostor.physicsBody);
  115162. //try to keep the body moving in the right direction by taking old properties.
  115163. //Should be tested!
  115164. if (oldBody) {
  115165. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  115166. impostor.physicsBody[param].copy(oldBody[param]);
  115167. });
  115168. }
  115169. this._processChildMeshes(impostor);
  115170. }
  115171. //now update the body's transformation
  115172. this._updatePhysicsBodyTransformation(impostor);
  115173. };
  115174. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  115175. var _this = this;
  115176. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  115177. var currentRotation = mainImpostor.object.rotationQuaternion;
  115178. if (meshChildren.length) {
  115179. var processMesh = function (localPosition, mesh) {
  115180. if (!currentRotation || !mesh.rotationQuaternion) {
  115181. return;
  115182. }
  115183. var childImpostor = mesh.getPhysicsImpostor();
  115184. if (childImpostor) {
  115185. var parent = childImpostor.parent;
  115186. if (parent !== mainImpostor) {
  115187. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  115188. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  115189. if (childImpostor.physicsBody) {
  115190. _this.removePhysicsBody(childImpostor);
  115191. childImpostor.physicsBody = null;
  115192. }
  115193. childImpostor.parent = mainImpostor;
  115194. childImpostor.resetUpdateFlags();
  115195. 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));
  115196. //Add the mass of the children.
  115197. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  115198. }
  115199. }
  115200. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  115201. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  115202. };
  115203. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  115204. }
  115205. };
  115206. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  115207. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  115208. this.world.removeEventListener("preStep", impostor.beforeStep);
  115209. this.world.removeEventListener("postStep", impostor.afterStep);
  115210. // Only remove the physics body after the physics step to avoid disrupting cannon's internal state
  115211. this._removeAfterStep.push(impostor);
  115212. };
  115213. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  115214. var mainBody = impostorJoint.mainImpostor.physicsBody;
  115215. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  115216. if (!mainBody || !connectedBody) {
  115217. return;
  115218. }
  115219. var constraint;
  115220. var jointData = impostorJoint.joint.jointData;
  115221. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  115222. var constraintData = {
  115223. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  115224. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  115225. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  115226. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  115227. maxForce: jointData.nativeParams.maxForce,
  115228. collideConnected: !!jointData.collision
  115229. };
  115230. switch (impostorJoint.joint.type) {
  115231. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  115232. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  115233. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  115234. break;
  115235. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  115236. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  115237. break;
  115238. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  115239. var springData = jointData;
  115240. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  115241. restLength: springData.length,
  115242. stiffness: springData.stiffness,
  115243. damping: springData.damping,
  115244. localAnchorA: constraintData.pivotA,
  115245. localAnchorB: constraintData.pivotB
  115246. });
  115247. break;
  115248. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  115249. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  115250. break;
  115251. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  115252. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  115253. default:
  115254. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  115255. break;
  115256. }
  115257. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  115258. constraint.collideConnected = !!jointData.collision;
  115259. impostorJoint.joint.physicsJoint = constraint;
  115260. //don't add spring as constraint, as it is not one.
  115261. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  115262. this.world.addConstraint(constraint);
  115263. }
  115264. else {
  115265. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  115266. constraint.applyForce();
  115267. };
  115268. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  115269. }
  115270. };
  115271. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  115272. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  115273. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  115274. }
  115275. else {
  115276. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  115277. }
  115278. };
  115279. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  115280. var index;
  115281. var mat;
  115282. for (index = 0; index < this._physicsMaterials.length; index++) {
  115283. mat = this._physicsMaterials[index];
  115284. if (mat.friction === friction && mat.restitution === restitution) {
  115285. return mat;
  115286. }
  115287. }
  115288. var currentMat = new this.BJSCANNON.Material(name);
  115289. currentMat.friction = friction;
  115290. currentMat.restitution = restitution;
  115291. this._physicsMaterials.push(currentMat);
  115292. return currentMat;
  115293. };
  115294. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  115295. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  115296. };
  115297. CannonJSPlugin.prototype._createShape = function (impostor) {
  115298. var object = impostor.object;
  115299. var returnValue;
  115300. var extendSize = impostor.getObjectExtendSize();
  115301. switch (impostor.type) {
  115302. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  115303. var radiusX = extendSize.x;
  115304. var radiusY = extendSize.y;
  115305. var radiusZ = extendSize.z;
  115306. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  115307. break;
  115308. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  115309. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  115310. var nativeParams = impostor.getParam("nativeOptions");
  115311. if (!nativeParams) {
  115312. nativeParams = {};
  115313. }
  115314. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  115315. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  115316. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y);
  115317. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  115318. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  115319. // Rotate 90 degrees as this shape is horizontal in cannon
  115320. var quat = new this.BJSCANNON.Quaternion();
  115321. quat.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);
  115322. var translation = new this.BJSCANNON.Vec3(0, 0, 0);
  115323. returnValue.transformAllPoints(translation, quat);
  115324. break;
  115325. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  115326. var box = extendSize.scale(0.5);
  115327. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  115328. break;
  115329. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  115330. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  115331. returnValue = new this.BJSCANNON.Plane();
  115332. break;
  115333. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  115334. // should transform the vertex data to world coordinates!!
  115335. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  115336. var rawFaces = object.getIndices ? object.getIndices() : [];
  115337. if (!rawVerts) {
  115338. return;
  115339. }
  115340. // get only scale! so the object could transform correctly.
  115341. var oldPosition = object.position.clone();
  115342. var oldRotation = object.rotation && object.rotation.clone();
  115343. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  115344. object.position.copyFromFloats(0, 0, 0);
  115345. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  115346. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  115347. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  115348. var transform = object.computeWorldMatrix(true);
  115349. // convert rawVerts to object space
  115350. var temp = new Array();
  115351. var index;
  115352. for (index = 0; index < rawVerts.length; index += 3) {
  115353. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  115354. }
  115355. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  115356. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  115357. //now set back the transformation!
  115358. object.position.copyFrom(oldPosition);
  115359. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  115360. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  115361. break;
  115362. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  115363. var oldPosition2 = object.position.clone();
  115364. var oldRotation2 = object.rotation && object.rotation.clone();
  115365. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  115366. object.position.copyFromFloats(0, 0, 0);
  115367. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  115368. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  115369. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  115370. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  115371. returnValue = this._createHeightmap(object);
  115372. object.position.copyFrom(oldPosition2);
  115373. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  115374. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  115375. object.computeWorldMatrix(true);
  115376. break;
  115377. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  115378. returnValue = new this.BJSCANNON.Particle();
  115379. break;
  115380. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].NoImpostor:
  115381. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));
  115382. break;
  115383. }
  115384. return returnValue;
  115385. };
  115386. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  115387. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  115388. var transform = object.computeWorldMatrix(true);
  115389. // convert rawVerts to object space
  115390. var temp = new Array();
  115391. var index;
  115392. for (index = 0; index < pos.length; index += 3) {
  115393. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  115394. }
  115395. pos = temp;
  115396. var matrix = new Array();
  115397. //For now pointDepth will not be used and will be automatically calculated.
  115398. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  115399. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  115400. var boundingInfo = object.getBoundingInfo();
  115401. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  115402. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  115403. var elementSize = dim * 2 / arraySize;
  115404. for (var i = 0; i < pos.length; i = i + 3) {
  115405. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  115406. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  115407. var y = -pos[i + 2] + minY;
  115408. if (!matrix[x]) {
  115409. matrix[x] = [];
  115410. }
  115411. if (!matrix[x][z]) {
  115412. matrix[x][z] = y;
  115413. }
  115414. matrix[x][z] = Math.max(y, matrix[x][z]);
  115415. }
  115416. for (var x = 0; x <= arraySize; ++x) {
  115417. if (!matrix[x]) {
  115418. var loc = 1;
  115419. while (!matrix[(x + loc) % arraySize]) {
  115420. loc++;
  115421. }
  115422. matrix[x] = matrix[(x + loc) % arraySize].slice();
  115423. //console.log("missing x", x);
  115424. }
  115425. for (var z = 0; z <= arraySize; ++z) {
  115426. if (!matrix[x][z]) {
  115427. var loc = 1;
  115428. var newValue;
  115429. while (newValue === undefined) {
  115430. newValue = matrix[x][(z + loc++) % arraySize];
  115431. }
  115432. matrix[x][z] = newValue;
  115433. }
  115434. }
  115435. }
  115436. var shape = new this.BJSCANNON.Heightfield(matrix, {
  115437. elementSize: elementSize
  115438. });
  115439. //For future reference, needed for body transformation
  115440. shape.minY = minY;
  115441. return shape;
  115442. };
  115443. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  115444. var object = impostor.object;
  115445. //make sure it is updated...
  115446. object.computeWorldMatrix && object.computeWorldMatrix(true);
  115447. // The delta between the mesh position and the mesh bounding box center
  115448. var bInfo = object.getBoundingInfo();
  115449. if (!bInfo) {
  115450. return;
  115451. }
  115452. var center = impostor.getObjectCenter();
  115453. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  115454. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  115455. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  115456. this._tmpPosition.copyFrom(center);
  115457. var quaternion = object.rotationQuaternion;
  115458. if (!quaternion) {
  115459. return;
  115460. }
  115461. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  115462. //ideally these would be rotated at time of creation like cylinder but they dont extend ConvexPolyhedron
  115463. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  115464. //-90 DEG in X, precalculated
  115465. quaternion = quaternion.multiply(this._minus90X);
  115466. //Invert! (Precalculated, 90 deg in X)
  115467. //No need to clone. this will never change.
  115468. impostor.setDeltaRotation(this._plus90X);
  115469. }
  115470. //If it is a heightfield, if should be centered.
  115471. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  115472. var mesh = object;
  115473. var boundingInfo = mesh.getBoundingInfo();
  115474. //calculate the correct body position:
  115475. var rotationQuaternion = mesh.rotationQuaternion;
  115476. mesh.rotationQuaternion = this._tmpUnityRotation;
  115477. mesh.computeWorldMatrix(true);
  115478. //get original center with no rotation
  115479. var c = center.clone();
  115480. var oldPivot = mesh.getPivotMatrix();
  115481. if (oldPivot) {
  115482. // create a copy the pivot Matrix as it is modified in place
  115483. oldPivot = oldPivot.clone();
  115484. }
  115485. else {
  115486. oldPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  115487. }
  115488. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  115489. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  115490. mesh.setPreTransformMatrix(p);
  115491. mesh.computeWorldMatrix(true);
  115492. //calculate the translation
  115493. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  115494. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  115495. //add it inverted to the delta
  115496. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  115497. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  115498. //rotation is back
  115499. mesh.rotationQuaternion = rotationQuaternion;
  115500. mesh.setPreTransformMatrix(oldPivot);
  115501. mesh.computeWorldMatrix(true);
  115502. }
  115503. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  115504. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  115505. //this._tmpPosition.copyFrom(object.position);
  115506. }
  115507. impostor.setDeltaPosition(this._tmpDeltaPosition);
  115508. //Now update the impostor object
  115509. impostor.physicsBody.position.copy(this._tmpPosition);
  115510. impostor.physicsBody.quaternion.copy(quaternion);
  115511. };
  115512. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  115513. impostor.object.position.copyFrom(impostor.physicsBody.position);
  115514. if (impostor.object.rotationQuaternion) {
  115515. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  115516. }
  115517. };
  115518. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  115519. impostor.physicsBody.position.copy(newPosition);
  115520. impostor.physicsBody.quaternion.copy(newRotation);
  115521. };
  115522. CannonJSPlugin.prototype.isSupported = function () {
  115523. return this.BJSCANNON !== undefined;
  115524. };
  115525. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  115526. impostor.physicsBody.velocity.copy(velocity);
  115527. };
  115528. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  115529. impostor.physicsBody.angularVelocity.copy(velocity);
  115530. };
  115531. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  115532. var v = impostor.physicsBody.velocity;
  115533. if (!v) {
  115534. return null;
  115535. }
  115536. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  115537. };
  115538. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  115539. var v = impostor.physicsBody.angularVelocity;
  115540. if (!v) {
  115541. return null;
  115542. }
  115543. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  115544. };
  115545. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  115546. impostor.physicsBody.mass = mass;
  115547. impostor.physicsBody.updateMassProperties();
  115548. };
  115549. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  115550. return impostor.physicsBody.mass;
  115551. };
  115552. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  115553. return impostor.physicsBody.material.friction;
  115554. };
  115555. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  115556. impostor.physicsBody.material.friction = friction;
  115557. };
  115558. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  115559. return impostor.physicsBody.material.restitution;
  115560. };
  115561. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  115562. impostor.physicsBody.material.restitution = restitution;
  115563. };
  115564. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  115565. impostor.physicsBody.sleep();
  115566. };
  115567. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  115568. impostor.physicsBody.wakeUp();
  115569. };
  115570. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  115571. joint.physicsJoint.distance = maxDistance;
  115572. };
  115573. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  115574. // if (!motorIndex) {
  115575. // joint.physicsJoint.enableMotor();
  115576. // }
  115577. // }
  115578. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  115579. // if (!motorIndex) {
  115580. // joint.physicsJoint.disableMotor();
  115581. // }
  115582. // }
  115583. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  115584. if (!motorIndex) {
  115585. joint.physicsJoint.enableMotor();
  115586. joint.physicsJoint.setMotorSpeed(speed);
  115587. if (maxForce) {
  115588. this.setLimit(joint, maxForce);
  115589. }
  115590. }
  115591. };
  115592. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  115593. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  115594. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  115595. };
  115596. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  115597. var body = impostor.physicsBody;
  115598. mesh.position.x = body.position.x;
  115599. mesh.position.y = body.position.y;
  115600. mesh.position.z = body.position.z;
  115601. if (mesh.rotationQuaternion) {
  115602. mesh.rotationQuaternion.x = body.quaternion.x;
  115603. mesh.rotationQuaternion.y = body.quaternion.y;
  115604. mesh.rotationQuaternion.z = body.quaternion.z;
  115605. mesh.rotationQuaternion.w = body.quaternion.w;
  115606. }
  115607. };
  115608. CannonJSPlugin.prototype.getRadius = function (impostor) {
  115609. var shape = impostor.physicsBody.shapes[0];
  115610. return shape.boundingSphereRadius;
  115611. };
  115612. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  115613. var shape = impostor.physicsBody.shapes[0];
  115614. result.x = shape.halfExtents.x * 2;
  115615. result.y = shape.halfExtents.y * 2;
  115616. result.z = shape.halfExtents.z * 2;
  115617. };
  115618. CannonJSPlugin.prototype.dispose = function () {
  115619. };
  115620. CannonJSPlugin.prototype._extendNamespace = function () {
  115621. //this will force cannon to execute at least one step when using interpolation
  115622. var step_tmp1 = new this.BJSCANNON.Vec3();
  115623. var Engine = this.BJSCANNON;
  115624. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  115625. maxSubSteps = maxSubSteps || 10;
  115626. timeSinceLastCalled = timeSinceLastCalled || 0;
  115627. if (timeSinceLastCalled === 0) {
  115628. this.internalStep(dt);
  115629. this.time += dt;
  115630. }
  115631. else {
  115632. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  115633. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  115634. var t0 = performance.now();
  115635. for (var i = 0; i !== internalSteps; i++) {
  115636. this.internalStep(dt);
  115637. if (performance.now() - t0 > dt * 1000) {
  115638. break;
  115639. }
  115640. }
  115641. this.time += timeSinceLastCalled;
  115642. var h = this.time % dt;
  115643. var h_div_dt = h / dt;
  115644. var interpvelo = step_tmp1;
  115645. var bodies = this.bodies;
  115646. for (var j = 0; j !== bodies.length; j++) {
  115647. var b = bodies[j];
  115648. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  115649. b.position.vsub(b.previousPosition, interpvelo);
  115650. interpvelo.scale(h_div_dt, interpvelo);
  115651. b.position.vadd(interpvelo, b.interpolatedPosition);
  115652. }
  115653. else {
  115654. b.interpolatedPosition.copy(b.position);
  115655. b.interpolatedQuaternion.copy(b.quaternion);
  115656. }
  115657. }
  115658. }
  115659. };
  115660. };
  115661. /**
  115662. * Does a raycast in the physics world
  115663. * @param from when should the ray start?
  115664. * @param to when should the ray end?
  115665. * @returns PhysicsRaycastResult
  115666. */
  115667. CannonJSPlugin.prototype.raycast = function (from, to) {
  115668. this._cannonRaycastResult.reset();
  115669. this.world.raycastClosest(from, to, {}, this._cannonRaycastResult);
  115670. this._raycastResult.reset(from, to);
  115671. if (this._cannonRaycastResult.hasHit) {
  115672. // TODO: do we also want to get the body it hit?
  115673. this._raycastResult.setHitData({
  115674. x: this._cannonRaycastResult.hitNormalWorld.x,
  115675. y: this._cannonRaycastResult.hitNormalWorld.y,
  115676. z: this._cannonRaycastResult.hitNormalWorld.z,
  115677. }, {
  115678. x: this._cannonRaycastResult.hitPointWorld.x,
  115679. y: this._cannonRaycastResult.hitPointWorld.y,
  115680. z: this._cannonRaycastResult.hitPointWorld.z,
  115681. });
  115682. this._raycastResult.setHitDistance(this._cannonRaycastResult.distance);
  115683. }
  115684. return this._raycastResult;
  115685. };
  115686. return CannonJSPlugin;
  115687. }());
  115688. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  115689. /***/ }),
  115690. /***/ "./Physics/Plugins/index.ts":
  115691. /*!**********************************!*\
  115692. !*** ./Physics/Plugins/index.ts ***!
  115693. \**********************************/
  115694. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  115695. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115696. "use strict";
  115697. __webpack_require__.r(__webpack_exports__);
  115698. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  115699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  115700. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  115701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  115702. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  115703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  115704. /***/ }),
  115705. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  115706. /*!*****************************************!*\
  115707. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  115708. \*****************************************/
  115709. /*! exports provided: OimoJSPlugin */
  115710. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115711. "use strict";
  115712. __webpack_require__.r(__webpack_exports__);
  115713. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  115714. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  115715. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  115716. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  115717. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  115718. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  115719. /* harmony import */ var _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../physicsRaycastResult */ "./Physics/physicsRaycastResult.ts");
  115720. /** @hidden */
  115721. var OimoJSPlugin = /** @class */ (function () {
  115722. function OimoJSPlugin(iterations, oimoInjection) {
  115723. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  115724. this.name = "OimoJSPlugin";
  115725. this._tmpImpostorsArray = [];
  115726. this._tmpPositionVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  115727. this.BJSOIMO = oimoInjection;
  115728. this.world = new this.BJSOIMO.World({
  115729. iterations: iterations
  115730. });
  115731. this.world.clear();
  115732. this._raycastResult = new _physicsRaycastResult__WEBPACK_IMPORTED_MODULE_5__["PhysicsRaycastResult"]();
  115733. }
  115734. OimoJSPlugin.prototype.setGravity = function (gravity) {
  115735. this.world.gravity.copy(gravity);
  115736. };
  115737. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  115738. this.world.timeStep = timeStep;
  115739. };
  115740. OimoJSPlugin.prototype.getTimeStep = function () {
  115741. return this.world.timeStep;
  115742. };
  115743. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  115744. var _this = this;
  115745. impostors.forEach(function (impostor) {
  115746. impostor.beforeStep();
  115747. });
  115748. this.world.step();
  115749. impostors.forEach(function (impostor) {
  115750. impostor.afterStep();
  115751. //update the ordered impostors array
  115752. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  115753. });
  115754. //check for collisions
  115755. var contact = this.world.contacts;
  115756. while (contact !== null) {
  115757. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  115758. contact = contact.next;
  115759. continue;
  115760. }
  115761. //is this body colliding with any other? get the impostor
  115762. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  115763. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  115764. if (!mainImpostor || !collidingImpostor) {
  115765. contact = contact.next;
  115766. continue;
  115767. }
  115768. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  115769. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  115770. contact = contact.next;
  115771. }
  115772. };
  115773. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  115774. var mass = impostor.physicsBody.mass;
  115775. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  115776. };
  115777. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  115778. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  115779. this.applyImpulse(impostor, force, contactPoint);
  115780. };
  115781. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  115782. var _this = this;
  115783. //parent-child relationship. Does this impostor has a parent impostor?
  115784. if (impostor.parent) {
  115785. if (impostor.physicsBody) {
  115786. this.removePhysicsBody(impostor);
  115787. //TODO is that needed?
  115788. impostor.forceUpdate();
  115789. }
  115790. return;
  115791. }
  115792. if (impostor.isBodyInitRequired()) {
  115793. var bodyConfig = {
  115794. name: impostor.uniqueId,
  115795. //Oimo must have mass, also for static objects.
  115796. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  115797. size: [],
  115798. type: [],
  115799. pos: [],
  115800. posShape: [],
  115801. rot: [],
  115802. rotShape: [],
  115803. move: impostor.getParam("mass") !== 0,
  115804. density: impostor.getParam("mass"),
  115805. friction: impostor.getParam("friction"),
  115806. restitution: impostor.getParam("restitution"),
  115807. //Supporting older versions of Oimo
  115808. world: this.world
  115809. };
  115810. var impostors = [impostor];
  115811. var addToArray = function (parent) {
  115812. if (!parent.getChildMeshes) {
  115813. return;
  115814. }
  115815. parent.getChildMeshes().forEach(function (m) {
  115816. if (m.physicsImpostor) {
  115817. impostors.push(m.physicsImpostor);
  115818. //m.physicsImpostor._init();
  115819. }
  115820. });
  115821. };
  115822. addToArray(impostor.object);
  115823. var checkWithEpsilon_1 = function (value) {
  115824. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  115825. };
  115826. var globalQuaternion_1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  115827. impostors.forEach(function (i) {
  115828. if (!i.object.rotationQuaternion) {
  115829. return;
  115830. }
  115831. //get the correct bounding box
  115832. var oldQuaternion = i.object.rotationQuaternion;
  115833. globalQuaternion_1 = oldQuaternion.clone();
  115834. var rot = oldQuaternion.toEulerAngles();
  115835. var extendSize = i.getObjectExtendSize();
  115836. var radToDeg = 57.295779513082320876;
  115837. if (i === impostor) {
  115838. var center = impostor.getObjectCenter();
  115839. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  115840. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  115841. //Can also use Array.prototype.push.apply
  115842. bodyConfig.pos.push(center.x);
  115843. bodyConfig.pos.push(center.y);
  115844. bodyConfig.pos.push(center.z);
  115845. bodyConfig.posShape.push(0, 0, 0);
  115846. bodyConfig.rotShape.push(0, 0, 0);
  115847. }
  115848. else {
  115849. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  115850. bodyConfig.posShape.push(localPosition.x);
  115851. bodyConfig.posShape.push(localPosition.y);
  115852. bodyConfig.posShape.push(localPosition.z);
  115853. bodyConfig.pos.push(0, 0, 0);
  115854. bodyConfig.rotShape.push(rot.x * radToDeg);
  115855. bodyConfig.rotShape.push(rot.y * radToDeg);
  115856. bodyConfig.rotShape.push(rot.z * radToDeg);
  115857. }
  115858. // register mesh
  115859. switch (i.type) {
  115860. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  115861. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  115862. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  115863. var radiusX = extendSize.x;
  115864. var radiusY = extendSize.y;
  115865. var radiusZ = extendSize.z;
  115866. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  115867. bodyConfig.type.push('sphere');
  115868. //due to the way oimo works with compounds, add 3 times
  115869. bodyConfig.size.push(size);
  115870. bodyConfig.size.push(size);
  115871. bodyConfig.size.push(size);
  115872. break;
  115873. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  115874. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  115875. var sizeY = checkWithEpsilon_1(extendSize.y);
  115876. bodyConfig.type.push('cylinder');
  115877. bodyConfig.size.push(sizeX);
  115878. bodyConfig.size.push(sizeY);
  115879. //due to the way oimo works with compounds, add one more value.
  115880. bodyConfig.size.push(sizeY);
  115881. break;
  115882. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  115883. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  115884. default:
  115885. var sizeX = checkWithEpsilon_1(extendSize.x);
  115886. var sizeY = checkWithEpsilon_1(extendSize.y);
  115887. var sizeZ = checkWithEpsilon_1(extendSize.z);
  115888. bodyConfig.type.push('box');
  115889. //if (i === impostor) {
  115890. bodyConfig.size.push(sizeX);
  115891. bodyConfig.size.push(sizeY);
  115892. bodyConfig.size.push(sizeZ);
  115893. //} else {
  115894. // bodyConfig.size.push(0,0,0);
  115895. //}
  115896. break;
  115897. }
  115898. //actually not needed, but hey...
  115899. i.object.rotationQuaternion = oldQuaternion;
  115900. });
  115901. impostor.physicsBody = this.world.add(bodyConfig);
  115902. // set the quaternion, ignoring the previously defined (euler) rotation
  115903. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  115904. // update with delta 0, so the body will reveive the new rotation.
  115905. impostor.physicsBody.updatePosition(0);
  115906. }
  115907. else {
  115908. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  115909. }
  115910. impostor.setDeltaPosition(this._tmpPositionVector);
  115911. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  115912. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  115913. };
  115914. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  115915. //impostor.physicsBody.dispose();
  115916. //Same as : (older oimo versions)
  115917. this.world.removeRigidBody(impostor.physicsBody);
  115918. };
  115919. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  115920. var mainBody = impostorJoint.mainImpostor.physicsBody;
  115921. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  115922. if (!mainBody || !connectedBody) {
  115923. return;
  115924. }
  115925. var jointData = impostorJoint.joint.jointData;
  115926. var options = jointData.nativeParams || {};
  115927. var type;
  115928. var nativeJointData = {
  115929. body1: mainBody,
  115930. body2: connectedBody,
  115931. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  115932. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  115933. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  115934. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  115935. min: options.min,
  115936. max: options.max,
  115937. collision: options.collision || jointData.collision,
  115938. spring: options.spring,
  115939. //supporting older version of Oimo
  115940. world: this.world
  115941. };
  115942. switch (impostorJoint.joint.type) {
  115943. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  115944. type = "jointBall";
  115945. break;
  115946. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  115947. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  115948. var springData = jointData;
  115949. nativeJointData.min = springData.length || nativeJointData.min;
  115950. //Max should also be set, just make sure it is at least min
  115951. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  115952. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  115953. type = "jointDistance";
  115954. nativeJointData.max = jointData.maxDistance;
  115955. break;
  115956. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  115957. type = "jointPrisme";
  115958. break;
  115959. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  115960. type = "jointSlide";
  115961. break;
  115962. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  115963. type = "jointWheel";
  115964. break;
  115965. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  115966. default:
  115967. type = "jointHinge";
  115968. break;
  115969. }
  115970. nativeJointData.type = type;
  115971. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  115972. };
  115973. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  115974. //Bug in Oimo prevents us from disposing a joint in the playground
  115975. //joint.joint.physicsJoint.dispose();
  115976. //So we will bruteforce it!
  115977. try {
  115978. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  115979. }
  115980. catch (e) {
  115981. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  115982. }
  115983. };
  115984. OimoJSPlugin.prototype.isSupported = function () {
  115985. return this.BJSOIMO !== undefined;
  115986. };
  115987. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  115988. if (!impostor.physicsBody.sleeping) {
  115989. //TODO check that
  115990. /*if (impostor.physicsBody.shapes.next) {
  115991. var parentShape = this._getLastShape(impostor.physicsBody);
  115992. impostor.object.position.copyFrom(parentShape.position);
  115993. console.log(parentShape.position);
  115994. } else {*/
  115995. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  115996. //}
  115997. if (impostor.object.rotationQuaternion) {
  115998. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  115999. }
  116000. }
  116001. };
  116002. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  116003. var body = impostor.physicsBody;
  116004. body.position.copy(newPosition);
  116005. body.orientation.copy(newRotation);
  116006. body.syncShapes();
  116007. body.awake();
  116008. };
  116009. /*private _getLastShape(body: any): any {
  116010. var lastShape = body.shapes;
  116011. while (lastShape.next) {
  116012. lastShape = lastShape.next;
  116013. }
  116014. return lastShape;
  116015. }*/
  116016. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  116017. impostor.physicsBody.linearVelocity.copy(velocity);
  116018. };
  116019. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  116020. impostor.physicsBody.angularVelocity.copy(velocity);
  116021. };
  116022. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  116023. var v = impostor.physicsBody.linearVelocity;
  116024. if (!v) {
  116025. return null;
  116026. }
  116027. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  116028. };
  116029. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  116030. var v = impostor.physicsBody.angularVelocity;
  116031. if (!v) {
  116032. return null;
  116033. }
  116034. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  116035. };
  116036. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  116037. var staticBody = mass === 0;
  116038. //this will actually set the body's density and not its mass.
  116039. //But this is how oimo treats the mass variable.
  116040. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  116041. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  116042. };
  116043. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  116044. return impostor.physicsBody.shapes.density;
  116045. };
  116046. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  116047. return impostor.physicsBody.shapes.friction;
  116048. };
  116049. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  116050. impostor.physicsBody.shapes.friction = friction;
  116051. };
  116052. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  116053. return impostor.physicsBody.shapes.restitution;
  116054. };
  116055. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  116056. impostor.physicsBody.shapes.restitution = restitution;
  116057. };
  116058. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  116059. impostor.physicsBody.sleep();
  116060. };
  116061. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  116062. impostor.physicsBody.awake();
  116063. };
  116064. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  116065. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  116066. if (minDistance !== void 0) {
  116067. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  116068. }
  116069. };
  116070. OimoJSPlugin.prototype.setMotor = function (joint, speed, force, motorIndex) {
  116071. if (force !== undefined) {
  116072. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter");
  116073. }
  116074. else {
  116075. force = 1e6;
  116076. }
  116077. speed *= -1;
  116078. //TODO separate rotational and transational motors.
  116079. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  116080. if (motor) {
  116081. motor.setMotor(speed, force);
  116082. }
  116083. };
  116084. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  116085. //TODO separate rotational and transational motors.
  116086. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  116087. if (motor) {
  116088. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  116089. }
  116090. };
  116091. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  116092. var body = impostor.physicsBody;
  116093. mesh.position.x = body.position.x;
  116094. mesh.position.y = body.position.y;
  116095. mesh.position.z = body.position.z;
  116096. if (mesh.rotationQuaternion) {
  116097. mesh.rotationQuaternion.x = body.orientation.x;
  116098. mesh.rotationQuaternion.y = body.orientation.y;
  116099. mesh.rotationQuaternion.z = body.orientation.z;
  116100. mesh.rotationQuaternion.w = body.orientation.s;
  116101. }
  116102. };
  116103. OimoJSPlugin.prototype.getRadius = function (impostor) {
  116104. return impostor.physicsBody.shapes.radius;
  116105. };
  116106. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  116107. var shape = impostor.physicsBody.shapes;
  116108. result.x = shape.halfWidth * 2;
  116109. result.y = shape.halfHeight * 2;
  116110. result.z = shape.halfDepth * 2;
  116111. };
  116112. OimoJSPlugin.prototype.dispose = function () {
  116113. this.world.clear();
  116114. };
  116115. /**
  116116. * Does a raycast in the physics world
  116117. * @param from when should the ray start?
  116118. * @param to when should the ray end?
  116119. * @returns PhysicsRaycastResult
  116120. */
  116121. OimoJSPlugin.prototype.raycast = function (from, to) {
  116122. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("raycast is not currently supported by the Oimo physics plugin");
  116123. this._raycastResult.reset(from, to);
  116124. return this._raycastResult;
  116125. };
  116126. return OimoJSPlugin;
  116127. }());
  116128. /***/ }),
  116129. /***/ "./Physics/index.ts":
  116130. /*!**************************!*\
  116131. !*** ./Physics/index.ts ***!
  116132. \**************************/
  116133. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  116134. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116135. "use strict";
  116136. __webpack_require__.r(__webpack_exports__);
  116137. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  116138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  116139. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  116140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  116141. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  116142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  116143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEventOptions"]; });
  116144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEventOptions"]; });
  116145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEventOptions"]; });
  116146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  116147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  116148. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  116149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  116150. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  116151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  116152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  116153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  116154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  116155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  116156. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  116157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  116158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  116159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  116160. /***/ }),
  116161. /***/ "./Physics/physicsEngine.ts":
  116162. /*!**********************************!*\
  116163. !*** ./Physics/physicsEngine.ts ***!
  116164. \**********************************/
  116165. /*! exports provided: PhysicsEngine */
  116166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116167. "use strict";
  116168. __webpack_require__.r(__webpack_exports__);
  116169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return PhysicsEngine; });
  116170. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116171. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  116172. /**
  116173. * Class used to control physics engine
  116174. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116175. */
  116176. var PhysicsEngine = /** @class */ (function () {
  116177. /**
  116178. * Creates a new Physics Engine
  116179. * @param gravity defines the gravity vector used by the simulation
  116180. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  116181. */
  116182. function PhysicsEngine(gravity, _physicsPlugin) {
  116183. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  116184. this._physicsPlugin = _physicsPlugin;
  116185. this._impostors = [];
  116186. this._joints = [];
  116187. if (!this._physicsPlugin.isSupported()) {
  116188. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  116189. + "Please make sure it is included.");
  116190. }
  116191. gravity = gravity || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  116192. this.setGravity(gravity);
  116193. this.setTimeStep();
  116194. }
  116195. /**
  116196. * Factory used to create the default physics plugin.
  116197. * @returns The default physics plugin
  116198. */
  116199. PhysicsEngine.DefaultPluginFactory = function () {
  116200. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__["_DevTools"].WarnImport("CannonJSPlugin");
  116201. };
  116202. /**
  116203. * Sets the gravity vector used by the simulation
  116204. * @param gravity defines the gravity vector to use
  116205. */
  116206. PhysicsEngine.prototype.setGravity = function (gravity) {
  116207. this.gravity = gravity;
  116208. this._physicsPlugin.setGravity(this.gravity);
  116209. };
  116210. /**
  116211. * Set the time step of the physics engine.
  116212. * Default is 1/60.
  116213. * To slow it down, enter 1/600 for example.
  116214. * To speed it up, 1/30
  116215. * @param newTimeStep defines the new timestep to apply to this world.
  116216. */
  116217. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  116218. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  116219. this._physicsPlugin.setTimeStep(newTimeStep);
  116220. };
  116221. /**
  116222. * Get the time step of the physics engine.
  116223. * @returns the current time step
  116224. */
  116225. PhysicsEngine.prototype.getTimeStep = function () {
  116226. return this._physicsPlugin.getTimeStep();
  116227. };
  116228. /**
  116229. * Release all resources
  116230. */
  116231. PhysicsEngine.prototype.dispose = function () {
  116232. this._impostors.forEach(function (impostor) {
  116233. impostor.dispose();
  116234. });
  116235. this._physicsPlugin.dispose();
  116236. };
  116237. /**
  116238. * Gets the name of the current physics plugin
  116239. * @returns the name of the plugin
  116240. */
  116241. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  116242. return this._physicsPlugin.name;
  116243. };
  116244. /**
  116245. * Adding a new impostor for the impostor tracking.
  116246. * This will be done by the impostor itself.
  116247. * @param impostor the impostor to add
  116248. */
  116249. PhysicsEngine.prototype.addImpostor = function (impostor) {
  116250. impostor.uniqueId = this._impostors.push(impostor);
  116251. //if no parent, generate the body
  116252. if (!impostor.parent) {
  116253. this._physicsPlugin.generatePhysicsBody(impostor);
  116254. }
  116255. };
  116256. /**
  116257. * Remove an impostor from the engine.
  116258. * This impostor and its mesh will not longer be updated by the physics engine.
  116259. * @param impostor the impostor to remove
  116260. */
  116261. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  116262. var index = this._impostors.indexOf(impostor);
  116263. if (index > -1) {
  116264. var removed = this._impostors.splice(index, 1);
  116265. //Is it needed?
  116266. if (removed.length) {
  116267. this.getPhysicsPlugin().removePhysicsBody(impostor);
  116268. }
  116269. }
  116270. };
  116271. /**
  116272. * Add a joint to the physics engine
  116273. * @param mainImpostor defines the main impostor to which the joint is added.
  116274. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  116275. * @param joint defines the joint that will connect both impostors.
  116276. */
  116277. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  116278. var impostorJoint = {
  116279. mainImpostor: mainImpostor,
  116280. connectedImpostor: connectedImpostor,
  116281. joint: joint
  116282. };
  116283. joint.physicsPlugin = this._physicsPlugin;
  116284. this._joints.push(impostorJoint);
  116285. this._physicsPlugin.generateJoint(impostorJoint);
  116286. };
  116287. /**
  116288. * Removes a joint from the simulation
  116289. * @param mainImpostor defines the impostor used with the joint
  116290. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  116291. * @param joint defines the joint to remove
  116292. */
  116293. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  116294. var matchingJoints = this._joints.filter(function (impostorJoint) {
  116295. return (impostorJoint.connectedImpostor === connectedImpostor
  116296. && impostorJoint.joint === joint
  116297. && impostorJoint.mainImpostor === mainImpostor);
  116298. });
  116299. if (matchingJoints.length) {
  116300. this._physicsPlugin.removeJoint(matchingJoints[0]);
  116301. //TODO remove it from the list as well
  116302. }
  116303. };
  116304. /**
  116305. * Called by the scene. No need to call it.
  116306. * @param delta defines the timespam between frames
  116307. */
  116308. PhysicsEngine.prototype._step = function (delta) {
  116309. var _this = this;
  116310. //check if any mesh has no body / requires an update
  116311. this._impostors.forEach(function (impostor) {
  116312. if (impostor.isBodyInitRequired()) {
  116313. _this._physicsPlugin.generatePhysicsBody(impostor);
  116314. }
  116315. });
  116316. if (delta > 0.1) {
  116317. delta = 0.1;
  116318. }
  116319. else if (delta <= 0) {
  116320. delta = 1.0 / 60.0;
  116321. }
  116322. this._physicsPlugin.executeStep(delta, this._impostors);
  116323. };
  116324. /**
  116325. * Gets the current plugin used to run the simulation
  116326. * @returns current plugin
  116327. */
  116328. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  116329. return this._physicsPlugin;
  116330. };
  116331. /**
  116332. * Gets the list of physic impostors
  116333. * @returns an array of PhysicsImpostor
  116334. */
  116335. PhysicsEngine.prototype.getImpostors = function () {
  116336. return this._impostors;
  116337. };
  116338. /**
  116339. * Gets the impostor for a physics enabled object
  116340. * @param object defines the object impersonated by the impostor
  116341. * @returns the PhysicsImpostor or null if not found
  116342. */
  116343. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  116344. for (var i = 0; i < this._impostors.length; ++i) {
  116345. if (this._impostors[i].object === object) {
  116346. return this._impostors[i];
  116347. }
  116348. }
  116349. return null;
  116350. };
  116351. /**
  116352. * Gets the impostor for a physics body object
  116353. * @param body defines physics body used by the impostor
  116354. * @returns the PhysicsImpostor or null if not found
  116355. */
  116356. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  116357. for (var i = 0; i < this._impostors.length; ++i) {
  116358. if (this._impostors[i].physicsBody === body) {
  116359. return this._impostors[i];
  116360. }
  116361. }
  116362. return null;
  116363. };
  116364. /**
  116365. * Does a raycast in the physics world
  116366. * @param from when should the ray start?
  116367. * @param to when should the ray end?
  116368. * @returns PhysicsRaycastResult
  116369. */
  116370. PhysicsEngine.prototype.raycast = function (from, to) {
  116371. return this._physicsPlugin.raycast(from, to);
  116372. };
  116373. /**
  116374. * Global value used to control the smallest number supported by the simulation
  116375. */
  116376. PhysicsEngine.Epsilon = 0.001;
  116377. return PhysicsEngine;
  116378. }());
  116379. /***/ }),
  116380. /***/ "./Physics/physicsEngineComponent.ts":
  116381. /*!*******************************************!*\
  116382. !*** ./Physics/physicsEngineComponent.ts ***!
  116383. \*******************************************/
  116384. /*! exports provided: PhysicsEngineSceneComponent */
  116385. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116386. "use strict";
  116387. __webpack_require__.r(__webpack_exports__);
  116388. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  116389. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  116390. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  116391. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  116392. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  116393. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  116394. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  116395. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  116396. /**
  116397. * Gets the current physics engine
  116398. * @returns a IPhysicsEngine or null if none attached
  116399. */
  116400. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  116401. return this._physicsEngine;
  116402. };
  116403. /**
  116404. * Enables physics to the current scene
  116405. * @param gravity defines the scene's gravity for the physics engine
  116406. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  116407. * @return a boolean indicating if the physics engine was initialized
  116408. */
  116409. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  116410. if (gravity === void 0) { gravity = null; }
  116411. if (this._physicsEngine) {
  116412. return true;
  116413. }
  116414. // Register the component to the scene
  116415. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  116416. if (!component) {
  116417. component = new PhysicsEngineSceneComponent(this);
  116418. this._addComponent(component);
  116419. }
  116420. try {
  116421. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  116422. return true;
  116423. }
  116424. catch (e) {
  116425. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  116426. return false;
  116427. }
  116428. };
  116429. /**
  116430. * Disables and disposes the physics engine associated with the scene
  116431. */
  116432. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  116433. if (!this._physicsEngine) {
  116434. return;
  116435. }
  116436. this._physicsEngine.dispose();
  116437. this._physicsEngine = null;
  116438. };
  116439. /**
  116440. * Gets a boolean indicating if there is an active physics engine
  116441. * @returns a boolean indicating if there is an active physics engine
  116442. */
  116443. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  116444. return this._physicsEngine !== undefined;
  116445. };
  116446. /**
  116447. * Deletes a physics compound impostor
  116448. * @param compound defines the compound to delete
  116449. */
  116450. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  116451. var mesh = compound.parts[0].mesh;
  116452. if (mesh.physicsImpostor) {
  116453. mesh.physicsImpostor.dispose( /*true*/);
  116454. mesh.physicsImpostor = null;
  116455. }
  116456. };
  116457. /** @hidden */
  116458. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  116459. if (this._physicsEngine) {
  116460. this.onBeforePhysicsObservable.notifyObservers(this);
  116461. this._physicsEngine._step(step / 1000);
  116462. this.onAfterPhysicsObservable.notifyObservers(this);
  116463. }
  116464. };
  116465. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  116466. get: function () {
  116467. return this._physicsImpostor;
  116468. },
  116469. set: function (value) {
  116470. var _this = this;
  116471. if (this._physicsImpostor === value) {
  116472. return;
  116473. }
  116474. if (this._disposePhysicsObserver) {
  116475. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  116476. }
  116477. this._physicsImpostor = value;
  116478. if (value) {
  116479. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  116480. // Physics
  116481. if (_this.physicsImpostor) {
  116482. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  116483. _this.physicsImpostor = null;
  116484. }
  116485. });
  116486. }
  116487. },
  116488. enumerable: true,
  116489. configurable: true
  116490. });
  116491. /**
  116492. * Gets the current physics impostor
  116493. * @see http://doc.babylonjs.com/features/physics_engine
  116494. * @returns a physics impostor or null
  116495. */
  116496. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  116497. return this.physicsImpostor;
  116498. };
  116499. /**
  116500. * Apply a physic impulse to the mesh
  116501. * @param force defines the force to apply
  116502. * @param contactPoint defines where to apply the force
  116503. * @returns the current mesh
  116504. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116505. */
  116506. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  116507. if (!this.physicsImpostor) {
  116508. return this;
  116509. }
  116510. this.physicsImpostor.applyImpulse(force, contactPoint);
  116511. return this;
  116512. };
  116513. /**
  116514. * Creates a physic joint between two meshes
  116515. * @param otherMesh defines the other mesh to use
  116516. * @param pivot1 defines the pivot to use on this mesh
  116517. * @param pivot2 defines the pivot to use on the other mesh
  116518. * @param options defines additional options (can be plugin dependent)
  116519. * @returns the current mesh
  116520. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  116521. */
  116522. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  116523. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  116524. return this;
  116525. }
  116526. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  116527. mainPivot: pivot1,
  116528. connectedPivot: pivot2,
  116529. nativeParams: options
  116530. });
  116531. return this;
  116532. };
  116533. /**
  116534. * Defines the physics engine scene component responsible to manage a physics engine
  116535. */
  116536. var PhysicsEngineSceneComponent = /** @class */ (function () {
  116537. /**
  116538. * Creates a new instance of the component for the given scene
  116539. * @param scene Defines the scene to register the component in
  116540. */
  116541. function PhysicsEngineSceneComponent(scene) {
  116542. var _this = this;
  116543. /**
  116544. * The component name helpful to identify the component in the list of scene components.
  116545. */
  116546. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  116547. this.scene = scene;
  116548. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  116549. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  116550. // Replace the function used to get the deterministic frame time
  116551. this.scene.getDeterministicFrameTime = function () {
  116552. if (_this.scene._physicsEngine) {
  116553. return _this.scene._physicsEngine.getTimeStep() * 1000;
  116554. }
  116555. return 1000.0 / 60.0;
  116556. };
  116557. }
  116558. /**
  116559. * Registers the component in a given scene
  116560. */
  116561. PhysicsEngineSceneComponent.prototype.register = function () {
  116562. };
  116563. /**
  116564. * Rebuilds the elements related to this component in case of
  116565. * context lost for instance.
  116566. */
  116567. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  116568. // Nothing to do for this component
  116569. };
  116570. /**
  116571. * Disposes the component and the associated ressources
  116572. */
  116573. PhysicsEngineSceneComponent.prototype.dispose = function () {
  116574. this.scene.onBeforePhysicsObservable.clear();
  116575. this.scene.onAfterPhysicsObservable.clear();
  116576. if (this.scene._physicsEngine) {
  116577. this.scene.disablePhysicsEngine();
  116578. }
  116579. };
  116580. return PhysicsEngineSceneComponent;
  116581. }());
  116582. /***/ }),
  116583. /***/ "./Physics/physicsHelper.ts":
  116584. /*!**********************************!*\
  116585. !*** ./Physics/physicsHelper.ts ***!
  116586. \**********************************/
  116587. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  116588. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116589. "use strict";
  116590. __webpack_require__.r(__webpack_exports__);
  116591. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  116592. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return PhysicsRadialExplosionEventOptions; });
  116593. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return PhysicsUpdraftEventOptions; });
  116594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return PhysicsVortexEventOptions; });
  116595. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  116596. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  116597. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116598. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  116599. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  116600. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  116601. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  116602. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  116603. /**
  116604. * A helper for physics simulations
  116605. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116606. */
  116607. var PhysicsHelper = /** @class */ (function () {
  116608. /**
  116609. * Initializes the Physics helper
  116610. * @param scene Babylon.js scene
  116611. */
  116612. function PhysicsHelper(scene) {
  116613. this._scene = scene;
  116614. this._physicsEngine = this._scene.getPhysicsEngine();
  116615. if (!this._physicsEngine) {
  116616. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  116617. return;
  116618. }
  116619. }
  116620. /**
  116621. * Applies a radial explosion impulse
  116622. * @param origin the origin of the explosion
  116623. * @param radiusOrEventOptions the radius or the options of radial explosion
  116624. * @param strength the explosion strength
  116625. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116626. * @returns A physics radial explosion event, or null
  116627. */
  116628. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radiusOrEventOptions, strength, falloff) {
  116629. if (!this._physicsEngine) {
  116630. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  116631. return null;
  116632. }
  116633. var impostors = this._physicsEngine.getImpostors();
  116634. if (impostors.length === 0) {
  116635. return null;
  116636. }
  116637. if (typeof radiusOrEventOptions === 'number') {
  116638. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  116639. radiusOrEventOptions.radius = radiusOrEventOptions;
  116640. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  116641. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  116642. }
  116643. var event = new PhysicsRadialExplosionEvent(this._scene, radiusOrEventOptions);
  116644. var affectedImpostorsWithData = Array();
  116645. impostors.forEach(function (impostor) {
  116646. var impostorHitData = event.getImpostorHitData(impostor, origin);
  116647. if (!impostorHitData) {
  116648. return;
  116649. }
  116650. impostor.applyImpulse(impostorHitData.force, impostorHitData.contactPoint);
  116651. affectedImpostorsWithData.push({
  116652. impostor: impostor,
  116653. hitData: impostorHitData,
  116654. });
  116655. });
  116656. event.triggerAffectedImpostorsCallback(affectedImpostorsWithData);
  116657. event.dispose(false);
  116658. return event;
  116659. };
  116660. /**
  116661. * Applies a radial explosion force
  116662. * @param origin the origin of the explosion
  116663. * @param radiusOrEventOptions the radius or the options of radial explosion
  116664. * @param strength the explosion strength
  116665. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116666. * @returns A physics radial explosion event, or null
  116667. */
  116668. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radiusOrEventOptions, strength, falloff) {
  116669. if (!this._physicsEngine) {
  116670. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  116671. return null;
  116672. }
  116673. var impostors = this._physicsEngine.getImpostors();
  116674. if (impostors.length === 0) {
  116675. return null;
  116676. }
  116677. if (typeof radiusOrEventOptions === 'number') {
  116678. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  116679. radiusOrEventOptions.radius = radiusOrEventOptions;
  116680. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  116681. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  116682. }
  116683. var event = new PhysicsRadialExplosionEvent(this._scene, radiusOrEventOptions);
  116684. var affectedImpostorsWithData = Array();
  116685. impostors.forEach(function (impostor) {
  116686. var impostorHitData = event.getImpostorHitData(impostor, origin);
  116687. if (!impostorHitData) {
  116688. return;
  116689. }
  116690. impostor.applyForce(impostorHitData.force, impostorHitData.contactPoint);
  116691. affectedImpostorsWithData.push({
  116692. impostor: impostor,
  116693. hitData: impostorHitData,
  116694. });
  116695. });
  116696. event.triggerAffectedImpostorsCallback(affectedImpostorsWithData);
  116697. event.dispose(false);
  116698. return event;
  116699. };
  116700. /**
  116701. * Creates a gravitational field
  116702. * @param origin the origin of the explosion
  116703. * @param radiusOrEventOptions the radius or the options of radial explosion
  116704. * @param strength the explosion strength
  116705. * @param falloff possible options: Constant & Linear. Defaults to Constant
  116706. * @returns A physics gravitational field event, or null
  116707. */
  116708. PhysicsHelper.prototype.gravitationalField = function (origin, radiusOrEventOptions, strength, falloff) {
  116709. if (!this._physicsEngine) {
  116710. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  116711. return null;
  116712. }
  116713. var impostors = this._physicsEngine.getImpostors();
  116714. if (impostors.length === 0) {
  116715. return null;
  116716. }
  116717. if (typeof radiusOrEventOptions === 'number') {
  116718. radiusOrEventOptions = new PhysicsRadialExplosionEventOptions();
  116719. radiusOrEventOptions.radius = radiusOrEventOptions;
  116720. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  116721. radiusOrEventOptions.falloff = falloff || radiusOrEventOptions.falloff;
  116722. }
  116723. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radiusOrEventOptions);
  116724. event.dispose(false);
  116725. return event;
  116726. };
  116727. /**
  116728. * Creates a physics updraft event
  116729. * @param origin the origin of the updraft
  116730. * @param radiusOrEventOptions the radius or the options of the updraft
  116731. * @param strength the strength of the updraft
  116732. * @param height the height of the updraft
  116733. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  116734. * @returns A physics updraft event, or null
  116735. */
  116736. PhysicsHelper.prototype.updraft = function (origin, radiusOrEventOptions, strength, height, updraftMode) {
  116737. if (!this._physicsEngine) {
  116738. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  116739. return null;
  116740. }
  116741. if (this._physicsEngine.getImpostors().length === 0) {
  116742. return null;
  116743. }
  116744. if (typeof radiusOrEventOptions === 'number') {
  116745. radiusOrEventOptions = new PhysicsUpdraftEventOptions();
  116746. radiusOrEventOptions.radius = radiusOrEventOptions;
  116747. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  116748. radiusOrEventOptions.height = height || radiusOrEventOptions.height;
  116749. radiusOrEventOptions.updraftMode = updraftMode || radiusOrEventOptions.updraftMode;
  116750. }
  116751. var event = new PhysicsUpdraftEvent(this._scene, origin, radiusOrEventOptions);
  116752. event.dispose(false);
  116753. return event;
  116754. };
  116755. /**
  116756. * Creates a physics vortex event
  116757. * @param origin the of the vortex
  116758. * @param radiusOrEventOptions the radius or the options of the vortex
  116759. * @param strength the strength of the vortex
  116760. * @param height the height of the vortex
  116761. * @returns a Physics vortex event, or null
  116762. * A physics vortex event or null
  116763. */
  116764. PhysicsHelper.prototype.vortex = function (origin, radiusOrEventOptions, strength, height) {
  116765. if (!this._physicsEngine) {
  116766. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  116767. return null;
  116768. }
  116769. if (this._physicsEngine.getImpostors().length === 0) {
  116770. return null;
  116771. }
  116772. if (typeof radiusOrEventOptions === 'number') {
  116773. radiusOrEventOptions = new PhysicsVortexEventOptions();
  116774. radiusOrEventOptions.radius = radiusOrEventOptions;
  116775. radiusOrEventOptions.strength = strength || radiusOrEventOptions.strength;
  116776. radiusOrEventOptions.height = height || radiusOrEventOptions.height;
  116777. }
  116778. var event = new PhysicsVortexEvent(this._scene, origin, radiusOrEventOptions);
  116779. event.dispose(false);
  116780. return event;
  116781. };
  116782. return PhysicsHelper;
  116783. }());
  116784. /**
  116785. * Represents a physics radial explosion event
  116786. */
  116787. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  116788. /**
  116789. * Initializes a radial explosioin event
  116790. * @param _scene BabylonJS scene
  116791. * @param _options The options for the vortex event
  116792. */
  116793. function PhysicsRadialExplosionEvent(_scene, _options) {
  116794. this._scene = _scene;
  116795. this._options = _options;
  116796. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  116797. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsRadialExplosionEventOptions()), this._options);
  116798. }
  116799. /**
  116800. * Returns the data related to the radial explosion event (sphere).
  116801. * @returns The radial explosion event data
  116802. */
  116803. PhysicsRadialExplosionEvent.prototype.getData = function () {
  116804. this._dataFetched = true;
  116805. return {
  116806. sphere: this._sphere,
  116807. };
  116808. };
  116809. /**
  116810. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  116811. * @param impostor A physics imposter
  116812. * @param origin the origin of the explosion
  116813. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  116814. */
  116815. PhysicsRadialExplosionEvent.prototype.getImpostorHitData = function (impostor, origin) {
  116816. if (impostor.mass === 0) {
  116817. return null;
  116818. }
  116819. if (!this._intersectsWithSphere(impostor, origin, this._options.radius)) {
  116820. return null;
  116821. }
  116822. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  116823. return null;
  116824. }
  116825. var impostorObjectCenter = impostor.getObjectCenter();
  116826. var direction = impostorObjectCenter.subtract(origin);
  116827. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, this._options.radius);
  116828. var hit = ray.intersectsMesh(impostor.object);
  116829. var contactPoint = hit.pickedPoint;
  116830. if (!contactPoint) {
  116831. return null;
  116832. }
  116833. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Distance(origin, contactPoint);
  116834. if (distanceFromOrigin > this._options.radius) {
  116835. return null;
  116836. }
  116837. var multiplier = this._options.falloff === PhysicsRadialImpulseFalloff.Constant
  116838. ? this._options.strength
  116839. : this._options.strength * (1 - (distanceFromOrigin / this._options.radius));
  116840. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  116841. return { force: force, contactPoint: contactPoint, distanceFromOrigin: distanceFromOrigin };
  116842. };
  116843. /**
  116844. * Triggers affecterd impostors callbacks
  116845. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  116846. */
  116847. PhysicsRadialExplosionEvent.prototype.triggerAffectedImpostorsCallback = function (affectedImpostorsWithData) {
  116848. if (this._options.affectedImpostorsCallback) {
  116849. this._options.affectedImpostorsCallback(affectedImpostorsWithData);
  116850. }
  116851. };
  116852. /**
  116853. * Disposes the sphere.
  116854. * @param force Specifies if the sphere should be disposed by force
  116855. */
  116856. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  116857. var _this = this;
  116858. if (force === void 0) { force = true; }
  116859. if (force) {
  116860. this._sphere.dispose();
  116861. }
  116862. else {
  116863. setTimeout(function () {
  116864. if (!_this._dataFetched) {
  116865. _this._sphere.dispose();
  116866. }
  116867. }, 0);
  116868. }
  116869. };
  116870. /*** Helpers ***/
  116871. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  116872. if (!this._sphere) {
  116873. this._sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere("radialExplosionEventSphere", this._options.sphere, this._scene);
  116874. this._sphere.isVisible = false;
  116875. }
  116876. };
  116877. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  116878. var impostorObject = impostor.object;
  116879. this._prepareSphere();
  116880. this._sphere.position = origin;
  116881. this._sphere.scaling = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * 2, radius * 2, radius * 2);
  116882. this._sphere._updateBoundingInfo();
  116883. this._sphere.computeWorldMatrix(true);
  116884. return this._sphere.intersectsMesh(impostorObject, true);
  116885. };
  116886. return PhysicsRadialExplosionEvent;
  116887. }());
  116888. /**
  116889. * Represents a gravitational field event
  116890. */
  116891. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  116892. /**
  116893. * Initializes the physics gravitational field event
  116894. * @param _physicsHelper A physics helper
  116895. * @param _scene BabylonJS scene
  116896. * @param _origin The origin position of the gravitational field event
  116897. * @param _options The options for the vortex event
  116898. */
  116899. function PhysicsGravitationalFieldEvent(_physicsHelper, _scene, _origin, _options) {
  116900. this._physicsHelper = _physicsHelper;
  116901. this._scene = _scene;
  116902. this._origin = _origin;
  116903. this._options = _options;
  116904. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  116905. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsRadialExplosionEventOptions()), this._options);
  116906. this._tickCallback = this._tick.bind(this);
  116907. this._options.strength = this._options.strength * -1;
  116908. }
  116909. /**
  116910. * Returns the data related to the gravitational field event (sphere).
  116911. * @returns A gravitational field event
  116912. */
  116913. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  116914. this._dataFetched = true;
  116915. return {
  116916. sphere: this._sphere,
  116917. };
  116918. };
  116919. /**
  116920. * Enables the gravitational field.
  116921. */
  116922. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  116923. this._tickCallback.call(this);
  116924. this._scene.registerBeforeRender(this._tickCallback);
  116925. };
  116926. /**
  116927. * Disables the gravitational field.
  116928. */
  116929. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  116930. this._scene.unregisterBeforeRender(this._tickCallback);
  116931. };
  116932. /**
  116933. * Disposes the sphere.
  116934. * @param force The force to dispose from the gravitational field event
  116935. */
  116936. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  116937. var _this = this;
  116938. if (force === void 0) { force = true; }
  116939. if (force) {
  116940. this._sphere.dispose();
  116941. }
  116942. else {
  116943. setTimeout(function () {
  116944. if (!_this._dataFetched) {
  116945. _this._sphere.dispose();
  116946. }
  116947. }, 0);
  116948. }
  116949. };
  116950. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  116951. // Since the params won't change, we fetch the event only once
  116952. if (this._sphere) {
  116953. this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
  116954. }
  116955. else {
  116956. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._options);
  116957. if (radialExplosionEvent) {
  116958. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  116959. }
  116960. }
  116961. };
  116962. return PhysicsGravitationalFieldEvent;
  116963. }());
  116964. /**
  116965. * Represents a physics updraft event
  116966. */
  116967. var PhysicsUpdraftEvent = /** @class */ (function () {
  116968. /**
  116969. * Initializes the physics updraft event
  116970. * @param _scene BabylonJS scene
  116971. * @param _origin The origin position of the updraft
  116972. * @param _options The options for the updraft event
  116973. */
  116974. function PhysicsUpdraftEvent(_scene, _origin, _options) {
  116975. this._scene = _scene;
  116976. this._origin = _origin;
  116977. this._options = _options;
  116978. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // the most upper part of the cylinder
  116979. this._originDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  116980. 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
  116981. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  116982. this._physicsEngine = this._scene.getPhysicsEngine();
  116983. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsUpdraftEventOptions()), this._options);
  116984. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height / 2, 0), this._cylinderPosition);
  116985. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height, 0), this._originTop);
  116986. if (this._options.updraftMode === PhysicsUpdraftMode.Perpendicular) {
  116987. this._originDirection = this._origin.subtract(this._originTop).normalize();
  116988. }
  116989. this._tickCallback = this._tick.bind(this);
  116990. this._prepareCylinder();
  116991. }
  116992. /**
  116993. * Returns the data related to the updraft event (cylinder).
  116994. * @returns A physics updraft event
  116995. */
  116996. PhysicsUpdraftEvent.prototype.getData = function () {
  116997. this._dataFetched = true;
  116998. return {
  116999. cylinder: this._cylinder,
  117000. };
  117001. };
  117002. /**
  117003. * Enables the updraft.
  117004. */
  117005. PhysicsUpdraftEvent.prototype.enable = function () {
  117006. this._tickCallback.call(this);
  117007. this._scene.registerBeforeRender(this._tickCallback);
  117008. };
  117009. /**
  117010. * Disables the updraft.
  117011. */
  117012. PhysicsUpdraftEvent.prototype.disable = function () {
  117013. this._scene.unregisterBeforeRender(this._tickCallback);
  117014. };
  117015. /**
  117016. * Disposes the cylinder.
  117017. * @param force Specifies if the updraft should be disposed by force
  117018. */
  117019. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  117020. var _this = this;
  117021. if (force === void 0) { force = true; }
  117022. if (!this._cylinder) {
  117023. return;
  117024. }
  117025. if (force) {
  117026. this._cylinder.dispose();
  117027. }
  117028. else {
  117029. setTimeout(function () {
  117030. if (!_this._dataFetched) {
  117031. _this._cylinder.dispose();
  117032. }
  117033. }, 0);
  117034. }
  117035. };
  117036. PhysicsUpdraftEvent.prototype.getImpostorHitData = function (impostor) {
  117037. if (impostor.mass === 0) {
  117038. return null;
  117039. }
  117040. if (!this._intersectsWithCylinder(impostor)) {
  117041. return null;
  117042. }
  117043. var impostorObjectCenter = impostor.getObjectCenter();
  117044. if (this._options.updraftMode === PhysicsUpdraftMode.Perpendicular) {
  117045. var direction = this._originDirection;
  117046. }
  117047. else {
  117048. var direction = impostorObjectCenter.subtract(this._originTop);
  117049. }
  117050. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Distance(this._origin, impostorObjectCenter);
  117051. var multiplier = this._options.strength * -1;
  117052. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  117053. return { force: force, contactPoint: impostorObjectCenter, distanceFromOrigin: distanceFromOrigin };
  117054. };
  117055. PhysicsUpdraftEvent.prototype._tick = function () {
  117056. var _this = this;
  117057. this._physicsEngine.getImpostors().forEach(function (impostor) {
  117058. var impostorHitData = _this.getImpostorHitData(impostor);
  117059. if (!impostorHitData) {
  117060. return;
  117061. }
  117062. impostor.applyForce(impostorHitData.force, impostorHitData.contactPoint);
  117063. });
  117064. };
  117065. /*** Helpers ***/
  117066. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  117067. if (!this._cylinder) {
  117068. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("updraftEventCylinder", {
  117069. height: this._options.height,
  117070. diameter: this._options.radius * 2,
  117071. }, this._scene);
  117072. this._cylinder.isVisible = false;
  117073. }
  117074. };
  117075. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  117076. var impostorObject = impostor.object;
  117077. this._cylinder.position = this._cylinderPosition;
  117078. return this._cylinder.intersectsMesh(impostorObject, true);
  117079. };
  117080. return PhysicsUpdraftEvent;
  117081. }());
  117082. /**
  117083. * Represents a physics vortex event
  117084. */
  117085. var PhysicsVortexEvent = /** @class */ (function () {
  117086. /**
  117087. * Initializes the physics vortex event
  117088. * @param _scene The BabylonJS scene
  117089. * @param _origin The origin position of the vortex
  117090. * @param _options The options for the vortex event
  117091. */
  117092. function PhysicsVortexEvent(_scene, _origin, _options) {
  117093. this._scene = _scene;
  117094. this._origin = _origin;
  117095. this._options = _options;
  117096. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(); // the most upper part of the cylinder
  117097. 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
  117098. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  117099. this._physicsEngine = this._scene.getPhysicsEngine();
  117100. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, (new PhysicsVortexEventOptions()), this._options);
  117101. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height / 2, 0), this._cylinderPosition);
  117102. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, this._options.height, 0), this._originTop);
  117103. this._tickCallback = this._tick.bind(this);
  117104. this._prepareCylinder();
  117105. }
  117106. /**
  117107. * Returns the data related to the vortex event (cylinder).
  117108. * @returns The physics vortex event data
  117109. */
  117110. PhysicsVortexEvent.prototype.getData = function () {
  117111. this._dataFetched = true;
  117112. return {
  117113. cylinder: this._cylinder,
  117114. };
  117115. };
  117116. /**
  117117. * Enables the vortex.
  117118. */
  117119. PhysicsVortexEvent.prototype.enable = function () {
  117120. this._tickCallback.call(this);
  117121. this._scene.registerBeforeRender(this._tickCallback);
  117122. };
  117123. /**
  117124. * Disables the cortex.
  117125. */
  117126. PhysicsVortexEvent.prototype.disable = function () {
  117127. this._scene.unregisterBeforeRender(this._tickCallback);
  117128. };
  117129. /**
  117130. * Disposes the sphere.
  117131. * @param force
  117132. */
  117133. PhysicsVortexEvent.prototype.dispose = function (force) {
  117134. var _this = this;
  117135. if (force === void 0) { force = true; }
  117136. if (force) {
  117137. this._cylinder.dispose();
  117138. }
  117139. else {
  117140. setTimeout(function () {
  117141. if (!_this._dataFetched) {
  117142. _this._cylinder.dispose();
  117143. }
  117144. }, 0);
  117145. }
  117146. };
  117147. PhysicsVortexEvent.prototype.getImpostorHitData = function (impostor) {
  117148. if (impostor.mass === 0) {
  117149. return null;
  117150. }
  117151. if (!this._intersectsWithCylinder(impostor)) {
  117152. return null;
  117153. }
  117154. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  117155. return null;
  117156. }
  117157. var impostorObjectCenter = impostor.getObjectCenter();
  117158. 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)
  117159. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  117160. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](originOnPlane, originToImpostorDirection, this._options.radius);
  117161. var hit = ray.intersectsMesh(impostor.object);
  117162. var contactPoint = hit.pickedPoint;
  117163. if (!contactPoint) {
  117164. return null;
  117165. }
  117166. var absoluteDistanceFromOrigin = hit.distance / this._options.radius;
  117167. var directionToOrigin = contactPoint.normalize();
  117168. if (absoluteDistanceFromOrigin > this._options.centripetalForceThreshold) {
  117169. directionToOrigin = directionToOrigin.negate();
  117170. }
  117171. if (absoluteDistanceFromOrigin > this._options.centripetalForceThreshold) {
  117172. var forceX = directionToOrigin.x * this._options.centripetalForceMultiplier;
  117173. var forceY = directionToOrigin.y * this._options.updraftForceMultiplier;
  117174. var forceZ = directionToOrigin.z * this._options.centripetalForceMultiplier;
  117175. }
  117176. else {
  117177. var perpendicularDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  117178. var forceX = (perpendicularDirection.x + directionToOrigin.x) * this._options.centrifugalForceMultiplier;
  117179. var forceY = this._originTop.y * this._options.updraftForceMultiplier;
  117180. var forceZ = (perpendicularDirection.z + directionToOrigin.z) * this._options.centrifugalForceMultiplier;
  117181. }
  117182. var force = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](forceX, forceY, forceZ);
  117183. force = force.multiplyByFloats(this._options.strength, this._options.strength, this._options.strength);
  117184. return { force: force, contactPoint: impostorObjectCenter, distanceFromOrigin: absoluteDistanceFromOrigin };
  117185. };
  117186. PhysicsVortexEvent.prototype._tick = function () {
  117187. var _this = this;
  117188. this._physicsEngine.getImpostors().forEach(function (impostor) {
  117189. var impostorHitData = _this.getImpostorHitData(impostor);
  117190. if (!impostorHitData) {
  117191. return;
  117192. }
  117193. impostor.applyForce(impostorHitData.force, impostorHitData.contactPoint);
  117194. });
  117195. };
  117196. /*** Helpers ***/
  117197. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  117198. if (!this._cylinder) {
  117199. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("vortexEventCylinder", {
  117200. height: this._options.height,
  117201. diameter: this._options.radius * 2,
  117202. }, this._scene);
  117203. this._cylinder.isVisible = false;
  117204. }
  117205. };
  117206. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  117207. var impostorObject = impostor.object;
  117208. this._cylinder.position = this._cylinderPosition;
  117209. return this._cylinder.intersectsMesh(impostorObject, true);
  117210. };
  117211. return PhysicsVortexEvent;
  117212. }());
  117213. /**
  117214. * Options fot the radial explosion event
  117215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117216. */
  117217. var PhysicsRadialExplosionEventOptions = /** @class */ (function () {
  117218. function PhysicsRadialExplosionEventOptions() {
  117219. /**
  117220. * The radius of the sphere for the radial explosion.
  117221. */
  117222. this.radius = 5;
  117223. /**
  117224. * The strenth of the explosion.
  117225. */
  117226. this.strength = 10;
  117227. /**
  117228. * The strenght of the force in correspondence to the distance of the affected object
  117229. */
  117230. this.falloff = PhysicsRadialImpulseFalloff.Constant;
  117231. /**
  117232. * Sphere options for the radial explosion.
  117233. */
  117234. this.sphere = { segments: 32, diameter: 1 };
  117235. }
  117236. return PhysicsRadialExplosionEventOptions;
  117237. }());
  117238. /**
  117239. * Options fot the updraft event
  117240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117241. */
  117242. var PhysicsUpdraftEventOptions = /** @class */ (function () {
  117243. function PhysicsUpdraftEventOptions() {
  117244. /**
  117245. * The radius of the cylinder for the vortex
  117246. */
  117247. this.radius = 5;
  117248. /**
  117249. * The strenth of the updraft.
  117250. */
  117251. this.strength = 10;
  117252. /**
  117253. * The height of the cylinder for the updraft.
  117254. */
  117255. this.height = 10;
  117256. /**
  117257. * The mode for the the updraft.
  117258. */
  117259. this.updraftMode = PhysicsUpdraftMode.Center;
  117260. }
  117261. return PhysicsUpdraftEventOptions;
  117262. }());
  117263. /**
  117264. * Options fot the vortex event
  117265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117266. */
  117267. var PhysicsVortexEventOptions = /** @class */ (function () {
  117268. function PhysicsVortexEventOptions() {
  117269. /**
  117270. * The radius of the cylinder for the vortex
  117271. */
  117272. this.radius = 5;
  117273. /**
  117274. * The strenth of the vortex.
  117275. */
  117276. this.strength = 10;
  117277. /**
  117278. * The height of the cylinder for the vortex.
  117279. */
  117280. this.height = 10;
  117281. /**
  117282. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  117283. */
  117284. this.centripetalForceThreshold = 0.7;
  117285. /**
  117286. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  117287. */
  117288. this.centripetalForceMultiplier = 5;
  117289. /**
  117290. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  117291. */
  117292. this.centrifugalForceMultiplier = 0.5;
  117293. /**
  117294. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  117295. */
  117296. this.updraftForceMultiplier = 0.02;
  117297. }
  117298. return PhysicsVortexEventOptions;
  117299. }());
  117300. /**
  117301. * The strenght of the force in correspondence to the distance of the affected object
  117302. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117303. */
  117304. var PhysicsRadialImpulseFalloff;
  117305. (function (PhysicsRadialImpulseFalloff) {
  117306. /** Defines that impulse is constant in strength across it's whole radius */
  117307. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  117308. /** Defines that impulse gets weaker if it's further from the origin */
  117309. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  117310. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  117311. /**
  117312. * The strength of the force in correspondence to the distance of the affected object
  117313. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117314. */
  117315. var PhysicsUpdraftMode;
  117316. (function (PhysicsUpdraftMode) {
  117317. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  117318. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  117319. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  117320. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  117321. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  117322. /***/ }),
  117323. /***/ "./Physics/physicsImpostor.ts":
  117324. /*!************************************!*\
  117325. !*** ./Physics/physicsImpostor.ts ***!
  117326. \************************************/
  117327. /*! exports provided: PhysicsImpostor */
  117328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117329. "use strict";
  117330. __webpack_require__.r(__webpack_exports__);
  117331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  117332. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  117333. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  117334. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117335. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  117336. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  117337. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  117338. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  117339. return new PhysicsImpostor(physicObject, jsonObject.physicsImpostor, {
  117340. mass: jsonObject.physicsMass,
  117341. friction: jsonObject.physicsFriction,
  117342. restitution: jsonObject.physicsRestitution
  117343. }, scene);
  117344. };
  117345. /**
  117346. * Represents a physics imposter
  117347. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117348. */
  117349. var PhysicsImpostor = /** @class */ (function () {
  117350. /**
  117351. * Initializes the physics imposter
  117352. * @param object The physics-enabled object used as the physics imposter
  117353. * @param type The type of the physics imposter
  117354. * @param _options The options for the physics imposter
  117355. * @param _scene The Babylon scene
  117356. */
  117357. function PhysicsImpostor(
  117358. /**
  117359. * The physics-enabled object used as the physics imposter
  117360. */
  117361. object,
  117362. /**
  117363. * The type of the physics imposter
  117364. */
  117365. type, _options, _scene) {
  117366. if (_options === void 0) { _options = { mass: 0 }; }
  117367. var _this = this;
  117368. this.object = object;
  117369. this.type = type;
  117370. this._options = _options;
  117371. this._scene = _scene;
  117372. /** @hidden */
  117373. this._pluginData = {};
  117374. this._bodyUpdateRequired = false;
  117375. this._onBeforePhysicsStepCallbacks = new Array();
  117376. this._onAfterPhysicsStepCallbacks = new Array();
  117377. /** @hidden */
  117378. this._onPhysicsCollideCallbacks = [];
  117379. this._deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  117380. this._isDisposed = false;
  117381. /**
  117382. * @hidden
  117383. */
  117384. this.soft = false;
  117385. /**
  117386. * @hidden
  117387. */
  117388. this.segments = 0;
  117389. //temp variables for parent rotation calculations
  117390. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  117391. this._tmpQuat = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  117392. this._tmpQuat2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  117393. /**
  117394. * this function is executed by the physics engine.
  117395. */
  117396. this.beforeStep = function () {
  117397. if (!_this._physicsEngine) {
  117398. return;
  117399. }
  117400. _this.object.translate(_this._deltaPosition, -1);
  117401. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  117402. _this.object.computeWorldMatrix(false);
  117403. if (_this.object.parent && _this.object.rotationQuaternion) {
  117404. _this.getParentsRotation();
  117405. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  117406. }
  117407. else {
  117408. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  117409. }
  117410. if (!_this._options.disableBidirectionalTransformation) {
  117411. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  117412. }
  117413. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  117414. func(_this);
  117415. });
  117416. };
  117417. /**
  117418. * this function is executed by the physics engine
  117419. */
  117420. this.afterStep = function () {
  117421. if (!_this._physicsEngine) {
  117422. return;
  117423. }
  117424. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  117425. func(_this);
  117426. });
  117427. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  117428. // object has now its world rotation. needs to be converted to local.
  117429. if (_this.object.parent && _this.object.rotationQuaternion) {
  117430. _this.getParentsRotation();
  117431. _this._tmpQuat.conjugateInPlace();
  117432. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  117433. }
  117434. // take the position set and make it the absolute position of this object.
  117435. _this.object.setAbsolutePosition(_this.object.position);
  117436. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  117437. _this.object.translate(_this._deltaPosition, 1);
  117438. };
  117439. /**
  117440. * Legacy collision detection event support
  117441. */
  117442. this.onCollideEvent = null;
  117443. /**
  117444. * event and body object due to cannon's event-based architecture.
  117445. */
  117446. this.onCollide = function (e) {
  117447. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  117448. return;
  117449. }
  117450. if (!_this._physicsEngine) {
  117451. return;
  117452. }
  117453. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  117454. if (otherImpostor) {
  117455. // Legacy collision detection event support
  117456. if (_this.onCollideEvent) {
  117457. _this.onCollideEvent(_this, otherImpostor);
  117458. }
  117459. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  117460. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  117461. }).forEach(function (obj) {
  117462. obj.callback(_this, otherImpostor);
  117463. });
  117464. }
  117465. };
  117466. //sanity check!
  117467. if (!this.object) {
  117468. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  117469. return;
  117470. }
  117471. // Legacy support for old syntax.
  117472. if (!this._scene && object.getScene) {
  117473. this._scene = object.getScene();
  117474. }
  117475. if (!this._scene) {
  117476. return;
  117477. }
  117478. if (this.type > 100) {
  117479. this.soft = true;
  117480. }
  117481. this._physicsEngine = this._scene.getPhysicsEngine();
  117482. if (!this._physicsEngine) {
  117483. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  117484. }
  117485. else {
  117486. //set the object's quaternion, if not set
  117487. if (!this.object.rotationQuaternion) {
  117488. if (this.object.rotation) {
  117489. this.object.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  117490. }
  117491. else {
  117492. this.object.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  117493. }
  117494. }
  117495. //default options params
  117496. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  117497. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  117498. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  117499. if (this.soft) {
  117500. //softbody mass must be above 0;
  117501. this._options.mass = this._options.mass > 0 ? this._options.mass : 1;
  117502. this._options.pressure = (_options.pressure === void 0) ? 200 : _options.pressure;
  117503. this._options.stiffness = (_options.stiffness === void 0) ? 1 : _options.stiffness;
  117504. this._options.velocityIterations = (_options.velocityIterations === void 0) ? 20 : _options.velocityIterations;
  117505. this._options.positionIterations = (_options.positionIterations === void 0) ? 20 : _options.positionIterations;
  117506. this._options.fixedPoints = (_options.fixedPoints === void 0) ? 0 : _options.fixedPoints;
  117507. this._options.margin = (_options.margin === void 0) ? 0 : _options.margin;
  117508. this._options.damping = (_options.damping === void 0) ? 0 : _options.damping;
  117509. this._options.path = (_options.path === void 0) ? null : _options.path;
  117510. this._options.shape = (_options.shape === void 0) ? null : _options.shape;
  117511. }
  117512. this._joints = [];
  117513. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  117514. if (!this.object.parent || this._options.ignoreParent) {
  117515. this._init();
  117516. }
  117517. else if (this.object.parent.physicsImpostor) {
  117518. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  117519. }
  117520. }
  117521. }
  117522. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  117523. /**
  117524. * Specifies if the physics imposter is disposed
  117525. */
  117526. get: function () {
  117527. return this._isDisposed;
  117528. },
  117529. enumerable: true,
  117530. configurable: true
  117531. });
  117532. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  117533. /**
  117534. * Gets the mass of the physics imposter
  117535. */
  117536. get: function () {
  117537. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  117538. },
  117539. set: function (value) {
  117540. this.setMass(value);
  117541. },
  117542. enumerable: true,
  117543. configurable: true
  117544. });
  117545. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  117546. /**
  117547. * Gets the coefficient of friction
  117548. */
  117549. get: function () {
  117550. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  117551. },
  117552. /**
  117553. * Sets the coefficient of friction
  117554. */
  117555. set: function (value) {
  117556. if (!this._physicsEngine) {
  117557. return;
  117558. }
  117559. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  117560. },
  117561. enumerable: true,
  117562. configurable: true
  117563. });
  117564. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  117565. /**
  117566. * Gets the coefficient of restitution
  117567. */
  117568. get: function () {
  117569. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  117570. },
  117571. /**
  117572. * Sets the coefficient of restitution
  117573. */
  117574. set: function (value) {
  117575. if (!this._physicsEngine) {
  117576. return;
  117577. }
  117578. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  117579. },
  117580. enumerable: true,
  117581. configurable: true
  117582. });
  117583. Object.defineProperty(PhysicsImpostor.prototype, "pressure", {
  117584. /**
  117585. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  117586. */
  117587. get: function () {
  117588. if (!this._physicsEngine) {
  117589. return 0;
  117590. }
  117591. var plugin = this._physicsEngine.getPhysicsPlugin();
  117592. if (!plugin.setBodyPressure) {
  117593. return 0;
  117594. }
  117595. return plugin.getBodyPressure(this);
  117596. },
  117597. /**
  117598. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  117599. */
  117600. set: function (value) {
  117601. if (!this._physicsEngine) {
  117602. return;
  117603. }
  117604. var plugin = this._physicsEngine.getPhysicsPlugin();
  117605. if (!plugin.setBodyPressure) {
  117606. return;
  117607. }
  117608. plugin.setBodyPressure(this, value);
  117609. },
  117610. enumerable: true,
  117611. configurable: true
  117612. });
  117613. Object.defineProperty(PhysicsImpostor.prototype, "stiffness", {
  117614. /**
  117615. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  117616. */
  117617. get: function () {
  117618. if (!this._physicsEngine) {
  117619. return 0;
  117620. }
  117621. var plugin = this._physicsEngine.getPhysicsPlugin();
  117622. if (!plugin.getBodyStiffness) {
  117623. return 0;
  117624. }
  117625. return plugin.getBodyStiffness(this);
  117626. },
  117627. /**
  117628. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  117629. */
  117630. set: function (value) {
  117631. if (!this._physicsEngine) {
  117632. return;
  117633. }
  117634. var plugin = this._physicsEngine.getPhysicsPlugin();
  117635. if (!plugin.setBodyStiffness) {
  117636. return;
  117637. }
  117638. plugin.setBodyStiffness(this, value);
  117639. },
  117640. enumerable: true,
  117641. configurable: true
  117642. });
  117643. Object.defineProperty(PhysicsImpostor.prototype, "velocityIterations", {
  117644. /**
  117645. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  117646. */
  117647. get: function () {
  117648. if (!this._physicsEngine) {
  117649. return 0;
  117650. }
  117651. var plugin = this._physicsEngine.getPhysicsPlugin();
  117652. if (!plugin.getBodyVelocityIterations) {
  117653. return 0;
  117654. }
  117655. return plugin.getBodyVelocityIterations(this);
  117656. },
  117657. /**
  117658. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  117659. */
  117660. set: function (value) {
  117661. if (!this._physicsEngine) {
  117662. return;
  117663. }
  117664. var plugin = this._physicsEngine.getPhysicsPlugin();
  117665. if (!plugin.setBodyVelocityIterations) {
  117666. return;
  117667. }
  117668. plugin.setBodyVelocityIterations(this, value);
  117669. },
  117670. enumerable: true,
  117671. configurable: true
  117672. });
  117673. Object.defineProperty(PhysicsImpostor.prototype, "positionIterations", {
  117674. /**
  117675. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  117676. */
  117677. get: function () {
  117678. if (!this._physicsEngine) {
  117679. return 0;
  117680. }
  117681. var plugin = this._physicsEngine.getPhysicsPlugin();
  117682. if (!plugin.getBodyPositionIterations) {
  117683. return 0;
  117684. }
  117685. return plugin.getBodyPositionIterations(this);
  117686. },
  117687. /**
  117688. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  117689. */
  117690. set: function (value) {
  117691. if (!this._physicsEngine) {
  117692. return;
  117693. }
  117694. var plugin = this._physicsEngine.getPhysicsPlugin();
  117695. if (!plugin.setBodyPositionIterations) {
  117696. return;
  117697. }
  117698. plugin.setBodyPositionIterations(this, value);
  117699. },
  117700. enumerable: true,
  117701. configurable: true
  117702. });
  117703. /**
  117704. * This function will completly initialize this impostor.
  117705. * It will create a new body - but only if this mesh has no parent.
  117706. * If it has, this impostor will not be used other than to define the impostor
  117707. * of the child mesh.
  117708. * @hidden
  117709. */
  117710. PhysicsImpostor.prototype._init = function () {
  117711. if (!this._physicsEngine) {
  117712. return;
  117713. }
  117714. this._physicsEngine.removeImpostor(this);
  117715. this.physicsBody = null;
  117716. this._parent = this._parent || this._getPhysicsParent();
  117717. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  117718. this._physicsEngine.addImpostor(this);
  117719. }
  117720. };
  117721. PhysicsImpostor.prototype._getPhysicsParent = function () {
  117722. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  117723. var parentMesh = this.object.parent;
  117724. return parentMesh.physicsImpostor;
  117725. }
  117726. return null;
  117727. };
  117728. /**
  117729. * Should a new body be generated.
  117730. * @returns boolean specifying if body initialization is required
  117731. */
  117732. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  117733. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  117734. };
  117735. /**
  117736. * Sets the updated scaling
  117737. * @param updated Specifies if the scaling is updated
  117738. */
  117739. PhysicsImpostor.prototype.setScalingUpdated = function () {
  117740. this.forceUpdate();
  117741. };
  117742. /**
  117743. * Force a regeneration of this or the parent's impostor's body.
  117744. * Use under cautious - This will remove all joints already implemented.
  117745. */
  117746. PhysicsImpostor.prototype.forceUpdate = function () {
  117747. this._init();
  117748. if (this.parent && !this._options.ignoreParent) {
  117749. this.parent.forceUpdate();
  117750. }
  117751. };
  117752. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  117753. /*public get mesh(): AbstractMesh {
  117754. return this._mesh;
  117755. }*/
  117756. /**
  117757. * Gets the body that holds this impostor. Either its own, or its parent.
  117758. */
  117759. get: function () {
  117760. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  117761. },
  117762. /**
  117763. * Set the physics body. Used mainly by the physics engine/plugin
  117764. */
  117765. set: function (physicsBody) {
  117766. if (this._physicsBody && this._physicsEngine) {
  117767. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  117768. }
  117769. this._physicsBody = physicsBody;
  117770. this.resetUpdateFlags();
  117771. },
  117772. enumerable: true,
  117773. configurable: true
  117774. });
  117775. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  117776. /**
  117777. * Get the parent of the physics imposter
  117778. * @returns Physics imposter or null
  117779. */
  117780. get: function () {
  117781. return !this._options.ignoreParent && this._parent ? this._parent : null;
  117782. },
  117783. /**
  117784. * Sets the parent of the physics imposter
  117785. */
  117786. set: function (value) {
  117787. this._parent = value;
  117788. },
  117789. enumerable: true,
  117790. configurable: true
  117791. });
  117792. /**
  117793. * Resets the update flags
  117794. */
  117795. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  117796. this._bodyUpdateRequired = false;
  117797. };
  117798. /**
  117799. * Gets the object extend size
  117800. * @returns the object extend size
  117801. */
  117802. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  117803. if (this.object.getBoundingInfo) {
  117804. var q = this.object.rotationQuaternion;
  117805. //reset rotation
  117806. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  117807. //calculate the world matrix with no rotation
  117808. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  117809. var boundingInfo = this.object.getBoundingInfo();
  117810. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  117811. //bring back the rotation
  117812. this.object.rotationQuaternion = q;
  117813. //calculate the world matrix with the new rotation
  117814. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  117815. return size;
  117816. }
  117817. else {
  117818. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  117819. }
  117820. };
  117821. /**
  117822. * Gets the object center
  117823. * @returns The object center
  117824. */
  117825. PhysicsImpostor.prototype.getObjectCenter = function () {
  117826. if (this.object.getBoundingInfo) {
  117827. var boundingInfo = this.object.getBoundingInfo();
  117828. return boundingInfo.boundingBox.centerWorld;
  117829. }
  117830. else {
  117831. return this.object.position;
  117832. }
  117833. };
  117834. /**
  117835. * Get a specific parametes from the options parameter
  117836. * @param paramName The object parameter name
  117837. * @returns The object parameter
  117838. */
  117839. PhysicsImpostor.prototype.getParam = function (paramName) {
  117840. return this._options[paramName];
  117841. };
  117842. /**
  117843. * Sets a specific parameter in the options given to the physics plugin
  117844. * @param paramName The parameter name
  117845. * @param value The value of the parameter
  117846. */
  117847. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  117848. this._options[paramName] = value;
  117849. this._bodyUpdateRequired = true;
  117850. };
  117851. /**
  117852. * Specifically change the body's mass option. Won't recreate the physics body object
  117853. * @param mass The mass of the physics imposter
  117854. */
  117855. PhysicsImpostor.prototype.setMass = function (mass) {
  117856. if (this.getParam("mass") !== mass) {
  117857. this.setParam("mass", mass);
  117858. }
  117859. if (this._physicsEngine) {
  117860. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  117861. }
  117862. };
  117863. /**
  117864. * Gets the linear velocity
  117865. * @returns linear velocity or null
  117866. */
  117867. PhysicsImpostor.prototype.getLinearVelocity = function () {
  117868. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  117869. };
  117870. /**
  117871. * Sets the linear velocity
  117872. * @param velocity linear velocity or null
  117873. */
  117874. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  117875. if (this._physicsEngine) {
  117876. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  117877. }
  117878. };
  117879. /**
  117880. * Gets the angular velocity
  117881. * @returns angular velocity or null
  117882. */
  117883. PhysicsImpostor.prototype.getAngularVelocity = function () {
  117884. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  117885. };
  117886. /**
  117887. * Sets the angular velocity
  117888. * @param velocity The velocity or null
  117889. */
  117890. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  117891. if (this._physicsEngine) {
  117892. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  117893. }
  117894. };
  117895. /**
  117896. * Execute a function with the physics plugin native code
  117897. * Provide a function the will have two variables - the world object and the physics body object
  117898. * @param func The function to execute with the physics plugin native code
  117899. */
  117900. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  117901. if (this._physicsEngine) {
  117902. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  117903. }
  117904. };
  117905. /**
  117906. * Register a function that will be executed before the physics world is stepping forward
  117907. * @param func The function to execute before the physics world is stepped forward
  117908. */
  117909. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  117910. this._onBeforePhysicsStepCallbacks.push(func);
  117911. };
  117912. /**
  117913. * Unregister a function that will be executed before the physics world is stepping forward
  117914. * @param func The function to execute before the physics world is stepped forward
  117915. */
  117916. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  117917. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  117918. if (index > -1) {
  117919. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  117920. }
  117921. else {
  117922. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  117923. }
  117924. };
  117925. /**
  117926. * Register a function that will be executed after the physics step
  117927. * @param func The function to execute after physics step
  117928. */
  117929. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  117930. this._onAfterPhysicsStepCallbacks.push(func);
  117931. };
  117932. /**
  117933. * Unregisters a function that will be executed after the physics step
  117934. * @param func The function to execute after physics step
  117935. */
  117936. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  117937. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  117938. if (index > -1) {
  117939. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  117940. }
  117941. else {
  117942. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  117943. }
  117944. };
  117945. /**
  117946. * register a function that will be executed when this impostor collides against a different body
  117947. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  117948. * @param func Callback that is executed on collision
  117949. */
  117950. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  117951. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  117952. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  117953. };
  117954. /**
  117955. * Unregisters the physics imposter on contact
  117956. * @param collideAgainst The physics object to collide against
  117957. * @param func Callback to execute on collision
  117958. */
  117959. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  117960. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  117961. var index = -1;
  117962. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  117963. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  117964. // chcek the arrays match
  117965. var sameList = cbDef.otherImpostors.every(function (impostor) {
  117966. return collidedAgainstList.indexOf(impostor) > -1;
  117967. });
  117968. if (sameList) {
  117969. index = idx;
  117970. }
  117971. return sameList;
  117972. }
  117973. return false;
  117974. });
  117975. if (found) {
  117976. this._onPhysicsCollideCallbacks.splice(index, 1);
  117977. }
  117978. else {
  117979. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  117980. }
  117981. };
  117982. /**
  117983. * Get the parent rotation
  117984. * @returns The parent rotation
  117985. */
  117986. PhysicsImpostor.prototype.getParentsRotation = function () {
  117987. var parent = this.object.parent;
  117988. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  117989. while (parent) {
  117990. if (parent.rotationQuaternion) {
  117991. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  117992. }
  117993. else {
  117994. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  117995. }
  117996. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  117997. parent = parent.parent;
  117998. }
  117999. return this._tmpQuat;
  118000. };
  118001. /**
  118002. * Apply a force
  118003. * @param force The force to apply
  118004. * @param contactPoint The contact point for the force
  118005. * @returns The physics imposter
  118006. */
  118007. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  118008. if (this._physicsEngine) {
  118009. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  118010. }
  118011. return this;
  118012. };
  118013. /**
  118014. * Apply an impulse
  118015. * @param force The impulse force
  118016. * @param contactPoint The contact point for the impulse force
  118017. * @returns The physics imposter
  118018. */
  118019. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  118020. if (this._physicsEngine) {
  118021. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  118022. }
  118023. return this;
  118024. };
  118025. /**
  118026. * A help function to create a joint
  118027. * @param otherImpostor A physics imposter used to create a joint
  118028. * @param jointType The type of joint
  118029. * @param jointData The data for the joint
  118030. * @returns The physics imposter
  118031. */
  118032. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  118033. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_5__["PhysicsJoint"](jointType, jointData);
  118034. this.addJoint(otherImpostor, joint);
  118035. return this;
  118036. };
  118037. /**
  118038. * Add a joint to this impostor with a different impostor
  118039. * @param otherImpostor A physics imposter used to add a joint
  118040. * @param joint The joint to add
  118041. * @returns The physics imposter
  118042. */
  118043. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  118044. this._joints.push({
  118045. otherImpostor: otherImpostor,
  118046. joint: joint
  118047. });
  118048. if (this._physicsEngine) {
  118049. this._physicsEngine.addJoint(this, otherImpostor, joint);
  118050. }
  118051. return this;
  118052. };
  118053. /**
  118054. * Add an anchor to a cloth impostor
  118055. * @param otherImpostor rigid impostor to anchor to
  118056. * @param width ratio across width from 0 to 1
  118057. * @param height ratio up height from 0 to 1
  118058. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  118059. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  118060. * @returns impostor the soft imposter
  118061. */
  118062. PhysicsImpostor.prototype.addAnchor = function (otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies) {
  118063. if (!this._physicsEngine) {
  118064. return this;
  118065. }
  118066. var plugin = this._physicsEngine.getPhysicsPlugin();
  118067. if (!plugin.appendAnchor) {
  118068. return this;
  118069. }
  118070. if (this._physicsEngine) {
  118071. plugin.appendAnchor(this, otherImpostor, width, height, influence, noCollisionBetweenLinkedBodies);
  118072. }
  118073. return this;
  118074. };
  118075. /**
  118076. * Add a hook to a rope impostor
  118077. * @param otherImpostor rigid impostor to anchor to
  118078. * @param length ratio across rope from 0 to 1
  118079. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  118080. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118081. * @returns impostor the rope imposter
  118082. */
  118083. PhysicsImpostor.prototype.addHook = function (otherImpostor, length, influence, noCollisionBetweenLinkedBodies) {
  118084. if (!this._physicsEngine) {
  118085. return this;
  118086. }
  118087. var plugin = this._physicsEngine.getPhysicsPlugin();
  118088. if (!plugin.appendAnchor) {
  118089. return this;
  118090. }
  118091. if (this._physicsEngine) {
  118092. plugin.appendHook(this, otherImpostor, length, influence, noCollisionBetweenLinkedBodies);
  118093. }
  118094. return this;
  118095. };
  118096. /**
  118097. * Will keep this body still, in a sleep mode.
  118098. * @returns the physics imposter
  118099. */
  118100. PhysicsImpostor.prototype.sleep = function () {
  118101. if (this._physicsEngine) {
  118102. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  118103. }
  118104. return this;
  118105. };
  118106. /**
  118107. * Wake the body up.
  118108. * @returns The physics imposter
  118109. */
  118110. PhysicsImpostor.prototype.wakeUp = function () {
  118111. if (this._physicsEngine) {
  118112. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  118113. }
  118114. return this;
  118115. };
  118116. /**
  118117. * Clones the physics imposter
  118118. * @param newObject The physics imposter clones to this physics-enabled object
  118119. * @returns A nullable physics imposter
  118120. */
  118121. PhysicsImpostor.prototype.clone = function (newObject) {
  118122. if (!newObject) {
  118123. return null;
  118124. }
  118125. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  118126. };
  118127. /**
  118128. * Disposes the physics imposter
  118129. */
  118130. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  118131. var _this = this;
  118132. //no dispose if no physics engine is available.
  118133. if (!this._physicsEngine) {
  118134. return;
  118135. }
  118136. this._joints.forEach(function (j) {
  118137. if (_this._physicsEngine) {
  118138. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  118139. }
  118140. });
  118141. //dispose the physics body
  118142. this._physicsEngine.removeImpostor(this);
  118143. if (this.parent) {
  118144. this.parent.forceUpdate();
  118145. }
  118146. else {
  118147. /*this._object.getChildMeshes().forEach(function(mesh) {
  118148. if (mesh.physicsImpostor) {
  118149. if (disposeChildren) {
  118150. mesh.physicsImpostor.dispose();
  118151. mesh.physicsImpostor = null;
  118152. }
  118153. }
  118154. })*/
  118155. }
  118156. this._isDisposed = true;
  118157. };
  118158. /**
  118159. * Sets the delta position
  118160. * @param position The delta position amount
  118161. */
  118162. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  118163. this._deltaPosition.copyFrom(position);
  118164. };
  118165. /**
  118166. * Sets the delta rotation
  118167. * @param rotation The delta rotation amount
  118168. */
  118169. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  118170. if (!this._deltaRotation) {
  118171. this._deltaRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  118172. }
  118173. this._deltaRotation.copyFrom(rotation);
  118174. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  118175. };
  118176. /**
  118177. * Gets the box size of the physics imposter and stores the result in the input parameter
  118178. * @param result Stores the box size
  118179. * @returns The physics imposter
  118180. */
  118181. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  118182. if (this._physicsEngine) {
  118183. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  118184. }
  118185. return this;
  118186. };
  118187. /**
  118188. * Gets the radius of the physics imposter
  118189. * @returns Radius of the physics imposter
  118190. */
  118191. PhysicsImpostor.prototype.getRadius = function () {
  118192. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  118193. };
  118194. /**
  118195. * Sync a bone with this impostor
  118196. * @param bone The bone to sync to the impostor.
  118197. * @param boneMesh The mesh that the bone is influencing.
  118198. * @param jointPivot The pivot of the joint / bone in local space.
  118199. * @param distToJoint Optional distance from the impostor to the joint.
  118200. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  118201. */
  118202. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  118203. var tempVec = PhysicsImpostor._tmpVecs[0];
  118204. var mesh = this.object;
  118205. if (mesh.rotationQuaternion) {
  118206. if (adjustRotation) {
  118207. var tempQuat = PhysicsImpostor._tmpQuat;
  118208. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  118209. bone.setRotationQuaternion(tempQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  118210. }
  118211. else {
  118212. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  118213. }
  118214. }
  118215. tempVec.x = 0;
  118216. tempVec.y = 0;
  118217. tempVec.z = 0;
  118218. if (jointPivot) {
  118219. tempVec.x = jointPivot.x;
  118220. tempVec.y = jointPivot.y;
  118221. tempVec.z = jointPivot.z;
  118222. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  118223. if (distToJoint === undefined || distToJoint === null) {
  118224. distToJoint = jointPivot.length();
  118225. }
  118226. tempVec.x *= distToJoint;
  118227. tempVec.y *= distToJoint;
  118228. tempVec.z *= distToJoint;
  118229. }
  118230. if (bone.getParent()) {
  118231. tempVec.addInPlace(mesh.getAbsolutePosition());
  118232. bone.setAbsolutePosition(tempVec, boneMesh);
  118233. }
  118234. else {
  118235. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  118236. boneMesh.position.x -= tempVec.x;
  118237. boneMesh.position.y -= tempVec.y;
  118238. boneMesh.position.z -= tempVec.z;
  118239. }
  118240. };
  118241. /**
  118242. * Sync impostor to a bone
  118243. * @param bone The bone that the impostor will be synced to.
  118244. * @param boneMesh The mesh that the bone is influencing.
  118245. * @param jointPivot The pivot of the joint / bone in local space.
  118246. * @param distToJoint Optional distance from the impostor to the joint.
  118247. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  118248. * @param boneAxis Optional vector3 axis the bone is aligned with
  118249. */
  118250. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  118251. var mesh = this.object;
  118252. if (mesh.rotationQuaternion) {
  118253. if (adjustRotation) {
  118254. var tempQuat = PhysicsImpostor._tmpQuat;
  118255. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, tempQuat);
  118256. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  118257. }
  118258. else {
  118259. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  118260. }
  118261. }
  118262. var pos = PhysicsImpostor._tmpVecs[0];
  118263. var boneDir = PhysicsImpostor._tmpVecs[1];
  118264. if (!boneAxis) {
  118265. boneAxis = PhysicsImpostor._tmpVecs[2];
  118266. boneAxis.x = 0;
  118267. boneAxis.y = 1;
  118268. boneAxis.z = 0;
  118269. }
  118270. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  118271. bone.getAbsolutePositionToRef(boneMesh, pos);
  118272. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  118273. distToJoint = jointPivot.length();
  118274. }
  118275. if (distToJoint !== undefined && distToJoint !== null) {
  118276. pos.x += boneDir.x * distToJoint;
  118277. pos.y += boneDir.y * distToJoint;
  118278. pos.z += boneDir.z * distToJoint;
  118279. }
  118280. mesh.setAbsolutePosition(pos);
  118281. };
  118282. /**
  118283. * The default object size of the imposter
  118284. */
  118285. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  118286. /**
  118287. * The identity quaternion of the imposter
  118288. */
  118289. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  118290. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  118291. PhysicsImpostor._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  118292. //Impostor types
  118293. /**
  118294. * No-Imposter type
  118295. */
  118296. PhysicsImpostor.NoImpostor = 0;
  118297. /**
  118298. * Sphere-Imposter type
  118299. */
  118300. PhysicsImpostor.SphereImpostor = 1;
  118301. /**
  118302. * Box-Imposter type
  118303. */
  118304. PhysicsImpostor.BoxImpostor = 2;
  118305. /**
  118306. * Plane-Imposter type
  118307. */
  118308. PhysicsImpostor.PlaneImpostor = 3;
  118309. /**
  118310. * Mesh-imposter type
  118311. */
  118312. PhysicsImpostor.MeshImpostor = 4;
  118313. /**
  118314. * Cylinder-Imposter type
  118315. */
  118316. PhysicsImpostor.CylinderImpostor = 7;
  118317. /**
  118318. * Particle-Imposter type
  118319. */
  118320. PhysicsImpostor.ParticleImpostor = 8;
  118321. /**
  118322. * Heightmap-Imposter type
  118323. */
  118324. PhysicsImpostor.HeightmapImpostor = 9;
  118325. /**
  118326. * ConvexHull-Impostor type (Ammo.js plugin only)
  118327. */
  118328. PhysicsImpostor.ConvexHullImpostor = 10;
  118329. /**
  118330. * Rope-Imposter type
  118331. */
  118332. PhysicsImpostor.RopeImpostor = 101;
  118333. /**
  118334. * Cloth-Imposter type
  118335. */
  118336. PhysicsImpostor.ClothImpostor = 102;
  118337. /**
  118338. * Softbody-Imposter type
  118339. */
  118340. PhysicsImpostor.SoftbodyImpostor = 103;
  118341. return PhysicsImpostor;
  118342. }());
  118343. /***/ }),
  118344. /***/ "./Physics/physicsJoint.ts":
  118345. /*!*********************************!*\
  118346. !*** ./Physics/physicsJoint.ts ***!
  118347. \*********************************/
  118348. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  118349. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118350. "use strict";
  118351. __webpack_require__.r(__webpack_exports__);
  118352. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  118353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  118354. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  118355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  118356. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  118357. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118358. /**
  118359. * This is a holder class for the physics joint created by the physics plugin
  118360. * It holds a set of functions to control the underlying joint
  118361. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118362. */
  118363. var PhysicsJoint = /** @class */ (function () {
  118364. /**
  118365. * Initializes the physics joint
  118366. * @param type The type of the physics joint
  118367. * @param jointData The data for the physics joint
  118368. */
  118369. function PhysicsJoint(
  118370. /**
  118371. * The type of the physics joint
  118372. */
  118373. type,
  118374. /**
  118375. * The data for the physics joint
  118376. */
  118377. jointData) {
  118378. this.type = type;
  118379. this.jointData = jointData;
  118380. jointData.nativeParams = jointData.nativeParams || {};
  118381. }
  118382. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  118383. /**
  118384. * Gets the physics joint
  118385. */
  118386. get: function () {
  118387. return this._physicsJoint;
  118388. },
  118389. /**
  118390. * Sets the physics joint
  118391. */
  118392. set: function (newJoint) {
  118393. if (this._physicsJoint) {
  118394. //remove from the wolrd
  118395. }
  118396. this._physicsJoint = newJoint;
  118397. },
  118398. enumerable: true,
  118399. configurable: true
  118400. });
  118401. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  118402. /**
  118403. * Sets the physics plugin
  118404. */
  118405. set: function (physicsPlugin) {
  118406. this._physicsPlugin = physicsPlugin;
  118407. },
  118408. enumerable: true,
  118409. configurable: true
  118410. });
  118411. /**
  118412. * Execute a function that is physics-plugin specific.
  118413. * @param {Function} func the function that will be executed.
  118414. * It accepts two parameters: the physics world and the physics joint
  118415. */
  118416. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  118417. func(this._physicsPlugin.world, this._physicsJoint);
  118418. };
  118419. //TODO check if the native joints are the same
  118420. //Joint Types
  118421. /**
  118422. * Distance-Joint type
  118423. */
  118424. PhysicsJoint.DistanceJoint = 0;
  118425. /**
  118426. * Hinge-Joint type
  118427. */
  118428. PhysicsJoint.HingeJoint = 1;
  118429. /**
  118430. * Ball-and-Socket joint type
  118431. */
  118432. PhysicsJoint.BallAndSocketJoint = 2;
  118433. /**
  118434. * Wheel-Joint type
  118435. */
  118436. PhysicsJoint.WheelJoint = 3;
  118437. /**
  118438. * Slider-Joint type
  118439. */
  118440. PhysicsJoint.SliderJoint = 4;
  118441. //OIMO
  118442. /**
  118443. * Prismatic-Joint type
  118444. */
  118445. PhysicsJoint.PrismaticJoint = 5;
  118446. //
  118447. /**
  118448. * Universal-Joint type
  118449. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  118450. */
  118451. PhysicsJoint.UniversalJoint = 6;
  118452. /**
  118453. * Hinge-Joint 2 type
  118454. */
  118455. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  118456. //Cannon
  118457. /**
  118458. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  118459. */
  118460. PhysicsJoint.PointToPointJoint = 8;
  118461. //Cannon only at the moment
  118462. /**
  118463. * Spring-Joint type
  118464. */
  118465. PhysicsJoint.SpringJoint = 9;
  118466. /**
  118467. * Lock-Joint type
  118468. */
  118469. PhysicsJoint.LockJoint = 10;
  118470. return PhysicsJoint;
  118471. }());
  118472. /**
  118473. * A class representing a physics distance joint
  118474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118475. */
  118476. var DistanceJoint = /** @class */ (function (_super) {
  118477. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  118478. /**
  118479. *
  118480. * @param jointData The data for the Distance-Joint
  118481. */
  118482. function DistanceJoint(jointData) {
  118483. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  118484. }
  118485. /**
  118486. * Update the predefined distance.
  118487. * @param maxDistance The maximum preferred distance
  118488. * @param minDistance The minimum preferred distance
  118489. */
  118490. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  118491. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  118492. };
  118493. return DistanceJoint;
  118494. }(PhysicsJoint));
  118495. /**
  118496. * Represents a Motor-Enabled Joint
  118497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118498. */
  118499. var MotorEnabledJoint = /** @class */ (function (_super) {
  118500. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  118501. /**
  118502. * Initializes the Motor-Enabled Joint
  118503. * @param type The type of the joint
  118504. * @param jointData The physica joint data for the joint
  118505. */
  118506. function MotorEnabledJoint(type, jointData) {
  118507. return _super.call(this, type, jointData) || this;
  118508. }
  118509. /**
  118510. * Set the motor values.
  118511. * Attention, this function is plugin specific. Engines won't react 100% the same.
  118512. * @param force the force to apply
  118513. * @param maxForce max force for this motor.
  118514. */
  118515. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  118516. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  118517. };
  118518. /**
  118519. * Set the motor's limits.
  118520. * Attention, this function is plugin specific. Engines won't react 100% the same.
  118521. * @param upperLimit The upper limit of the motor
  118522. * @param lowerLimit The lower limit of the motor
  118523. */
  118524. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  118525. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  118526. };
  118527. return MotorEnabledJoint;
  118528. }(PhysicsJoint));
  118529. /**
  118530. * This class represents a single physics Hinge-Joint
  118531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118532. */
  118533. var HingeJoint = /** @class */ (function (_super) {
  118534. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  118535. /**
  118536. * Initializes the Hinge-Joint
  118537. * @param jointData The joint data for the Hinge-Joint
  118538. */
  118539. function HingeJoint(jointData) {
  118540. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  118541. }
  118542. /**
  118543. * Set the motor values.
  118544. * Attention, this function is plugin specific. Engines won't react 100% the same.
  118545. * @param {number} force the force to apply
  118546. * @param {number} maxForce max force for this motor.
  118547. */
  118548. HingeJoint.prototype.setMotor = function (force, maxForce) {
  118549. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  118550. };
  118551. /**
  118552. * Set the motor's limits.
  118553. * Attention, this function is plugin specific. Engines won't react 100% the same.
  118554. * @param upperLimit The upper limit of the motor
  118555. * @param lowerLimit The lower limit of the motor
  118556. */
  118557. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  118558. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  118559. };
  118560. return HingeJoint;
  118561. }(MotorEnabledJoint));
  118562. /**
  118563. * This class represents a dual hinge physics joint (same as wheel joint)
  118564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118565. */
  118566. var Hinge2Joint = /** @class */ (function (_super) {
  118567. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  118568. /**
  118569. * Initializes the Hinge2-Joint
  118570. * @param jointData The joint data for the Hinge2-Joint
  118571. */
  118572. function Hinge2Joint(jointData) {
  118573. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  118574. }
  118575. /**
  118576. * Set the motor values.
  118577. * Attention, this function is plugin specific. Engines won't react 100% the same.
  118578. * @param {number} targetSpeed the speed the motor is to reach
  118579. * @param {number} maxForce max force for this motor.
  118580. * @param {motorIndex} the motor's index, 0 or 1.
  118581. */
  118582. Hinge2Joint.prototype.setMotor = function (targetSpeed, maxForce, motorIndex) {
  118583. if (motorIndex === void 0) { motorIndex = 0; }
  118584. this._physicsPlugin.setMotor(this, targetSpeed || 0, maxForce, motorIndex);
  118585. };
  118586. /**
  118587. * Set the motor limits.
  118588. * Attention, this function is plugin specific. Engines won't react 100% the same.
  118589. * @param {number} upperLimit the upper limit
  118590. * @param {number} lowerLimit lower limit
  118591. * @param {motorIndex} the motor's index, 0 or 1.
  118592. */
  118593. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  118594. if (motorIndex === void 0) { motorIndex = 0; }
  118595. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  118596. };
  118597. return Hinge2Joint;
  118598. }(MotorEnabledJoint));
  118599. /***/ }),
  118600. /***/ "./Physics/physicsRaycastResult.ts":
  118601. /*!*****************************************!*\
  118602. !*** ./Physics/physicsRaycastResult.ts ***!
  118603. \*****************************************/
  118604. /*! exports provided: PhysicsRaycastResult */
  118605. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118606. "use strict";
  118607. __webpack_require__.r(__webpack_exports__);
  118608. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRaycastResult", function() { return PhysicsRaycastResult; });
  118609. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118610. /**
  118611. * Holds the data for the raycast result
  118612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118613. */
  118614. var PhysicsRaycastResult = /** @class */ (function () {
  118615. function PhysicsRaycastResult() {
  118616. this._hasHit = false;
  118617. this._hitDistance = 0;
  118618. this._hitNormalWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  118619. this._hitPointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  118620. this._rayFromWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  118621. this._rayToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  118622. }
  118623. Object.defineProperty(PhysicsRaycastResult.prototype, "hasHit", {
  118624. /**
  118625. * Gets if there was a hit
  118626. */
  118627. get: function () {
  118628. return this._hasHit;
  118629. },
  118630. enumerable: true,
  118631. configurable: true
  118632. });
  118633. Object.defineProperty(PhysicsRaycastResult.prototype, "hitDistance", {
  118634. /**
  118635. * Gets the distance from the hit
  118636. */
  118637. get: function () {
  118638. return this._hitDistance;
  118639. },
  118640. enumerable: true,
  118641. configurable: true
  118642. });
  118643. Object.defineProperty(PhysicsRaycastResult.prototype, "hitNormalWorld", {
  118644. /**
  118645. * Gets the hit normal/direction in the world
  118646. */
  118647. get: function () {
  118648. return this._hitNormalWorld;
  118649. },
  118650. enumerable: true,
  118651. configurable: true
  118652. });
  118653. Object.defineProperty(PhysicsRaycastResult.prototype, "hitPointWorld", {
  118654. /**
  118655. * Gets the hit point in the world
  118656. */
  118657. get: function () {
  118658. return this._hitPointWorld;
  118659. },
  118660. enumerable: true,
  118661. configurable: true
  118662. });
  118663. Object.defineProperty(PhysicsRaycastResult.prototype, "rayFromWorld", {
  118664. /**
  118665. * Gets the ray "start point" of the ray in the world
  118666. */
  118667. get: function () {
  118668. return this._rayFromWorld;
  118669. },
  118670. enumerable: true,
  118671. configurable: true
  118672. });
  118673. Object.defineProperty(PhysicsRaycastResult.prototype, "rayToWorld", {
  118674. /**
  118675. * Gets the ray "end point" of the ray in the world
  118676. */
  118677. get: function () {
  118678. return this._rayToWorld;
  118679. },
  118680. enumerable: true,
  118681. configurable: true
  118682. });
  118683. /**
  118684. * Sets the hit data (normal & point in world space)
  118685. * @param hitNormalWorld defines the normal in world space
  118686. * @param hitPointWorld defines the point in world space
  118687. */
  118688. PhysicsRaycastResult.prototype.setHitData = function (hitNormalWorld, hitPointWorld) {
  118689. this._hasHit = true;
  118690. this._hitNormalWorld = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](hitNormalWorld.x, hitNormalWorld.y, hitNormalWorld.z);
  118691. this._hitPointWorld = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](hitPointWorld.x, hitPointWorld.y, hitPointWorld.z);
  118692. };
  118693. /**
  118694. * Sets the distance from the start point to the hit point
  118695. * @param distance
  118696. */
  118697. PhysicsRaycastResult.prototype.setHitDistance = function (distance) {
  118698. this._hitDistance = distance;
  118699. };
  118700. /**
  118701. * Calculates the distance manually
  118702. */
  118703. PhysicsRaycastResult.prototype.calculateHitDistance = function () {
  118704. this._hitDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._rayFromWorld, this._hitPointWorld);
  118705. };
  118706. /**
  118707. * Resets all the values to default
  118708. * @param from The from point on world space
  118709. * @param to The to point on world space
  118710. */
  118711. PhysicsRaycastResult.prototype.reset = function (from, to) {
  118712. if (from === void 0) { from = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(); }
  118713. if (to === void 0) { to = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(); }
  118714. this._rayFromWorld = from;
  118715. this._rayToWorld = to;
  118716. this._hasHit = false;
  118717. this._hitDistance = 0;
  118718. this._hitNormalWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  118719. this._hitPointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  118720. };
  118721. return PhysicsRaycastResult;
  118722. }());
  118723. /***/ }),
  118724. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  118725. /*!****************************************************************************!*\
  118726. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  118727. \****************************************************************************/
  118728. /*! exports provided: DefaultRenderingPipeline */
  118729. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118730. "use strict";
  118731. __webpack_require__.r(__webpack_exports__);
  118732. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  118733. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118734. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  118735. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  118736. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118737. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  118738. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  118739. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  118740. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  118741. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  118742. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  118743. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  118744. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  118745. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  118746. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  118747. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  118748. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  118749. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  118750. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  118751. /**
  118752. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  118753. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118754. */
  118755. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  118756. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  118757. /**
  118758. * @constructor
  118759. * @param name - The rendering pipeline name (default: "")
  118760. * @param hdr - If high dynamic range textures should be used (default: true)
  118761. * @param scene - The scene linked to this pipeline (default: the last created scene)
  118762. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  118763. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  118764. */
  118765. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  118766. if (name === void 0) { name = ""; }
  118767. if (hdr === void 0) { hdr = true; }
  118768. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  118769. if (automaticBuild === void 0) { automaticBuild = true; }
  118770. var _this = _super.call(this, scene.getEngine(), name) || this;
  118771. _this._camerasToBeAttached = [];
  118772. /**
  118773. * ID of the sharpen post process,
  118774. */
  118775. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  118776. /**
  118777. * @ignore
  118778. * ID of the image processing post process;
  118779. */
  118780. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  118781. /**
  118782. * @ignore
  118783. * ID of the Fast Approximate Anti-Aliasing post process;
  118784. */
  118785. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  118786. /**
  118787. * ID of the chromatic aberration post process,
  118788. */
  118789. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  118790. /**
  118791. * ID of the grain post process
  118792. */
  118793. _this.GrainPostProcessId = "GrainPostProcessEffect";
  118794. /**
  118795. * Glow post process which adds a glow to emissive areas of the image
  118796. */
  118797. _this._glowLayer = null;
  118798. /**
  118799. * Animations which can be used to tweak settings over a period of time
  118800. */
  118801. _this.animations = [];
  118802. _this._imageProcessingConfigurationObserver = null;
  118803. // Values
  118804. _this._sharpenEnabled = false;
  118805. _this._bloomEnabled = false;
  118806. _this._depthOfFieldEnabled = false;
  118807. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  118808. _this._fxaaEnabled = false;
  118809. _this._imageProcessingEnabled = true;
  118810. _this._bloomScale = 0.5;
  118811. _this._chromaticAberrationEnabled = false;
  118812. _this._grainEnabled = false;
  118813. _this._buildAllowed = true;
  118814. _this._resizeObserver = null;
  118815. _this._hardwareScaleLevel = 1.0;
  118816. _this._bloomKernel = 64;
  118817. /**
  118818. * Specifies the weight of the bloom in the final rendering
  118819. */
  118820. _this._bloomWeight = 0.15;
  118821. /**
  118822. * Specifies the luma threshold for the area that will be blurred by the bloom
  118823. */
  118824. _this._bloomThreshold = 0.9;
  118825. _this._samples = 1;
  118826. _this._hasCleared = false;
  118827. _this._prevPostProcess = null;
  118828. _this._prevPrevPostProcess = null;
  118829. _this._depthOfFieldSceneObserver = null;
  118830. _this._cameras = cameras || scene.cameras;
  118831. _this._cameras = _this._cameras.slice();
  118832. _this._camerasToBeAttached = _this._cameras.slice();
  118833. _this._buildAllowed = automaticBuild;
  118834. // Initialize
  118835. _this._scene = scene;
  118836. var caps = _this._scene.getEngine().getCaps();
  118837. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  118838. // Misc
  118839. if (_this._hdr) {
  118840. if (caps.textureHalfFloatRender) {
  118841. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  118842. }
  118843. else if (caps.textureFloatRender) {
  118844. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  118845. }
  118846. }
  118847. else {
  118848. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  118849. }
  118850. // Attach
  118851. scene.postProcessRenderPipelineManager.addPipeline(_this);
  118852. var engine = _this._scene.getEngine();
  118853. // Create post processes before hand so they can be modified before enabled.
  118854. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  118855. _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);
  118856. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  118857. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  118858. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  118859. _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);
  118860. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  118861. _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);
  118862. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  118863. _this._resizeObserver = engine.onResizeObservable.add(function () {
  118864. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  118865. _this.bloomKernel = _this.bloomKernel;
  118866. });
  118867. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  118868. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  118869. });
  118870. _this._buildPipeline();
  118871. return _this;
  118872. }
  118873. Object.defineProperty(DefaultRenderingPipeline.prototype, "scene", {
  118874. /**
  118875. * Gets active scene
  118876. */
  118877. get: function () {
  118878. return this._scene;
  118879. },
  118880. enumerable: true,
  118881. configurable: true
  118882. });
  118883. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  118884. get: function () {
  118885. return this._sharpenEnabled;
  118886. },
  118887. /**
  118888. * Enable or disable the sharpen process from the pipeline
  118889. */
  118890. set: function (enabled) {
  118891. if (this._sharpenEnabled === enabled) {
  118892. return;
  118893. }
  118894. this._sharpenEnabled = enabled;
  118895. this._buildPipeline();
  118896. },
  118897. enumerable: true,
  118898. configurable: true
  118899. });
  118900. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  118901. /**
  118902. * Specifies the size of the bloom blur kernel, relative to the final output size
  118903. */
  118904. get: function () {
  118905. return this._bloomKernel;
  118906. },
  118907. set: function (value) {
  118908. this._bloomKernel = value;
  118909. this.bloom.kernel = value / this._hardwareScaleLevel;
  118910. },
  118911. enumerable: true,
  118912. configurable: true
  118913. });
  118914. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  118915. get: function () {
  118916. return this._bloomWeight;
  118917. },
  118918. /**
  118919. * The strength of the bloom.
  118920. */
  118921. set: function (value) {
  118922. if (this._bloomWeight === value) {
  118923. return;
  118924. }
  118925. this.bloom.weight = value;
  118926. this._bloomWeight = value;
  118927. },
  118928. enumerable: true,
  118929. configurable: true
  118930. });
  118931. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  118932. get: function () {
  118933. return this._bloomThreshold;
  118934. },
  118935. /**
  118936. * The strength of the bloom.
  118937. */
  118938. set: function (value) {
  118939. if (this._bloomThreshold === value) {
  118940. return;
  118941. }
  118942. this.bloom.threshold = value;
  118943. this._bloomThreshold = value;
  118944. },
  118945. enumerable: true,
  118946. configurable: true
  118947. });
  118948. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  118949. get: function () {
  118950. return this._bloomScale;
  118951. },
  118952. /**
  118953. * The scale of the bloom, lower value will provide better performance.
  118954. */
  118955. set: function (value) {
  118956. if (this._bloomScale === value) {
  118957. return;
  118958. }
  118959. this._bloomScale = value;
  118960. // recreate bloom and dispose old as this setting is not dynamic
  118961. this._rebuildBloom();
  118962. this._buildPipeline();
  118963. },
  118964. enumerable: true,
  118965. configurable: true
  118966. });
  118967. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  118968. get: function () {
  118969. return this._bloomEnabled;
  118970. },
  118971. /**
  118972. * Enable or disable the bloom from the pipeline
  118973. */
  118974. set: function (enabled) {
  118975. if (this._bloomEnabled === enabled) {
  118976. return;
  118977. }
  118978. this._bloomEnabled = enabled;
  118979. this._buildPipeline();
  118980. },
  118981. enumerable: true,
  118982. configurable: true
  118983. });
  118984. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  118985. // recreate bloom and dispose old as this setting is not dynamic
  118986. var oldBloom = this.bloom;
  118987. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  118988. this.bloom.threshold = oldBloom.threshold;
  118989. for (var i = 0; i < this._cameras.length; i++) {
  118990. oldBloom.disposeEffects(this._cameras[i]);
  118991. }
  118992. };
  118993. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  118994. /**
  118995. * If the depth of field is enabled.
  118996. */
  118997. get: function () {
  118998. return this._depthOfFieldEnabled;
  118999. },
  119000. set: function (enabled) {
  119001. if (this._depthOfFieldEnabled === enabled) {
  119002. return;
  119003. }
  119004. this._depthOfFieldEnabled = enabled;
  119005. this._buildPipeline();
  119006. },
  119007. enumerable: true,
  119008. configurable: true
  119009. });
  119010. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  119011. /**
  119012. * Blur level of the depth of field effect. (Higher blur will effect performance)
  119013. */
  119014. get: function () {
  119015. return this._depthOfFieldBlurLevel;
  119016. },
  119017. set: function (value) {
  119018. if (this._depthOfFieldBlurLevel === value) {
  119019. return;
  119020. }
  119021. this._depthOfFieldBlurLevel = value;
  119022. // recreate dof and dispose old as this setting is not dynamic
  119023. var oldDof = this.depthOfField;
  119024. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  119025. this.depthOfField.focalLength = oldDof.focalLength;
  119026. this.depthOfField.focusDistance = oldDof.focusDistance;
  119027. this.depthOfField.fStop = oldDof.fStop;
  119028. this.depthOfField.lensSize = oldDof.lensSize;
  119029. for (var i = 0; i < this._cameras.length; i++) {
  119030. oldDof.disposeEffects(this._cameras[i]);
  119031. }
  119032. this._buildPipeline();
  119033. },
  119034. enumerable: true,
  119035. configurable: true
  119036. });
  119037. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  119038. get: function () {
  119039. return this._fxaaEnabled;
  119040. },
  119041. /**
  119042. * If the anti aliasing is enabled.
  119043. */
  119044. set: function (enabled) {
  119045. if (this._fxaaEnabled === enabled) {
  119046. return;
  119047. }
  119048. this._fxaaEnabled = enabled;
  119049. this._buildPipeline();
  119050. },
  119051. enumerable: true,
  119052. configurable: true
  119053. });
  119054. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  119055. get: function () {
  119056. return this._samples;
  119057. },
  119058. /**
  119059. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119060. */
  119061. set: function (sampleCount) {
  119062. if (this._samples === sampleCount) {
  119063. return;
  119064. }
  119065. this._samples = sampleCount;
  119066. this._buildPipeline();
  119067. },
  119068. enumerable: true,
  119069. configurable: true
  119070. });
  119071. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  119072. get: function () {
  119073. return this._imageProcessingEnabled;
  119074. },
  119075. /**
  119076. * If image processing is enabled.
  119077. */
  119078. set: function (enabled) {
  119079. if (this._imageProcessingEnabled === enabled) {
  119080. return;
  119081. }
  119082. this._imageProcessingEnabled = enabled;
  119083. this._buildPipeline();
  119084. },
  119085. enumerable: true,
  119086. configurable: true
  119087. });
  119088. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  119089. get: function () {
  119090. return this._glowLayer != null;
  119091. },
  119092. /**
  119093. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  119094. */
  119095. set: function (enabled) {
  119096. if (enabled && !this._glowLayer) {
  119097. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  119098. }
  119099. else if (!enabled && this._glowLayer) {
  119100. this._glowLayer.dispose();
  119101. this._glowLayer = null;
  119102. }
  119103. },
  119104. enumerable: true,
  119105. configurable: true
  119106. });
  119107. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  119108. get: function () {
  119109. return this._chromaticAberrationEnabled;
  119110. },
  119111. /**
  119112. * Enable or disable the chromaticAberration process from the pipeline
  119113. */
  119114. set: function (enabled) {
  119115. if (this._chromaticAberrationEnabled === enabled) {
  119116. return;
  119117. }
  119118. this._chromaticAberrationEnabled = enabled;
  119119. this._buildPipeline();
  119120. },
  119121. enumerable: true,
  119122. configurable: true
  119123. });
  119124. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  119125. get: function () {
  119126. return this._grainEnabled;
  119127. },
  119128. /**
  119129. * Enable or disable the grain process from the pipeline
  119130. */
  119131. set: function (enabled) {
  119132. if (this._grainEnabled === enabled) {
  119133. return;
  119134. }
  119135. this._grainEnabled = enabled;
  119136. this._buildPipeline();
  119137. },
  119138. enumerable: true,
  119139. configurable: true
  119140. });
  119141. /**
  119142. * Get the class name
  119143. * @returns "DefaultRenderingPipeline"
  119144. */
  119145. DefaultRenderingPipeline.prototype.getClassName = function () {
  119146. return "DefaultRenderingPipeline";
  119147. };
  119148. /**
  119149. * Force the compilation of the entire pipeline.
  119150. */
  119151. DefaultRenderingPipeline.prototype.prepare = function () {
  119152. var previousState = this._buildAllowed;
  119153. this._buildAllowed = true;
  119154. this._buildPipeline();
  119155. this._buildAllowed = previousState;
  119156. };
  119157. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  119158. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  119159. if (this._hasCleared) {
  119160. postProcess.autoClear = false;
  119161. }
  119162. else {
  119163. postProcess.autoClear = true;
  119164. this._scene.autoClear = false;
  119165. this._hasCleared = true;
  119166. }
  119167. if (!skipTextureSharing) {
  119168. if (this._prevPrevPostProcess) {
  119169. postProcess.shareOutputWith(this._prevPrevPostProcess);
  119170. }
  119171. else {
  119172. postProcess.useOwnOutput();
  119173. }
  119174. if (this._prevPostProcess) {
  119175. this._prevPrevPostProcess = this._prevPostProcess;
  119176. }
  119177. this._prevPostProcess = postProcess;
  119178. }
  119179. };
  119180. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  119181. var _this = this;
  119182. if (!this._buildAllowed) {
  119183. return;
  119184. }
  119185. this._scene.autoClear = true;
  119186. var engine = this._scene.getEngine();
  119187. this._disposePostProcesses();
  119188. if (this._cameras !== null) {
  119189. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  119190. // get back cameras to be used to reattach pipeline
  119191. this._cameras = this._camerasToBeAttached.slice();
  119192. }
  119193. this._reset();
  119194. this._prevPostProcess = null;
  119195. this._prevPrevPostProcess = null;
  119196. this._hasCleared = false;
  119197. if (this.depthOfFieldEnabled) {
  119198. // Multi camera suport
  119199. if (this._cameras.length > 1) {
  119200. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  119201. var camera = _a[_i];
  119202. var depthRenderer = this._scene.enableDepthRenderer(camera);
  119203. depthRenderer.useOnlyInActiveCamera = true;
  119204. }
  119205. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  119206. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  119207. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  119208. }
  119209. });
  119210. }
  119211. else {
  119212. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  119213. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  119214. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  119215. }
  119216. if (!this.depthOfField._isReady()) {
  119217. this.depthOfField._updateEffects();
  119218. }
  119219. this.addEffect(this.depthOfField);
  119220. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  119221. }
  119222. else {
  119223. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  119224. }
  119225. if (this.bloomEnabled) {
  119226. if (!this.bloom._isReady()) {
  119227. this.bloom._updateEffects();
  119228. }
  119229. this.addEffect(this.bloom);
  119230. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  119231. }
  119232. if (this._imageProcessingEnabled) {
  119233. 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);
  119234. if (this._hdr) {
  119235. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  119236. this._setAutoClearAndTextureSharing(this.imageProcessing);
  119237. }
  119238. else {
  119239. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  119240. }
  119241. }
  119242. if (this.sharpenEnabled) {
  119243. if (!this.sharpen.isReady()) {
  119244. this.sharpen.updateEffect();
  119245. }
  119246. this.addEffect(this._sharpenEffect);
  119247. this._setAutoClearAndTextureSharing(this.sharpen);
  119248. }
  119249. if (this.grainEnabled) {
  119250. if (!this.grain.isReady()) {
  119251. this.grain.updateEffect();
  119252. }
  119253. this.addEffect(this._grainEffect);
  119254. this._setAutoClearAndTextureSharing(this.grain);
  119255. }
  119256. if (this.chromaticAberrationEnabled) {
  119257. if (!this.chromaticAberration.isReady()) {
  119258. this.chromaticAberration.updateEffect();
  119259. }
  119260. this.addEffect(this._chromaticAberrationEffect);
  119261. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  119262. }
  119263. if (this.fxaaEnabled) {
  119264. 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);
  119265. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  119266. this._setAutoClearAndTextureSharing(this.fxaa, true);
  119267. }
  119268. if (this._cameras !== null) {
  119269. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  119270. }
  119271. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  119272. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  119273. }
  119274. };
  119275. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  119276. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  119277. for (var i = 0; i < this._cameras.length; i++) {
  119278. var camera = this._cameras[i];
  119279. if (this.imageProcessing) {
  119280. this.imageProcessing.dispose(camera);
  119281. }
  119282. if (this.fxaa) {
  119283. this.fxaa.dispose(camera);
  119284. }
  119285. // These are created in the constructor and should not be disposed on every pipeline change
  119286. if (disposeNonRecreated) {
  119287. if (this.sharpen) {
  119288. this.sharpen.dispose(camera);
  119289. }
  119290. if (this.depthOfField) {
  119291. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  119292. this.depthOfField.disposeEffects(camera);
  119293. }
  119294. if (this.bloom) {
  119295. this.bloom.disposeEffects(camera);
  119296. }
  119297. if (this.chromaticAberration) {
  119298. this.chromaticAberration.dispose(camera);
  119299. }
  119300. if (this.grain) {
  119301. this.grain.dispose(camera);
  119302. }
  119303. if (this._glowLayer) {
  119304. this._glowLayer.dispose();
  119305. }
  119306. }
  119307. }
  119308. this.imageProcessing = null;
  119309. this.fxaa = null;
  119310. if (disposeNonRecreated) {
  119311. this.sharpen = null;
  119312. this._sharpenEffect = null;
  119313. this.depthOfField = null;
  119314. this.bloom = null;
  119315. this.chromaticAberration = null;
  119316. this._chromaticAberrationEffect = null;
  119317. this.grain = null;
  119318. this._grainEffect = null;
  119319. this._glowLayer = null;
  119320. }
  119321. };
  119322. /**
  119323. * Adds a camera to the pipeline
  119324. * @param camera the camera to be added
  119325. */
  119326. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  119327. this._camerasToBeAttached.push(camera);
  119328. this._buildPipeline();
  119329. };
  119330. /**
  119331. * Removes a camera from the pipeline
  119332. * @param camera the camera to remove
  119333. */
  119334. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  119335. var index = this._camerasToBeAttached.indexOf(camera);
  119336. this._camerasToBeAttached.splice(index, 1);
  119337. this._buildPipeline();
  119338. };
  119339. /**
  119340. * Dispose of the pipeline and stop all post processes
  119341. */
  119342. DefaultRenderingPipeline.prototype.dispose = function () {
  119343. this._disposePostProcesses(true);
  119344. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  119345. this._scene.autoClear = true;
  119346. if (this._resizeObserver) {
  119347. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  119348. this._resizeObserver = null;
  119349. }
  119350. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  119351. _super.prototype.dispose.call(this);
  119352. };
  119353. /**
  119354. * Serialize the rendering pipeline (Used when exporting)
  119355. * @returns the serialized object
  119356. */
  119357. DefaultRenderingPipeline.prototype.serialize = function () {
  119358. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  119359. serializationObject.customType = "DefaultRenderingPipeline";
  119360. return serializationObject;
  119361. };
  119362. /**
  119363. * Parse the serialized pipeline
  119364. * @param source Source pipeline.
  119365. * @param scene The scene to load the pipeline to.
  119366. * @param rootUrl The URL of the serialized pipeline.
  119367. * @returns An instantiated pipeline from the serialized object.
  119368. */
  119369. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  119370. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  119371. };
  119372. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119373. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119374. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  119375. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119376. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119377. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  119378. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119379. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119380. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  119381. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119382. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119383. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  119384. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119385. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119386. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  119387. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119388. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119389. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  119390. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119391. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119392. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  119393. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119394. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119395. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  119396. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119397. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119398. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  119399. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119400. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119401. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  119402. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119403. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119404. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  119405. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119406. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119407. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  119408. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119409. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119410. ], DefaultRenderingPipeline.prototype, "samples", null);
  119411. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119412. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119413. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  119414. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119415. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119416. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  119417. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119418. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119419. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  119420. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  119421. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  119422. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  119423. return DefaultRenderingPipeline;
  119424. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  119425. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  119426. /***/ }),
  119427. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  119428. /*!*********************************************************!*\
  119429. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  119430. \*********************************************************/
  119431. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  119432. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119433. "use strict";
  119434. __webpack_require__.r(__webpack_exports__);
  119435. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  119436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  119437. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  119438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  119439. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  119440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  119441. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  119442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  119443. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  119444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  119445. /***/ }),
  119446. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  119447. /*!*************************************************************************!*\
  119448. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  119449. \*************************************************************************/
  119450. /*! exports provided: LensRenderingPipeline */
  119451. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119452. "use strict";
  119453. __webpack_require__.r(__webpack_exports__);
  119454. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  119455. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119456. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119457. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  119458. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  119459. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  119460. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  119461. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  119462. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  119463. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  119464. /**
  119465. * BABYLON.JS Chromatic Aberration GLSL Shader
  119466. * Author: Olivier Guyot
  119467. * Separates very slightly R, G and B colors on the edges of the screen
  119468. * Inspired by Francois Tarlier & Martins Upitis
  119469. */
  119470. var LensRenderingPipeline = /** @class */ (function (_super) {
  119471. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  119472. /**
  119473. * @constructor
  119474. *
  119475. * Effect parameters are as follow:
  119476. * {
  119477. * chromatic_aberration: number; // from 0 to x (1 for realism)
  119478. * edge_blur: number; // from 0 to x (1 for realism)
  119479. * distortion: number; // from 0 to x (1 for realism)
  119480. * grain_amount: number; // from 0 to 1
  119481. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  119482. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  119483. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  119484. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  119485. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  119486. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  119487. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  119488. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  119489. * }
  119490. * Note: if an effect parameter is unset, effect is disabled
  119491. *
  119492. * @param name The rendering pipeline name
  119493. * @param parameters - An object containing all parameters (see above)
  119494. * @param scene The scene linked to this pipeline
  119495. * @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)
  119496. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119497. */
  119498. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  119499. if (ratio === void 0) { ratio = 1.0; }
  119500. var _this = _super.call(this, scene.getEngine(), name) || this;
  119501. // Lens effects can be of the following:
  119502. // - chromatic aberration (slight shift of RGB colors)
  119503. // - blur on the edge of the lens
  119504. // - lens distortion
  119505. // - depth-of-field blur & highlights enhancing
  119506. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  119507. // - grain effect (noise or custom texture)
  119508. // Two additional texture samplers are needed:
  119509. // - depth map (for depth-of-field)
  119510. // - grain texture
  119511. /**
  119512. * @ignore
  119513. * The chromatic aberration PostProcess id in the pipeline
  119514. */
  119515. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  119516. /**
  119517. * @ignore
  119518. * The highlights enhancing PostProcess id in the pipeline
  119519. */
  119520. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  119521. /**
  119522. * @ignore
  119523. * The depth-of-field PostProcess id in the pipeline
  119524. */
  119525. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  119526. _this._pentagonBokehIsEnabled = false;
  119527. _this._scene = scene;
  119528. // Fetch texture samplers
  119529. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  119530. if (parameters.grain_texture) {
  119531. _this._grainTexture = parameters.grain_texture;
  119532. }
  119533. else {
  119534. _this._createGrainTexture();
  119535. }
  119536. // save parameters
  119537. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  119538. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  119539. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  119540. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  119541. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  119542. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  119543. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  119544. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  119545. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  119546. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  119547. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  119548. // Create effects
  119549. _this._createChromaticAberrationPostProcess(ratio);
  119550. _this._createHighlightsPostProcess(ratio);
  119551. _this._createDepthOfFieldPostProcess(ratio / 4);
  119552. // Set up pipeline
  119553. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  119554. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  119555. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  119556. if (_this._highlightsGain === -1) {
  119557. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  119558. }
  119559. // Finish
  119560. scene.postProcessRenderPipelineManager.addPipeline(_this);
  119561. if (cameras) {
  119562. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  119563. }
  119564. return _this;
  119565. }
  119566. /**
  119567. * Get the class name
  119568. * @returns "LensRenderingPipeline"
  119569. */
  119570. LensRenderingPipeline.prototype.getClassName = function () {
  119571. return "LensRenderingPipeline";
  119572. };
  119573. Object.defineProperty(LensRenderingPipeline.prototype, "scene", {
  119574. // Properties
  119575. /**
  119576. * Gets associated scene
  119577. */
  119578. get: function () {
  119579. return this._scene;
  119580. },
  119581. enumerable: true,
  119582. configurable: true
  119583. });
  119584. Object.defineProperty(LensRenderingPipeline.prototype, "edgeBlur", {
  119585. /**
  119586. * Gets or sets the edge blur
  119587. */
  119588. get: function () {
  119589. return this._edgeBlur;
  119590. },
  119591. set: function (value) {
  119592. this.setEdgeBlur(value);
  119593. },
  119594. enumerable: true,
  119595. configurable: true
  119596. });
  119597. Object.defineProperty(LensRenderingPipeline.prototype, "grainAmount", {
  119598. /**
  119599. * Gets or sets the grain amount
  119600. */
  119601. get: function () {
  119602. return this._grainAmount;
  119603. },
  119604. set: function (value) {
  119605. this.setGrainAmount(value);
  119606. },
  119607. enumerable: true,
  119608. configurable: true
  119609. });
  119610. Object.defineProperty(LensRenderingPipeline.prototype, "chromaticAberration", {
  119611. /**
  119612. * Gets or sets the chromatic aberration amount
  119613. */
  119614. get: function () {
  119615. return this._chromaticAberration;
  119616. },
  119617. set: function (value) {
  119618. this.setChromaticAberration(value);
  119619. },
  119620. enumerable: true,
  119621. configurable: true
  119622. });
  119623. Object.defineProperty(LensRenderingPipeline.prototype, "dofAperture", {
  119624. /**
  119625. * Gets or sets the depth of field aperture
  119626. */
  119627. get: function () {
  119628. return this._dofAperture;
  119629. },
  119630. set: function (value) {
  119631. this.setAperture(value);
  119632. },
  119633. enumerable: true,
  119634. configurable: true
  119635. });
  119636. Object.defineProperty(LensRenderingPipeline.prototype, "edgeDistortion", {
  119637. /**
  119638. * Gets or sets the edge distortion
  119639. */
  119640. get: function () {
  119641. return this._distortion;
  119642. },
  119643. set: function (value) {
  119644. this.setEdgeDistortion(value);
  119645. },
  119646. enumerable: true,
  119647. configurable: true
  119648. });
  119649. Object.defineProperty(LensRenderingPipeline.prototype, "dofDistortion", {
  119650. /**
  119651. * Gets or sets the depth of field distortion
  119652. */
  119653. get: function () {
  119654. return this._dofDistance;
  119655. },
  119656. set: function (value) {
  119657. this.setFocusDistance(value);
  119658. },
  119659. enumerable: true,
  119660. configurable: true
  119661. });
  119662. Object.defineProperty(LensRenderingPipeline.prototype, "darkenOutOfFocus", {
  119663. /**
  119664. * Gets or sets the darken out of focus amount
  119665. */
  119666. get: function () {
  119667. return this._dofDarken;
  119668. },
  119669. set: function (value) {
  119670. this.setDarkenOutOfFocus(value);
  119671. },
  119672. enumerable: true,
  119673. configurable: true
  119674. });
  119675. Object.defineProperty(LensRenderingPipeline.prototype, "blurNoise", {
  119676. /**
  119677. * Gets or sets a boolean indicating if blur noise is enabled
  119678. */
  119679. get: function () {
  119680. return this._blurNoise;
  119681. },
  119682. set: function (value) {
  119683. this._blurNoise = value;
  119684. },
  119685. enumerable: true,
  119686. configurable: true
  119687. });
  119688. Object.defineProperty(LensRenderingPipeline.prototype, "pentagonBokeh", {
  119689. /**
  119690. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  119691. */
  119692. get: function () {
  119693. return this._pentagonBokehIsEnabled;
  119694. },
  119695. set: function (value) {
  119696. if (value) {
  119697. this.enablePentagonBokeh();
  119698. }
  119699. else {
  119700. this.disablePentagonBokeh();
  119701. }
  119702. },
  119703. enumerable: true,
  119704. configurable: true
  119705. });
  119706. Object.defineProperty(LensRenderingPipeline.prototype, "highlightsGain", {
  119707. /**
  119708. * Gets or sets the highlight grain amount
  119709. */
  119710. get: function () {
  119711. return this._highlightsGain;
  119712. },
  119713. set: function (value) {
  119714. this.setHighlightsGain(value);
  119715. },
  119716. enumerable: true,
  119717. configurable: true
  119718. });
  119719. Object.defineProperty(LensRenderingPipeline.prototype, "highlightsThreshold", {
  119720. /**
  119721. * Gets or sets the highlight threshold
  119722. */
  119723. get: function () {
  119724. return this._highlightsThreshold;
  119725. },
  119726. set: function (value) {
  119727. this.setHighlightsThreshold(value);
  119728. },
  119729. enumerable: true,
  119730. configurable: true
  119731. });
  119732. // public methods (self explanatory)
  119733. /**
  119734. * Sets the amount of blur at the edges
  119735. * @param amount blur amount
  119736. */
  119737. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  119738. /**
  119739. * Sets edge blur to 0
  119740. */
  119741. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  119742. /**
  119743. * Sets the amout of grain
  119744. * @param amount Amount of grain
  119745. */
  119746. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  119747. /**
  119748. * Set grain amount to 0
  119749. */
  119750. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  119751. /**
  119752. * Sets the chromatic aberration amount
  119753. * @param amount amount of chromatic aberration
  119754. */
  119755. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  119756. /**
  119757. * Sets chromatic aberration amount to 0
  119758. */
  119759. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  119760. /**
  119761. * Sets the EdgeDistortion amount
  119762. * @param amount amount of EdgeDistortion
  119763. */
  119764. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  119765. /**
  119766. * Sets edge distortion to 0
  119767. */
  119768. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  119769. /**
  119770. * Sets the FocusDistance amount
  119771. * @param amount amount of FocusDistance
  119772. */
  119773. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  119774. /**
  119775. * Disables depth of field
  119776. */
  119777. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  119778. /**
  119779. * Sets the Aperture amount
  119780. * @param amount amount of Aperture
  119781. */
  119782. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  119783. /**
  119784. * Sets the DarkenOutOfFocus amount
  119785. * @param amount amount of DarkenOutOfFocus
  119786. */
  119787. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  119788. /**
  119789. * Creates a pentagon bokeh effect
  119790. */
  119791. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  119792. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  119793. this._pentagonBokehIsEnabled = true;
  119794. };
  119795. /**
  119796. * Disables the pentagon bokeh effect
  119797. */
  119798. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  119799. this._pentagonBokehIsEnabled = false;
  119800. this._highlightsPostProcess.updateEffect();
  119801. };
  119802. /**
  119803. * Enables noise blur
  119804. */
  119805. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  119806. /**
  119807. * Disables noise blur
  119808. */
  119809. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  119810. /**
  119811. * Sets the HighlightsGain amount
  119812. * @param amount amount of HighlightsGain
  119813. */
  119814. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  119815. this._highlightsGain = amount;
  119816. };
  119817. /**
  119818. * Sets the HighlightsThreshold amount
  119819. * @param amount amount of HighlightsThreshold
  119820. */
  119821. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  119822. if (this._highlightsGain === -1) {
  119823. this._highlightsGain = 1.0;
  119824. }
  119825. this._highlightsThreshold = amount;
  119826. };
  119827. /**
  119828. * Disables highlights
  119829. */
  119830. LensRenderingPipeline.prototype.disableHighlights = function () {
  119831. this._highlightsGain = -1;
  119832. };
  119833. /**
  119834. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  119835. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  119836. */
  119837. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  119838. if (disableDepthRender === void 0) { disableDepthRender = false; }
  119839. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  119840. this._chromaticAberrationPostProcess = null;
  119841. this._highlightsPostProcess = null;
  119842. this._depthOfFieldPostProcess = null;
  119843. this._grainTexture.dispose();
  119844. if (disableDepthRender) {
  119845. this._scene.disableDepthRenderer();
  119846. }
  119847. };
  119848. // colors shifting and distortion
  119849. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  119850. var _this = this;
  119851. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  119852. [], // samplers
  119853. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  119854. this._chromaticAberrationPostProcess.onApply = function (effect) {
  119855. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  119856. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  119857. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  119858. effect.setFloat('radialIntensity', 1);
  119859. effect.setFloat2('direction', 17, 17);
  119860. effect.setFloat2('centerPosition', 0.5, 0.5);
  119861. };
  119862. };
  119863. // highlights enhancing
  119864. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  119865. var _this = this;
  119866. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  119867. [], // samplers
  119868. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  119869. this._highlightsPostProcess.onApply = function (effect) {
  119870. effect.setFloat('gain', _this._highlightsGain);
  119871. effect.setFloat('threshold', _this._highlightsThreshold);
  119872. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  119873. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  119874. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  119875. };
  119876. };
  119877. // colors shifting and distortion
  119878. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  119879. var _this = this;
  119880. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  119881. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  119882. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  119883. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  119884. this._depthOfFieldPostProcess.onApply = function (effect) {
  119885. effect.setTexture("depthSampler", _this._depthTexture);
  119886. effect.setTexture("grainSampler", _this._grainTexture);
  119887. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  119888. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  119889. effect.setFloat('grain_amount', _this._grainAmount);
  119890. effect.setBool('blur_noise', _this._blurNoise);
  119891. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  119892. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  119893. effect.setFloat('distortion', _this._distortion);
  119894. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  119895. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  119896. effect.setFloat('aperture', _this._dofAperture);
  119897. effect.setFloat('darken', _this._dofDarken);
  119898. effect.setFloat('edge_blur', _this._edgeBlur);
  119899. effect.setBool('highlights', (_this._highlightsGain !== -1));
  119900. if (_this._scene.activeCamera) {
  119901. effect.setFloat('near', _this._scene.activeCamera.minZ);
  119902. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  119903. }
  119904. };
  119905. };
  119906. // creates a black and white random noise texture, 512x512
  119907. LensRenderingPipeline.prototype._createGrainTexture = function () {
  119908. var size = 512;
  119909. 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);
  119910. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  119911. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  119912. var context = this._grainTexture.getContext();
  119913. var rand = function (min, max) {
  119914. return Math.random() * (max - min) + min;
  119915. };
  119916. var value;
  119917. for (var x = 0; x < size; x++) {
  119918. for (var y = 0; y < size; y++) {
  119919. value = Math.floor(rand(0.42, 0.58) * 255);
  119920. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  119921. context.fillRect(x, y, 1, 1);
  119922. }
  119923. }
  119924. this._grainTexture.update(false);
  119925. };
  119926. return LensRenderingPipeline;
  119927. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  119928. /***/ }),
  119929. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  119930. /*!**************************************************************************!*\
  119931. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  119932. \**************************************************************************/
  119933. /*! exports provided: SSAO2RenderingPipeline */
  119934. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119935. "use strict";
  119936. __webpack_require__.r(__webpack_exports__);
  119937. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  119938. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119939. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  119940. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  119941. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  119942. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119943. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  119944. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  119945. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  119946. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  119947. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  119948. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  119949. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  119950. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  119951. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  119952. /**
  119953. * Render pipeline to produce ssao effect
  119954. */
  119955. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  119956. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  119957. /**
  119958. * @constructor
  119959. * @param name The rendering pipeline name
  119960. * @param scene The scene linked to this pipeline
  119961. * @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 }
  119962. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119963. */
  119964. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  119965. var _this = _super.call(this, scene.getEngine(), name) || this;
  119966. // Members
  119967. /**
  119968. * @ignore
  119969. * The PassPostProcess id in the pipeline that contains the original scene color
  119970. */
  119971. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  119972. /**
  119973. * @ignore
  119974. * The SSAO PostProcess id in the pipeline
  119975. */
  119976. _this.SSAORenderEffect = "SSAORenderEffect";
  119977. /**
  119978. * @ignore
  119979. * The horizontal blur PostProcess id in the pipeline
  119980. */
  119981. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  119982. /**
  119983. * @ignore
  119984. * The vertical blur PostProcess id in the pipeline
  119985. */
  119986. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  119987. /**
  119988. * @ignore
  119989. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119990. */
  119991. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  119992. /**
  119993. * The output strength of the SSAO post-process. Default value is 1.0.
  119994. */
  119995. _this.totalStrength = 1.0;
  119996. /**
  119997. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  119998. */
  119999. _this.maxZ = 100.0;
  120000. /**
  120001. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  120002. */
  120003. _this.minZAspect = 0.2;
  120004. _this._samples = 8;
  120005. _this._textureSamples = 1;
  120006. _this._expensiveBlur = true;
  120007. /**
  120008. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  120009. */
  120010. _this.radius = 2.0;
  120011. /**
  120012. * The base color of the SSAO post-process
  120013. * The final result is "base + ssao" between [0, 1]
  120014. */
  120015. _this.base = 0;
  120016. _this._firstUpdate = true;
  120017. _this._bits = new Uint32Array(1);
  120018. _this._scene = scene;
  120019. _this._ratio = ratio;
  120020. if (!_this.isSupported) {
  120021. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  120022. return _this;
  120023. }
  120024. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  120025. var blurRatio = _this._ratio.blurRatio || ratio;
  120026. // Set up assets
  120027. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  120028. _this._createRandomTexture();
  120029. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  120030. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  120031. _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);
  120032. _this._originalColorPostProcess.samples = _this.textureSamples;
  120033. _this._createSSAOPostProcess(1.0);
  120034. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  120035. _this._createSSAOCombinePostProcess(blurRatio);
  120036. // Set up pipeline
  120037. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  120038. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  120039. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  120040. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  120041. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  120042. // Finish
  120043. scene.postProcessRenderPipelineManager.addPipeline(_this);
  120044. if (cameras) {
  120045. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  120046. }
  120047. return _this;
  120048. }
  120049. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  120050. get: function () {
  120051. return this._samples;
  120052. },
  120053. /**
  120054. * Number of samples used for the SSAO calculations. Default value is 8
  120055. */
  120056. set: function (n) {
  120057. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  120058. this._samples = n;
  120059. this._sampleSphere = this._generateHemisphere();
  120060. this._firstUpdate = true;
  120061. },
  120062. enumerable: true,
  120063. configurable: true
  120064. });
  120065. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  120066. get: function () {
  120067. return this._textureSamples;
  120068. },
  120069. /**
  120070. * Number of samples to use for antialiasing
  120071. */
  120072. set: function (n) {
  120073. this._textureSamples = n;
  120074. this._originalColorPostProcess.samples = n;
  120075. this._blurHPostProcess.samples = n;
  120076. this._blurVPostProcess.samples = n;
  120077. this._ssaoPostProcess.samples = n;
  120078. this._ssaoCombinePostProcess.samples = n;
  120079. },
  120080. enumerable: true,
  120081. configurable: true
  120082. });
  120083. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  120084. get: function () {
  120085. return this._expensiveBlur;
  120086. },
  120087. /**
  120088. * If bilateral blur should be used
  120089. */
  120090. set: function (b) {
  120091. 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"]);
  120092. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  120093. this._expensiveBlur = b;
  120094. this._firstUpdate = true;
  120095. },
  120096. enumerable: true,
  120097. configurable: true
  120098. });
  120099. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  120100. /**
  120101. * Support test.
  120102. */
  120103. get: function () {
  120104. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  120105. if (!engine) {
  120106. return false;
  120107. }
  120108. return engine.getCaps().drawBuffersExtension;
  120109. },
  120110. enumerable: true,
  120111. configurable: true
  120112. });
  120113. Object.defineProperty(SSAO2RenderingPipeline.prototype, "scene", {
  120114. /**
  120115. * Gets active scene
  120116. */
  120117. get: function () {
  120118. return this._scene;
  120119. },
  120120. enumerable: true,
  120121. configurable: true
  120122. });
  120123. // Public Methods
  120124. /**
  120125. * Get the class name
  120126. * @returns "SSAO2RenderingPipeline"
  120127. */
  120128. SSAO2RenderingPipeline.prototype.getClassName = function () {
  120129. return "SSAO2RenderingPipeline";
  120130. };
  120131. /**
  120132. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  120133. */
  120134. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  120135. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  120136. for (var i = 0; i < this._scene.cameras.length; i++) {
  120137. var camera = this._scene.cameras[i];
  120138. this._originalColorPostProcess.dispose(camera);
  120139. this._ssaoPostProcess.dispose(camera);
  120140. this._blurHPostProcess.dispose(camera);
  120141. this._blurVPostProcess.dispose(camera);
  120142. this._ssaoCombinePostProcess.dispose(camera);
  120143. }
  120144. this._randomTexture.dispose();
  120145. if (disableGeometryBufferRenderer) {
  120146. this._scene.disableGeometryBufferRenderer();
  120147. }
  120148. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  120149. _super.prototype.dispose.call(this);
  120150. };
  120151. // Private Methods
  120152. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  120153. var _this = this;
  120154. this._samplerOffsets = [];
  120155. var expensive = this.expensiveBlur;
  120156. for (var i = -8; i < 8; i++) {
  120157. this._samplerOffsets.push(i * 2 + 0.5);
  120158. }
  120159. 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");
  120160. this._blurHPostProcess.onApply = function (effect) {
  120161. if (!_this._scene.activeCamera) {
  120162. return;
  120163. }
  120164. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  120165. effect.setFloat("near", _this._scene.activeCamera.minZ);
  120166. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  120167. effect.setFloat("radius", _this.radius);
  120168. effect.setTexture("depthSampler", _this._depthTexture);
  120169. if (_this._firstUpdate) {
  120170. effect.setArray("samplerOffsets", _this._samplerOffsets);
  120171. }
  120172. };
  120173. 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");
  120174. this._blurVPostProcess.onApply = function (effect) {
  120175. if (!_this._scene.activeCamera) {
  120176. return;
  120177. }
  120178. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  120179. effect.setFloat("near", _this._scene.activeCamera.minZ);
  120180. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  120181. effect.setFloat("radius", _this.radius);
  120182. effect.setTexture("depthSampler", _this._depthTexture);
  120183. if (_this._firstUpdate) {
  120184. effect.setArray("samplerOffsets", _this._samplerOffsets);
  120185. _this._firstUpdate = false;
  120186. }
  120187. };
  120188. this._blurHPostProcess.samples = this.textureSamples;
  120189. this._blurVPostProcess.samples = this.textureSamples;
  120190. };
  120191. /** @hidden */
  120192. SSAO2RenderingPipeline.prototype._rebuild = function () {
  120193. this._firstUpdate = true;
  120194. _super.prototype._rebuild.call(this);
  120195. };
  120196. //Van der Corput radical inverse
  120197. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  120198. this._bits[0] = i;
  120199. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  120200. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  120201. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  120202. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  120203. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  120204. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  120205. };
  120206. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  120207. return [i / n, this._radicalInverse_VdC(i)];
  120208. };
  120209. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  120210. var phi = v * 2.0 * Math.PI;
  120211. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  120212. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  120213. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  120214. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  120215. };
  120216. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  120217. var numSamples = this.samples;
  120218. var result = [];
  120219. var vector;
  120220. var i = 0;
  120221. while (i < numSamples) {
  120222. if (numSamples < 16) {
  120223. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  120224. }
  120225. else {
  120226. var rand = this._hammersley(i, numSamples);
  120227. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  120228. }
  120229. result.push(vector.x, vector.y, vector.z);
  120230. i++;
  120231. }
  120232. return result;
  120233. };
  120234. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  120235. var _this = this;
  120236. var numSamples = this.samples;
  120237. this._sampleSphere = this._generateHemisphere();
  120238. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  120239. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  120240. "base", "range", "projection", "near", "far", "texelSize",
  120241. "xViewport", "yViewport", "maxZ", "minZAspect"
  120242. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  120243. this._ssaoPostProcess.onApply = function (effect) {
  120244. if (_this._firstUpdate) {
  120245. effect.setArray3("sampleSphere", _this._sampleSphere);
  120246. effect.setFloat("randTextureTiles", 32.0);
  120247. }
  120248. if (!_this._scene.activeCamera) {
  120249. return;
  120250. }
  120251. effect.setFloat("samplesFactor", 1 / _this.samples);
  120252. effect.setFloat("totalStrength", _this.totalStrength);
  120253. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  120254. effect.setFloat("radius", _this.radius);
  120255. effect.setFloat("maxZ", _this.maxZ);
  120256. effect.setFloat("minZAspect", _this.minZAspect);
  120257. effect.setFloat("base", _this.base);
  120258. effect.setFloat("near", _this._scene.activeCamera.minZ);
  120259. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  120260. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  120261. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  120262. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  120263. effect.setTexture("textureSampler", _this._depthTexture);
  120264. effect.setTexture("normalSampler", _this._normalTexture);
  120265. effect.setTexture("randomSampler", _this._randomTexture);
  120266. };
  120267. this._ssaoPostProcess.samples = this.textureSamples;
  120268. };
  120269. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  120270. var _this = this;
  120271. 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);
  120272. this._ssaoCombinePostProcess.onApply = function (effect) {
  120273. var viewport = _this._scene.activeCamera.viewport;
  120274. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  120275. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  120276. };
  120277. this._ssaoCombinePostProcess.samples = this.textureSamples;
  120278. };
  120279. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  120280. var size = 128;
  120281. 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);
  120282. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  120283. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  120284. var context = this._randomTexture.getContext();
  120285. var rand = function (min, max) {
  120286. return Math.random() * (max - min) + min;
  120287. };
  120288. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  120289. for (var x = 0; x < size; x++) {
  120290. for (var y = 0; y < size; y++) {
  120291. randVector.x = rand(0.0, 1.0);
  120292. randVector.y = rand(0.0, 1.0);
  120293. randVector.z = 0.0;
  120294. randVector.normalize();
  120295. randVector.scaleInPlace(255);
  120296. randVector.x = Math.floor(randVector.x);
  120297. randVector.y = Math.floor(randVector.y);
  120298. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  120299. context.fillRect(x, y, 1, 1);
  120300. }
  120301. }
  120302. this._randomTexture.update(false);
  120303. };
  120304. /**
  120305. * Serialize the rendering pipeline (Used when exporting)
  120306. * @returns the serialized object
  120307. */
  120308. SSAO2RenderingPipeline.prototype.serialize = function () {
  120309. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  120310. serializationObject.customType = "SSAO2RenderingPipeline";
  120311. return serializationObject;
  120312. };
  120313. /**
  120314. * Parse the serialized pipeline
  120315. * @param source Source pipeline.
  120316. * @param scene The scene to load the pipeline to.
  120317. * @param rootUrl The URL of the serialized pipeline.
  120318. * @returns An instantiated pipeline from the serialized object.
  120319. */
  120320. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  120321. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  120322. };
  120323. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120324. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120325. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  120326. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120327. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120328. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  120329. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120330. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120331. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  120332. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120333. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  120334. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  120335. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120336. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  120337. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  120338. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120339. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120340. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  120341. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120342. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  120343. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  120344. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120345. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120346. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  120347. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120348. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  120349. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  120350. return SSAO2RenderingPipeline;
  120351. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  120352. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  120353. /***/ }),
  120354. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  120355. /*!*************************************************************************!*\
  120356. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  120357. \*************************************************************************/
  120358. /*! exports provided: SSAORenderingPipeline */
  120359. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120360. "use strict";
  120361. __webpack_require__.r(__webpack_exports__);
  120362. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  120363. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120364. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  120365. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120366. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  120367. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  120368. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  120369. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  120370. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  120371. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  120372. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  120373. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  120374. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  120375. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  120376. /**
  120377. * Render pipeline to produce ssao effect
  120378. */
  120379. var SSAORenderingPipeline = /** @class */ (function (_super) {
  120380. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  120381. /**
  120382. * @constructor
  120383. * @param name - The rendering pipeline name
  120384. * @param scene - The scene linked to this pipeline
  120385. * @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 }
  120386. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  120387. */
  120388. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  120389. var _this = _super.call(this, scene.getEngine(), name) || this;
  120390. // Members
  120391. /**
  120392. * @ignore
  120393. * The PassPostProcess id in the pipeline that contains the original scene color
  120394. */
  120395. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  120396. /**
  120397. * @ignore
  120398. * The SSAO PostProcess id in the pipeline
  120399. */
  120400. _this.SSAORenderEffect = "SSAORenderEffect";
  120401. /**
  120402. * @ignore
  120403. * The horizontal blur PostProcess id in the pipeline
  120404. */
  120405. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  120406. /**
  120407. * @ignore
  120408. * The vertical blur PostProcess id in the pipeline
  120409. */
  120410. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  120411. /**
  120412. * @ignore
  120413. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  120414. */
  120415. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  120416. /**
  120417. * The output strength of the SSAO post-process. Default value is 1.0.
  120418. */
  120419. _this.totalStrength = 1.0;
  120420. /**
  120421. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  120422. */
  120423. _this.radius = 0.0001;
  120424. /**
  120425. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  120426. * Must not be equal to fallOff and superior to fallOff.
  120427. * Default value is 0.0075
  120428. */
  120429. _this.area = 0.0075;
  120430. /**
  120431. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  120432. * Must not be equal to area and inferior to area.
  120433. * Default value is 0.000001
  120434. */
  120435. _this.fallOff = 0.000001;
  120436. /**
  120437. * The base color of the SSAO post-process
  120438. * The final result is "base + ssao" between [0, 1]
  120439. */
  120440. _this.base = 0.5;
  120441. _this._firstUpdate = true;
  120442. _this._scene = scene;
  120443. // Set up assets
  120444. _this._createRandomTexture();
  120445. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  120446. var ssaoRatio = ratio.ssaoRatio || ratio;
  120447. var combineRatio = ratio.combineRatio || ratio;
  120448. _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);
  120449. _this._createSSAOPostProcess(ssaoRatio);
  120450. _this._createBlurPostProcess(ssaoRatio);
  120451. _this._createSSAOCombinePostProcess(combineRatio);
  120452. // Set up pipeline
  120453. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  120454. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  120455. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  120456. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  120457. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  120458. // Finish
  120459. scene.postProcessRenderPipelineManager.addPipeline(_this);
  120460. if (cameras) {
  120461. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  120462. }
  120463. return _this;
  120464. }
  120465. Object.defineProperty(SSAORenderingPipeline.prototype, "scene", {
  120466. /**
  120467. * Gets active scene
  120468. */
  120469. get: function () {
  120470. return this._scene;
  120471. },
  120472. enumerable: true,
  120473. configurable: true
  120474. });
  120475. // Public Methods
  120476. /**
  120477. * Get the class name
  120478. * @returns "SSAORenderingPipeline"
  120479. */
  120480. SSAORenderingPipeline.prototype.getClassName = function () {
  120481. return "SSAORenderingPipeline";
  120482. };
  120483. /**
  120484. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  120485. */
  120486. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  120487. if (disableDepthRender === void 0) { disableDepthRender = false; }
  120488. for (var i = 0; i < this._scene.cameras.length; i++) {
  120489. var camera = this._scene.cameras[i];
  120490. this._originalColorPostProcess.dispose(camera);
  120491. this._ssaoPostProcess.dispose(camera);
  120492. this._blurHPostProcess.dispose(camera);
  120493. this._blurVPostProcess.dispose(camera);
  120494. this._ssaoCombinePostProcess.dispose(camera);
  120495. }
  120496. this._randomTexture.dispose();
  120497. if (disableDepthRender) {
  120498. this._scene.disableDepthRenderer();
  120499. }
  120500. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  120501. _super.prototype.dispose.call(this);
  120502. };
  120503. // Private Methods
  120504. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  120505. var _this = this;
  120506. var size = 16;
  120507. 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);
  120508. 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);
  120509. this._blurHPostProcess.onActivateObservable.add(function () {
  120510. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  120511. _this._blurHPostProcess.kernel = size * dw;
  120512. });
  120513. this._blurVPostProcess.onActivateObservable.add(function () {
  120514. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  120515. _this._blurVPostProcess.kernel = size * dw;
  120516. });
  120517. };
  120518. /** @hidden */
  120519. SSAORenderingPipeline.prototype._rebuild = function () {
  120520. this._firstUpdate = true;
  120521. _super.prototype._rebuild.call(this);
  120522. };
  120523. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  120524. var _this = this;
  120525. var numSamples = 16;
  120526. var sampleSphere = [
  120527. 0.5381, 0.1856, -0.4319,
  120528. 0.1379, 0.2486, 0.4430,
  120529. 0.3371, 0.5679, -0.0057,
  120530. -0.6999, -0.0451, -0.0019,
  120531. 0.0689, -0.1598, -0.8547,
  120532. 0.0560, 0.0069, -0.1843,
  120533. -0.0146, 0.1402, 0.0762,
  120534. 0.0100, -0.1924, -0.0344,
  120535. -0.3577, -0.5301, -0.4358,
  120536. -0.3169, 0.1063, 0.0158,
  120537. 0.0103, -0.5869, 0.0046,
  120538. -0.0897, -0.4940, 0.3287,
  120539. 0.7119, -0.0154, -0.0918,
  120540. -0.0533, 0.0596, -0.5411,
  120541. 0.0352, -0.0631, 0.5460,
  120542. -0.4776, 0.2847, -0.0271
  120543. ];
  120544. var samplesFactor = 1.0 / numSamples;
  120545. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  120546. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  120547. "area", "fallOff", "base", "range", "viewport"
  120548. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  120549. this._ssaoPostProcess.onApply = function (effect) {
  120550. if (_this._firstUpdate) {
  120551. effect.setArray3("sampleSphere", sampleSphere);
  120552. effect.setFloat("samplesFactor", samplesFactor);
  120553. effect.setFloat("randTextureTiles", 4.0);
  120554. }
  120555. effect.setFloat("totalStrength", _this.totalStrength);
  120556. effect.setFloat("radius", _this.radius);
  120557. effect.setFloat("area", _this.area);
  120558. effect.setFloat("fallOff", _this.fallOff);
  120559. effect.setFloat("base", _this.base);
  120560. effect.setTexture("textureSampler", _this._depthTexture);
  120561. effect.setTexture("randomSampler", _this._randomTexture);
  120562. };
  120563. };
  120564. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  120565. var _this = this;
  120566. 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);
  120567. this._ssaoCombinePostProcess.onApply = function (effect) {
  120568. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  120569. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  120570. };
  120571. };
  120572. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  120573. var size = 512;
  120574. 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);
  120575. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  120576. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  120577. var context = this._randomTexture.getContext();
  120578. var rand = function (min, max) {
  120579. return Math.random() * (max - min) + min;
  120580. };
  120581. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  120582. for (var x = 0; x < size; x++) {
  120583. for (var y = 0; y < size; y++) {
  120584. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  120585. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  120586. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  120587. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  120588. context.fillRect(x, y, 1, 1);
  120589. }
  120590. }
  120591. this._randomTexture.update(false);
  120592. };
  120593. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120594. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  120595. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  120596. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120597. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  120598. ], SSAORenderingPipeline.prototype, "radius", void 0);
  120599. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120600. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  120601. ], SSAORenderingPipeline.prototype, "area", void 0);
  120602. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120603. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  120604. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  120605. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120606. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  120607. ], SSAORenderingPipeline.prototype, "base", void 0);
  120608. return SSAORenderingPipeline;
  120609. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  120610. /***/ }),
  120611. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  120612. /*!*****************************************************************************!*\
  120613. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  120614. \*****************************************************************************/
  120615. /*! exports provided: StandardRenderingPipeline */
  120616. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120617. "use strict";
  120618. __webpack_require__.r(__webpack_exports__);
  120619. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  120620. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120621. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  120622. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  120623. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  120624. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  120625. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120626. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  120627. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  120628. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  120629. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  120630. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  120631. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  120632. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  120633. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  120634. /**
  120635. * Standard rendering pipeline
  120636. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  120637. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  120638. */
  120639. var StandardRenderingPipeline = /** @class */ (function (_super) {
  120640. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  120641. /**
  120642. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  120643. * @constructor
  120644. * @param name The rendering pipeline name
  120645. * @param scene The scene linked to this pipeline
  120646. * @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)
  120647. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  120648. * @param cameras The array of cameras that the rendering pipeline will be attached to
  120649. */
  120650. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  120651. if (originalPostProcess === void 0) { originalPostProcess = null; }
  120652. var _this = _super.call(this, scene.getEngine(), name) || this;
  120653. /**
  120654. * Post-process used to down scale an image x4
  120655. */
  120656. _this.downSampleX4PostProcess = null;
  120657. /**
  120658. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  120659. */
  120660. _this.brightPassPostProcess = null;
  120661. /**
  120662. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  120663. */
  120664. _this.blurHPostProcesses = [];
  120665. /**
  120666. * Post-process array storing all the vertical blur post-processes used by the pipeline
  120667. */
  120668. _this.blurVPostProcesses = [];
  120669. /**
  120670. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  120671. */
  120672. _this.textureAdderPostProcess = null;
  120673. /**
  120674. * Post-process used to create volumetric lighting effect
  120675. */
  120676. _this.volumetricLightPostProcess = null;
  120677. /**
  120678. * Post-process used to smooth the previous volumetric light post-process on the X axis
  120679. */
  120680. _this.volumetricLightSmoothXPostProcess = null;
  120681. /**
  120682. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  120683. */
  120684. _this.volumetricLightSmoothYPostProcess = null;
  120685. /**
  120686. * Post-process used to merge the volumetric light effect and the real scene color
  120687. */
  120688. _this.volumetricLightMergePostProces = null;
  120689. /**
  120690. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  120691. */
  120692. _this.volumetricLightFinalPostProcess = null;
  120693. /**
  120694. * Base post-process used to calculate the average luminance of the final image for HDR
  120695. */
  120696. _this.luminancePostProcess = null;
  120697. /**
  120698. * Post-processes used to create down sample post-processes in order to get
  120699. * the average luminance of the final image for HDR
  120700. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  120701. */
  120702. _this.luminanceDownSamplePostProcesses = [];
  120703. /**
  120704. * Post-process used to create a HDR effect (light adaptation)
  120705. */
  120706. _this.hdrPostProcess = null;
  120707. /**
  120708. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  120709. */
  120710. _this.textureAdderFinalPostProcess = null;
  120711. /**
  120712. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  120713. */
  120714. _this.lensFlareFinalPostProcess = null;
  120715. /**
  120716. * Post-process used to merge the final HDR post-process and the real scene color
  120717. */
  120718. _this.hdrFinalPostProcess = null;
  120719. /**
  120720. * Post-process used to create a lens flare effect
  120721. */
  120722. _this.lensFlarePostProcess = null;
  120723. /**
  120724. * Post-process that merges the result of the lens flare post-process and the real scene color
  120725. */
  120726. _this.lensFlareComposePostProcess = null;
  120727. /**
  120728. * Post-process used to create a motion blur effect
  120729. */
  120730. _this.motionBlurPostProcess = null;
  120731. /**
  120732. * Post-process used to create a depth of field effect
  120733. */
  120734. _this.depthOfFieldPostProcess = null;
  120735. /**
  120736. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  120737. */
  120738. _this.fxaaPostProcess = null;
  120739. // Values
  120740. /**
  120741. * Represents the brightness threshold in order to configure the illuminated surfaces
  120742. */
  120743. _this.brightThreshold = 1.0;
  120744. /**
  120745. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  120746. */
  120747. _this.blurWidth = 512.0;
  120748. /**
  120749. * Sets if the blur for highlighted surfaces must be only horizontal
  120750. */
  120751. _this.horizontalBlur = false;
  120752. /**
  120753. * Texture used typically to simulate "dirty" on camera lens
  120754. */
  120755. _this.lensTexture = null;
  120756. /**
  120757. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  120758. */
  120759. _this.volumetricLightCoefficient = 0.2;
  120760. /**
  120761. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  120762. */
  120763. _this.volumetricLightPower = 4.0;
  120764. /**
  120765. * Used the set the blur intensity to smooth the volumetric lights
  120766. */
  120767. _this.volumetricLightBlurScale = 64.0;
  120768. /**
  120769. * Light (spot or directional) used to generate the volumetric lights rays
  120770. * The source light must have a shadow generate so the pipeline can get its
  120771. * depth map
  120772. */
  120773. _this.sourceLight = null;
  120774. /**
  120775. * For eye adaptation, represents the minimum luminance the eye can see
  120776. */
  120777. _this.hdrMinimumLuminance = 1.0;
  120778. /**
  120779. * For eye adaptation, represents the decrease luminance speed
  120780. */
  120781. _this.hdrDecreaseRate = 0.5;
  120782. /**
  120783. * For eye adaptation, represents the increase luminance speed
  120784. */
  120785. _this.hdrIncreaseRate = 0.5;
  120786. /**
  120787. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  120788. */
  120789. _this.lensColorTexture = null;
  120790. /**
  120791. * The overall strengh for the lens flare effect
  120792. */
  120793. _this.lensFlareStrength = 20.0;
  120794. /**
  120795. * Dispersion coefficient for lens flare ghosts
  120796. */
  120797. _this.lensFlareGhostDispersal = 1.4;
  120798. /**
  120799. * Main lens flare halo width
  120800. */
  120801. _this.lensFlareHaloWidth = 0.7;
  120802. /**
  120803. * Based on the lens distortion effect, defines how much the lens flare result
  120804. * is distorted
  120805. */
  120806. _this.lensFlareDistortionStrength = 16.0;
  120807. /**
  120808. * Lens star texture must be used to simulate rays on the flares and is available
  120809. * in the documentation
  120810. */
  120811. _this.lensStarTexture = null;
  120812. /**
  120813. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  120814. * flare effect by taking account of the dirt texture
  120815. */
  120816. _this.lensFlareDirtTexture = null;
  120817. /**
  120818. * Represents the focal length for the depth of field effect
  120819. */
  120820. _this.depthOfFieldDistance = 10.0;
  120821. /**
  120822. * Represents the blur intensity for the blurred part of the depth of field effect
  120823. */
  120824. _this.depthOfFieldBlurWidth = 64.0;
  120825. /**
  120826. * For motion blur, defines how much the image is blurred by the movement
  120827. */
  120828. _this.motionStrength = 1.0;
  120829. /**
  120830. * List of animations for the pipeline (IAnimatable implementation)
  120831. */
  120832. _this.animations = [];
  120833. _this._currentDepthOfFieldSource = null;
  120834. _this._fixedExposure = 1.0;
  120835. _this._currentExposure = 1.0;
  120836. _this._hdrAutoExposure = false;
  120837. _this._hdrCurrentLuminance = 1.0;
  120838. // Getters and setters
  120839. _this._bloomEnabled = false;
  120840. _this._depthOfFieldEnabled = false;
  120841. _this._vlsEnabled = false;
  120842. _this._lensFlareEnabled = false;
  120843. _this._hdrEnabled = false;
  120844. _this._motionBlurEnabled = false;
  120845. _this._fxaaEnabled = false;
  120846. _this._motionBlurSamples = 64.0;
  120847. _this._volumetricLightStepsCount = 50.0;
  120848. _this._samples = 1;
  120849. _this._cameras = cameras || [];
  120850. // Initialize
  120851. _this._scene = scene;
  120852. _this._basePostProcess = originalPostProcess;
  120853. _this._ratio = ratio;
  120854. // Misc
  120855. _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;
  120856. // Finish
  120857. scene.postProcessRenderPipelineManager.addPipeline(_this);
  120858. _this._buildPipeline();
  120859. return _this;
  120860. }
  120861. Object.defineProperty(StandardRenderingPipeline.prototype, "exposure", {
  120862. /**
  120863. * Gets the overall exposure used by the pipeline
  120864. */
  120865. get: function () {
  120866. return this._fixedExposure;
  120867. },
  120868. /**
  120869. * Sets the overall exposure used by the pipeline
  120870. */
  120871. set: function (value) {
  120872. this._fixedExposure = value;
  120873. this._currentExposure = value;
  120874. },
  120875. enumerable: true,
  120876. configurable: true
  120877. });
  120878. Object.defineProperty(StandardRenderingPipeline.prototype, "hdrAutoExposure", {
  120879. /**
  120880. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  120881. */
  120882. get: function () {
  120883. return this._hdrAutoExposure;
  120884. },
  120885. /**
  120886. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  120887. */
  120888. set: function (value) {
  120889. this._hdrAutoExposure = value;
  120890. if (this.hdrPostProcess) {
  120891. var defines = ["#define HDR"];
  120892. if (value) {
  120893. defines.push("#define AUTO_EXPOSURE");
  120894. }
  120895. this.hdrPostProcess.updateEffect(defines.join("\n"));
  120896. }
  120897. },
  120898. enumerable: true,
  120899. configurable: true
  120900. });
  120901. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  120902. /**
  120903. * @ignore
  120904. * Specifies if the bloom pipeline is enabled
  120905. */
  120906. get: function () {
  120907. return this._bloomEnabled;
  120908. },
  120909. set: function (enabled) {
  120910. if (this._bloomEnabled === enabled) {
  120911. return;
  120912. }
  120913. this._bloomEnabled = enabled;
  120914. this._buildPipeline();
  120915. },
  120916. enumerable: true,
  120917. configurable: true
  120918. });
  120919. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  120920. /**
  120921. * @ignore
  120922. * Specifies if the depth of field pipeline is enabed
  120923. */
  120924. get: function () {
  120925. return this._depthOfFieldEnabled;
  120926. },
  120927. set: function (enabled) {
  120928. if (this._depthOfFieldEnabled === enabled) {
  120929. return;
  120930. }
  120931. this._depthOfFieldEnabled = enabled;
  120932. this._buildPipeline();
  120933. },
  120934. enumerable: true,
  120935. configurable: true
  120936. });
  120937. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  120938. /**
  120939. * @ignore
  120940. * Specifies if the lens flare pipeline is enabed
  120941. */
  120942. get: function () {
  120943. return this._lensFlareEnabled;
  120944. },
  120945. set: function (enabled) {
  120946. if (this._lensFlareEnabled === enabled) {
  120947. return;
  120948. }
  120949. this._lensFlareEnabled = enabled;
  120950. this._buildPipeline();
  120951. },
  120952. enumerable: true,
  120953. configurable: true
  120954. });
  120955. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  120956. /**
  120957. * @ignore
  120958. * Specifies if the HDR pipeline is enabled
  120959. */
  120960. get: function () {
  120961. return this._hdrEnabled;
  120962. },
  120963. set: function (enabled) {
  120964. if (this._hdrEnabled === enabled) {
  120965. return;
  120966. }
  120967. this._hdrEnabled = enabled;
  120968. this._buildPipeline();
  120969. },
  120970. enumerable: true,
  120971. configurable: true
  120972. });
  120973. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  120974. /**
  120975. * @ignore
  120976. * Specifies if the volumetric lights scattering effect is enabled
  120977. */
  120978. get: function () {
  120979. return this._vlsEnabled;
  120980. },
  120981. set: function (enabled) {
  120982. if (this._vlsEnabled === enabled) {
  120983. return;
  120984. }
  120985. if (enabled) {
  120986. var geometry = this._scene.enableGeometryBufferRenderer();
  120987. if (!geometry) {
  120988. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  120989. return;
  120990. }
  120991. }
  120992. this._vlsEnabled = enabled;
  120993. this._buildPipeline();
  120994. },
  120995. enumerable: true,
  120996. configurable: true
  120997. });
  120998. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  120999. /**
  121000. * @ignore
  121001. * Specifies if the motion blur effect is enabled
  121002. */
  121003. get: function () {
  121004. return this._motionBlurEnabled;
  121005. },
  121006. set: function (enabled) {
  121007. if (this._motionBlurEnabled === enabled) {
  121008. return;
  121009. }
  121010. this._motionBlurEnabled = enabled;
  121011. this._buildPipeline();
  121012. },
  121013. enumerable: true,
  121014. configurable: true
  121015. });
  121016. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  121017. /**
  121018. * Specifies if anti-aliasing is enabled
  121019. */
  121020. get: function () {
  121021. return this._fxaaEnabled;
  121022. },
  121023. set: function (enabled) {
  121024. if (this._fxaaEnabled === enabled) {
  121025. return;
  121026. }
  121027. this._fxaaEnabled = enabled;
  121028. this._buildPipeline();
  121029. },
  121030. enumerable: true,
  121031. configurable: true
  121032. });
  121033. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  121034. /**
  121035. * Specifies the number of steps used to calculate the volumetric lights
  121036. * Typically in interval [50, 200]
  121037. */
  121038. get: function () {
  121039. return this._volumetricLightStepsCount;
  121040. },
  121041. set: function (count) {
  121042. if (this.volumetricLightPostProcess) {
  121043. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  121044. }
  121045. this._volumetricLightStepsCount = count;
  121046. },
  121047. enumerable: true,
  121048. configurable: true
  121049. });
  121050. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  121051. /**
  121052. * Specifies the number of samples used for the motion blur effect
  121053. * Typically in interval [16, 64]
  121054. */
  121055. get: function () {
  121056. return this._motionBlurSamples;
  121057. },
  121058. set: function (samples) {
  121059. if (this.motionBlurPostProcess) {
  121060. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  121061. }
  121062. this._motionBlurSamples = samples;
  121063. },
  121064. enumerable: true,
  121065. configurable: true
  121066. });
  121067. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  121068. /**
  121069. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  121070. */
  121071. get: function () {
  121072. return this._samples;
  121073. },
  121074. set: function (sampleCount) {
  121075. if (this._samples === sampleCount) {
  121076. return;
  121077. }
  121078. this._samples = sampleCount;
  121079. this._buildPipeline();
  121080. },
  121081. enumerable: true,
  121082. configurable: true
  121083. });
  121084. StandardRenderingPipeline.prototype._buildPipeline = function () {
  121085. var _this = this;
  121086. var ratio = this._ratio;
  121087. var scene = this._scene;
  121088. this._disposePostProcesses();
  121089. this._reset();
  121090. // Create pass post-process
  121091. if (!this._basePostProcess) {
  121092. 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);
  121093. this.originalPostProcess.onApply = function () {
  121094. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  121095. };
  121096. }
  121097. else {
  121098. this.originalPostProcess = this._basePostProcess;
  121099. }
  121100. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  121101. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  121102. }
  121103. this._currentDepthOfFieldSource = this.originalPostProcess;
  121104. if (this._bloomEnabled) {
  121105. // Create down sample X4 post-process
  121106. this._createDownSampleX4PostProcess(scene, ratio / 2);
  121107. // Create bright pass post-process
  121108. this._createBrightPassPostProcess(scene, ratio / 2);
  121109. // Create gaussian blur post-processes (down sampling blurs)
  121110. this._createBlurPostProcesses(scene, ratio / 4, 1);
  121111. // Create texture adder post-process
  121112. this._createTextureAdderPostProcess(scene, ratio);
  121113. // Create depth-of-field source post-process
  121114. 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);
  121115. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  121116. }
  121117. if (this._vlsEnabled) {
  121118. // Create volumetric light
  121119. this._createVolumetricLightPostProcess(scene, ratio);
  121120. // Create volumetric light final post-process
  121121. 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);
  121122. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  121123. }
  121124. if (this._lensFlareEnabled) {
  121125. // Create lens flare post-process
  121126. this._createLensFlarePostProcess(scene, ratio);
  121127. // Create depth-of-field source post-process post lens-flare and disable it now
  121128. 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);
  121129. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  121130. }
  121131. if (this._hdrEnabled) {
  121132. // Create luminance
  121133. this._createLuminancePostProcesses(scene, this._floatTextureType);
  121134. // Create HDR
  121135. this._createHdrPostProcess(scene, ratio);
  121136. // Create depth-of-field source post-process post hdr and disable it now
  121137. 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);
  121138. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  121139. }
  121140. if (this._depthOfFieldEnabled) {
  121141. // Create gaussian blur used by depth-of-field
  121142. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  121143. // Create depth-of-field post-process
  121144. this._createDepthOfFieldPostProcess(scene, ratio);
  121145. }
  121146. if (this._motionBlurEnabled) {
  121147. // Create motion blur post-process
  121148. this._createMotionBlurPostProcess(scene, ratio);
  121149. }
  121150. if (this._fxaaEnabled) {
  121151. // Create fxaa post-process
  121152. 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);
  121153. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  121154. }
  121155. if (this._cameras !== null) {
  121156. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  121157. }
  121158. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  121159. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  121160. }
  121161. };
  121162. // Down Sample X4 Post-Processs
  121163. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  121164. var _this = this;
  121165. var downSampleX4Offsets = new Array(32);
  121166. 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);
  121167. this.downSampleX4PostProcess.onApply = function (effect) {
  121168. var id = 0;
  121169. var width = _this.downSampleX4PostProcess.width;
  121170. var height = _this.downSampleX4PostProcess.height;
  121171. for (var i = -2; i < 2; i++) {
  121172. for (var j = -2; j < 2; j++) {
  121173. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  121174. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  121175. id += 2;
  121176. }
  121177. }
  121178. effect.setArray2("dsOffsets", downSampleX4Offsets);
  121179. };
  121180. // Add to pipeline
  121181. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  121182. };
  121183. // Brightpass Post-Process
  121184. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  121185. var _this = this;
  121186. var brightOffsets = new Array(8);
  121187. 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);
  121188. this.brightPassPostProcess.onApply = function (effect) {
  121189. var sU = (1.0 / _this.brightPassPostProcess.width);
  121190. var sV = (1.0 / _this.brightPassPostProcess.height);
  121191. brightOffsets[0] = -0.5 * sU;
  121192. brightOffsets[1] = 0.5 * sV;
  121193. brightOffsets[2] = 0.5 * sU;
  121194. brightOffsets[3] = 0.5 * sV;
  121195. brightOffsets[4] = -0.5 * sU;
  121196. brightOffsets[5] = -0.5 * sV;
  121197. brightOffsets[6] = 0.5 * sU;
  121198. brightOffsets[7] = -0.5 * sV;
  121199. effect.setArray2("dsOffsets", brightOffsets);
  121200. effect.setFloat("brightThreshold", _this.brightThreshold);
  121201. };
  121202. // Add to pipeline
  121203. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  121204. };
  121205. // Create blur H&V post-processes
  121206. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  121207. var _this = this;
  121208. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  121209. var engine = scene.getEngine();
  121210. 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);
  121211. 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);
  121212. blurX.onActivateObservable.add(function () {
  121213. var dw = blurX.width / engine.getRenderWidth();
  121214. blurX.kernel = _this[blurWidthKey] * dw;
  121215. });
  121216. blurY.onActivateObservable.add(function () {
  121217. var dw = blurY.height / engine.getRenderHeight();
  121218. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  121219. });
  121220. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  121221. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  121222. this.blurHPostProcesses.push(blurX);
  121223. this.blurVPostProcesses.push(blurY);
  121224. };
  121225. // Create texture adder post-process
  121226. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  121227. var _this = this;
  121228. 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);
  121229. this.textureAdderPostProcess.onApply = function (effect) {
  121230. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  121231. effect.setTexture("lensSampler", _this.lensTexture);
  121232. effect.setFloat("exposure", _this._currentExposure);
  121233. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  121234. };
  121235. // Add to pipeline
  121236. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  121237. };
  121238. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  121239. var _this = this;
  121240. var geometryRenderer = scene.enableGeometryBufferRenderer();
  121241. geometryRenderer.enablePosition = true;
  121242. var geometry = geometryRenderer.getGBuffer();
  121243. // Base post-process
  121244. 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));
  121245. var depthValues = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  121246. this.volumetricLightPostProcess.onApply = function (effect) {
  121247. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  121248. var generator = _this.sourceLight.getShadowGenerator();
  121249. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  121250. effect.setTexture("positionSampler", geometry.textures[2]);
  121251. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  121252. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  121253. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  121254. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  121255. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  121256. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  121257. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  121258. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  121259. effect.setVector2("depthValues", depthValues);
  121260. }
  121261. };
  121262. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  121263. // Smooth
  121264. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  121265. // Merge
  121266. 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");
  121267. this.volumetricLightMergePostProces.onApply = function (effect) {
  121268. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  121269. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  121270. };
  121271. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  121272. };
  121273. // Create luminance
  121274. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  121275. var _this = this;
  121276. // Create luminance
  121277. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  121278. 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);
  121279. var offsets = [];
  121280. this.luminancePostProcess.onApply = function (effect) {
  121281. var sU = (1.0 / _this.luminancePostProcess.width);
  121282. var sV = (1.0 / _this.luminancePostProcess.height);
  121283. offsets[0] = -0.5 * sU;
  121284. offsets[1] = 0.5 * sV;
  121285. offsets[2] = 0.5 * sU;
  121286. offsets[3] = 0.5 * sV;
  121287. offsets[4] = -0.5 * sU;
  121288. offsets[5] = -0.5 * sV;
  121289. offsets[6] = 0.5 * sU;
  121290. offsets[7] = -0.5 * sV;
  121291. effect.setArray2("lumOffsets", offsets);
  121292. };
  121293. // Add to pipeline
  121294. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  121295. // Create down sample luminance
  121296. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  121297. var size = Math.pow(3, i);
  121298. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  121299. if (i === 0) {
  121300. defines += "#define FINAL_DOWN_SAMPLER";
  121301. }
  121302. 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);
  121303. this.luminanceDownSamplePostProcesses.push(postProcess);
  121304. }
  121305. // Create callbacks and add effects
  121306. var lastLuminance = this.luminancePostProcess;
  121307. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  121308. var downSampleOffsets = new Array(18);
  121309. pp.onApply = function (effect) {
  121310. if (!lastLuminance) {
  121311. return;
  121312. }
  121313. var id = 0;
  121314. for (var x = -1; x < 2; x++) {
  121315. for (var y = -1; y < 2; y++) {
  121316. downSampleOffsets[id] = x / lastLuminance.width;
  121317. downSampleOffsets[id + 1] = y / lastLuminance.height;
  121318. id += 2;
  121319. }
  121320. }
  121321. effect.setArray2("dsOffsets", downSampleOffsets);
  121322. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  121323. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  121324. lastLuminance = _this.luminancePostProcess;
  121325. }
  121326. else {
  121327. lastLuminance = pp;
  121328. }
  121329. };
  121330. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  121331. pp.onAfterRender = function () {
  121332. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  121333. 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);
  121334. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  121335. };
  121336. }
  121337. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  121338. });
  121339. };
  121340. // Create HDR post-process
  121341. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  121342. var _this = this;
  121343. var defines = ["#define HDR"];
  121344. if (this._hdrAutoExposure) {
  121345. defines.push("#define AUTO_EXPOSURE");
  121346. }
  121347. this.hdrPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDR", "standard", ["averageLuminance"], ["textureAdderSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, defines.join("\n"), _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  121348. var outputLiminance = 1;
  121349. var time = 0;
  121350. var lastTime = 0;
  121351. this.hdrPostProcess.onApply = function (effect) {
  121352. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  121353. time += scene.getEngine().getDeltaTime();
  121354. if (outputLiminance < 0) {
  121355. outputLiminance = _this._hdrCurrentLuminance;
  121356. }
  121357. else {
  121358. var dt = (lastTime - time) / 1000.0;
  121359. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  121360. outputLiminance += _this.hdrDecreaseRate * dt;
  121361. }
  121362. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  121363. outputLiminance -= _this.hdrIncreaseRate * dt;
  121364. }
  121365. else {
  121366. outputLiminance = _this._hdrCurrentLuminance;
  121367. }
  121368. }
  121369. if (_this.hdrAutoExposure) {
  121370. _this._currentExposure = _this._fixedExposure / outputLiminance;
  121371. }
  121372. else {
  121373. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  121374. effect.setFloat("averageLuminance", outputLiminance);
  121375. }
  121376. lastTime = time;
  121377. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  121378. };
  121379. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  121380. };
  121381. // Create lens flare post-process
  121382. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  121383. var _this = this;
  121384. 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);
  121385. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  121386. this._createBlurPostProcesses(scene, ratio / 4, 2);
  121387. 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);
  121388. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  121389. var resolution = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  121390. // Lens flare
  121391. this.lensFlarePostProcess.onApply = function (effect) {
  121392. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  121393. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  121394. effect.setFloat("strength", _this.lensFlareStrength);
  121395. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  121396. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  121397. // Shift
  121398. resolution.x = _this.lensFlarePostProcess.width;
  121399. resolution.y = _this.lensFlarePostProcess.height;
  121400. effect.setVector2("resolution", resolution);
  121401. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  121402. };
  121403. // Compose
  121404. 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);
  121405. 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);
  121406. this.lensFlareComposePostProcess.onApply = function (effect) {
  121407. if (!_this._scene.activeCamera) {
  121408. return;
  121409. }
  121410. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  121411. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  121412. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  121413. // Lens start rotation matrix
  121414. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  121415. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  121416. 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));
  121417. camRot *= 4.0;
  121418. 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);
  121419. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  121420. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  121421. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  121422. };
  121423. };
  121424. // Create depth-of-field post-process
  121425. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  121426. var _this = this;
  121427. 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);
  121428. this.depthOfFieldPostProcess.onApply = function (effect) {
  121429. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  121430. effect.setTexture("depthSampler", _this._getDepthTexture());
  121431. effect.setFloat("distance", _this.depthOfFieldDistance);
  121432. };
  121433. // Add to pipeline
  121434. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  121435. };
  121436. // Create motion blur post-process
  121437. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  121438. var _this = this;
  121439. 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);
  121440. var motionScale = 0;
  121441. var prevViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  121442. var invViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  121443. var viewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  121444. var screenSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  121445. this.motionBlurPostProcess.onApply = function (effect) {
  121446. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  121447. viewProjection.invertToRef(invViewProjection);
  121448. effect.setMatrix("inverseViewProjection", invViewProjection);
  121449. effect.setMatrix("prevViewProjection", prevViewProjection);
  121450. prevViewProjection = viewProjection;
  121451. screenSize.x = _this.motionBlurPostProcess.width;
  121452. screenSize.y = _this.motionBlurPostProcess.height;
  121453. effect.setVector2("screenSize", screenSize);
  121454. motionScale = scene.getEngine().getFps() / 60.0;
  121455. effect.setFloat("motionScale", motionScale);
  121456. effect.setFloat("motionStrength", _this.motionStrength);
  121457. effect.setTexture("depthSampler", _this._getDepthTexture());
  121458. };
  121459. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  121460. };
  121461. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  121462. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  121463. var renderer = this._scene.enableGeometryBufferRenderer();
  121464. return renderer.getGBuffer().textures[0];
  121465. }
  121466. return this._scene.enableDepthRenderer().getDepthMap();
  121467. };
  121468. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  121469. for (var i = 0; i < this._cameras.length; i++) {
  121470. var camera = this._cameras[i];
  121471. if (this.originalPostProcess) {
  121472. this.originalPostProcess.dispose(camera);
  121473. }
  121474. if (this.downSampleX4PostProcess) {
  121475. this.downSampleX4PostProcess.dispose(camera);
  121476. }
  121477. if (this.brightPassPostProcess) {
  121478. this.brightPassPostProcess.dispose(camera);
  121479. }
  121480. if (this.textureAdderPostProcess) {
  121481. this.textureAdderPostProcess.dispose(camera);
  121482. }
  121483. if (this.textureAdderFinalPostProcess) {
  121484. this.textureAdderFinalPostProcess.dispose(camera);
  121485. }
  121486. if (this.volumetricLightPostProcess) {
  121487. this.volumetricLightPostProcess.dispose(camera);
  121488. }
  121489. if (this.volumetricLightSmoothXPostProcess) {
  121490. this.volumetricLightSmoothXPostProcess.dispose(camera);
  121491. }
  121492. if (this.volumetricLightSmoothYPostProcess) {
  121493. this.volumetricLightSmoothYPostProcess.dispose(camera);
  121494. }
  121495. if (this.volumetricLightMergePostProces) {
  121496. this.volumetricLightMergePostProces.dispose(camera);
  121497. }
  121498. if (this.volumetricLightFinalPostProcess) {
  121499. this.volumetricLightFinalPostProcess.dispose(camera);
  121500. }
  121501. if (this.lensFlarePostProcess) {
  121502. this.lensFlarePostProcess.dispose(camera);
  121503. }
  121504. if (this.lensFlareComposePostProcess) {
  121505. this.lensFlareComposePostProcess.dispose(camera);
  121506. }
  121507. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  121508. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  121509. }
  121510. if (this.luminancePostProcess) {
  121511. this.luminancePostProcess.dispose(camera);
  121512. }
  121513. if (this.hdrPostProcess) {
  121514. this.hdrPostProcess.dispose(camera);
  121515. }
  121516. if (this.hdrFinalPostProcess) {
  121517. this.hdrFinalPostProcess.dispose(camera);
  121518. }
  121519. if (this.depthOfFieldPostProcess) {
  121520. this.depthOfFieldPostProcess.dispose(camera);
  121521. }
  121522. if (this.motionBlurPostProcess) {
  121523. this.motionBlurPostProcess.dispose(camera);
  121524. }
  121525. if (this.fxaaPostProcess) {
  121526. this.fxaaPostProcess.dispose(camera);
  121527. }
  121528. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  121529. this.blurHPostProcesses[j].dispose(camera);
  121530. }
  121531. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  121532. this.blurVPostProcesses[j].dispose(camera);
  121533. }
  121534. }
  121535. this.originalPostProcess = null;
  121536. this.downSampleX4PostProcess = null;
  121537. this.brightPassPostProcess = null;
  121538. this.textureAdderPostProcess = null;
  121539. this.textureAdderFinalPostProcess = null;
  121540. this.volumetricLightPostProcess = null;
  121541. this.volumetricLightSmoothXPostProcess = null;
  121542. this.volumetricLightSmoothYPostProcess = null;
  121543. this.volumetricLightMergePostProces = null;
  121544. this.volumetricLightFinalPostProcess = null;
  121545. this.lensFlarePostProcess = null;
  121546. this.lensFlareComposePostProcess = null;
  121547. this.luminancePostProcess = null;
  121548. this.hdrPostProcess = null;
  121549. this.hdrFinalPostProcess = null;
  121550. this.depthOfFieldPostProcess = null;
  121551. this.motionBlurPostProcess = null;
  121552. this.fxaaPostProcess = null;
  121553. this.luminanceDownSamplePostProcesses = [];
  121554. this.blurHPostProcesses = [];
  121555. this.blurVPostProcesses = [];
  121556. };
  121557. /**
  121558. * Dispose of the pipeline and stop all post processes
  121559. */
  121560. StandardRenderingPipeline.prototype.dispose = function () {
  121561. this._disposePostProcesses();
  121562. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  121563. _super.prototype.dispose.call(this);
  121564. };
  121565. /**
  121566. * Serialize the rendering pipeline (Used when exporting)
  121567. * @returns the serialized object
  121568. */
  121569. StandardRenderingPipeline.prototype.serialize = function () {
  121570. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  121571. if (this.sourceLight) {
  121572. serializationObject.sourceLightId = this.sourceLight.id;
  121573. }
  121574. serializationObject.customType = "StandardRenderingPipeline";
  121575. return serializationObject;
  121576. };
  121577. /**
  121578. * Parse the serialized pipeline
  121579. * @param source Source pipeline.
  121580. * @param scene The scene to load the pipeline to.
  121581. * @param rootUrl The URL of the serialized pipeline.
  121582. * @returns An instantiated pipeline from the serialized object.
  121583. */
  121584. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  121585. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  121586. if (source.sourceLightId) {
  121587. p.sourceLight = scene.getLightByID(source.sourceLightId);
  121588. }
  121589. return p;
  121590. };
  121591. /**
  121592. * Luminance steps
  121593. */
  121594. StandardRenderingPipeline.LuminanceSteps = 6;
  121595. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121596. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121597. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  121598. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121599. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121600. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  121601. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121602. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121603. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  121604. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121605. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121606. ], StandardRenderingPipeline.prototype, "exposure", null);
  121607. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121608. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  121609. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  121610. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121611. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121612. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  121613. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121614. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121615. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  121616. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121617. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121618. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  121619. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121620. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121621. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  121622. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121623. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121624. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  121625. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121626. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121627. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  121628. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121629. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121630. ], StandardRenderingPipeline.prototype, "hdrAutoExposure", null);
  121631. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121632. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  121633. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  121634. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121635. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121636. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  121637. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121638. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121639. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  121640. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121641. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121642. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  121643. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121644. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121645. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  121646. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121647. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  121648. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  121649. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121650. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  121651. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  121652. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121653. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121654. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  121655. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121656. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121657. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  121658. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121659. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121660. ], StandardRenderingPipeline.prototype, "motionStrength", void 0);
  121661. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121662. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121663. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  121664. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121665. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121666. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  121667. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121668. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121669. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  121670. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121671. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121672. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  121673. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121674. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121675. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  121676. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121677. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121678. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  121679. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121680. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121681. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  121682. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121683. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121684. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  121685. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121686. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121687. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  121688. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121689. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121690. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  121691. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  121692. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  121693. ], StandardRenderingPipeline.prototype, "samples", null);
  121694. return StandardRenderingPipeline;
  121695. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  121696. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  121697. /***/ }),
  121698. /***/ "./PostProcesses/RenderPipeline/index.ts":
  121699. /*!***********************************************!*\
  121700. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  121701. \***********************************************/
  121702. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  121703. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121704. "use strict";
  121705. __webpack_require__.r(__webpack_exports__);
  121706. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  121707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  121708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  121709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  121710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  121711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  121712. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  121713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  121714. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  121715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  121716. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  121717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  121718. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  121719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  121720. /***/ }),
  121721. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  121722. /*!*****************************************************************!*\
  121723. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  121724. \*****************************************************************/
  121725. /*! exports provided: PostProcessRenderEffect */
  121726. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121727. "use strict";
  121728. __webpack_require__.r(__webpack_exports__);
  121729. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  121730. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  121731. /**
  121732. * This represents a set of one or more post processes in Babylon.
  121733. * A post process can be used to apply a shader to a texture after it is rendered.
  121734. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121735. */
  121736. var PostProcessRenderEffect = /** @class */ (function () {
  121737. /**
  121738. * Instantiates a post process render effect.
  121739. * A post process can be used to apply a shader to a texture after it is rendered.
  121740. * @param engine The engine the effect is tied to
  121741. * @param name The name of the effect
  121742. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  121743. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  121744. */
  121745. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  121746. this._name = name;
  121747. this._singleInstance = singleInstance || true;
  121748. this._getPostProcesses = getPostProcesses;
  121749. this._cameras = {};
  121750. this._indicesForCamera = {};
  121751. this._postProcesses = {};
  121752. }
  121753. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  121754. /**
  121755. * Checks if all the post processes in the effect are supported.
  121756. */
  121757. get: function () {
  121758. for (var index in this._postProcesses) {
  121759. if (this._postProcesses.hasOwnProperty(index)) {
  121760. var pps = this._postProcesses[index];
  121761. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  121762. if (!pps[ppIndex].isSupported) {
  121763. return false;
  121764. }
  121765. }
  121766. }
  121767. }
  121768. return true;
  121769. },
  121770. enumerable: true,
  121771. configurable: true
  121772. });
  121773. /**
  121774. * Updates the current state of the effect
  121775. * @hidden
  121776. */
  121777. PostProcessRenderEffect.prototype._update = function () {
  121778. };
  121779. /**
  121780. * Attaches the effect on cameras
  121781. * @param cameras The camera to attach to.
  121782. * @hidden
  121783. */
  121784. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  121785. var _this = this;
  121786. var cameraKey;
  121787. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  121788. if (!cams) {
  121789. return;
  121790. }
  121791. for (var i = 0; i < cams.length; i++) {
  121792. var camera = cams[i];
  121793. var cameraName = camera.name;
  121794. if (this._singleInstance) {
  121795. cameraKey = 0;
  121796. }
  121797. else {
  121798. cameraKey = cameraName;
  121799. }
  121800. if (!this._postProcesses[cameraKey]) {
  121801. var postProcess = this._getPostProcesses();
  121802. if (postProcess) {
  121803. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  121804. }
  121805. }
  121806. if (!this._indicesForCamera[cameraName]) {
  121807. this._indicesForCamera[cameraName] = [];
  121808. }
  121809. this._postProcesses[cameraKey].forEach(function (postProcess) {
  121810. var index = camera.attachPostProcess(postProcess);
  121811. _this._indicesForCamera[cameraName].push(index);
  121812. });
  121813. if (!this._cameras[cameraName]) {
  121814. this._cameras[cameraName] = camera;
  121815. }
  121816. }
  121817. };
  121818. /**
  121819. * Detatches the effect on cameras
  121820. * @param cameras The camera to detatch from.
  121821. * @hidden
  121822. */
  121823. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  121824. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  121825. if (!cams) {
  121826. return;
  121827. }
  121828. for (var i = 0; i < cams.length; i++) {
  121829. var camera = cams[i];
  121830. var cameraName = camera.name;
  121831. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  121832. if (postProcesses) {
  121833. postProcesses.forEach(function (postProcess) {
  121834. camera.detachPostProcess(postProcess);
  121835. });
  121836. }
  121837. if (this._cameras[cameraName]) {
  121838. this._cameras[cameraName] = null;
  121839. }
  121840. }
  121841. };
  121842. /**
  121843. * Enables the effect on given cameras
  121844. * @param cameras The camera to enable.
  121845. * @hidden
  121846. */
  121847. PostProcessRenderEffect.prototype._enable = function (cameras) {
  121848. var _this = this;
  121849. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  121850. if (!cams) {
  121851. return;
  121852. }
  121853. for (var i = 0; i < cams.length; i++) {
  121854. var camera = cams[i];
  121855. var cameraName = camera.name;
  121856. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  121857. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  121858. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  121859. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  121860. });
  121861. }
  121862. }
  121863. }
  121864. };
  121865. /**
  121866. * Disables the effect on the given cameras
  121867. * @param cameras The camera to disable.
  121868. * @hidden
  121869. */
  121870. PostProcessRenderEffect.prototype._disable = function (cameras) {
  121871. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  121872. if (!cams) {
  121873. return;
  121874. }
  121875. for (var i = 0; i < cams.length; i++) {
  121876. var camera = cams[i];
  121877. var cameraName = camera.name;
  121878. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  121879. camera.detachPostProcess(postProcess);
  121880. });
  121881. }
  121882. };
  121883. /**
  121884. * Gets a list of the post processes contained in the effect.
  121885. * @param camera The camera to get the post processes on.
  121886. * @returns The list of the post processes in the effect.
  121887. */
  121888. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  121889. if (this._singleInstance) {
  121890. return this._postProcesses[0];
  121891. }
  121892. else {
  121893. if (!camera) {
  121894. return null;
  121895. }
  121896. return this._postProcesses[camera.name];
  121897. }
  121898. };
  121899. return PostProcessRenderEffect;
  121900. }());
  121901. /***/ }),
  121902. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  121903. /*!*******************************************************************!*\
  121904. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  121905. \*******************************************************************/
  121906. /*! exports provided: PostProcessRenderPipeline */
  121907. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121908. "use strict";
  121909. __webpack_require__.r(__webpack_exports__);
  121910. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  121911. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121912. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  121913. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  121914. /**
  121915. * PostProcessRenderPipeline
  121916. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121917. */
  121918. var PostProcessRenderPipeline = /** @class */ (function () {
  121919. /**
  121920. * Initializes a PostProcessRenderPipeline
  121921. * @param engine engine to add the pipeline to
  121922. * @param name name of the pipeline
  121923. */
  121924. function PostProcessRenderPipeline(engine, name) {
  121925. this.engine = engine;
  121926. this._name = name;
  121927. this._renderEffects = {};
  121928. this._renderEffectsForIsolatedPass = new Array();
  121929. this._cameras = [];
  121930. }
  121931. Object.defineProperty(PostProcessRenderPipeline.prototype, "name", {
  121932. /**
  121933. * Gets pipeline name
  121934. */
  121935. get: function () {
  121936. return this._name;
  121937. },
  121938. enumerable: true,
  121939. configurable: true
  121940. });
  121941. /**
  121942. * Gets the class name
  121943. * @returns "PostProcessRenderPipeline"
  121944. */
  121945. PostProcessRenderPipeline.prototype.getClassName = function () {
  121946. return "PostProcessRenderPipeline";
  121947. };
  121948. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  121949. /**
  121950. * If all the render effects in the pipeline are supported
  121951. */
  121952. get: function () {
  121953. for (var renderEffectName in this._renderEffects) {
  121954. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  121955. if (!this._renderEffects[renderEffectName].isSupported) {
  121956. return false;
  121957. }
  121958. }
  121959. }
  121960. return true;
  121961. },
  121962. enumerable: true,
  121963. configurable: true
  121964. });
  121965. /**
  121966. * Adds an effect to the pipeline
  121967. * @param renderEffect the effect to add
  121968. */
  121969. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  121970. this._renderEffects[renderEffect._name] = renderEffect;
  121971. };
  121972. // private
  121973. /** @hidden */
  121974. PostProcessRenderPipeline.prototype._rebuild = function () {
  121975. };
  121976. /** @hidden */
  121977. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  121978. var renderEffects = this._renderEffects[renderEffectName];
  121979. if (!renderEffects) {
  121980. return;
  121981. }
  121982. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  121983. };
  121984. /** @hidden */
  121985. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  121986. var renderEffects = this._renderEffects[renderEffectName];
  121987. if (!renderEffects) {
  121988. return;
  121989. }
  121990. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  121991. };
  121992. /** @hidden */
  121993. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  121994. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  121995. if (!cams) {
  121996. return;
  121997. }
  121998. var indicesToDelete = [];
  121999. var i;
  122000. for (i = 0; i < cams.length; i++) {
  122001. var camera = cams[i];
  122002. var cameraName = camera.name;
  122003. if (this._cameras.indexOf(camera) === -1) {
  122004. this._cameras[cameraName] = camera;
  122005. }
  122006. else if (unique) {
  122007. indicesToDelete.push(i);
  122008. }
  122009. }
  122010. for (i = 0; i < indicesToDelete.length; i++) {
  122011. cameras.splice(indicesToDelete[i], 1);
  122012. }
  122013. for (var renderEffectName in this._renderEffects) {
  122014. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  122015. this._renderEffects[renderEffectName]._attachCameras(cams);
  122016. }
  122017. }
  122018. };
  122019. /** @hidden */
  122020. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  122021. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  122022. if (!cams) {
  122023. return;
  122024. }
  122025. for (var renderEffectName in this._renderEffects) {
  122026. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  122027. this._renderEffects[renderEffectName]._detachCameras(cams);
  122028. }
  122029. }
  122030. for (var i = 0; i < cams.length; i++) {
  122031. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  122032. }
  122033. };
  122034. /** @hidden */
  122035. PostProcessRenderPipeline.prototype._update = function () {
  122036. for (var renderEffectName in this._renderEffects) {
  122037. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  122038. this._renderEffects[renderEffectName]._update();
  122039. }
  122040. }
  122041. for (var i = 0; i < this._cameras.length; i++) {
  122042. var cameraName = this._cameras[i].name;
  122043. if (this._renderEffectsForIsolatedPass[cameraName]) {
  122044. this._renderEffectsForIsolatedPass[cameraName]._update();
  122045. }
  122046. }
  122047. };
  122048. /** @hidden */
  122049. PostProcessRenderPipeline.prototype._reset = function () {
  122050. this._renderEffects = {};
  122051. this._renderEffectsForIsolatedPass = new Array();
  122052. };
  122053. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  122054. // 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)
  122055. var effectKeys = Object.keys(this._renderEffects);
  122056. if (this.engine.webGLVersion === 1) {
  122057. return false;
  122058. }
  122059. if (effectKeys.length > 0) {
  122060. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  122061. if (postProcesses) {
  122062. postProcesses[0].samples = sampleCount;
  122063. }
  122064. }
  122065. return true;
  122066. };
  122067. /**
  122068. * Disposes of the pipeline
  122069. */
  122070. PostProcessRenderPipeline.prototype.dispose = function () {
  122071. // Must be implemented by children
  122072. };
  122073. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  122074. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  122075. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  122076. return PostProcessRenderPipeline;
  122077. }());
  122078. /***/ }),
  122079. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  122080. /*!**************************************************************************!*\
  122081. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  122082. \**************************************************************************/
  122083. /*! exports provided: PostProcessRenderPipelineManager */
  122084. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122085. "use strict";
  122086. __webpack_require__.r(__webpack_exports__);
  122087. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  122088. /**
  122089. * PostProcessRenderPipelineManager class
  122090. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122091. */
  122092. var PostProcessRenderPipelineManager = /** @class */ (function () {
  122093. /**
  122094. * Initializes a PostProcessRenderPipelineManager
  122095. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  122096. */
  122097. function PostProcessRenderPipelineManager() {
  122098. this._renderPipelines = {};
  122099. }
  122100. Object.defineProperty(PostProcessRenderPipelineManager.prototype, "supportedPipelines", {
  122101. /**
  122102. * Gets the list of supported render pipelines
  122103. */
  122104. get: function () {
  122105. var result = [];
  122106. for (var renderPipelineName in this._renderPipelines) {
  122107. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  122108. var pipeline = this._renderPipelines[renderPipelineName];
  122109. if (pipeline.isSupported) {
  122110. result.push(pipeline);
  122111. }
  122112. }
  122113. }
  122114. return result;
  122115. },
  122116. enumerable: true,
  122117. configurable: true
  122118. });
  122119. /**
  122120. * Adds a pipeline to the manager
  122121. * @param renderPipeline The pipeline to add
  122122. */
  122123. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  122124. this._renderPipelines[renderPipeline._name] = renderPipeline;
  122125. };
  122126. /**
  122127. * Attaches a camera to the pipeline
  122128. * @param renderPipelineName The name of the pipeline to attach to
  122129. * @param cameras the camera to attach
  122130. * @param unique if the camera can be attached multiple times to the pipeline
  122131. */
  122132. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  122133. if (unique === void 0) { unique = false; }
  122134. var renderPipeline = this._renderPipelines[renderPipelineName];
  122135. if (!renderPipeline) {
  122136. return;
  122137. }
  122138. renderPipeline._attachCameras(cameras, unique);
  122139. };
  122140. /**
  122141. * Detaches a camera from the pipeline
  122142. * @param renderPipelineName The name of the pipeline to detach from
  122143. * @param cameras the camera to detach
  122144. */
  122145. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  122146. var renderPipeline = this._renderPipelines[renderPipelineName];
  122147. if (!renderPipeline) {
  122148. return;
  122149. }
  122150. renderPipeline._detachCameras(cameras);
  122151. };
  122152. /**
  122153. * Enables an effect by name on a pipeline
  122154. * @param renderPipelineName the name of the pipeline to enable the effect in
  122155. * @param renderEffectName the name of the effect to enable
  122156. * @param cameras the cameras that the effect should be enabled on
  122157. */
  122158. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  122159. var renderPipeline = this._renderPipelines[renderPipelineName];
  122160. if (!renderPipeline) {
  122161. return;
  122162. }
  122163. renderPipeline._enableEffect(renderEffectName, cameras);
  122164. };
  122165. /**
  122166. * Disables an effect by name on a pipeline
  122167. * @param renderPipelineName the name of the pipeline to disable the effect in
  122168. * @param renderEffectName the name of the effect to disable
  122169. * @param cameras the cameras that the effect should be disabled on
  122170. */
  122171. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  122172. var renderPipeline = this._renderPipelines[renderPipelineName];
  122173. if (!renderPipeline) {
  122174. return;
  122175. }
  122176. renderPipeline._disableEffect(renderEffectName, cameras);
  122177. };
  122178. /**
  122179. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  122180. */
  122181. PostProcessRenderPipelineManager.prototype.update = function () {
  122182. for (var renderPipelineName in this._renderPipelines) {
  122183. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  122184. var pipeline = this._renderPipelines[renderPipelineName];
  122185. if (!pipeline.isSupported) {
  122186. pipeline.dispose();
  122187. delete this._renderPipelines[renderPipelineName];
  122188. }
  122189. else {
  122190. pipeline._update();
  122191. }
  122192. }
  122193. }
  122194. };
  122195. /** @hidden */
  122196. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  122197. for (var renderPipelineName in this._renderPipelines) {
  122198. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  122199. var pipeline = this._renderPipelines[renderPipelineName];
  122200. pipeline._rebuild();
  122201. }
  122202. }
  122203. };
  122204. /**
  122205. * Disposes of the manager and pipelines
  122206. */
  122207. PostProcessRenderPipelineManager.prototype.dispose = function () {
  122208. for (var renderPipelineName in this._renderPipelines) {
  122209. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  122210. var pipeline = this._renderPipelines[renderPipelineName];
  122211. pipeline.dispose();
  122212. }
  122213. }
  122214. };
  122215. return PostProcessRenderPipelineManager;
  122216. }());
  122217. /***/ }),
  122218. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  122219. /*!****************************************************************************************!*\
  122220. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  122221. \****************************************************************************************/
  122222. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  122223. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122224. "use strict";
  122225. __webpack_require__.r(__webpack_exports__);
  122226. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  122227. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  122228. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  122229. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  122230. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  122231. get: function () {
  122232. if (!this._postProcessRenderPipelineManager) {
  122233. // Register the G Buffer component to the scene.
  122234. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  122235. if (!component) {
  122236. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  122237. this._addComponent(component);
  122238. }
  122239. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  122240. }
  122241. return this._postProcessRenderPipelineManager;
  122242. },
  122243. enumerable: true,
  122244. configurable: true
  122245. });
  122246. /**
  122247. * Defines the Render Pipeline scene component responsible to rendering pipelines
  122248. */
  122249. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  122250. /**
  122251. * Creates a new instance of the component for the given scene
  122252. * @param scene Defines the scene to register the component in
  122253. */
  122254. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  122255. /**
  122256. * The component name helpfull to identify the component in the list of scene components.
  122257. */
  122258. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  122259. this.scene = scene;
  122260. }
  122261. /**
  122262. * Registers the component in a given scene
  122263. */
  122264. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  122265. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  122266. };
  122267. /**
  122268. * Rebuilds the elements related to this component in case of
  122269. * context lost for instance.
  122270. */
  122271. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  122272. if (this.scene._postProcessRenderPipelineManager) {
  122273. this.scene._postProcessRenderPipelineManager._rebuild();
  122274. }
  122275. };
  122276. /**
  122277. * Disposes the component and the associated ressources
  122278. */
  122279. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  122280. if (this.scene._postProcessRenderPipelineManager) {
  122281. this.scene._postProcessRenderPipelineManager.dispose();
  122282. }
  122283. };
  122284. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  122285. if (this.scene._postProcessRenderPipelineManager) {
  122286. this.scene._postProcessRenderPipelineManager.update();
  122287. }
  122288. };
  122289. return PostProcessRenderPipelineManagerSceneComponent;
  122290. }());
  122291. /***/ }),
  122292. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  122293. /*!**********************************************!*\
  122294. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  122295. \**********************************************/
  122296. /*! exports provided: AnaglyphPostProcess */
  122297. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122298. "use strict";
  122299. __webpack_require__.r(__webpack_exports__);
  122300. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  122301. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122302. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122303. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  122304. /**
  122305. * Postprocess used to generate anaglyphic rendering
  122306. */
  122307. var AnaglyphPostProcess = /** @class */ (function (_super) {
  122308. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  122309. /**
  122310. * Creates a new AnaglyphPostProcess
  122311. * @param name defines postprocess name
  122312. * @param options defines creation options or target ratio scale
  122313. * @param rigCameras defines cameras using this postprocess
  122314. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  122315. * @param engine defines hosting engine
  122316. * @param reusable defines if the postprocess will be reused multiple times per frame
  122317. */
  122318. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  122319. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  122320. _this._passedProcess = rigCameras[0]._rigPostProcess;
  122321. _this.onApplyObservable.add(function (effect) {
  122322. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  122323. });
  122324. return _this;
  122325. }
  122326. return AnaglyphPostProcess;
  122327. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122328. /***/ }),
  122329. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  122330. /*!***************************************************!*\
  122331. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  122332. \***************************************************/
  122333. /*! exports provided: BlackAndWhitePostProcess */
  122334. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122335. "use strict";
  122336. __webpack_require__.r(__webpack_exports__);
  122337. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  122338. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122339. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122340. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  122341. /**
  122342. * Post process used to render in black and white
  122343. */
  122344. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  122345. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  122346. /**
  122347. * Creates a black and white post process
  122348. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  122349. * @param name The name of the effect.
  122350. * @param options The required width/height ratio to downsize to before computing the render pass.
  122351. * @param camera The camera to apply the render pass to.
  122352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122353. * @param engine The engine which the post process will be applied. (default: current engine)
  122354. * @param reusable If the post process can be reused on the same frame. (default: false)
  122355. */
  122356. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  122357. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  122358. /**
  122359. * Linear about to convert he result to black and white (default: 1)
  122360. */
  122361. _this.degree = 1;
  122362. _this.onApplyObservable.add(function (effect) {
  122363. effect.setFloat("degree", _this.degree);
  122364. });
  122365. return _this;
  122366. }
  122367. return BlackAndWhitePostProcess;
  122368. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122369. /***/ }),
  122370. /***/ "./PostProcesses/bloomEffect.ts":
  122371. /*!**************************************!*\
  122372. !*** ./PostProcesses/bloomEffect.ts ***!
  122373. \**************************************/
  122374. /*! exports provided: BloomEffect */
  122375. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122376. "use strict";
  122377. __webpack_require__.r(__webpack_exports__);
  122378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  122379. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122380. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  122381. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  122382. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  122383. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  122384. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122385. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122386. /**
  122387. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  122388. */
  122389. var BloomEffect = /** @class */ (function (_super) {
  122390. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  122391. /**
  122392. * Creates a new instance of @see BloomEffect
  122393. * @param scene The scene the effect belongs to.
  122394. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  122395. * @param bloomKernel The size of the kernel to be used when applying the blur.
  122396. * @param bloomWeight The the strength of bloom.
  122397. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  122398. * @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)
  122399. */
  122400. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  122401. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  122402. if (blockCompilation === void 0) { blockCompilation = false; }
  122403. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  122404. return _this._effects;
  122405. }, true) || this;
  122406. _this.bloomScale = bloomScale;
  122407. /**
  122408. * @hidden Internal
  122409. */
  122410. _this._effects = [];
  122411. _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);
  122412. _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);
  122413. _this._blurX.alwaysForcePOT = true;
  122414. _this._blurX.autoClear = false;
  122415. _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);
  122416. _this._blurY.alwaysForcePOT = true;
  122417. _this._blurY.autoClear = false;
  122418. _this.kernel = bloomKernel;
  122419. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  122420. _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);
  122421. _this._merge.autoClear = false;
  122422. _this._effects.push(_this._merge);
  122423. return _this;
  122424. }
  122425. Object.defineProperty(BloomEffect.prototype, "threshold", {
  122426. /**
  122427. * The luminance threshold to find bright areas of the image to bloom.
  122428. */
  122429. get: function () {
  122430. return this._downscale.threshold;
  122431. },
  122432. set: function (value) {
  122433. this._downscale.threshold = value;
  122434. },
  122435. enumerable: true,
  122436. configurable: true
  122437. });
  122438. Object.defineProperty(BloomEffect.prototype, "weight", {
  122439. /**
  122440. * The strength of the bloom.
  122441. */
  122442. get: function () {
  122443. return this._merge.weight;
  122444. },
  122445. set: function (value) {
  122446. this._merge.weight = value;
  122447. },
  122448. enumerable: true,
  122449. configurable: true
  122450. });
  122451. Object.defineProperty(BloomEffect.prototype, "kernel", {
  122452. /**
  122453. * Specifies the size of the bloom blur kernel, relative to the final output size
  122454. */
  122455. get: function () {
  122456. return this._blurX.kernel / this.bloomScale;
  122457. },
  122458. set: function (value) {
  122459. this._blurX.kernel = value * this.bloomScale;
  122460. this._blurY.kernel = value * this.bloomScale;
  122461. },
  122462. enumerable: true,
  122463. configurable: true
  122464. });
  122465. /**
  122466. * Disposes each of the internal effects for a given camera.
  122467. * @param camera The camera to dispose the effect on.
  122468. */
  122469. BloomEffect.prototype.disposeEffects = function (camera) {
  122470. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  122471. this._effects[effectIndex].dispose(camera);
  122472. }
  122473. };
  122474. /**
  122475. * @hidden Internal
  122476. */
  122477. BloomEffect.prototype._updateEffects = function () {
  122478. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  122479. this._effects[effectIndex].updateEffect();
  122480. }
  122481. };
  122482. /**
  122483. * Internal
  122484. * @returns if all the contained post processes are ready.
  122485. * @hidden
  122486. */
  122487. BloomEffect.prototype._isReady = function () {
  122488. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  122489. if (!this._effects[effectIndex].isReady()) {
  122490. return false;
  122491. }
  122492. }
  122493. return true;
  122494. };
  122495. return BloomEffect;
  122496. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  122497. /***/ }),
  122498. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  122499. /*!************************************************!*\
  122500. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  122501. \************************************************/
  122502. /*! exports provided: BloomMergePostProcess */
  122503. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122504. "use strict";
  122505. __webpack_require__.r(__webpack_exports__);
  122506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  122507. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122508. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122509. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122510. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  122511. /**
  122512. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  122513. */
  122514. var BloomMergePostProcess = /** @class */ (function (_super) {
  122515. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  122516. /**
  122517. * Creates a new instance of @see BloomMergePostProcess
  122518. * @param name The name of the effect.
  122519. * @param originalFromInput Post process which's input will be used for the merge.
  122520. * @param blurred Blurred highlights post process which's output will be used.
  122521. * @param weight Weight of the bloom to be added to the original input.
  122522. * @param options The required width/height ratio to downsize to before computing the render pass.
  122523. * @param camera The camera to apply the render pass to.
  122524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122525. * @param engine The engine which the post process will be applied. (default: current engine)
  122526. * @param reusable If the post process can be reused on the same frame. (default: false)
  122527. * @param textureType Type of textures used when performing the post process. (default: 0)
  122528. * @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)
  122529. */
  122530. function BloomMergePostProcess(name, originalFromInput, blurred,
  122531. /** Weight of the bloom to be added to the original input. */
  122532. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122533. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122534. if (blockCompilation === void 0) { blockCompilation = false; }
  122535. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  122536. _this.weight = weight;
  122537. _this.onApplyObservable.add(function (effect) {
  122538. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  122539. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  122540. effect.setFloat("bloomWeight", _this.weight);
  122541. });
  122542. if (!blockCompilation) {
  122543. _this.updateEffect();
  122544. }
  122545. return _this;
  122546. }
  122547. return BloomMergePostProcess;
  122548. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122549. /***/ }),
  122550. /***/ "./PostProcesses/blurPostProcess.ts":
  122551. /*!******************************************!*\
  122552. !*** ./PostProcesses/blurPostProcess.ts ***!
  122553. \******************************************/
  122554. /*! exports provided: BlurPostProcess */
  122555. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122556. "use strict";
  122557. __webpack_require__.r(__webpack_exports__);
  122558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  122559. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122560. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122561. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122562. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122563. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  122564. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  122565. /**
  122566. * The Blur Post Process which blurs an image based on a kernel and direction.
  122567. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  122568. */
  122569. var BlurPostProcess = /** @class */ (function (_super) {
  122570. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  122571. /**
  122572. * Creates a new instance BlurPostProcess
  122573. * @param name The name of the effect.
  122574. * @param direction The direction in which to blur the image.
  122575. * @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.
  122576. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  122577. * @param camera The camera to apply the render pass to.
  122578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122579. * @param engine The engine which the post process will be applied. (default: current engine)
  122580. * @param reusable If the post process can be reused on the same frame. (default: false)
  122581. * @param textureType Type of textures used when performing the post process. (default: 0)
  122582. * @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)
  122583. */
  122584. function BlurPostProcess(name,
  122585. /** The direction in which to blur the image. */
  122586. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  122587. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  122588. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122589. if (defines === void 0) { defines = ""; }
  122590. if (blockCompilation === void 0) { blockCompilation = false; }
  122591. 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;
  122592. _this.direction = direction;
  122593. _this.blockCompilation = blockCompilation;
  122594. _this._packedFloat = false;
  122595. _this._staticDefines = "";
  122596. _this._staticDefines = defines;
  122597. _this.onApplyObservable.add(function (effect) {
  122598. if (_this._outputTexture) {
  122599. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  122600. }
  122601. else {
  122602. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  122603. }
  122604. });
  122605. _this.kernel = kernel;
  122606. return _this;
  122607. }
  122608. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  122609. /**
  122610. * Gets the length in pixels of the blur sample region
  122611. */
  122612. get: function () {
  122613. return this._idealKernel;
  122614. },
  122615. /**
  122616. * Sets the length in pixels of the blur sample region
  122617. */
  122618. set: function (v) {
  122619. if (this._idealKernel === v) {
  122620. return;
  122621. }
  122622. v = Math.max(v, 1);
  122623. this._idealKernel = v;
  122624. this._kernel = this._nearestBestKernel(v);
  122625. if (!this.blockCompilation) {
  122626. this._updateParameters();
  122627. }
  122628. },
  122629. enumerable: true,
  122630. configurable: true
  122631. });
  122632. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  122633. /**
  122634. * Gets wether or not the blur is unpacking/repacking floats
  122635. */
  122636. get: function () {
  122637. return this._packedFloat;
  122638. },
  122639. /**
  122640. * Sets wether or not the blur needs to unpack/repack floats
  122641. */
  122642. set: function (v) {
  122643. if (this._packedFloat === v) {
  122644. return;
  122645. }
  122646. this._packedFloat = v;
  122647. if (!this.blockCompilation) {
  122648. this._updateParameters();
  122649. }
  122650. },
  122651. enumerable: true,
  122652. configurable: true
  122653. });
  122654. /**
  122655. * Updates the effect with the current post process compile time values and recompiles the shader.
  122656. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  122657. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  122658. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  122659. * @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
  122660. * @param onCompiled Called when the shader has been compiled.
  122661. * @param onError Called if there is an error when compiling a shader.
  122662. */
  122663. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  122664. if (defines === void 0) { defines = null; }
  122665. if (uniforms === void 0) { uniforms = null; }
  122666. if (samplers === void 0) { samplers = null; }
  122667. this._updateParameters(onCompiled, onError);
  122668. };
  122669. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  122670. // Generate sampling offsets and weights
  122671. var N = this._kernel;
  122672. var centerIndex = (N - 1) / 2;
  122673. // Generate Gaussian sampling weights over kernel
  122674. var offsets = [];
  122675. var weights = [];
  122676. var totalWeight = 0;
  122677. for (var i = 0; i < N; i++) {
  122678. var u = i / (N - 1);
  122679. var w = this._gaussianWeight(u * 2.0 - 1);
  122680. offsets[i] = (i - centerIndex);
  122681. weights[i] = w;
  122682. totalWeight += w;
  122683. }
  122684. // Normalize weights
  122685. for (var i = 0; i < weights.length; i++) {
  122686. weights[i] /= totalWeight;
  122687. }
  122688. // Optimize: combine samples to take advantage of hardware linear sampling
  122689. // Walk from left to center, combining pairs (symmetrically)
  122690. var linearSamplingWeights = [];
  122691. var linearSamplingOffsets = [];
  122692. var linearSamplingMap = [];
  122693. for (var i = 0; i <= centerIndex; i += 2) {
  122694. var j = Math.min(i + 1, Math.floor(centerIndex));
  122695. var singleCenterSample = i === j;
  122696. if (singleCenterSample) {
  122697. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  122698. }
  122699. else {
  122700. var sharedCell = j === centerIndex;
  122701. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  122702. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  122703. if (offsetLinear === 0) {
  122704. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  122705. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  122706. }
  122707. else {
  122708. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  122709. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  122710. }
  122711. }
  122712. }
  122713. for (var i = 0; i < linearSamplingMap.length; i++) {
  122714. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  122715. linearSamplingWeights[i] = linearSamplingMap[i].w;
  122716. }
  122717. // Replace with optimized
  122718. offsets = linearSamplingOffsets;
  122719. weights = linearSamplingWeights;
  122720. // Generate shaders
  122721. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  122722. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  122723. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  122724. var defines = "";
  122725. defines += this._staticDefines;
  122726. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  122727. if (this._staticDefines.indexOf("DOF") != -1) {
  122728. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  122729. varyingCount--;
  122730. }
  122731. for (var i = 0; i < varyingCount; i++) {
  122732. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  122733. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  122734. }
  122735. var depCount = 0;
  122736. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  122737. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  122738. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  122739. depCount++;
  122740. }
  122741. if (this.packedFloat) {
  122742. defines += "#define PACKEDFLOAT 1";
  122743. }
  122744. this.blockCompilation = false;
  122745. _super.prototype.updateEffect.call(this, defines, null, null, {
  122746. varyingCount: varyingCount,
  122747. depCount: depCount
  122748. }, onCompiled, onError);
  122749. };
  122750. /**
  122751. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  122752. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  122753. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  122754. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  122755. * The gaps between physical kernels are compensated for in the weighting of the samples
  122756. * @param idealKernel Ideal blur kernel.
  122757. * @return Nearest best kernel.
  122758. */
  122759. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  122760. var v = Math.round(idealKernel);
  122761. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  122762. var k = _a[_i];
  122763. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  122764. return Math.max(k, 3);
  122765. }
  122766. }
  122767. return Math.max(v, 3);
  122768. };
  122769. /**
  122770. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  122771. * @param x The point on the Gaussian distribution to sample.
  122772. * @return the value of the Gaussian function at x.
  122773. */
  122774. BlurPostProcess.prototype._gaussianWeight = function (x) {
  122775. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  122776. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  122777. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  122778. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  122779. // truncated at around 1.3% of peak strength.
  122780. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  122781. var sigma = (1 / 3);
  122782. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  122783. var exponent = -((x * x) / (2.0 * sigma * sigma));
  122784. var weight = (1.0 / denominator) * Math.exp(exponent);
  122785. return weight;
  122786. };
  122787. /**
  122788. * Generates a string that can be used as a floating point number in GLSL.
  122789. * @param x Value to print.
  122790. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  122791. * @return GLSL float string.
  122792. */
  122793. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  122794. if (decimalFigures === void 0) { decimalFigures = 8; }
  122795. return x.toFixed(decimalFigures).replace(/0+$/, '');
  122796. };
  122797. return BlurPostProcess;
  122798. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122799. /***/ }),
  122800. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  122801. /*!*********************************************************!*\
  122802. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  122803. \*********************************************************/
  122804. /*! exports provided: ChromaticAberrationPostProcess */
  122805. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122806. "use strict";
  122807. __webpack_require__.r(__webpack_exports__);
  122808. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  122809. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122810. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122811. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122812. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122813. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  122814. /**
  122815. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  122816. */
  122817. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  122818. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  122819. /**
  122820. * Creates a new instance ChromaticAberrationPostProcess
  122821. * @param name The name of the effect.
  122822. * @param screenWidth The width of the screen to apply the effect on.
  122823. * @param screenHeight The height of the screen to apply the effect on.
  122824. * @param options The required width/height ratio to downsize to before computing the render pass.
  122825. * @param camera The camera to apply the render pass to.
  122826. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122827. * @param engine The engine which the post process will be applied. (default: current engine)
  122828. * @param reusable If the post process can be reused on the same frame. (default: false)
  122829. * @param textureType Type of textures used when performing the post process. (default: 0)
  122830. * @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)
  122831. */
  122832. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122833. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122834. if (blockCompilation === void 0) { blockCompilation = false; }
  122835. 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;
  122836. /**
  122837. * The amount of seperation of rgb channels (default: 30)
  122838. */
  122839. _this.aberrationAmount = 30;
  122840. /**
  122841. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  122842. */
  122843. _this.radialIntensity = 0;
  122844. /**
  122845. * 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))
  122846. */
  122847. _this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  122848. /**
  122849. * 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))
  122850. */
  122851. _this.centerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  122852. _this.onApplyObservable.add(function (effect) {
  122853. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  122854. effect.setFloat('screen_width', screenWidth);
  122855. effect.setFloat('screen_height', screenHeight);
  122856. effect.setFloat('radialIntensity', _this.radialIntensity);
  122857. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  122858. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  122859. });
  122860. return _this;
  122861. }
  122862. return ChromaticAberrationPostProcess;
  122863. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  122864. /***/ }),
  122865. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  122866. /*!*******************************************************!*\
  122867. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  122868. \*******************************************************/
  122869. /*! exports provided: CircleOfConfusionPostProcess */
  122870. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122871. "use strict";
  122872. __webpack_require__.r(__webpack_exports__);
  122873. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  122874. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122875. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122876. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  122877. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122878. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  122879. /**
  122880. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  122881. */
  122882. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  122883. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  122884. /**
  122885. * Creates a new instance CircleOfConfusionPostProcess
  122886. * @param name The name of the effect.
  122887. * @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.
  122888. * @param options The required width/height ratio to downsize to before computing the render pass.
  122889. * @param camera The camera to apply the render pass to.
  122890. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  122891. * @param engine The engine which the post process will be applied. (default: current engine)
  122892. * @param reusable If the post process can be reused on the same frame. (default: false)
  122893. * @param textureType Type of textures used when performing the post process. (default: 0)
  122894. * @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)
  122895. */
  122896. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  122897. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  122898. if (blockCompilation === void 0) { blockCompilation = false; }
  122899. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  122900. /**
  122901. * 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.
  122902. */
  122903. _this.lensSize = 50;
  122904. /**
  122905. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  122906. */
  122907. _this.fStop = 1.4;
  122908. /**
  122909. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  122910. */
  122911. _this.focusDistance = 2000;
  122912. /**
  122913. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  122914. */
  122915. _this.focalLength = 50;
  122916. _this._depthTexture = null;
  122917. _this._depthTexture = depthTexture;
  122918. _this.onApplyObservable.add(function (effect) {
  122919. if (!_this._depthTexture) {
  122920. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  122921. return;
  122922. }
  122923. effect.setTexture("depthSampler", _this._depthTexture);
  122924. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  122925. var aperture = _this.lensSize / _this.fStop;
  122926. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  122927. effect.setFloat('focusDistance', _this.focusDistance);
  122928. effect.setFloat('cocPrecalculation', cocPrecalculation);
  122929. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  122930. });
  122931. return _this;
  122932. }
  122933. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  122934. /**
  122935. * 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.
  122936. */
  122937. set: function (value) {
  122938. this._depthTexture = value;
  122939. },
  122940. enumerable: true,
  122941. configurable: true
  122942. });
  122943. return CircleOfConfusionPostProcess;
  122944. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122945. /***/ }),
  122946. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  122947. /*!*****************************************************!*\
  122948. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  122949. \*****************************************************/
  122950. /*! exports provided: ColorCorrectionPostProcess */
  122951. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122952. "use strict";
  122953. __webpack_require__.r(__webpack_exports__);
  122954. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  122955. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  122956. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  122957. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  122958. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  122959. /**
  122960. *
  122961. * This post-process allows the modification of rendered colors by using
  122962. * a 'look-up table' (LUT). This effect is also called Color Grading.
  122963. *
  122964. * The object needs to be provided an url to a texture containing the color
  122965. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  122966. * Use an image editing software to tweak the LUT to match your needs.
  122967. *
  122968. * For an example of a color LUT, see here:
  122969. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  122970. * For explanations on color grading, see here:
  122971. * @see http://udn.epicgames.com/Three/ColorGrading.html
  122972. *
  122973. */
  122974. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  122975. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  122976. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  122977. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  122978. _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);
  122979. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  122980. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  122981. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  122982. _this.onApply = function (effect) {
  122983. effect.setTexture("colorTable", _this._colorTableTexture);
  122984. };
  122985. return _this;
  122986. }
  122987. return ColorCorrectionPostProcess;
  122988. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  122989. /***/ }),
  122990. /***/ "./PostProcesses/convolutionPostProcess.ts":
  122991. /*!*************************************************!*\
  122992. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  122993. \*************************************************/
  122994. /*! exports provided: ConvolutionPostProcess */
  122995. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122996. "use strict";
  122997. __webpack_require__.r(__webpack_exports__);
  122998. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  122999. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123000. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123001. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123002. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  123003. /**
  123004. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  123005. * input texture to perform effects such as edge detection or sharpening
  123006. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  123007. */
  123008. var ConvolutionPostProcess = /** @class */ (function (_super) {
  123009. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  123010. /**
  123011. * Creates a new instance ConvolutionPostProcess
  123012. * @param name The name of the effect.
  123013. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  123014. * @param options The required width/height ratio to downsize to before computing the render pass.
  123015. * @param camera The camera to apply the render pass to.
  123016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123017. * @param engine The engine which the post process will be applied. (default: current engine)
  123018. * @param reusable If the post process can be reused on the same frame. (default: false)
  123019. * @param textureType Type of textures used when performing the post process. (default: 0)
  123020. */
  123021. function ConvolutionPostProcess(name,
  123022. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  123023. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  123024. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123025. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  123026. _this.kernel = kernel;
  123027. _this.onApply = function (effect) {
  123028. effect.setFloat2("screenSize", _this.width, _this.height);
  123029. effect.setArray("kernel", _this.kernel);
  123030. };
  123031. return _this;
  123032. }
  123033. // Statics
  123034. /**
  123035. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123036. */
  123037. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  123038. /**
  123039. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123040. */
  123041. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  123042. /**
  123043. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123044. */
  123045. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  123046. /**
  123047. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123048. */
  123049. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  123050. /**
  123051. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123052. */
  123053. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  123054. /**
  123055. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  123056. */
  123057. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  123058. return ConvolutionPostProcess;
  123059. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123060. /***/ }),
  123061. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  123062. /*!******************************************************!*\
  123063. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  123064. \******************************************************/
  123065. /*! exports provided: DepthOfFieldBlurPostProcess */
  123066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123067. "use strict";
  123068. __webpack_require__.r(__webpack_exports__);
  123069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  123070. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123071. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  123072. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  123073. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123074. /**
  123075. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  123076. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  123077. * based on samples that have a large difference in distance than the center pixel.
  123078. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  123079. */
  123080. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  123081. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  123082. /**
  123083. * Creates a new instance CircleOfConfusionPostProcess
  123084. * @param name The name of the effect.
  123085. * @param scene The scene the effect belongs to.
  123086. * @param direction The direction the blur should be applied.
  123087. * @param kernel The size of the kernel used to blur.
  123088. * @param options The required width/height ratio to downsize to before computing the render pass.
  123089. * @param camera The camera to apply the render pass to.
  123090. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  123091. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  123092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123093. * @param engine The engine which the post process will be applied. (default: current engine)
  123094. * @param reusable If the post process can be reused on the same frame. (default: false)
  123095. * @param textureType Type of textures used when performing the post process. (default: 0)
  123096. * @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)
  123097. */
  123098. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  123099. if (imageToBlur === void 0) { imageToBlur = null; }
  123100. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  123101. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123102. if (blockCompilation === void 0) { blockCompilation = false; }
  123103. 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;
  123104. _this.direction = direction;
  123105. _this.onApplyObservable.add(function (effect) {
  123106. if (imageToBlur != null) {
  123107. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  123108. }
  123109. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  123110. if (scene.activeCamera) {
  123111. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  123112. }
  123113. });
  123114. return _this;
  123115. }
  123116. return DepthOfFieldBlurPostProcess;
  123117. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  123118. /***/ }),
  123119. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  123120. /*!*********************************************!*\
  123121. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  123122. \*********************************************/
  123123. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  123124. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123125. "use strict";
  123126. __webpack_require__.r(__webpack_exports__);
  123127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  123128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  123129. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123130. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123131. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  123132. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  123133. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  123134. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  123135. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  123136. /**
  123137. * Specifies the level of max blur that should be applied when using the depth of field effect
  123138. */
  123139. var DepthOfFieldEffectBlurLevel;
  123140. (function (DepthOfFieldEffectBlurLevel) {
  123141. /**
  123142. * Subtle blur
  123143. */
  123144. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  123145. /**
  123146. * Medium blur
  123147. */
  123148. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  123149. /**
  123150. * Large blur
  123151. */
  123152. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  123153. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  123154. /**
  123155. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  123156. */
  123157. var DepthOfFieldEffect = /** @class */ (function (_super) {
  123158. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  123159. /**
  123160. * Creates a new instance DepthOfFieldEffect
  123161. * @param scene The scene the effect belongs to.
  123162. * @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.
  123163. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  123164. * @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)
  123165. */
  123166. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  123167. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  123168. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  123169. if (blockCompilation === void 0) { blockCompilation = false; }
  123170. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  123171. return _this._effects;
  123172. }, true) || this;
  123173. /**
  123174. * @hidden Internal post processes in depth of field effect
  123175. */
  123176. _this._effects = [];
  123177. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  123178. _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);
  123179. // 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)
  123180. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  123181. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  123182. _this._depthOfFieldBlurY = [];
  123183. _this._depthOfFieldBlurX = [];
  123184. var blurCount = 1;
  123185. var kernelSize = 15;
  123186. switch (blurLevel) {
  123187. case DepthOfFieldEffectBlurLevel.High: {
  123188. blurCount = 3;
  123189. kernelSize = 51;
  123190. break;
  123191. }
  123192. case DepthOfFieldEffectBlurLevel.Medium: {
  123193. blurCount = 2;
  123194. kernelSize = 31;
  123195. break;
  123196. }
  123197. default: {
  123198. kernelSize = 15;
  123199. blurCount = 1;
  123200. break;
  123201. }
  123202. }
  123203. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  123204. var ratio = 1.0;
  123205. for (var i = 0; i < blurCount; i++) {
  123206. 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);
  123207. blurY.autoClear = false;
  123208. ratio = 0.75 / Math.pow(2, i);
  123209. 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);
  123210. blurX.autoClear = false;
  123211. _this._depthOfFieldBlurY.push(blurY);
  123212. _this._depthOfFieldBlurX.push(blurX);
  123213. }
  123214. // Set all post processes on the effect.
  123215. _this._effects = [_this._circleOfConfusion];
  123216. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  123217. _this._effects.push(_this._depthOfFieldBlurY[i]);
  123218. _this._effects.push(_this._depthOfFieldBlurX[i]);
  123219. }
  123220. // Merge blurred images with original image based on circleOfConfusion
  123221. _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);
  123222. _this._dofMerge.autoClear = false;
  123223. _this._effects.push(_this._dofMerge);
  123224. return _this;
  123225. }
  123226. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  123227. get: function () {
  123228. return this._circleOfConfusion.focalLength;
  123229. },
  123230. /**
  123231. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  123232. */
  123233. set: function (value) {
  123234. this._circleOfConfusion.focalLength = value;
  123235. },
  123236. enumerable: true,
  123237. configurable: true
  123238. });
  123239. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  123240. get: function () {
  123241. return this._circleOfConfusion.fStop;
  123242. },
  123243. /**
  123244. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  123245. */
  123246. set: function (value) {
  123247. this._circleOfConfusion.fStop = value;
  123248. },
  123249. enumerable: true,
  123250. configurable: true
  123251. });
  123252. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  123253. get: function () {
  123254. return this._circleOfConfusion.focusDistance;
  123255. },
  123256. /**
  123257. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  123258. */
  123259. set: function (value) {
  123260. this._circleOfConfusion.focusDistance = value;
  123261. },
  123262. enumerable: true,
  123263. configurable: true
  123264. });
  123265. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  123266. get: function () {
  123267. return this._circleOfConfusion.lensSize;
  123268. },
  123269. /**
  123270. * 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.
  123271. */
  123272. set: function (value) {
  123273. this._circleOfConfusion.lensSize = value;
  123274. },
  123275. enumerable: true,
  123276. configurable: true
  123277. });
  123278. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  123279. /**
  123280. * 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.
  123281. */
  123282. set: function (value) {
  123283. this._circleOfConfusion.depthTexture = value;
  123284. },
  123285. enumerable: true,
  123286. configurable: true
  123287. });
  123288. /**
  123289. * Disposes each of the internal effects for a given camera.
  123290. * @param camera The camera to dispose the effect on.
  123291. */
  123292. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  123293. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  123294. this._effects[effectIndex].dispose(camera);
  123295. }
  123296. };
  123297. /**
  123298. * @hidden Internal
  123299. */
  123300. DepthOfFieldEffect.prototype._updateEffects = function () {
  123301. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  123302. this._effects[effectIndex].updateEffect();
  123303. }
  123304. };
  123305. /**
  123306. * Internal
  123307. * @returns if all the contained post processes are ready.
  123308. * @hidden
  123309. */
  123310. DepthOfFieldEffect.prototype._isReady = function () {
  123311. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  123312. if (!this._effects[effectIndex].isReady()) {
  123313. return false;
  123314. }
  123315. }
  123316. return true;
  123317. };
  123318. return DepthOfFieldEffect;
  123319. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  123320. /***/ }),
  123321. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  123322. /*!*******************************************************!*\
  123323. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  123324. \*******************************************************/
  123325. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  123326. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123327. "use strict";
  123328. __webpack_require__.r(__webpack_exports__);
  123329. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  123330. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  123331. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123332. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123333. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123334. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  123335. /**
  123336. * Options to be set when merging outputs from the default pipeline.
  123337. */
  123338. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  123339. function DepthOfFieldMergePostProcessOptions() {
  123340. }
  123341. return DepthOfFieldMergePostProcessOptions;
  123342. }());
  123343. /**
  123344. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123345. */
  123346. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  123347. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  123348. /**
  123349. * Creates a new instance of DepthOfFieldMergePostProcess
  123350. * @param name The name of the effect.
  123351. * @param originalFromInput Post process which's input will be used for the merge.
  123352. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  123353. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  123354. * @param options The required width/height ratio to downsize to before computing the render pass.
  123355. * @param camera The camera to apply the render pass to.
  123356. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123357. * @param engine The engine which the post process will be applied. (default: current engine)
  123358. * @param reusable If the post process can be reused on the same frame. (default: false)
  123359. * @param textureType Type of textures used when performing the post process. (default: 0)
  123360. * @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)
  123361. */
  123362. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  123363. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123364. if (blockCompilation === void 0) { blockCompilation = false; }
  123365. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  123366. _this.blurSteps = blurSteps;
  123367. _this.onApplyObservable.add(function (effect) {
  123368. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  123369. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  123370. blurSteps.forEach(function (step, index) {
  123371. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  123372. });
  123373. });
  123374. if (!blockCompilation) {
  123375. _this.updateEffect();
  123376. }
  123377. return _this;
  123378. }
  123379. /**
  123380. * Updates the effect with the current post process compile time values and recompiles the shader.
  123381. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  123382. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  123383. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  123384. * @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
  123385. * @param onCompiled Called when the shader has been compiled.
  123386. * @param onError Called if there is an error when compiling a shader.
  123387. */
  123388. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  123389. if (defines === void 0) { defines = null; }
  123390. if (uniforms === void 0) { uniforms = null; }
  123391. if (samplers === void 0) { samplers = null; }
  123392. if (!defines) {
  123393. defines = "";
  123394. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  123395. }
  123396. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  123397. };
  123398. return DepthOfFieldMergePostProcess;
  123399. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123400. /***/ }),
  123401. /***/ "./PostProcesses/displayPassPostProcess.ts":
  123402. /*!*************************************************!*\
  123403. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  123404. \*************************************************/
  123405. /*! exports provided: DisplayPassPostProcess */
  123406. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123407. "use strict";
  123408. __webpack_require__.r(__webpack_exports__);
  123409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  123410. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123411. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123412. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  123413. /**
  123414. * DisplayPassPostProcess which produces an output the same as it's input
  123415. */
  123416. var DisplayPassPostProcess = /** @class */ (function (_super) {
  123417. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  123418. /**
  123419. * Creates the DisplayPassPostProcess
  123420. * @param name The name of the effect.
  123421. * @param options The required width/height ratio to downsize to before computing the render pass.
  123422. * @param camera The camera to apply the render pass to.
  123423. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123424. * @param engine The engine which the post process will be applied. (default: current engine)
  123425. * @param reusable If the post process can be reused on the same frame. (default: false)
  123426. */
  123427. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  123428. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  123429. }
  123430. return DisplayPassPostProcess;
  123431. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123432. /***/ }),
  123433. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  123434. /*!*******************************************************!*\
  123435. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  123436. \*******************************************************/
  123437. /*! exports provided: ExtractHighlightsPostProcess */
  123438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123439. "use strict";
  123440. __webpack_require__.r(__webpack_exports__);
  123441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  123442. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123443. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123444. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  123445. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123446. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  123447. /**
  123448. * 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.
  123449. */
  123450. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  123451. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  123452. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  123453. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123454. if (blockCompilation === void 0) { blockCompilation = false; }
  123455. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  123456. /**
  123457. * The luminance threshold, pixels below this value will be set to black.
  123458. */
  123459. _this.threshold = 0.9;
  123460. /** @hidden */
  123461. _this._exposure = 1;
  123462. /**
  123463. * Post process which has the input texture to be used when performing highlight extraction
  123464. * @hidden
  123465. */
  123466. _this._inputPostProcess = null;
  123467. _this.onApplyObservable.add(function (effect) {
  123468. if (_this._inputPostProcess) {
  123469. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  123470. }
  123471. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  123472. effect.setFloat('exposure', _this._exposure);
  123473. });
  123474. return _this;
  123475. }
  123476. return ExtractHighlightsPostProcess;
  123477. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123478. /***/ }),
  123479. /***/ "./PostProcesses/filterPostProcess.ts":
  123480. /*!********************************************!*\
  123481. !*** ./PostProcesses/filterPostProcess.ts ***!
  123482. \********************************************/
  123483. /*! exports provided: FilterPostProcess */
  123484. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123485. "use strict";
  123486. __webpack_require__.r(__webpack_exports__);
  123487. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  123488. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123489. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123490. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  123491. /**
  123492. * Applies a kernel filter to the image
  123493. */
  123494. var FilterPostProcess = /** @class */ (function (_super) {
  123495. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  123496. /**
  123497. *
  123498. * @param name The name of the effect.
  123499. * @param kernelMatrix The matrix to be applied to the image
  123500. * @param options The required width/height ratio to downsize to before computing the render pass.
  123501. * @param camera The camera to apply the render pass to.
  123502. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123503. * @param engine The engine which the post process will be applied. (default: current engine)
  123504. * @param reusable If the post process can be reused on the same frame. (default: false)
  123505. */
  123506. function FilterPostProcess(name,
  123507. /** The matrix to be applied to the image */
  123508. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  123509. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  123510. _this.kernelMatrix = kernelMatrix;
  123511. _this.onApply = function (effect) {
  123512. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  123513. };
  123514. return _this;
  123515. }
  123516. return FilterPostProcess;
  123517. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123518. /***/ }),
  123519. /***/ "./PostProcesses/fxaaPostProcess.ts":
  123520. /*!******************************************!*\
  123521. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  123522. \******************************************/
  123523. /*! exports provided: FxaaPostProcess */
  123524. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123525. "use strict";
  123526. __webpack_require__.r(__webpack_exports__);
  123527. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  123528. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123529. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  123530. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123531. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123532. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  123533. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  123534. /**
  123535. * Fxaa post process
  123536. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  123537. */
  123538. var FxaaPostProcess = /** @class */ (function (_super) {
  123539. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  123540. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  123541. if (camera === void 0) { camera = null; }
  123542. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123543. 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;
  123544. var defines = _this._getDefines();
  123545. _this.updateEffect(defines);
  123546. _this.onApplyObservable.add(function (effect) {
  123547. var texelSize = _this.texelSize;
  123548. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  123549. });
  123550. return _this;
  123551. }
  123552. FxaaPostProcess.prototype._getDefines = function () {
  123553. var engine = this.getEngine();
  123554. if (!engine) {
  123555. return null;
  123556. }
  123557. var glInfo = engine.getGlInfo();
  123558. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  123559. return "#define MALI 1\n";
  123560. }
  123561. return null;
  123562. };
  123563. return FxaaPostProcess;
  123564. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  123565. /***/ }),
  123566. /***/ "./PostProcesses/grainPostProcess.ts":
  123567. /*!*******************************************!*\
  123568. !*** ./PostProcesses/grainPostProcess.ts ***!
  123569. \*******************************************/
  123570. /*! exports provided: GrainPostProcess */
  123571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123572. "use strict";
  123573. __webpack_require__.r(__webpack_exports__);
  123574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  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_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  123579. /**
  123580. * The GrainPostProcess adds noise to the image at mid luminance levels
  123581. */
  123582. var GrainPostProcess = /** @class */ (function (_super) {
  123583. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  123584. /**
  123585. * Creates a new instance of @see GrainPostProcess
  123586. * @param name The name of the effect.
  123587. * @param options The required width/height ratio to downsize to before computing the render pass.
  123588. * @param camera The camera to apply the render pass to.
  123589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123590. * @param engine The engine which the post process will be applied. (default: current engine)
  123591. * @param reusable If the post process can be reused on the same frame. (default: false)
  123592. * @param textureType Type of textures used when performing the post process. (default: 0)
  123593. * @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)
  123594. */
  123595. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  123596. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123597. if (blockCompilation === void 0) { blockCompilation = false; }
  123598. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  123599. /**
  123600. * The intensity of the grain added (default: 30)
  123601. */
  123602. _this.intensity = 30;
  123603. /**
  123604. * If the grain should be randomized on every frame
  123605. */
  123606. _this.animated = false;
  123607. _this.onApplyObservable.add(function (effect) {
  123608. effect.setFloat('intensity', _this.intensity);
  123609. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  123610. });
  123611. return _this;
  123612. }
  123613. return GrainPostProcess;
  123614. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123615. /***/ }),
  123616. /***/ "./PostProcesses/highlightsPostProcess.ts":
  123617. /*!************************************************!*\
  123618. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  123619. \************************************************/
  123620. /*! exports provided: HighlightsPostProcess */
  123621. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123622. "use strict";
  123623. __webpack_require__.r(__webpack_exports__);
  123624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  123625. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123626. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123627. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123628. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  123629. /**
  123630. * Extracts highlights from the image
  123631. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  123632. */
  123633. var HighlightsPostProcess = /** @class */ (function (_super) {
  123634. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  123635. /**
  123636. * Extracts highlights from the image
  123637. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  123638. * @param name The name of the effect.
  123639. * @param options The required width/height ratio to downsize to before computing the render pass.
  123640. * @param camera The camera to apply the render pass to.
  123641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123642. * @param engine The engine which the post process will be applied. (default: current engine)
  123643. * @param reusable If the post process can be reused on the same frame. (default: false)
  123644. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  123645. */
  123646. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  123647. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123648. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  123649. }
  123650. return HighlightsPostProcess;
  123651. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  123652. /***/ }),
  123653. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  123654. /*!*****************************************************!*\
  123655. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  123656. \*****************************************************/
  123657. /*! exports provided: ImageProcessingPostProcess */
  123658. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123659. "use strict";
  123660. __webpack_require__.r(__webpack_exports__);
  123661. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  123662. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  123663. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  123664. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  123665. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  123666. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  123667. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  123668. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  123669. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  123670. /**
  123671. * ImageProcessingPostProcess
  123672. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  123673. */
  123674. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  123675. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  123676. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  123677. if (camera === void 0) { camera = null; }
  123678. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  123679. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  123680. _this._fromLinearSpace = true;
  123681. /**
  123682. * Defines cache preventing GC.
  123683. */
  123684. _this._defines = {
  123685. IMAGEPROCESSING: false,
  123686. VIGNETTE: false,
  123687. VIGNETTEBLENDMODEMULTIPLY: false,
  123688. VIGNETTEBLENDMODEOPAQUE: false,
  123689. TONEMAPPING: false,
  123690. TONEMAPPING_ACES: false,
  123691. CONTRAST: false,
  123692. COLORCURVES: false,
  123693. COLORGRADING: false,
  123694. COLORGRADING3D: false,
  123695. FROMLINEARSPACE: false,
  123696. SAMPLER3DGREENDEPTH: false,
  123697. SAMPLER3DBGRMAP: false,
  123698. IMAGEPROCESSINGPOSTPROCESS: false,
  123699. EXPOSURE: false,
  123700. };
  123701. // Setup the configuration as forced by the constructor. This would then not force the
  123702. // scene materials output in linear space and let untouched the default forward pass.
  123703. if (imageProcessingConfiguration) {
  123704. imageProcessingConfiguration.applyByPostProcess = true;
  123705. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  123706. // This will cause the shader to be compiled
  123707. _this.fromLinearSpace = false;
  123708. }
  123709. // Setup the default processing configuration to the scene.
  123710. else {
  123711. _this._attachImageProcessingConfiguration(null, true);
  123712. _this.imageProcessingConfiguration.applyByPostProcess = true;
  123713. }
  123714. _this.onApply = function (effect) {
  123715. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  123716. };
  123717. return _this;
  123718. }
  123719. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  123720. /**
  123721. * Gets the image processing configuration used either in this material.
  123722. */
  123723. get: function () {
  123724. return this._imageProcessingConfiguration;
  123725. },
  123726. /**
  123727. * Sets the Default image processing configuration used either in the this material.
  123728. *
  123729. * If sets to null, the scene one is in use.
  123730. */
  123731. set: function (value) {
  123732. this._attachImageProcessingConfiguration(value);
  123733. },
  123734. enumerable: true,
  123735. configurable: true
  123736. });
  123737. /**
  123738. * Attaches a new image processing configuration to the PBR Material.
  123739. * @param configuration
  123740. */
  123741. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  123742. var _this = this;
  123743. if (doNotBuild === void 0) { doNotBuild = false; }
  123744. if (configuration === this._imageProcessingConfiguration) {
  123745. return;
  123746. }
  123747. // Detaches observer.
  123748. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  123749. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  123750. }
  123751. // Pick the scene configuration if needed.
  123752. if (!configuration) {
  123753. var scene = null;
  123754. var engine = this.getEngine();
  123755. var camera = this.getCamera();
  123756. if (camera) {
  123757. scene = camera.getScene();
  123758. }
  123759. else if (engine && engine.scenes) {
  123760. var scenes = engine.scenes;
  123761. scene = scenes[scenes.length - 1];
  123762. }
  123763. else {
  123764. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  123765. }
  123766. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  123767. }
  123768. else {
  123769. this._imageProcessingConfiguration = configuration;
  123770. }
  123771. // Attaches observer.
  123772. if (this._imageProcessingConfiguration) {
  123773. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  123774. _this._updateParameters();
  123775. });
  123776. }
  123777. // Ensure the effect will be rebuilt.
  123778. if (!doNotBuild) {
  123779. this._updateParameters();
  123780. }
  123781. };
  123782. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  123783. /**
  123784. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123785. */
  123786. get: function () {
  123787. return this.imageProcessingConfiguration.colorCurves;
  123788. },
  123789. /**
  123790. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  123791. */
  123792. set: function (value) {
  123793. this.imageProcessingConfiguration.colorCurves = value;
  123794. },
  123795. enumerable: true,
  123796. configurable: true
  123797. });
  123798. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  123799. /**
  123800. * Gets wether the color curves effect is enabled.
  123801. */
  123802. get: function () {
  123803. return this.imageProcessingConfiguration.colorCurvesEnabled;
  123804. },
  123805. /**
  123806. * Sets wether the color curves effect is enabled.
  123807. */
  123808. set: function (value) {
  123809. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  123810. },
  123811. enumerable: true,
  123812. configurable: true
  123813. });
  123814. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  123815. /**
  123816. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123817. */
  123818. get: function () {
  123819. return this.imageProcessingConfiguration.colorGradingTexture;
  123820. },
  123821. /**
  123822. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  123823. */
  123824. set: function (value) {
  123825. this.imageProcessingConfiguration.colorGradingTexture = value;
  123826. },
  123827. enumerable: true,
  123828. configurable: true
  123829. });
  123830. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  123831. /**
  123832. * Gets wether the color grading effect is enabled.
  123833. */
  123834. get: function () {
  123835. return this.imageProcessingConfiguration.colorGradingEnabled;
  123836. },
  123837. /**
  123838. * Gets wether the color grading effect is enabled.
  123839. */
  123840. set: function (value) {
  123841. this.imageProcessingConfiguration.colorGradingEnabled = value;
  123842. },
  123843. enumerable: true,
  123844. configurable: true
  123845. });
  123846. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  123847. /**
  123848. * Gets exposure used in the effect.
  123849. */
  123850. get: function () {
  123851. return this.imageProcessingConfiguration.exposure;
  123852. },
  123853. /**
  123854. * Sets exposure used in the effect.
  123855. */
  123856. set: function (value) {
  123857. this.imageProcessingConfiguration.exposure = value;
  123858. },
  123859. enumerable: true,
  123860. configurable: true
  123861. });
  123862. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  123863. /**
  123864. * Gets wether tonemapping is enabled or not.
  123865. */
  123866. get: function () {
  123867. return this._imageProcessingConfiguration.toneMappingEnabled;
  123868. },
  123869. /**
  123870. * Sets wether tonemapping is enabled or not
  123871. */
  123872. set: function (value) {
  123873. this._imageProcessingConfiguration.toneMappingEnabled = value;
  123874. },
  123875. enumerable: true,
  123876. configurable: true
  123877. });
  123878. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingType", {
  123879. /**
  123880. * Gets the type of tone mapping effect.
  123881. */
  123882. get: function () {
  123883. return this._imageProcessingConfiguration.toneMappingType;
  123884. },
  123885. /**
  123886. * Sets the type of tone mapping effect.
  123887. */
  123888. set: function (value) {
  123889. this._imageProcessingConfiguration.toneMappingType = value;
  123890. },
  123891. enumerable: true,
  123892. configurable: true
  123893. });
  123894. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  123895. /**
  123896. * Gets contrast used in the effect.
  123897. */
  123898. get: function () {
  123899. return this.imageProcessingConfiguration.contrast;
  123900. },
  123901. /**
  123902. * Sets contrast used in the effect.
  123903. */
  123904. set: function (value) {
  123905. this.imageProcessingConfiguration.contrast = value;
  123906. },
  123907. enumerable: true,
  123908. configurable: true
  123909. });
  123910. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  123911. /**
  123912. * Gets Vignette stretch size.
  123913. */
  123914. get: function () {
  123915. return this.imageProcessingConfiguration.vignetteStretch;
  123916. },
  123917. /**
  123918. * Sets Vignette stretch size.
  123919. */
  123920. set: function (value) {
  123921. this.imageProcessingConfiguration.vignetteStretch = value;
  123922. },
  123923. enumerable: true,
  123924. configurable: true
  123925. });
  123926. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  123927. /**
  123928. * Gets Vignette centre X Offset.
  123929. */
  123930. get: function () {
  123931. return this.imageProcessingConfiguration.vignetteCentreX;
  123932. },
  123933. /**
  123934. * Sets Vignette centre X Offset.
  123935. */
  123936. set: function (value) {
  123937. this.imageProcessingConfiguration.vignetteCentreX = value;
  123938. },
  123939. enumerable: true,
  123940. configurable: true
  123941. });
  123942. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  123943. /**
  123944. * Gets Vignette centre Y Offset.
  123945. */
  123946. get: function () {
  123947. return this.imageProcessingConfiguration.vignetteCentreY;
  123948. },
  123949. /**
  123950. * Sets Vignette centre Y Offset.
  123951. */
  123952. set: function (value) {
  123953. this.imageProcessingConfiguration.vignetteCentreY = value;
  123954. },
  123955. enumerable: true,
  123956. configurable: true
  123957. });
  123958. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  123959. /**
  123960. * Gets Vignette weight or intensity of the vignette effect.
  123961. */
  123962. get: function () {
  123963. return this.imageProcessingConfiguration.vignetteWeight;
  123964. },
  123965. /**
  123966. * Sets Vignette weight or intensity of the vignette effect.
  123967. */
  123968. set: function (value) {
  123969. this.imageProcessingConfiguration.vignetteWeight = value;
  123970. },
  123971. enumerable: true,
  123972. configurable: true
  123973. });
  123974. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  123975. /**
  123976. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123977. * if vignetteEnabled is set to true.
  123978. */
  123979. get: function () {
  123980. return this.imageProcessingConfiguration.vignetteColor;
  123981. },
  123982. /**
  123983. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  123984. * if vignetteEnabled is set to true.
  123985. */
  123986. set: function (value) {
  123987. this.imageProcessingConfiguration.vignetteColor = value;
  123988. },
  123989. enumerable: true,
  123990. configurable: true
  123991. });
  123992. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  123993. /**
  123994. * Gets Camera field of view used by the Vignette effect.
  123995. */
  123996. get: function () {
  123997. return this.imageProcessingConfiguration.vignetteCameraFov;
  123998. },
  123999. /**
  124000. * Sets Camera field of view used by the Vignette effect.
  124001. */
  124002. set: function (value) {
  124003. this.imageProcessingConfiguration.vignetteCameraFov = value;
  124004. },
  124005. enumerable: true,
  124006. configurable: true
  124007. });
  124008. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  124009. /**
  124010. * Gets the vignette blend mode allowing different kind of effect.
  124011. */
  124012. get: function () {
  124013. return this.imageProcessingConfiguration.vignetteBlendMode;
  124014. },
  124015. /**
  124016. * Sets the vignette blend mode allowing different kind of effect.
  124017. */
  124018. set: function (value) {
  124019. this.imageProcessingConfiguration.vignetteBlendMode = value;
  124020. },
  124021. enumerable: true,
  124022. configurable: true
  124023. });
  124024. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  124025. /**
  124026. * Gets wether the vignette effect is enabled.
  124027. */
  124028. get: function () {
  124029. return this.imageProcessingConfiguration.vignetteEnabled;
  124030. },
  124031. /**
  124032. * Sets wether the vignette effect is enabled.
  124033. */
  124034. set: function (value) {
  124035. this.imageProcessingConfiguration.vignetteEnabled = value;
  124036. },
  124037. enumerable: true,
  124038. configurable: true
  124039. });
  124040. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  124041. /**
  124042. * Gets wether the input of the processing is in Gamma or Linear Space.
  124043. */
  124044. get: function () {
  124045. return this._fromLinearSpace;
  124046. },
  124047. /**
  124048. * Sets wether the input of the processing is in Gamma or Linear Space.
  124049. */
  124050. set: function (value) {
  124051. if (this._fromLinearSpace === value) {
  124052. return;
  124053. }
  124054. this._fromLinearSpace = value;
  124055. this._updateParameters();
  124056. },
  124057. enumerable: true,
  124058. configurable: true
  124059. });
  124060. /**
  124061. * "ImageProcessingPostProcess"
  124062. * @returns "ImageProcessingPostProcess"
  124063. */
  124064. ImageProcessingPostProcess.prototype.getClassName = function () {
  124065. return "ImageProcessingPostProcess";
  124066. };
  124067. ImageProcessingPostProcess.prototype._updateParameters = function () {
  124068. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  124069. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  124070. var defines = "";
  124071. for (var define in this._defines) {
  124072. if (this._defines[define]) {
  124073. defines += "#define " + define + ";\r\n";
  124074. }
  124075. }
  124076. var samplers = ["textureSampler"];
  124077. var uniforms = ["scale"];
  124078. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  124079. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  124080. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  124081. }
  124082. this.updateEffect(defines, uniforms, samplers);
  124083. };
  124084. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  124085. _super.prototype.dispose.call(this, camera);
  124086. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  124087. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  124088. }
  124089. if (this._imageProcessingConfiguration) {
  124090. this.imageProcessingConfiguration.applyByPostProcess = false;
  124091. }
  124092. };
  124093. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  124094. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  124095. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  124096. return ImageProcessingPostProcess;
  124097. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  124098. /***/ }),
  124099. /***/ "./PostProcesses/index.ts":
  124100. /*!********************************!*\
  124101. !*** ./PostProcesses/index.ts ***!
  124102. \********************************/
  124103. /*! exports provided: AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, VRMultiviewToSingleviewPostProcess, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  124104. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124105. "use strict";
  124106. __webpack_require__.r(__webpack_exports__);
  124107. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  124108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  124109. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  124110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  124111. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  124112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  124113. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  124114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  124115. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  124116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  124117. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  124118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  124119. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  124120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  124121. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  124122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  124123. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  124124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  124125. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  124126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  124127. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  124128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  124129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  124130. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  124131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  124132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  124133. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  124134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  124135. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  124136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  124137. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  124138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  124139. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  124140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  124141. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  124142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  124143. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  124144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  124145. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  124146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  124147. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  124148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  124149. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  124150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  124151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  124152. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  124154. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  124155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  124156. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  124157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  124158. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  124159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  124160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  124161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  124162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  124163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  124164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  124165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  124166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  124167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  124168. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  124169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  124170. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  124171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  124172. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  124173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  124174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  124175. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  124176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  124177. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  124178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  124179. /* harmony import */ var _vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./vrMultiviewToSingleviewPostProcess */ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts");
  124180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return _vrMultiviewToSingleviewPostProcess__WEBPACK_IMPORTED_MODULE_30__["VRMultiviewToSingleviewPostProcess"]; });
  124181. /***/ }),
  124182. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  124183. /*!************************************************!*\
  124184. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  124185. \************************************************/
  124186. /*! exports provided: MotionBlurPostProcess */
  124187. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124188. "use strict";
  124189. __webpack_require__.r(__webpack_exports__);
  124190. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  124191. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124192. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  124193. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124194. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124195. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124196. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  124197. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Animations/animatable */ "./Animations/animatable.ts");
  124198. /* harmony import */ var _Rendering_geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  124199. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  124200. /**
  124201. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  124202. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  124203. * As an example, all you have to do is to create the post-process:
  124204. * var mb = new BABYLON.MotionBlurPostProcess(
  124205. * 'mb', // The name of the effect.
  124206. * scene, // The scene containing the objects to blur according to their velocity.
  124207. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  124208. * camera // The camera to apply the render pass to.
  124209. * );
  124210. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  124211. */
  124212. var MotionBlurPostProcess = /** @class */ (function (_super) {
  124213. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  124214. /**
  124215. * Creates a new instance MotionBlurPostProcess
  124216. * @param name The name of the effect.
  124217. * @param scene The scene containing the objects to blur according to their velocity.
  124218. * @param options The required width/height ratio to downsize to before computing the render pass.
  124219. * @param camera The camera to apply the render pass to.
  124220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124221. * @param engine The engine which the post process will be applied. (default: current engine)
  124222. * @param reusable If the post process can be reused on the same frame. (default: false)
  124223. * @param textureType Type of textures used when performing the post process. (default: 0)
  124224. * @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)
  124225. */
  124226. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  124227. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  124228. if (blockCompilation === void 0) { blockCompilation = false; }
  124229. 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;
  124230. /**
  124231. * Defines how much the image is blurred by the movement. Default value is equal to 1
  124232. */
  124233. _this.motionStrength = 1;
  124234. _this._motionBlurSamples = 32;
  124235. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  124236. if (!_this._geometryBufferRenderer) {
  124237. // Geometry buffer renderer is not supported. So, work as a passthrough.
  124238. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  124239. _this.updateEffect();
  124240. }
  124241. else {
  124242. // Geometry buffer renderer is supported.
  124243. _this._geometryBufferRenderer.enableVelocity = true;
  124244. _this.onApply = function (effect) {
  124245. effect.setVector2("screenSize", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  124246. effect.setFloat("motionScale", scene.getAnimationRatio());
  124247. effect.setFloat("motionStrength", _this.motionStrength);
  124248. if (_this._geometryBufferRenderer) {
  124249. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  124250. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  124251. }
  124252. };
  124253. }
  124254. return _this;
  124255. }
  124256. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  124257. /**
  124258. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  124259. */
  124260. get: function () {
  124261. return this._motionBlurSamples;
  124262. },
  124263. /**
  124264. * Sets the number of iterations to be used for motion blur quality
  124265. */
  124266. set: function (samples) {
  124267. this._motionBlurSamples = samples;
  124268. if (this._geometryBufferRenderer) {
  124269. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  124270. }
  124271. },
  124272. enumerable: true,
  124273. configurable: true
  124274. });
  124275. /**
  124276. * Disposes the post process.
  124277. * @param camera The camera to dispose the post process on.
  124278. */
  124279. MotionBlurPostProcess.prototype.dispose = function (camera) {
  124280. if (this._geometryBufferRenderer) {
  124281. // Clear previous transformation matrices dictionary used to compute objects velocities
  124282. this._geometryBufferRenderer._previousTransformationMatrices = {};
  124283. }
  124284. _super.prototype.dispose.call(this, camera);
  124285. };
  124286. return MotionBlurPostProcess;
  124287. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  124288. /***/ }),
  124289. /***/ "./PostProcesses/passPostProcess.ts":
  124290. /*!******************************************!*\
  124291. !*** ./PostProcesses/passPostProcess.ts ***!
  124292. \******************************************/
  124293. /*! exports provided: PassPostProcess, PassCubePostProcess */
  124294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124295. "use strict";
  124296. __webpack_require__.r(__webpack_exports__);
  124297. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  124298. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  124299. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  124300. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124301. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  124302. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  124303. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  124304. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  124305. /**
  124306. * PassPostProcess which produces an output the same as it's input
  124307. */
  124308. var PassPostProcess = /** @class */ (function (_super) {
  124309. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  124310. /**
  124311. * Creates the PassPostProcess
  124312. * @param name The name of the effect.
  124313. * @param options The required width/height ratio to downsize to before computing the render pass.
  124314. * @param camera The camera to apply the render pass to.
  124315. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124316. * @param engine The engine which the post process will be applied. (default: current engine)
  124317. * @param reusable If the post process can be reused on the same frame. (default: false)
  124318. * @param textureType The type of texture to be used when performing the post processing.
  124319. * @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)
  124320. */
  124321. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  124322. if (camera === void 0) { camera = null; }
  124323. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  124324. if (blockCompilation === void 0) { blockCompilation = false; }
  124325. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  124326. }
  124327. return PassPostProcess;
  124328. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  124329. /**
  124330. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  124331. */
  124332. var PassCubePostProcess = /** @class */ (function (_super) {
  124333. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  124334. /**
  124335. * Creates the PassCubePostProcess
  124336. * @param name The name of the effect.
  124337. * @param options The required width/height ratio to downsize to before computing the render pass.
  124338. * @param camera The camera to apply the render pass to.
  124339. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124340. * @param engine The engine which the post process will be applied. (default: current engine)
  124341. * @param reusable If the post process can be reused on the same frame. (default: false)
  124342. * @param textureType The type of texture to be used when performing the post processing.
  124343. * @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)
  124344. */
  124345. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  124346. if (camera === void 0) { camera = null; }
  124347. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  124348. if (blockCompilation === void 0) { blockCompilation = false; }
  124349. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  124350. _this._face = 0;
  124351. return _this;
  124352. }
  124353. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  124354. /**
  124355. * Gets or sets the cube face to display.
  124356. * * 0 is +X
  124357. * * 1 is -X
  124358. * * 2 is +Y
  124359. * * 3 is -Y
  124360. * * 4 is +Z
  124361. * * 5 is -Z
  124362. */
  124363. get: function () {
  124364. return this._face;
  124365. },
  124366. set: function (value) {
  124367. if (value < 0 || value > 5) {
  124368. return;
  124369. }
  124370. this._face = value;
  124371. switch (this._face) {
  124372. case 0:
  124373. this.updateEffect("#define POSITIVEX");
  124374. break;
  124375. case 1:
  124376. this.updateEffect("#define NEGATIVEX");
  124377. break;
  124378. case 2:
  124379. this.updateEffect("#define POSITIVEY");
  124380. break;
  124381. case 3:
  124382. this.updateEffect("#define NEGATIVEY");
  124383. break;
  124384. case 4:
  124385. this.updateEffect("#define POSITIVEZ");
  124386. break;
  124387. case 5:
  124388. this.updateEffect("#define NEGATIVEZ");
  124389. break;
  124390. }
  124391. },
  124392. enumerable: true,
  124393. configurable: true
  124394. });
  124395. return PassCubePostProcess;
  124396. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  124397. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  124398. 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);
  124399. };
  124400. /***/ }),
  124401. /***/ "./PostProcesses/postProcess.ts":
  124402. /*!**************************************!*\
  124403. !*** ./PostProcesses/postProcess.ts ***!
  124404. \**************************************/
  124405. /*! exports provided: PostProcess */
  124406. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124407. "use strict";
  124408. __webpack_require__.r(__webpack_exports__);
  124409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  124410. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  124411. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  124412. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  124413. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  124414. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124415. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  124416. /**
  124417. * PostProcess can be used to apply a shader to a texture after it has been rendered
  124418. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124419. */
  124420. var PostProcess = /** @class */ (function () {
  124421. /**
  124422. * Creates a new instance PostProcess
  124423. * @param name The name of the PostProcess.
  124424. * @param fragmentUrl The url of the fragment shader to be used.
  124425. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  124426. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  124427. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  124428. * @param camera The camera to apply the render pass to.
  124429. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124430. * @param engine The engine which the post process will be applied. (default: current engine)
  124431. * @param reusable If the post process can be reused on the same frame. (default: false)
  124432. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  124433. * @param textureType Type of textures used when performing the post process. (default: 0)
  124434. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  124435. * @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
  124436. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  124437. */
  124438. function PostProcess(
  124439. /** Name of the PostProcess. */
  124440. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  124441. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  124442. if (defines === void 0) { defines = null; }
  124443. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  124444. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  124445. if (blockCompilation === void 0) { blockCompilation = false; }
  124446. this.name = name;
  124447. /**
  124448. * Width of the texture to apply the post process on
  124449. */
  124450. this.width = -1;
  124451. /**
  124452. * Height of the texture to apply the post process on
  124453. */
  124454. this.height = -1;
  124455. /**
  124456. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  124457. * @hidden
  124458. */
  124459. this._outputTexture = null;
  124460. /**
  124461. * If the buffer needs to be cleared before applying the post process. (default: true)
  124462. * Should be set to false if shader will overwrite all previous pixels.
  124463. */
  124464. this.autoClear = true;
  124465. /**
  124466. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  124467. */
  124468. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE;
  124469. /**
  124470. * Animations to be used for the post processing
  124471. */
  124472. this.animations = new Array();
  124473. /**
  124474. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  124475. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  124476. */
  124477. this.enablePixelPerfectMode = false;
  124478. /**
  124479. * Force the postprocess to be applied without taking in account viewport
  124480. */
  124481. this.forceFullscreenViewport = true;
  124482. /**
  124483. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  124484. *
  124485. * | Value | Type | Description |
  124486. * | ----- | ----------------------------------- | ----------- |
  124487. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  124488. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  124489. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  124490. *
  124491. */
  124492. this.scaleMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].SCALEMODE_FLOOR;
  124493. /**
  124494. * Force textures to be a power of two (default: false)
  124495. */
  124496. this.alwaysForcePOT = false;
  124497. this._samples = 1;
  124498. /**
  124499. * Modify the scale of the post process to be the same as the viewport (default: false)
  124500. */
  124501. this.adaptScaleToCurrentViewport = false;
  124502. this._reusable = false;
  124503. /**
  124504. * Smart array of input and output textures for the post process.
  124505. * @hidden
  124506. */
  124507. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  124508. /**
  124509. * The index in _textures that corresponds to the output texture.
  124510. * @hidden
  124511. */
  124512. this._currentRenderTextureInd = 0;
  124513. this._scaleRatio = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 1);
  124514. this._texelSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  124515. // Events
  124516. /**
  124517. * An event triggered when the postprocess is activated.
  124518. */
  124519. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  124520. /**
  124521. * An event triggered when the postprocess changes its size.
  124522. */
  124523. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  124524. /**
  124525. * An event triggered when the postprocess applies its effect.
  124526. */
  124527. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  124528. /**
  124529. * An event triggered before rendering the postprocess
  124530. */
  124531. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  124532. /**
  124533. * An event triggered after rendering the postprocess
  124534. */
  124535. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  124536. if (camera != null) {
  124537. this._camera = camera;
  124538. this._scene = camera.getScene();
  124539. camera.attachPostProcess(this);
  124540. this._engine = this._scene.getEngine();
  124541. this._scene.postProcesses.push(this);
  124542. this.uniqueId = this._scene.getUniqueId();
  124543. }
  124544. else if (engine) {
  124545. this._engine = engine;
  124546. this._engine.postProcesses.push(this);
  124547. }
  124548. this._options = options;
  124549. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  124550. this._reusable = reusable || false;
  124551. this._textureType = textureType;
  124552. this._samplers = samplers || [];
  124553. this._samplers.push("textureSampler");
  124554. this._fragmentUrl = fragmentUrl;
  124555. this._vertexUrl = vertexUrl;
  124556. this._parameters = parameters || [];
  124557. this._parameters.push("scale");
  124558. this._indexParameters = indexParameters;
  124559. if (!blockCompilation) {
  124560. this.updateEffect(defines);
  124561. }
  124562. }
  124563. Object.defineProperty(PostProcess.prototype, "samples", {
  124564. /**
  124565. * Number of sample textures (default: 1)
  124566. */
  124567. get: function () {
  124568. return this._samples;
  124569. },
  124570. set: function (n) {
  124571. var _this = this;
  124572. this._samples = n;
  124573. this._textures.forEach(function (texture) {
  124574. if (texture.samples !== _this._samples) {
  124575. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  124576. }
  124577. });
  124578. },
  124579. enumerable: true,
  124580. configurable: true
  124581. });
  124582. /**
  124583. * Returns the fragment url or shader name used in the post process.
  124584. * @returns the fragment url or name in the shader store.
  124585. */
  124586. PostProcess.prototype.getEffectName = function () {
  124587. return this._fragmentUrl;
  124588. };
  124589. Object.defineProperty(PostProcess.prototype, "onActivate", {
  124590. /**
  124591. * A function that is added to the onActivateObservable
  124592. */
  124593. set: function (callback) {
  124594. if (this._onActivateObserver) {
  124595. this.onActivateObservable.remove(this._onActivateObserver);
  124596. }
  124597. if (callback) {
  124598. this._onActivateObserver = this.onActivateObservable.add(callback);
  124599. }
  124600. },
  124601. enumerable: true,
  124602. configurable: true
  124603. });
  124604. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  124605. /**
  124606. * A function that is added to the onSizeChangedObservable
  124607. */
  124608. set: function (callback) {
  124609. if (this._onSizeChangedObserver) {
  124610. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  124611. }
  124612. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  124613. },
  124614. enumerable: true,
  124615. configurable: true
  124616. });
  124617. Object.defineProperty(PostProcess.prototype, "onApply", {
  124618. /**
  124619. * A function that is added to the onApplyObservable
  124620. */
  124621. set: function (callback) {
  124622. if (this._onApplyObserver) {
  124623. this.onApplyObservable.remove(this._onApplyObserver);
  124624. }
  124625. this._onApplyObserver = this.onApplyObservable.add(callback);
  124626. },
  124627. enumerable: true,
  124628. configurable: true
  124629. });
  124630. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  124631. /**
  124632. * A function that is added to the onBeforeRenderObservable
  124633. */
  124634. set: function (callback) {
  124635. if (this._onBeforeRenderObserver) {
  124636. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  124637. }
  124638. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  124639. },
  124640. enumerable: true,
  124641. configurable: true
  124642. });
  124643. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  124644. /**
  124645. * A function that is added to the onAfterRenderObservable
  124646. */
  124647. set: function (callback) {
  124648. if (this._onAfterRenderObserver) {
  124649. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  124650. }
  124651. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  124652. },
  124653. enumerable: true,
  124654. configurable: true
  124655. });
  124656. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  124657. /**
  124658. * 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
  124659. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  124660. */
  124661. get: function () {
  124662. return this._textures.data[this._currentRenderTextureInd];
  124663. },
  124664. set: function (value) {
  124665. this._forcedOutputTexture = value;
  124666. },
  124667. enumerable: true,
  124668. configurable: true
  124669. });
  124670. /**
  124671. * Gets the camera which post process is applied to.
  124672. * @returns The camera the post process is applied to.
  124673. */
  124674. PostProcess.prototype.getCamera = function () {
  124675. return this._camera;
  124676. };
  124677. Object.defineProperty(PostProcess.prototype, "texelSize", {
  124678. /**
  124679. * Gets the texel size of the postprocess.
  124680. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  124681. */
  124682. get: function () {
  124683. if (this._shareOutputWithPostProcess) {
  124684. return this._shareOutputWithPostProcess.texelSize;
  124685. }
  124686. if (this._forcedOutputTexture) {
  124687. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  124688. }
  124689. return this._texelSize;
  124690. },
  124691. enumerable: true,
  124692. configurable: true
  124693. });
  124694. /**
  124695. * Gets a string idenfifying the name of the class
  124696. * @returns "PostProcess" string
  124697. */
  124698. PostProcess.prototype.getClassName = function () {
  124699. return "PostProcess";
  124700. };
  124701. /**
  124702. * Gets the engine which this post process belongs to.
  124703. * @returns The engine the post process was enabled with.
  124704. */
  124705. PostProcess.prototype.getEngine = function () {
  124706. return this._engine;
  124707. };
  124708. /**
  124709. * The effect that is created when initializing the post process.
  124710. * @returns The created effect corrisponding the the postprocess.
  124711. */
  124712. PostProcess.prototype.getEffect = function () {
  124713. return this._effect;
  124714. };
  124715. /**
  124716. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  124717. * @param postProcess The post process to share the output with.
  124718. * @returns This post process.
  124719. */
  124720. PostProcess.prototype.shareOutputWith = function (postProcess) {
  124721. this._disposeTextures();
  124722. this._shareOutputWithPostProcess = postProcess;
  124723. return this;
  124724. };
  124725. /**
  124726. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  124727. * This should be called if the post process that shares output with this post process is disabled/disposed.
  124728. */
  124729. PostProcess.prototype.useOwnOutput = function () {
  124730. if (this._textures.length == 0) {
  124731. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  124732. }
  124733. this._shareOutputWithPostProcess = null;
  124734. };
  124735. /**
  124736. * Updates the effect with the current post process compile time values and recompiles the shader.
  124737. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  124738. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  124739. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  124740. * @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
  124741. * @param onCompiled Called when the shader has been compiled.
  124742. * @param onError Called if there is an error when compiling a shader.
  124743. */
  124744. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  124745. if (defines === void 0) { defines = null; }
  124746. if (uniforms === void 0) { uniforms = null; }
  124747. if (samplers === void 0) { samplers = null; }
  124748. 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);
  124749. };
  124750. /**
  124751. * The post process is reusable if it can be used multiple times within one frame.
  124752. * @returns If the post process is reusable
  124753. */
  124754. PostProcess.prototype.isReusable = function () {
  124755. return this._reusable;
  124756. };
  124757. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  124758. PostProcess.prototype.markTextureDirty = function () {
  124759. this.width = -1;
  124760. };
  124761. /**
  124762. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  124763. * 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.
  124764. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  124765. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  124766. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  124767. * @returns The target texture that was bound to be written to.
  124768. */
  124769. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  124770. var _this = this;
  124771. if (sourceTexture === void 0) { sourceTexture = null; }
  124772. camera = camera || this._camera;
  124773. var scene = camera.getScene();
  124774. var engine = scene.getEngine();
  124775. var maxSize = engine.getCaps().maxTextureSize;
  124776. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  124777. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  124778. // 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
  124779. var webVRCamera = camera.parent;
  124780. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  124781. requiredWidth /= 2;
  124782. }
  124783. var desiredWidth = (this._options.width || requiredWidth);
  124784. var desiredHeight = this._options.height || requiredHeight;
  124785. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  124786. if (this.adaptScaleToCurrentViewport) {
  124787. var currentViewport = engine.currentViewport;
  124788. if (currentViewport) {
  124789. desiredWidth *= currentViewport.width;
  124790. desiredHeight *= currentViewport.height;
  124791. }
  124792. }
  124793. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  124794. if (!this._options.width) {
  124795. desiredWidth = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  124796. }
  124797. if (!this._options.height) {
  124798. desiredHeight = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  124799. }
  124800. }
  124801. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  124802. if (this._textures.length > 0) {
  124803. for (var i = 0; i < this._textures.length; i++) {
  124804. this._engine._releaseTexture(this._textures.data[i]);
  124805. }
  124806. this._textures.reset();
  124807. }
  124808. this.width = desiredWidth;
  124809. this.height = desiredHeight;
  124810. var textureSize = { width: this.width, height: this.height };
  124811. var textureOptions = {
  124812. generateMipMaps: false,
  124813. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  124814. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  124815. samplingMode: this.renderTargetSamplingMode,
  124816. type: this._textureType
  124817. };
  124818. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  124819. if (this._reusable) {
  124820. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  124821. }
  124822. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  124823. this.onSizeChangedObservable.notifyObservers(this);
  124824. }
  124825. this._textures.forEach(function (texture) {
  124826. if (texture.samples !== _this.samples) {
  124827. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  124828. }
  124829. });
  124830. }
  124831. var target;
  124832. if (this._shareOutputWithPostProcess) {
  124833. target = this._shareOutputWithPostProcess.inputTexture;
  124834. }
  124835. else if (this._forcedOutputTexture) {
  124836. target = this._forcedOutputTexture;
  124837. this.width = this._forcedOutputTexture.width;
  124838. this.height = this._forcedOutputTexture.height;
  124839. }
  124840. else {
  124841. target = this.inputTexture;
  124842. }
  124843. // Bind the input of this post process to be used as the output of the previous post process.
  124844. if (this.enablePixelPerfectMode) {
  124845. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  124846. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  124847. }
  124848. else {
  124849. this._scaleRatio.copyFromFloats(1, 1);
  124850. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  124851. }
  124852. this.onActivateObservable.notifyObservers(camera);
  124853. // Clear
  124854. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE) {
  124855. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  124856. }
  124857. if (this._reusable) {
  124858. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  124859. }
  124860. return target;
  124861. };
  124862. Object.defineProperty(PostProcess.prototype, "isSupported", {
  124863. /**
  124864. * If the post process is supported.
  124865. */
  124866. get: function () {
  124867. return this._effect.isSupported;
  124868. },
  124869. enumerable: true,
  124870. configurable: true
  124871. });
  124872. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  124873. /**
  124874. * The aspect ratio of the output texture.
  124875. */
  124876. get: function () {
  124877. if (this._shareOutputWithPostProcess) {
  124878. return this._shareOutputWithPostProcess.aspectRatio;
  124879. }
  124880. if (this._forcedOutputTexture) {
  124881. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  124882. }
  124883. return this.width / this.height;
  124884. },
  124885. enumerable: true,
  124886. configurable: true
  124887. });
  124888. /**
  124889. * Get a value indicating if the post-process is ready to be used
  124890. * @returns true if the post-process is ready (shader is compiled)
  124891. */
  124892. PostProcess.prototype.isReady = function () {
  124893. return this._effect && this._effect.isReady();
  124894. };
  124895. /**
  124896. * Binds all textures and uniforms to the shader, this will be run on every pass.
  124897. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  124898. */
  124899. PostProcess.prototype.apply = function () {
  124900. // Check
  124901. if (!this._effect || !this._effect.isReady()) {
  124902. return null;
  124903. }
  124904. // States
  124905. this._engine.enableEffect(this._effect);
  124906. this._engine.setState(false);
  124907. this._engine.setDepthBuffer(false);
  124908. this._engine.setDepthWrite(false);
  124909. // Alpha
  124910. this._engine.setAlphaMode(this.alphaMode);
  124911. if (this.alphaConstants) {
  124912. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  124913. }
  124914. // Bind the output texture of the preivous post process as the input to this post process.
  124915. var source;
  124916. if (this._shareOutputWithPostProcess) {
  124917. source = this._shareOutputWithPostProcess.inputTexture;
  124918. }
  124919. else if (this._forcedOutputTexture) {
  124920. source = this._forcedOutputTexture;
  124921. }
  124922. else {
  124923. source = this.inputTexture;
  124924. }
  124925. this._effect._bindTexture("textureSampler", source);
  124926. // Parameters
  124927. this._effect.setVector2("scale", this._scaleRatio);
  124928. this.onApplyObservable.notifyObservers(this._effect);
  124929. return this._effect;
  124930. };
  124931. PostProcess.prototype._disposeTextures = function () {
  124932. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  124933. return;
  124934. }
  124935. if (this._textures.length > 0) {
  124936. for (var i = 0; i < this._textures.length; i++) {
  124937. this._engine._releaseTexture(this._textures.data[i]);
  124938. }
  124939. }
  124940. this._textures.dispose();
  124941. };
  124942. /**
  124943. * Disposes the post process.
  124944. * @param camera The camera to dispose the post process on.
  124945. */
  124946. PostProcess.prototype.dispose = function (camera) {
  124947. camera = camera || this._camera;
  124948. this._disposeTextures();
  124949. if (this._scene) {
  124950. var index_1 = this._scene.postProcesses.indexOf(this);
  124951. if (index_1 !== -1) {
  124952. this._scene.postProcesses.splice(index_1, 1);
  124953. }
  124954. }
  124955. else {
  124956. var index_2 = this._engine.postProcesses.indexOf(this);
  124957. if (index_2 !== -1) {
  124958. this._engine.postProcesses.splice(index_2, 1);
  124959. }
  124960. }
  124961. if (!camera) {
  124962. return;
  124963. }
  124964. camera.detachPostProcess(this);
  124965. var index = camera._postProcesses.indexOf(this);
  124966. if (index === 0 && camera._postProcesses.length > 0) {
  124967. var firstPostProcess = this._camera._getFirstPostProcess();
  124968. if (firstPostProcess) {
  124969. firstPostProcess.markTextureDirty();
  124970. }
  124971. }
  124972. this.onActivateObservable.clear();
  124973. this.onAfterRenderObservable.clear();
  124974. this.onApplyObservable.clear();
  124975. this.onBeforeRenderObservable.clear();
  124976. this.onSizeChangedObservable.clear();
  124977. };
  124978. return PostProcess;
  124979. }());
  124980. /***/ }),
  124981. /***/ "./PostProcesses/postProcessManager.ts":
  124982. /*!*********************************************!*\
  124983. !*** ./PostProcesses/postProcessManager.ts ***!
  124984. \*********************************************/
  124985. /*! exports provided: PostProcessManager */
  124986. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124987. "use strict";
  124988. __webpack_require__.r(__webpack_exports__);
  124989. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  124990. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  124991. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  124992. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  124993. /**
  124994. * PostProcessManager is used to manage one or more post processes or post process pipelines
  124995. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124996. */
  124997. var PostProcessManager = /** @class */ (function () {
  124998. /**
  124999. * Creates a new instance PostProcess
  125000. * @param scene The scene that the post process is associated with.
  125001. */
  125002. function PostProcessManager(scene) {
  125003. this._vertexBuffers = {};
  125004. this._scene = scene;
  125005. }
  125006. PostProcessManager.prototype._prepareBuffers = function () {
  125007. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  125008. return;
  125009. }
  125010. // VBO
  125011. var vertices = [];
  125012. vertices.push(1, 1);
  125013. vertices.push(-1, 1);
  125014. vertices.push(-1, -1);
  125015. vertices.push(1, -1);
  125016. 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);
  125017. this._buildIndexBuffer();
  125018. };
  125019. PostProcessManager.prototype._buildIndexBuffer = function () {
  125020. // Indices
  125021. var indices = [];
  125022. indices.push(0);
  125023. indices.push(1);
  125024. indices.push(2);
  125025. indices.push(0);
  125026. indices.push(2);
  125027. indices.push(3);
  125028. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  125029. };
  125030. /**
  125031. * Rebuilds the vertex buffers of the manager.
  125032. * @hidden
  125033. */
  125034. PostProcessManager.prototype._rebuild = function () {
  125035. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  125036. if (!vb) {
  125037. return;
  125038. }
  125039. vb._rebuild();
  125040. this._buildIndexBuffer();
  125041. };
  125042. // Methods
  125043. /**
  125044. * Prepares a frame to be run through a post process.
  125045. * @param sourceTexture The input texture to the post procesess. (default: null)
  125046. * @param postProcesses An array of post processes to be run. (default: null)
  125047. * @returns True if the post processes were able to be run.
  125048. * @hidden
  125049. */
  125050. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  125051. if (sourceTexture === void 0) { sourceTexture = null; }
  125052. if (postProcesses === void 0) { postProcesses = null; }
  125053. var camera = this._scene.activeCamera;
  125054. if (!camera) {
  125055. return false;
  125056. }
  125057. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  125058. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  125059. return false;
  125060. }
  125061. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  125062. return true;
  125063. };
  125064. /**
  125065. * Manually render a set of post processes to a texture.
  125066. * @param postProcesses An array of post processes to be run.
  125067. * @param targetTexture The target texture to render to.
  125068. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  125069. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  125070. * @param lodLevel defines which lod of the texture to render to
  125071. */
  125072. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  125073. if (targetTexture === void 0) { targetTexture = null; }
  125074. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  125075. if (faceIndex === void 0) { faceIndex = 0; }
  125076. if (lodLevel === void 0) { lodLevel = 0; }
  125077. var engine = this._scene.getEngine();
  125078. for (var index = 0; index < postProcesses.length; index++) {
  125079. if (index < postProcesses.length - 1) {
  125080. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  125081. }
  125082. else {
  125083. if (targetTexture) {
  125084. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  125085. }
  125086. else {
  125087. engine.restoreDefaultFramebuffer();
  125088. }
  125089. }
  125090. var pp = postProcesses[index];
  125091. var effect = pp.apply();
  125092. if (effect) {
  125093. pp.onBeforeRenderObservable.notifyObservers(effect);
  125094. // VBOs
  125095. this._prepareBuffers();
  125096. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  125097. // Draw order
  125098. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  125099. pp.onAfterRenderObservable.notifyObservers(effect);
  125100. }
  125101. }
  125102. // Restore depth buffer
  125103. engine.setDepthBuffer(true);
  125104. engine.setDepthWrite(true);
  125105. };
  125106. /**
  125107. * Finalize the result of the output of the postprocesses.
  125108. * @param doNotPresent If true the result will not be displayed to the screen.
  125109. * @param targetTexture The target texture to render to.
  125110. * @param faceIndex The index of the face to bind the target texture to.
  125111. * @param postProcesses The array of post processes to render.
  125112. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  125113. * @hidden
  125114. */
  125115. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  125116. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  125117. var camera = this._scene.activeCamera;
  125118. if (!camera) {
  125119. return;
  125120. }
  125121. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  125122. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  125123. return;
  125124. }
  125125. var engine = this._scene.getEngine();
  125126. for (var index = 0, len = postProcesses.length; index < len; index++) {
  125127. var pp = postProcesses[index];
  125128. if (index < len - 1) {
  125129. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  125130. }
  125131. else {
  125132. if (targetTexture) {
  125133. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  125134. pp._outputTexture = targetTexture;
  125135. }
  125136. else {
  125137. engine.restoreDefaultFramebuffer();
  125138. pp._outputTexture = null;
  125139. }
  125140. }
  125141. if (doNotPresent) {
  125142. break;
  125143. }
  125144. var effect = pp.apply();
  125145. if (effect) {
  125146. pp.onBeforeRenderObservable.notifyObservers(effect);
  125147. // VBOs
  125148. this._prepareBuffers();
  125149. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  125150. // Draw order
  125151. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  125152. pp.onAfterRenderObservable.notifyObservers(effect);
  125153. }
  125154. }
  125155. // Restore states
  125156. engine.setDepthBuffer(true);
  125157. engine.setDepthWrite(true);
  125158. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  125159. };
  125160. /**
  125161. * Disposes of the post process manager.
  125162. */
  125163. PostProcessManager.prototype.dispose = function () {
  125164. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  125165. if (buffer) {
  125166. buffer.dispose();
  125167. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  125168. }
  125169. if (this._indexBuffer) {
  125170. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  125171. this._indexBuffer = null;
  125172. }
  125173. };
  125174. return PostProcessManager;
  125175. }());
  125176. /***/ }),
  125177. /***/ "./PostProcesses/refractionPostProcess.ts":
  125178. /*!************************************************!*\
  125179. !*** ./PostProcesses/refractionPostProcess.ts ***!
  125180. \************************************************/
  125181. /*! exports provided: RefractionPostProcess */
  125182. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125183. "use strict";
  125184. __webpack_require__.r(__webpack_exports__);
  125185. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  125186. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125187. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125188. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125189. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  125190. /**
  125191. * Post process which applies a refractin texture
  125192. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  125193. */
  125194. var RefractionPostProcess = /** @class */ (function (_super) {
  125195. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  125196. /**
  125197. * Initializes the RefractionPostProcess
  125198. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  125199. * @param name The name of the effect.
  125200. * @param refractionTextureUrl Url of the refraction texture to use
  125201. * @param color the base color of the refraction (used to taint the rendering)
  125202. * @param depth simulated refraction depth
  125203. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  125204. * @param camera The camera to apply the render pass to.
  125205. * @param options The required width/height ratio to downsize to before computing the render pass.
  125206. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125207. * @param engine The engine which the post process will be applied. (default: current engine)
  125208. * @param reusable If the post process can be reused on the same frame. (default: false)
  125209. */
  125210. function RefractionPostProcess(name, refractionTextureUrl,
  125211. /** the base color of the refraction (used to taint the rendering) */
  125212. color,
  125213. /** simulated refraction depth */
  125214. depth,
  125215. /** the coefficient of the base color (0 to remove base color tainting) */
  125216. colorLevel, options, camera, samplingMode, engine, reusable) {
  125217. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  125218. _this.color = color;
  125219. _this.depth = depth;
  125220. _this.colorLevel = colorLevel;
  125221. _this._ownRefractionTexture = true;
  125222. _this.onActivateObservable.add(function (cam) {
  125223. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  125224. });
  125225. _this.onApplyObservable.add(function (effect) {
  125226. effect.setColor3("baseColor", _this.color);
  125227. effect.setFloat("depth", _this.depth);
  125228. effect.setFloat("colorLevel", _this.colorLevel);
  125229. effect.setTexture("refractionSampler", _this._refTexture);
  125230. });
  125231. return _this;
  125232. }
  125233. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  125234. /**
  125235. * Gets or sets the refraction texture
  125236. * Please note that you are responsible for disposing the texture if you set it manually
  125237. */
  125238. get: function () {
  125239. return this._refTexture;
  125240. },
  125241. set: function (value) {
  125242. if (this._refTexture && this._ownRefractionTexture) {
  125243. this._refTexture.dispose();
  125244. }
  125245. this._refTexture = value;
  125246. this._ownRefractionTexture = false;
  125247. },
  125248. enumerable: true,
  125249. configurable: true
  125250. });
  125251. // Methods
  125252. /**
  125253. * Disposes of the post process
  125254. * @param camera Camera to dispose post process on
  125255. */
  125256. RefractionPostProcess.prototype.dispose = function (camera) {
  125257. if (this._refTexture && this._ownRefractionTexture) {
  125258. this._refTexture.dispose();
  125259. this._refTexture = null;
  125260. }
  125261. _super.prototype.dispose.call(this, camera);
  125262. };
  125263. return RefractionPostProcess;
  125264. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  125265. /***/ }),
  125266. /***/ "./PostProcesses/sharpenPostProcess.ts":
  125267. /*!*********************************************!*\
  125268. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  125269. \*********************************************/
  125270. /*! exports provided: SharpenPostProcess */
  125271. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125272. "use strict";
  125273. __webpack_require__.r(__webpack_exports__);
  125274. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  125275. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125276. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125277. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125278. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  125279. /**
  125280. * The SharpenPostProcess applies a sharpen kernel to every pixel
  125281. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125282. */
  125283. var SharpenPostProcess = /** @class */ (function (_super) {
  125284. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  125285. /**
  125286. * Creates a new instance ConvolutionPostProcess
  125287. * @param name The name of the effect.
  125288. * @param options The required width/height ratio to downsize to before computing the render pass.
  125289. * @param camera The camera to apply the render pass to.
  125290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125291. * @param engine The engine which the post process will be applied. (default: current engine)
  125292. * @param reusable If the post process can be reused on the same frame. (default: false)
  125293. * @param textureType Type of textures used when performing the post process. (default: 0)
  125294. * @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)
  125295. */
  125296. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  125297. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  125298. if (blockCompilation === void 0) { blockCompilation = false; }
  125299. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  125300. /**
  125301. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  125302. */
  125303. _this.colorAmount = 1.0;
  125304. /**
  125305. * How much sharpness should be applied (default: 0.3)
  125306. */
  125307. _this.edgeAmount = 0.3;
  125308. _this.onApply = function (effect) {
  125309. effect.setFloat2("screenSize", _this.width, _this.height);
  125310. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  125311. };
  125312. return _this;
  125313. }
  125314. return SharpenPostProcess;
  125315. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  125316. /***/ }),
  125317. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  125318. /*!***********************************************************!*\
  125319. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  125320. \***********************************************************/
  125321. /*! exports provided: StereoscopicInterlacePostProcess */
  125322. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125323. "use strict";
  125324. __webpack_require__.r(__webpack_exports__);
  125325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  125326. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125327. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125328. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125329. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  125330. /**
  125331. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  125332. */
  125333. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  125334. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  125335. /**
  125336. * Initializes a StereoscopicInterlacePostProcess
  125337. * @param name The name of the effect.
  125338. * @param rigCameras The rig cameras to be appled to the post process
  125339. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  125340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125341. * @param engine The engine which the post process will be applied. (default: current engine)
  125342. * @param reusable If the post process can be reused on the same frame. (default: false)
  125343. */
  125344. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  125345. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  125346. _this._passedProcess = rigCameras[0]._rigPostProcess;
  125347. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  125348. _this.onSizeChangedObservable.add(function () {
  125349. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  125350. });
  125351. _this.onApplyObservable.add(function (effect) {
  125352. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  125353. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  125354. });
  125355. return _this;
  125356. }
  125357. return StereoscopicInterlacePostProcess;
  125358. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  125359. /***/ }),
  125360. /***/ "./PostProcesses/tonemapPostProcess.ts":
  125361. /*!*********************************************!*\
  125362. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  125363. \*********************************************/
  125364. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  125365. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125366. "use strict";
  125367. __webpack_require__.r(__webpack_exports__);
  125368. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  125369. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  125370. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125371. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125372. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125373. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  125374. /** Defines operator used for tonemapping */
  125375. var TonemappingOperator;
  125376. (function (TonemappingOperator) {
  125377. /** Hable */
  125378. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  125379. /** Reinhard */
  125380. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  125381. /** HejiDawson */
  125382. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  125383. /** Photographic */
  125384. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  125385. })(TonemappingOperator || (TonemappingOperator = {}));
  125386. /**
  125387. * Defines a post process to apply tone mapping
  125388. */
  125389. var TonemapPostProcess = /** @class */ (function (_super) {
  125390. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  125391. /**
  125392. * Creates a new TonemapPostProcess
  125393. * @param name defines the name of the postprocess
  125394. * @param _operator defines the operator to use
  125395. * @param exposureAdjustment defines the required exposure adjustement
  125396. * @param camera defines the camera to use (can be null)
  125397. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  125398. * @param engine defines the hosting engine (can be ignore if camera is set)
  125399. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  125400. */
  125401. function TonemapPostProcess(name, _operator,
  125402. /** Defines the required exposure adjustement */
  125403. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  125404. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  125405. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  125406. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  125407. _this._operator = _operator;
  125408. _this.exposureAdjustment = exposureAdjustment;
  125409. var defines = "#define ";
  125410. if (_this._operator === TonemappingOperator.Hable) {
  125411. defines += "HABLE_TONEMAPPING";
  125412. }
  125413. else if (_this._operator === TonemappingOperator.Reinhard) {
  125414. defines += "REINHARD_TONEMAPPING";
  125415. }
  125416. else if (_this._operator === TonemappingOperator.HejiDawson) {
  125417. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  125418. }
  125419. else if (_this._operator === TonemappingOperator.Photographic) {
  125420. defines += "PHOTOGRAPHIC_TONEMAPPING";
  125421. }
  125422. //sadly a second call to create the effect.
  125423. _this.updateEffect(defines);
  125424. _this.onApply = function (effect) {
  125425. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  125426. };
  125427. return _this;
  125428. }
  125429. return TonemapPostProcess;
  125430. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  125431. /***/ }),
  125432. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  125433. /*!***************************************************************!*\
  125434. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  125435. \***************************************************************/
  125436. /*! exports provided: VolumetricLightScatteringPostProcess */
  125437. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125438. "use strict";
  125439. __webpack_require__.r(__webpack_exports__);
  125440. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  125441. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125442. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  125443. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  125444. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125445. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  125446. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  125447. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  125448. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  125449. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  125450. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125451. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  125452. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125453. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125454. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  125455. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  125456. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  125457. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  125458. /**
  125459. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  125460. */
  125461. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  125462. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  125463. /**
  125464. * @constructor
  125465. * @param name The post-process name
  125466. * @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)
  125467. * @param camera The camera that the post-process will be attached to
  125468. * @param mesh The mesh used to create the light scattering
  125469. * @param samples The post-process quality, default 100
  125470. * @param samplingModeThe post-process filtering mode
  125471. * @param engine The babylon engine
  125472. * @param reusable If the post-process is reusable
  125473. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  125474. */
  125475. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  125476. if (samples === void 0) { samples = 100; }
  125477. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].BILINEAR_SAMPLINGMODE; }
  125478. 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;
  125479. _this._screenCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  125480. /**
  125481. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  125482. */
  125483. _this.customMeshPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125484. /**
  125485. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  125486. */
  125487. _this.useCustomMeshPosition = false;
  125488. /**
  125489. * If the post-process should inverse the light scattering direction
  125490. */
  125491. _this.invert = true;
  125492. /**
  125493. * Array containing the excluded meshes not rendered in the internal pass
  125494. */
  125495. _this.excludedMeshes = new Array();
  125496. /**
  125497. * Controls the overall intensity of the post-process
  125498. */
  125499. _this.exposure = 0.3;
  125500. /**
  125501. * Dissipates each sample's contribution in range [0, 1]
  125502. */
  125503. _this.decay = 0.96815;
  125504. /**
  125505. * Controls the overall intensity of each sample
  125506. */
  125507. _this.weight = 0.58767;
  125508. /**
  125509. * Controls the density of each sample
  125510. */
  125511. _this.density = 0.926;
  125512. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  125513. engine = scene.getEngine();
  125514. _this._viewPort = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  125515. // Configure mesh
  125516. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  125517. // Configure
  125518. _this._createPass(scene, ratio.passRatio || ratio);
  125519. _this.onActivate = function (camera) {
  125520. if (!_this.isSupported) {
  125521. _this.dispose(camera);
  125522. }
  125523. _this.onActivate = null;
  125524. };
  125525. _this.onApplyObservable.add(function (effect) {
  125526. _this._updateMeshScreenCoordinates(scene);
  125527. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  125528. effect.setFloat("exposure", _this.exposure);
  125529. effect.setFloat("decay", _this.decay);
  125530. effect.setFloat("weight", _this.weight);
  125531. effect.setFloat("density", _this.density);
  125532. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  125533. });
  125534. return _this;
  125535. }
  125536. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  125537. /**
  125538. * @hidden
  125539. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  125540. */
  125541. get: function () {
  125542. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  125543. return false;
  125544. },
  125545. set: function (useDiffuseColor) {
  125546. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  125547. },
  125548. enumerable: true,
  125549. configurable: true
  125550. });
  125551. /**
  125552. * Returns the string "VolumetricLightScatteringPostProcess"
  125553. * @returns "VolumetricLightScatteringPostProcess"
  125554. */
  125555. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  125556. return "VolumetricLightScatteringPostProcess";
  125557. };
  125558. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  125559. var mesh = subMesh.getMesh();
  125560. // Render this.mesh as default
  125561. if (mesh === this.mesh && mesh.material) {
  125562. return mesh.material.isReady(mesh);
  125563. }
  125564. var defines = [];
  125565. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  125566. var material = subMesh.getMaterial();
  125567. // Alpha test
  125568. if (material) {
  125569. if (material.needAlphaTesting()) {
  125570. defines.push("#define ALPHATEST");
  125571. }
  125572. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  125573. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  125574. defines.push("#define UV1");
  125575. }
  125576. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  125577. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  125578. defines.push("#define UV2");
  125579. }
  125580. }
  125581. // Bones
  125582. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  125583. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  125584. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  125585. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  125586. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  125587. }
  125588. else {
  125589. defines.push("#define NUM_BONE_INFLUENCERS 0");
  125590. }
  125591. // Instances
  125592. if (useInstances) {
  125593. defines.push("#define INSTANCES");
  125594. attribs.push("world0");
  125595. attribs.push("world1");
  125596. attribs.push("world2");
  125597. attribs.push("world3");
  125598. }
  125599. // Get correct effect
  125600. var join = defines.join("\n");
  125601. if (this._cachedDefines !== join) {
  125602. this._cachedDefines = join;
  125603. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
  125604. }
  125605. return this._volumetricLightScatteringPass.isReady();
  125606. };
  125607. /**
  125608. * Sets the new light position for light scattering effect
  125609. * @param position The new custom light position
  125610. */
  125611. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  125612. this.customMeshPosition = position;
  125613. };
  125614. /**
  125615. * Returns the light position for light scattering effect
  125616. * @return Vector3 The custom light position
  125617. */
  125618. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  125619. return this.customMeshPosition;
  125620. };
  125621. /**
  125622. * Disposes the internal assets and detaches the post-process from the camera
  125623. */
  125624. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  125625. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  125626. if (rttIndex !== -1) {
  125627. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  125628. }
  125629. this._volumetricLightScatteringRTT.dispose();
  125630. _super.prototype.dispose.call(this, camera);
  125631. };
  125632. /**
  125633. * Returns the render target texture used by the post-process
  125634. * @return the render target texture used by the post-process
  125635. */
  125636. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  125637. return this._volumetricLightScatteringRTT;
  125638. };
  125639. // Private methods
  125640. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  125641. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  125642. return true;
  125643. }
  125644. return false;
  125645. };
  125646. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  125647. var _this = this;
  125648. var engine = scene.getEngine();
  125649. 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);
  125650. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  125651. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  125652. this._volumetricLightScatteringRTT.renderList = null;
  125653. this._volumetricLightScatteringRTT.renderParticles = false;
  125654. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  125655. var camera = this.getCamera();
  125656. if (camera) {
  125657. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  125658. }
  125659. else {
  125660. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  125661. }
  125662. // Custom render function for submeshes
  125663. var renderSubMesh = function (subMesh) {
  125664. var mesh = subMesh.getRenderingMesh();
  125665. if (_this._meshExcluded(mesh)) {
  125666. return;
  125667. }
  125668. var material = subMesh.getMaterial();
  125669. if (!material) {
  125670. return;
  125671. }
  125672. var scene = mesh.getScene();
  125673. var engine = scene.getEngine();
  125674. // Culling
  125675. engine.setState(material.backFaceCulling);
  125676. // Managing instances
  125677. var batch = mesh._getInstancesRenderList(subMesh._id);
  125678. if (batch.mustReturn) {
  125679. return;
  125680. }
  125681. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  125682. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  125683. var effect = _this._volumetricLightScatteringPass;
  125684. if (mesh === _this.mesh) {
  125685. if (subMesh.effect) {
  125686. effect = subMesh.effect;
  125687. }
  125688. else {
  125689. effect = material.getEffect();
  125690. }
  125691. }
  125692. engine.enableEffect(effect);
  125693. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  125694. if (mesh === _this.mesh) {
  125695. material.bind(mesh.getWorldMatrix(), mesh);
  125696. }
  125697. else {
  125698. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  125699. // Alpha test
  125700. if (material && material.needAlphaTesting()) {
  125701. var alphaTexture = material.getAlphaTestTexture();
  125702. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  125703. if (alphaTexture) {
  125704. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  125705. }
  125706. }
  125707. // Bones
  125708. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  125709. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  125710. }
  125711. }
  125712. // Draw
  125713. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  125714. }
  125715. };
  125716. // Render target texture callbacks
  125717. var savedSceneClearColor;
  125718. var sceneClearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.0, 0.0, 0.0, 1.0);
  125719. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  125720. savedSceneClearColor = scene.clearColor;
  125721. scene.clearColor = sceneClearColor;
  125722. });
  125723. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  125724. scene.clearColor = savedSceneClearColor;
  125725. });
  125726. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  125727. var engine = scene.getEngine();
  125728. var index;
  125729. if (depthOnlySubMeshes.length) {
  125730. engine.setColorWrite(false);
  125731. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  125732. renderSubMesh(depthOnlySubMeshes.data[index]);
  125733. }
  125734. engine.setColorWrite(true);
  125735. }
  125736. for (index = 0; index < opaqueSubMeshes.length; index++) {
  125737. renderSubMesh(opaqueSubMeshes.data[index]);
  125738. }
  125739. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  125740. renderSubMesh(alphaTestSubMeshes.data[index]);
  125741. }
  125742. if (transparentSubMeshes.length) {
  125743. // Sort sub meshes
  125744. for (index = 0; index < transparentSubMeshes.length; index++) {
  125745. var submesh = transparentSubMeshes.data[index];
  125746. var boundingInfo = submesh.getBoundingInfo();
  125747. if (boundingInfo && scene.activeCamera) {
  125748. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  125749. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  125750. }
  125751. }
  125752. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  125753. sortedArray.sort(function (a, b) {
  125754. // Alpha index first
  125755. if (a._alphaIndex > b._alphaIndex) {
  125756. return 1;
  125757. }
  125758. if (a._alphaIndex < b._alphaIndex) {
  125759. return -1;
  125760. }
  125761. // Then distance to camera
  125762. if (a._distanceToCamera < b._distanceToCamera) {
  125763. return 1;
  125764. }
  125765. if (a._distanceToCamera > b._distanceToCamera) {
  125766. return -1;
  125767. }
  125768. return 0;
  125769. });
  125770. // Render sub meshes
  125771. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE);
  125772. for (index = 0; index < sortedArray.length; index++) {
  125773. renderSubMesh(sortedArray[index]);
  125774. }
  125775. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE);
  125776. }
  125777. };
  125778. };
  125779. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  125780. var transform = scene.getTransformMatrix();
  125781. var meshPosition;
  125782. if (this.useCustomMeshPosition) {
  125783. meshPosition = this.customMeshPosition;
  125784. }
  125785. else if (this.attachedNode) {
  125786. meshPosition = this.attachedNode.position;
  125787. }
  125788. else {
  125789. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  125790. }
  125791. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  125792. this._screenCoordinates.x = pos.x / this._viewPort.width;
  125793. this._screenCoordinates.y = pos.y / this._viewPort.height;
  125794. if (this.invert) {
  125795. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  125796. }
  125797. };
  125798. // Static methods
  125799. /**
  125800. * Creates a default mesh for the Volumeric Light Scattering post-process
  125801. * @param name The mesh name
  125802. * @param scene The scene where to create the mesh
  125803. * @return the default mesh
  125804. */
  125805. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  125806. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  125807. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  125808. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"](name + "Material", scene);
  125809. material.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  125810. mesh.material = material;
  125811. return mesh;
  125812. };
  125813. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125814. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  125815. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  125816. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125817. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125818. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  125819. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125820. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125821. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  125822. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125823. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  125824. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  125825. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125826. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125827. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  125828. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125829. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125830. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  125831. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125832. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125833. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  125834. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125835. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125836. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  125837. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  125838. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  125839. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  125840. return VolumetricLightScatteringPostProcess;
  125841. }(_postProcess__WEBPACK_IMPORTED_MODULE_11__["PostProcess"]));
  125842. /***/ }),
  125843. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  125844. /*!************************************************************!*\
  125845. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  125846. \************************************************************/
  125847. /*! exports provided: VRDistortionCorrectionPostProcess */
  125848. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125849. "use strict";
  125850. __webpack_require__.r(__webpack_exports__);
  125851. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  125852. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125853. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125854. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125855. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125856. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  125857. /**
  125858. * VRDistortionCorrectionPostProcess used for mobile VR
  125859. */
  125860. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  125861. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  125862. /**
  125863. * Initializes the VRDistortionCorrectionPostProcess
  125864. * @param name The name of the effect.
  125865. * @param camera The camera to apply the render pass to.
  125866. * @param isRightEye If this is for the right eye distortion
  125867. * @param vrMetrics All the required metrics for the VR camera
  125868. */
  125869. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  125870. var _this = _super.call(this, name, "vrDistortionCorrection", [
  125871. 'LensCenter',
  125872. 'Scale',
  125873. 'ScaleIn',
  125874. 'HmdWarpParam'
  125875. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  125876. _this._isRightEye = isRightEye;
  125877. _this._distortionFactors = vrMetrics.distortionK;
  125878. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  125879. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  125880. _this.adaptScaleToCurrentViewport = true;
  125881. _this.onSizeChangedObservable.add(function () {
  125882. _this._scaleIn = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  125883. _this._scaleFactor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  125884. _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);
  125885. });
  125886. _this.onApplyObservable.add(function (effect) {
  125887. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  125888. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  125889. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  125890. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  125891. });
  125892. return _this;
  125893. }
  125894. return VRDistortionCorrectionPostProcess;
  125895. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  125896. /***/ }),
  125897. /***/ "./PostProcesses/vrMultiviewToSingleviewPostProcess.ts":
  125898. /*!*************************************************************!*\
  125899. !*** ./PostProcesses/vrMultiviewToSingleviewPostProcess.ts ***!
  125900. \*************************************************************/
  125901. /*! exports provided: VRMultiviewToSingleviewPostProcess */
  125902. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125903. "use strict";
  125904. __webpack_require__.r(__webpack_exports__);
  125905. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return VRMultiviewToSingleviewPostProcess; });
  125906. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125907. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125908. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  125909. /* harmony import */ var _Shaders_vrMultiviewToSingleview_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/vrMultiviewToSingleview.fragment */ "./Shaders/vrMultiviewToSingleview.fragment.ts");
  125910. /* harmony import */ var _Engines_Extensions_engine_multiview__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/Extensions/engine.multiview */ "./Engines/Extensions/engine.multiview.ts");
  125911. /**
  125912. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  125913. * This will not be used for webXR as it supports displaying texture arrays directly
  125914. */
  125915. var VRMultiviewToSingleviewPostProcess = /** @class */ (function (_super) {
  125916. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRMultiviewToSingleviewPostProcess, _super);
  125917. /**
  125918. * Initializes a VRMultiviewToSingleview
  125919. * @param name name of the post process
  125920. * @param camera camera to be applied to
  125921. * @param scaleFactor scaling factor to the size of the output texture
  125922. */
  125923. function VRMultiviewToSingleviewPostProcess(name, camera, scaleFactor) {
  125924. var _this = _super.call(this, name, "vrMultiviewToSingleview", ["imageIndex"], ["multiviewSampler"], scaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  125925. _this.onSizeChangedObservable.add(function () {
  125926. });
  125927. _this.onApplyObservable.add(function (effect) {
  125928. if (camera._scene.activeCamera && camera._scene.activeCamera.isLeftCamera) {
  125929. effect.setInt("imageIndex", 0);
  125930. }
  125931. else {
  125932. effect.setInt("imageIndex", 1);
  125933. }
  125934. effect.setTexture("multiviewSampler", camera._multiviewTexture);
  125935. });
  125936. return _this;
  125937. }
  125938. return VRMultiviewToSingleviewPostProcess;
  125939. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  125940. /***/ }),
  125941. /***/ "./Probes/index.ts":
  125942. /*!*************************!*\
  125943. !*** ./Probes/index.ts ***!
  125944. \*************************/
  125945. /*! exports provided: ReflectionProbe */
  125946. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125947. "use strict";
  125948. __webpack_require__.r(__webpack_exports__);
  125949. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  125950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  125951. /***/ }),
  125952. /***/ "./Probes/reflectionProbe.ts":
  125953. /*!***********************************!*\
  125954. !*** ./Probes/reflectionProbe.ts ***!
  125955. \***********************************/
  125956. /*! exports provided: ReflectionProbe */
  125957. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125958. "use strict";
  125959. __webpack_require__.r(__webpack_exports__);
  125960. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  125961. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  125962. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  125963. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  125964. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125965. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  125966. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125967. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  125968. if (!this.reflectionProbes) {
  125969. return -1;
  125970. }
  125971. var index = this.reflectionProbes.indexOf(toRemove);
  125972. if (index !== -1) {
  125973. this.reflectionProbes.splice(index, 1);
  125974. }
  125975. return index;
  125976. };
  125977. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  125978. if (!this.reflectionProbes) {
  125979. this.reflectionProbes = [];
  125980. }
  125981. this.reflectionProbes.push(newReflectionProbe);
  125982. };
  125983. /**
  125984. * Class used to generate realtime reflection / refraction cube textures
  125985. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  125986. */
  125987. var ReflectionProbe = /** @class */ (function () {
  125988. /**
  125989. * Creates a new reflection probe
  125990. * @param name defines the name of the probe
  125991. * @param size defines the texture resolution (for each face)
  125992. * @param scene defines the hosting scene
  125993. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  125994. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  125995. */
  125996. function ReflectionProbe(
  125997. /** defines the name of the probe */
  125998. name, size, scene, generateMipMaps, useFloat) {
  125999. if (generateMipMaps === void 0) { generateMipMaps = true; }
  126000. if (useFloat === void 0) { useFloat = false; }
  126001. var _this = this;
  126002. this.name = name;
  126003. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  126004. this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  126005. this._add = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  126006. this._invertYAxis = false;
  126007. /** Gets or sets probe position (center of the cube map) */
  126008. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  126009. this._scene = scene;
  126010. // Create the scene field if not exist.
  126011. if (!this._scene.reflectionProbes) {
  126012. this._scene.reflectionProbes = new Array();
  126013. }
  126014. this._scene.reflectionProbes.push(this);
  126015. 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);
  126016. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  126017. switch (faceIndex) {
  126018. case 0:
  126019. _this._add.copyFromFloats(1, 0, 0);
  126020. break;
  126021. case 1:
  126022. _this._add.copyFromFloats(-1, 0, 0);
  126023. break;
  126024. case 2:
  126025. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  126026. break;
  126027. case 3:
  126028. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  126029. break;
  126030. case 4:
  126031. _this._add.copyFromFloats(0, 0, 1);
  126032. break;
  126033. case 5:
  126034. _this._add.copyFromFloats(0, 0, -1);
  126035. break;
  126036. }
  126037. if (_this._attachedMesh) {
  126038. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  126039. }
  126040. _this.position.addToRef(_this._add, _this._target);
  126041. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  126042. if (scene.activeCamera) {
  126043. _this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  126044. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  126045. }
  126046. scene._forcedViewPosition = _this.position;
  126047. });
  126048. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  126049. scene._forcedViewPosition = null;
  126050. scene.updateTransformMatrix(true);
  126051. });
  126052. }
  126053. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  126054. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  126055. get: function () {
  126056. return this._renderTargetTexture.samples;
  126057. },
  126058. set: function (value) {
  126059. this._renderTargetTexture.samples = value;
  126060. },
  126061. enumerable: true,
  126062. configurable: true
  126063. });
  126064. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  126065. /** Gets or sets the refresh rate to use (on every frame by default) */
  126066. get: function () {
  126067. return this._renderTargetTexture.refreshRate;
  126068. },
  126069. set: function (value) {
  126070. this._renderTargetTexture.refreshRate = value;
  126071. },
  126072. enumerable: true,
  126073. configurable: true
  126074. });
  126075. /**
  126076. * Gets the hosting scene
  126077. * @returns a Scene
  126078. */
  126079. ReflectionProbe.prototype.getScene = function () {
  126080. return this._scene;
  126081. };
  126082. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  126083. /** Gets the internal CubeTexture used to render to */
  126084. get: function () {
  126085. return this._renderTargetTexture;
  126086. },
  126087. enumerable: true,
  126088. configurable: true
  126089. });
  126090. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  126091. /** Gets the list of meshes to render */
  126092. get: function () {
  126093. return this._renderTargetTexture.renderList;
  126094. },
  126095. enumerable: true,
  126096. configurable: true
  126097. });
  126098. /**
  126099. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  126100. * @param mesh defines the mesh to attach to
  126101. */
  126102. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  126103. this._attachedMesh = mesh;
  126104. };
  126105. /**
  126106. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  126107. * @param renderingGroupId The rendering group id corresponding to its index
  126108. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  126109. */
  126110. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  126111. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  126112. };
  126113. /**
  126114. * Clean all associated resources
  126115. */
  126116. ReflectionProbe.prototype.dispose = function () {
  126117. var index = this._scene.reflectionProbes.indexOf(this);
  126118. if (index !== -1) {
  126119. // Remove from the scene if found
  126120. this._scene.reflectionProbes.splice(index, 1);
  126121. }
  126122. if (this._renderTargetTexture) {
  126123. this._renderTargetTexture.dispose();
  126124. this._renderTargetTexture = null;
  126125. }
  126126. };
  126127. /**
  126128. * Converts the reflection probe information to a readable string for debug purpose.
  126129. * @param fullDetails Supports for multiple levels of logging within scene loading
  126130. * @returns the human readable reflection probe info
  126131. */
  126132. ReflectionProbe.prototype.toString = function (fullDetails) {
  126133. var ret = "Name: " + this.name;
  126134. if (fullDetails) {
  126135. ret += ", position: " + this.position.toString();
  126136. if (this._attachedMesh) {
  126137. ret += ", attached mesh: " + this._attachedMesh.name;
  126138. }
  126139. }
  126140. return ret;
  126141. };
  126142. /**
  126143. * Get the class name of the relfection probe.
  126144. * @returns "ReflectionProbe"
  126145. */
  126146. ReflectionProbe.prototype.getClassName = function () {
  126147. return "ReflectionProbe";
  126148. };
  126149. /**
  126150. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  126151. * @returns The JSON representation of the texture
  126152. */
  126153. ReflectionProbe.prototype.serialize = function () {
  126154. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  126155. serializationObject.isReflectionProbe = true;
  126156. return serializationObject;
  126157. };
  126158. /**
  126159. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  126160. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  126161. * @param scene Define the scene the parsed reflection probe should be instantiated in
  126162. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  126163. * @returns The parsed reflection probe if successful
  126164. */
  126165. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  126166. var reflectionProbe = null;
  126167. if (scene.reflectionProbes) {
  126168. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  126169. var rp = scene.reflectionProbes[index];
  126170. if (rp.name === parsedReflectionProbe.name) {
  126171. reflectionProbe = rp;
  126172. break;
  126173. }
  126174. }
  126175. }
  126176. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  126177. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  126178. if (parsedReflectionProbe._attachedMesh) {
  126179. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  126180. }
  126181. return reflectionProbe;
  126182. };
  126183. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126184. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  126185. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  126186. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  126187. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  126188. ], ReflectionProbe.prototype, "position", void 0);
  126189. return ReflectionProbe;
  126190. }());
  126191. /***/ }),
  126192. /***/ "./Rendering/boundingBoxRenderer.ts":
  126193. /*!******************************************!*\
  126194. !*** ./Rendering/boundingBoxRenderer.ts ***!
  126195. \******************************************/
  126196. /*! exports provided: BoundingBoxRenderer */
  126197. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126198. "use strict";
  126199. __webpack_require__.r(__webpack_exports__);
  126200. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  126201. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  126202. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  126203. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  126204. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  126205. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  126206. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  126207. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  126208. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  126209. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  126210. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  126211. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  126212. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  126213. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  126214. get: function () {
  126215. return this._forceShowBoundingBoxes || false;
  126216. },
  126217. set: function (value) {
  126218. this._forceShowBoundingBoxes = value;
  126219. // Lazyly creates a BB renderer if needed.
  126220. if (value) {
  126221. this.getBoundingBoxRenderer();
  126222. }
  126223. },
  126224. enumerable: true,
  126225. configurable: true
  126226. });
  126227. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  126228. if (!this._boundingBoxRenderer) {
  126229. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  126230. }
  126231. return this._boundingBoxRenderer;
  126232. };
  126233. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  126234. get: function () {
  126235. return this._showBoundingBox || false;
  126236. },
  126237. set: function (value) {
  126238. this._showBoundingBox = value;
  126239. // Lazyly creates a BB renderer if needed.
  126240. if (value) {
  126241. this.getScene().getBoundingBoxRenderer();
  126242. }
  126243. },
  126244. enumerable: true,
  126245. configurable: true
  126246. });
  126247. /**
  126248. * Component responsible of rendering the bounding box of the meshes in a scene.
  126249. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  126250. */
  126251. var BoundingBoxRenderer = /** @class */ (function () {
  126252. /**
  126253. * Instantiates a new bounding box renderer in a scene.
  126254. * @param scene the scene the renderer renders in
  126255. */
  126256. function BoundingBoxRenderer(scene) {
  126257. /**
  126258. * The component name helpfull to identify the component in the list of scene components.
  126259. */
  126260. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  126261. /**
  126262. * Color of the bounding box lines placed in front of an object
  126263. */
  126264. this.frontColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  126265. /**
  126266. * Color of the bounding box lines placed behind an object
  126267. */
  126268. this.backColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.1, 0.1, 0.1);
  126269. /**
  126270. * Defines if the renderer should show the back lines or not
  126271. */
  126272. this.showBackLines = true;
  126273. /**
  126274. * @hidden
  126275. */
  126276. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  126277. this._vertexBuffers = {};
  126278. this.scene = scene;
  126279. scene._addComponent(this);
  126280. }
  126281. /**
  126282. * Registers the component in a given scene
  126283. */
  126284. BoundingBoxRenderer.prototype.register = function () {
  126285. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  126286. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  126287. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  126288. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  126289. };
  126290. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  126291. if (mesh.showSubMeshesBoundingBox) {
  126292. var boundingInfo = subMesh.getBoundingInfo();
  126293. if (boundingInfo !== null && boundingInfo !== undefined) {
  126294. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  126295. this.renderList.push(boundingInfo.boundingBox);
  126296. }
  126297. }
  126298. };
  126299. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  126300. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  126301. var boundingInfo = sourceMesh.getBoundingInfo();
  126302. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  126303. this.renderList.push(boundingInfo.boundingBox);
  126304. }
  126305. };
  126306. BoundingBoxRenderer.prototype._prepareRessources = function () {
  126307. if (this._colorShader) {
  126308. return;
  126309. }
  126310. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  126311. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  126312. uniforms: ["world", "viewProjection", "color"]
  126313. });
  126314. var engine = this.scene.getEngine();
  126315. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  126316. 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);
  126317. this._createIndexBuffer();
  126318. };
  126319. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  126320. var engine = this.scene.getEngine();
  126321. 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]);
  126322. };
  126323. /**
  126324. * Rebuilds the elements related to this component in case of
  126325. * context lost for instance.
  126326. */
  126327. BoundingBoxRenderer.prototype.rebuild = function () {
  126328. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  126329. if (vb) {
  126330. vb._rebuild();
  126331. }
  126332. this._createIndexBuffer();
  126333. };
  126334. /**
  126335. * @hidden
  126336. */
  126337. BoundingBoxRenderer.prototype.reset = function () {
  126338. this.renderList.reset();
  126339. };
  126340. /**
  126341. * Render the bounding boxes of a specific rendering group
  126342. * @param renderingGroupId defines the rendering group to render
  126343. */
  126344. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  126345. if (this.renderList.length === 0) {
  126346. return;
  126347. }
  126348. this._prepareRessources();
  126349. if (!this._colorShader.isReady()) {
  126350. return;
  126351. }
  126352. var engine = this.scene.getEngine();
  126353. engine.setDepthWrite(false);
  126354. this._colorShader._preBind();
  126355. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  126356. var boundingBox = this.renderList.data[boundingBoxIndex];
  126357. if (boundingBox._tag !== renderingGroupId) {
  126358. continue;
  126359. }
  126360. var min = boundingBox.minimum;
  126361. var max = boundingBox.maximum;
  126362. var diff = max.subtract(min);
  126363. var median = min.add(diff.scale(0.5));
  126364. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  126365. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  126366. .multiply(boundingBox.getWorldMatrix());
  126367. // VBOs
  126368. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  126369. if (this.showBackLines) {
  126370. // Back
  126371. engine.setDepthFunctionToGreaterOrEqual();
  126372. this.scene.resetCachedMaterial();
  126373. this._colorShader.setColor4("color", this.backColor.toColor4());
  126374. this._colorShader.bind(worldMatrix);
  126375. // Draw order
  126376. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  126377. }
  126378. // Front
  126379. engine.setDepthFunctionToLess();
  126380. this.scene.resetCachedMaterial();
  126381. this._colorShader.setColor4("color", this.frontColor.toColor4());
  126382. this._colorShader.bind(worldMatrix);
  126383. // Draw order
  126384. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  126385. }
  126386. this._colorShader.unbind();
  126387. engine.setDepthFunctionToLessOrEqual();
  126388. engine.setDepthWrite(true);
  126389. };
  126390. /**
  126391. * In case of occlusion queries, we can render the occlusion bounding box through this method
  126392. * @param mesh Define the mesh to render the occlusion bounding box for
  126393. */
  126394. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  126395. this._prepareRessources();
  126396. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  126397. return;
  126398. }
  126399. var engine = this.scene.getEngine();
  126400. engine.setDepthWrite(false);
  126401. engine.setColorWrite(false);
  126402. this._colorShader._preBind();
  126403. var boundingBox = mesh._boundingInfo.boundingBox;
  126404. var min = boundingBox.minimum;
  126405. var max = boundingBox.maximum;
  126406. var diff = max.subtract(min);
  126407. var median = min.add(diff.scale(0.5));
  126408. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  126409. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  126410. .multiply(boundingBox.getWorldMatrix());
  126411. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  126412. engine.setDepthFunctionToLess();
  126413. this.scene.resetCachedMaterial();
  126414. this._colorShader.bind(worldMatrix);
  126415. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  126416. this._colorShader.unbind();
  126417. engine.setDepthFunctionToLessOrEqual();
  126418. engine.setDepthWrite(true);
  126419. engine.setColorWrite(true);
  126420. };
  126421. /**
  126422. * Dispose and release the resources attached to this renderer.
  126423. */
  126424. BoundingBoxRenderer.prototype.dispose = function () {
  126425. if (!this._colorShader) {
  126426. return;
  126427. }
  126428. this.renderList.dispose();
  126429. this._colorShader.dispose();
  126430. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  126431. if (buffer) {
  126432. buffer.dispose();
  126433. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  126434. }
  126435. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  126436. };
  126437. return BoundingBoxRenderer;
  126438. }());
  126439. /***/ }),
  126440. /***/ "./Rendering/depthRenderer.ts":
  126441. /*!************************************!*\
  126442. !*** ./Rendering/depthRenderer.ts ***!
  126443. \************************************/
  126444. /*! exports provided: DepthRenderer */
  126445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126446. "use strict";
  126447. __webpack_require__.r(__webpack_exports__);
  126448. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return DepthRenderer; });
  126449. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  126450. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  126451. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  126452. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  126453. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  126454. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126455. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  126456. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  126457. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  126458. /**
  126459. * This represents a depth renderer in Babylon.
  126460. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126461. */
  126462. var DepthRenderer = /** @class */ (function () {
  126463. /**
  126464. * Instantiates a depth renderer
  126465. * @param scene The scene the renderer belongs to
  126466. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126467. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126468. */
  126469. function DepthRenderer(scene, type, camera) {
  126470. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT; }
  126471. if (camera === void 0) { camera = null; }
  126472. var _this = this;
  126473. /**
  126474. * Specifiess that the depth renderer will only be used within
  126475. * the camera it is created for.
  126476. * This can help forcing its rendering during the camera processing.
  126477. */
  126478. this.useOnlyInActiveCamera = false;
  126479. this._scene = scene;
  126480. DepthRenderer._SceneComponentInitialization(this._scene);
  126481. this._camera = camera;
  126482. var engine = scene.getEngine();
  126483. // Render target
  126484. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
  126485. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  126486. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  126487. this._depthMap.refreshRate = 1;
  126488. this._depthMap.renderParticles = false;
  126489. this._depthMap.renderList = null;
  126490. // Camera to get depth map from to support multiple concurrent cameras
  126491. this._depthMap.activeCamera = this._camera;
  126492. this._depthMap.ignoreCameraViewport = true;
  126493. this._depthMap.useCameraPostProcesses = false;
  126494. // set default depth value to 1.0 (far away)
  126495. this._depthMap.onClearObservable.add(function (engine) {
  126496. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0), true, true, true);
  126497. });
  126498. // Custom render function
  126499. var renderSubMesh = function (subMesh) {
  126500. var mesh = subMesh.getRenderingMesh();
  126501. var scene = _this._scene;
  126502. var engine = scene.getEngine();
  126503. var material = subMesh.getMaterial();
  126504. if (!material) {
  126505. return;
  126506. }
  126507. // Culling and reverse (right handed system)
  126508. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  126509. // Managing instances
  126510. var batch = mesh._getInstancesRenderList(subMesh._id);
  126511. if (batch.mustReturn) {
  126512. return;
  126513. }
  126514. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  126515. var camera = _this._camera || scene.activeCamera;
  126516. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  126517. engine.enableEffect(_this._effect);
  126518. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  126519. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  126520. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  126521. // Alpha test
  126522. if (material && material.needAlphaTesting()) {
  126523. var alphaTexture = material.getAlphaTestTexture();
  126524. if (alphaTexture) {
  126525. _this._effect.setTexture("diffuseSampler", alphaTexture);
  126526. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  126527. }
  126528. }
  126529. // Bones
  126530. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  126531. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  126532. }
  126533. // Draw
  126534. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  126535. }
  126536. };
  126537. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  126538. var index;
  126539. if (depthOnlySubMeshes.length) {
  126540. engine.setColorWrite(false);
  126541. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  126542. renderSubMesh(depthOnlySubMeshes.data[index]);
  126543. }
  126544. engine.setColorWrite(true);
  126545. }
  126546. for (index = 0; index < opaqueSubMeshes.length; index++) {
  126547. renderSubMesh(opaqueSubMeshes.data[index]);
  126548. }
  126549. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  126550. renderSubMesh(alphaTestSubMeshes.data[index]);
  126551. }
  126552. };
  126553. }
  126554. /**
  126555. * Creates the depth rendering effect and checks if the effect is ready.
  126556. * @param subMesh The submesh to be used to render the depth map of
  126557. * @param useInstances If multiple world instances should be used
  126558. * @returns if the depth renderer is ready to render the depth map
  126559. */
  126560. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  126561. var material = subMesh.getMaterial();
  126562. if (material.disableDepthWrite) {
  126563. return false;
  126564. }
  126565. var defines = [];
  126566. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  126567. var mesh = subMesh.getMesh();
  126568. // Alpha test
  126569. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  126570. defines.push("#define ALPHATEST");
  126571. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  126572. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  126573. defines.push("#define UV1");
  126574. }
  126575. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  126576. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  126577. defines.push("#define UV2");
  126578. }
  126579. }
  126580. // Bones
  126581. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  126582. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  126583. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  126584. if (mesh.numBoneInfluencers > 4) {
  126585. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  126586. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  126587. }
  126588. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  126589. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  126590. }
  126591. else {
  126592. defines.push("#define NUM_BONE_INFLUENCERS 0");
  126593. }
  126594. // Instances
  126595. if (useInstances) {
  126596. defines.push("#define INSTANCES");
  126597. attribs.push("world0");
  126598. attribs.push("world1");
  126599. attribs.push("world2");
  126600. attribs.push("world3");
  126601. }
  126602. // Get correct effect
  126603. var join = defines.join("\n");
  126604. if (this._cachedDefines !== join) {
  126605. this._cachedDefines = join;
  126606. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues"], ["diffuseSampler"], join);
  126607. }
  126608. return this._effect.isReady();
  126609. };
  126610. /**
  126611. * Gets the texture which the depth map will be written to.
  126612. * @returns The depth map texture
  126613. */
  126614. DepthRenderer.prototype.getDepthMap = function () {
  126615. return this._depthMap;
  126616. };
  126617. /**
  126618. * Disposes of the depth renderer.
  126619. */
  126620. DepthRenderer.prototype.dispose = function () {
  126621. this._depthMap.dispose();
  126622. };
  126623. /** @hidden */
  126624. DepthRenderer._SceneComponentInitialization = function (_) {
  126625. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("DepthRendererSceneComponent");
  126626. };
  126627. return DepthRenderer;
  126628. }());
  126629. /***/ }),
  126630. /***/ "./Rendering/depthRendererSceneComponent.ts":
  126631. /*!**************************************************!*\
  126632. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  126633. \**************************************************/
  126634. /*! exports provided: DepthRendererSceneComponent */
  126635. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126636. "use strict";
  126637. __webpack_require__.r(__webpack_exports__);
  126638. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  126639. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  126640. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  126641. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126642. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  126643. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera) {
  126644. camera = camera || this.activeCamera;
  126645. if (!camera) {
  126646. throw "No camera available to enable depth renderer";
  126647. }
  126648. if (!this._depthRenderer) {
  126649. this._depthRenderer = {};
  126650. }
  126651. if (!this._depthRenderer[camera.id]) {
  126652. var textureType = 0;
  126653. if (this.getEngine().getCaps().textureHalfFloatRender) {
  126654. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  126655. }
  126656. else if (this.getEngine().getCaps().textureFloatRender) {
  126657. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  126658. }
  126659. else {
  126660. throw "Depth renderer does not support int texture type";
  126661. }
  126662. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera);
  126663. }
  126664. return this._depthRenderer[camera.id];
  126665. };
  126666. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  126667. camera = camera || this.activeCamera;
  126668. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  126669. return;
  126670. }
  126671. this._depthRenderer[camera.id].dispose();
  126672. delete this._depthRenderer[camera.id];
  126673. };
  126674. /**
  126675. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  126676. * in several rendering techniques.
  126677. */
  126678. var DepthRendererSceneComponent = /** @class */ (function () {
  126679. /**
  126680. * Creates a new instance of the component for the given scene
  126681. * @param scene Defines the scene to register the component in
  126682. */
  126683. function DepthRendererSceneComponent(scene) {
  126684. /**
  126685. * The component name helpfull to identify the component in the list of scene components.
  126686. */
  126687. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  126688. this.scene = scene;
  126689. }
  126690. /**
  126691. * Registers the component in a given scene
  126692. */
  126693. DepthRendererSceneComponent.prototype.register = function () {
  126694. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  126695. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  126696. };
  126697. /**
  126698. * Rebuilds the elements related to this component in case of
  126699. * context lost for instance.
  126700. */
  126701. DepthRendererSceneComponent.prototype.rebuild = function () {
  126702. // Nothing to do for this component
  126703. };
  126704. /**
  126705. * Disposes the component and the associated ressources
  126706. */
  126707. DepthRendererSceneComponent.prototype.dispose = function () {
  126708. for (var key in this.scene._depthRenderer) {
  126709. this.scene._depthRenderer[key].dispose();
  126710. }
  126711. };
  126712. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  126713. if (this.scene._depthRenderer) {
  126714. for (var key in this.scene._depthRenderer) {
  126715. var depthRenderer = this.scene._depthRenderer[key];
  126716. if (!depthRenderer.useOnlyInActiveCamera) {
  126717. renderTargets.push(depthRenderer.getDepthMap());
  126718. }
  126719. }
  126720. }
  126721. };
  126722. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  126723. if (this.scene._depthRenderer) {
  126724. for (var key in this.scene._depthRenderer) {
  126725. var depthRenderer = this.scene._depthRenderer[key];
  126726. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  126727. renderTargets.push(depthRenderer.getDepthMap());
  126728. }
  126729. }
  126730. }
  126731. };
  126732. return DepthRendererSceneComponent;
  126733. }());
  126734. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  126735. // Register the G Buffer component to the scene.
  126736. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  126737. if (!component) {
  126738. component = new DepthRendererSceneComponent(scene);
  126739. scene._addComponent(component);
  126740. }
  126741. };
  126742. /***/ }),
  126743. /***/ "./Rendering/edgesRenderer.ts":
  126744. /*!************************************!*\
  126745. !*** ./Rendering/edgesRenderer.ts ***!
  126746. \************************************/
  126747. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  126748. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126749. "use strict";
  126750. __webpack_require__.r(__webpack_exports__);
  126751. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  126752. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  126753. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126754. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  126755. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  126756. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  126757. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  126758. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  126759. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  126760. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  126761. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126762. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  126763. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  126764. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  126765. if (this._edgesRenderer) {
  126766. this._edgesRenderer.dispose();
  126767. this._edgesRenderer = null;
  126768. }
  126769. return this;
  126770. };
  126771. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  126772. if (epsilon === void 0) { epsilon = 0.95; }
  126773. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  126774. this.disableEdgesRendering();
  126775. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  126776. return this;
  126777. };
  126778. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  126779. get: function () {
  126780. return this._edgesRenderer;
  126781. },
  126782. enumerable: true,
  126783. configurable: true
  126784. });
  126785. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  126786. if (epsilon === void 0) { epsilon = 0.95; }
  126787. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  126788. this.disableEdgesRendering();
  126789. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  126790. return this;
  126791. };
  126792. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  126793. if (epsilon === void 0) { epsilon = 0.95; }
  126794. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  126795. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  126796. return this;
  126797. };
  126798. /**
  126799. * FaceAdjacencies Helper class to generate edges
  126800. */
  126801. var FaceAdjacencies = /** @class */ (function () {
  126802. function FaceAdjacencies() {
  126803. this.edges = new Array();
  126804. this.edgesConnectedCount = 0;
  126805. }
  126806. return FaceAdjacencies;
  126807. }());
  126808. /**
  126809. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  126810. */
  126811. var EdgesRenderer = /** @class */ (function () {
  126812. /**
  126813. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  126814. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  126815. * @param source Mesh used to create edges
  126816. * @param epsilon sum of angles in adjacency to check for edge
  126817. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  126818. * @param generateEdgesLines - should generate Lines or only prepare resources.
  126819. */
  126820. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  126821. if (epsilon === void 0) { epsilon = 0.95; }
  126822. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  126823. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  126824. var _this = this;
  126825. /**
  126826. * Define the size of the edges with an orthographic camera
  126827. */
  126828. this.edgesWidthScalerForOrthographic = 1000.0;
  126829. /**
  126830. * Define the size of the edges with a perspective camera
  126831. */
  126832. this.edgesWidthScalerForPerspective = 50.0;
  126833. this._linesPositions = new Array();
  126834. this._linesNormals = new Array();
  126835. this._linesIndices = new Array();
  126836. this._buffers = {};
  126837. this._checkVerticesInsteadOfIndices = false;
  126838. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  126839. this.isEnabled = true;
  126840. this._source = source;
  126841. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  126842. this._epsilon = epsilon;
  126843. this._prepareRessources();
  126844. if (generateEdgesLines) {
  126845. this._generateEdgesLines();
  126846. }
  126847. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  126848. _this._rebuild();
  126849. });
  126850. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  126851. _this.dispose();
  126852. });
  126853. }
  126854. EdgesRenderer.prototype._prepareRessources = function () {
  126855. if (this._lineShader) {
  126856. return;
  126857. }
  126858. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  126859. attributes: ["position", "normal"],
  126860. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  126861. });
  126862. this._lineShader.disableDepthWrite = true;
  126863. this._lineShader.backFaceCulling = false;
  126864. };
  126865. /** @hidden */
  126866. EdgesRenderer.prototype._rebuild = function () {
  126867. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  126868. if (buffer) {
  126869. buffer._rebuild();
  126870. }
  126871. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  126872. if (buffer) {
  126873. buffer._rebuild();
  126874. }
  126875. var scene = this._source.getScene();
  126876. var engine = scene.getEngine();
  126877. this._ib = engine.createIndexBuffer(this._linesIndices);
  126878. };
  126879. /**
  126880. * Releases the required resources for the edges renderer
  126881. */
  126882. EdgesRenderer.prototype.dispose = function () {
  126883. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  126884. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  126885. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  126886. if (buffer) {
  126887. buffer.dispose();
  126888. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  126889. }
  126890. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  126891. if (buffer) {
  126892. buffer.dispose();
  126893. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  126894. }
  126895. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  126896. this._lineShader.dispose();
  126897. };
  126898. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  126899. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  126900. return 0;
  126901. }
  126902. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  126903. return 1;
  126904. }
  126905. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  126906. return 2;
  126907. }
  126908. return -1;
  126909. };
  126910. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  126911. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  126912. return 0;
  126913. }
  126914. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  126915. return 1;
  126916. }
  126917. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  126918. return 2;
  126919. }
  126920. return -1;
  126921. };
  126922. /**
  126923. * Checks if the pair of p0 and p1 is en edge
  126924. * @param faceIndex
  126925. * @param edge
  126926. * @param faceNormals
  126927. * @param p0
  126928. * @param p1
  126929. * @private
  126930. */
  126931. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  126932. var needToCreateLine;
  126933. if (edge === undefined) {
  126934. needToCreateLine = true;
  126935. }
  126936. else {
  126937. var dotProduct = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  126938. needToCreateLine = dotProduct < this._epsilon;
  126939. }
  126940. if (needToCreateLine) {
  126941. this.createLine(p0, p1, this._linesPositions.length / 3);
  126942. }
  126943. };
  126944. /**
  126945. * push line into the position, normal and index buffer
  126946. * @protected
  126947. */
  126948. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  126949. // Positions
  126950. 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);
  126951. // Normals
  126952. 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);
  126953. // Indices
  126954. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  126955. };
  126956. /**
  126957. * Generates lines edges from adjacencjes
  126958. * @private
  126959. */
  126960. EdgesRenderer.prototype._generateEdgesLines = function () {
  126961. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  126962. var indices = this._source.getIndices();
  126963. if (!indices || !positions) {
  126964. return;
  126965. }
  126966. // First let's find adjacencies
  126967. var adjacencies = new Array();
  126968. var faceNormals = new Array();
  126969. var index;
  126970. var faceAdjacencies;
  126971. // Prepare faces
  126972. for (index = 0; index < indices.length; index += 3) {
  126973. faceAdjacencies = new FaceAdjacencies();
  126974. var p0Index = indices[index];
  126975. var p1Index = indices[index + 1];
  126976. var p2Index = indices[index + 2];
  126977. faceAdjacencies.p0 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  126978. faceAdjacencies.p1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  126979. faceAdjacencies.p2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  126980. var faceNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  126981. faceNormal.normalize();
  126982. faceNormals.push(faceNormal);
  126983. adjacencies.push(faceAdjacencies);
  126984. }
  126985. // Scan
  126986. for (index = 0; index < adjacencies.length; index++) {
  126987. faceAdjacencies = adjacencies[index];
  126988. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  126989. var otherFaceAdjacencies = adjacencies[otherIndex];
  126990. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  126991. break;
  126992. }
  126993. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  126994. continue;
  126995. }
  126996. var otherP0 = indices[otherIndex * 3];
  126997. var otherP1 = indices[otherIndex * 3 + 1];
  126998. var otherP2 = indices[otherIndex * 3 + 2];
  126999. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  127000. var otherEdgeIndex = 0;
  127001. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  127002. continue;
  127003. }
  127004. switch (edgeIndex) {
  127005. case 0:
  127006. if (this._checkVerticesInsteadOfIndices) {
  127007. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  127008. }
  127009. else {
  127010. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  127011. }
  127012. break;
  127013. case 1:
  127014. if (this._checkVerticesInsteadOfIndices) {
  127015. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  127016. }
  127017. else {
  127018. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  127019. }
  127020. break;
  127021. case 2:
  127022. if (this._checkVerticesInsteadOfIndices) {
  127023. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  127024. }
  127025. else {
  127026. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  127027. }
  127028. break;
  127029. }
  127030. if (otherEdgeIndex === -1) {
  127031. continue;
  127032. }
  127033. faceAdjacencies.edges[edgeIndex] = otherIndex;
  127034. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  127035. faceAdjacencies.edgesConnectedCount++;
  127036. otherFaceAdjacencies.edgesConnectedCount++;
  127037. if (faceAdjacencies.edgesConnectedCount === 3) {
  127038. break;
  127039. }
  127040. }
  127041. }
  127042. }
  127043. // Create lines
  127044. for (index = 0; index < adjacencies.length; index++) {
  127045. // 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
  127046. var current = adjacencies[index];
  127047. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  127048. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  127049. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  127050. }
  127051. // Merge into a single mesh
  127052. var engine = this._source.getScene().getEngine();
  127053. 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);
  127054. 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);
  127055. this._ib = engine.createIndexBuffer(this._linesIndices);
  127056. this._indicesCount = this._linesIndices.length;
  127057. };
  127058. /**
  127059. * Checks wether or not the edges renderer is ready to render.
  127060. * @return true if ready, otherwise false.
  127061. */
  127062. EdgesRenderer.prototype.isReady = function () {
  127063. return this._lineShader.isReady();
  127064. };
  127065. /**
  127066. * Renders the edges of the attached mesh,
  127067. */
  127068. EdgesRenderer.prototype.render = function () {
  127069. var scene = this._source.getScene();
  127070. if (!this.isReady() || !scene.activeCamera) {
  127071. return;
  127072. }
  127073. var engine = scene.getEngine();
  127074. this._lineShader._preBind();
  127075. if (this._source.edgesColor.a !== 1) {
  127076. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  127077. }
  127078. else {
  127079. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  127080. }
  127081. // VBOs
  127082. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  127083. scene.resetCachedMaterial();
  127084. this._lineShader.setColor4("color", this._source.edgesColor);
  127085. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  127086. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  127087. }
  127088. else {
  127089. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  127090. }
  127091. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  127092. this._lineShader.bind(this._source.getWorldMatrix());
  127093. // Draw order
  127094. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  127095. this._lineShader.unbind();
  127096. };
  127097. return EdgesRenderer;
  127098. }());
  127099. /**
  127100. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  127101. */
  127102. var LineEdgesRenderer = /** @class */ (function (_super) {
  127103. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  127104. /**
  127105. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  127106. * @param source LineMesh used to generate edges
  127107. * @param epsilon not important (specified angle for edge detection)
  127108. * @param checkVerticesInsteadOfIndices not important for LineMesh
  127109. */
  127110. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  127111. if (epsilon === void 0) { epsilon = 0.95; }
  127112. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  127113. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  127114. _this._generateEdgesLines();
  127115. return _this;
  127116. }
  127117. /**
  127118. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  127119. */
  127120. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  127121. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  127122. var indices = this._source.getIndices();
  127123. if (!indices || !positions) {
  127124. return;
  127125. }
  127126. var p0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  127127. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  127128. var len = indices.length - 1;
  127129. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  127130. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  127131. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  127132. this.createLine(p0, p1, offset);
  127133. }
  127134. // Merge into a single mesh
  127135. var engine = this._source.getScene().getEngine();
  127136. 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);
  127137. 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);
  127138. this._ib = engine.createIndexBuffer(this._linesIndices);
  127139. this._indicesCount = this._linesIndices.length;
  127140. };
  127141. return LineEdgesRenderer;
  127142. }(EdgesRenderer));
  127143. /***/ }),
  127144. /***/ "./Rendering/geometryBufferRenderer.ts":
  127145. /*!*********************************************!*\
  127146. !*** ./Rendering/geometryBufferRenderer.ts ***!
  127147. \*********************************************/
  127148. /*! exports provided: GeometryBufferRenderer */
  127149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127150. "use strict";
  127151. __webpack_require__.r(__webpack_exports__);
  127152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  127153. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  127154. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  127155. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  127156. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  127157. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  127158. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  127159. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  127160. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  127161. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  127162. /**
  127163. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  127164. */
  127165. var GeometryBufferRenderer = /** @class */ (function () {
  127166. /**
  127167. * Creates a new G Buffer for the scene
  127168. * @param scene The scene the buffer belongs to
  127169. * @param ratio How big is the buffer related to the main canvas.
  127170. */
  127171. function GeometryBufferRenderer(scene, ratio) {
  127172. if (ratio === void 0) { ratio = 1; }
  127173. /**
  127174. * Dictionary used to store the previous transformation matrices of each rendered mesh
  127175. * in order to compute objects velocities when enableVelocity is set to "true"
  127176. * @hidden
  127177. */
  127178. this._previousTransformationMatrices = {};
  127179. this._enablePosition = false;
  127180. this._enableVelocity = false;
  127181. this._positionIndex = -1;
  127182. this._velocityIndex = -1;
  127183. this._scene = scene;
  127184. this._ratio = ratio;
  127185. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  127186. // Render target
  127187. this._createRenderTargets();
  127188. }
  127189. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  127190. /**
  127191. * Set the render list (meshes to be rendered) used in the G buffer.
  127192. */
  127193. set: function (meshes) {
  127194. this._multiRenderTarget.renderList = meshes;
  127195. },
  127196. enumerable: true,
  127197. configurable: true
  127198. });
  127199. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  127200. /**
  127201. * Gets wether or not G buffer are supported by the running hardware.
  127202. * This requires draw buffer supports
  127203. */
  127204. get: function () {
  127205. return this._multiRenderTarget.isSupported;
  127206. },
  127207. enumerable: true,
  127208. configurable: true
  127209. });
  127210. /**
  127211. * Returns the index of the given texture type in the G-Buffer textures array
  127212. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  127213. * @returns the index of the given texture type in the G-Buffer textures array
  127214. */
  127215. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  127216. switch (textureType) {
  127217. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  127218. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  127219. default: return -1;
  127220. }
  127221. };
  127222. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  127223. /**
  127224. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  127225. */
  127226. get: function () {
  127227. return this._enablePosition;
  127228. },
  127229. /**
  127230. * Sets whether or not objects positions are enabled for the G buffer.
  127231. */
  127232. set: function (enable) {
  127233. this._enablePosition = enable;
  127234. this.dispose();
  127235. this._createRenderTargets();
  127236. },
  127237. enumerable: true,
  127238. configurable: true
  127239. });
  127240. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  127241. /**
  127242. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  127243. */
  127244. get: function () {
  127245. return this._enableVelocity;
  127246. },
  127247. /**
  127248. * Sets wether or not objects velocities are enabled for the G buffer.
  127249. */
  127250. set: function (enable) {
  127251. this._enableVelocity = enable;
  127252. this.dispose();
  127253. this._createRenderTargets();
  127254. },
  127255. enumerable: true,
  127256. configurable: true
  127257. });
  127258. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  127259. /**
  127260. * Gets the scene associated with the buffer.
  127261. */
  127262. get: function () {
  127263. return this._scene;
  127264. },
  127265. enumerable: true,
  127266. configurable: true
  127267. });
  127268. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  127269. /**
  127270. * Gets the ratio used by the buffer during its creation.
  127271. * How big is the buffer related to the main canvas.
  127272. */
  127273. get: function () {
  127274. return this._ratio;
  127275. },
  127276. enumerable: true,
  127277. configurable: true
  127278. });
  127279. /**
  127280. * Checks wether everything is ready to render a submesh to the G buffer.
  127281. * @param subMesh the submesh to check readiness for
  127282. * @param useInstances is the mesh drawn using instance or not
  127283. * @returns true if ready otherwise false
  127284. */
  127285. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  127286. var material = subMesh.getMaterial();
  127287. if (material && material.disableDepthWrite) {
  127288. return false;
  127289. }
  127290. var defines = [];
  127291. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  127292. var mesh = subMesh.getMesh();
  127293. // Alpha test
  127294. if (material && material.needAlphaTesting()) {
  127295. defines.push("#define ALPHATEST");
  127296. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  127297. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  127298. defines.push("#define UV1");
  127299. }
  127300. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  127301. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  127302. defines.push("#define UV2");
  127303. }
  127304. }
  127305. // Buffers
  127306. if (this._enablePosition) {
  127307. defines.push("#define POSITION");
  127308. defines.push("#define POSITION_INDEX " + this._positionIndex);
  127309. }
  127310. if (this._enableVelocity) {
  127311. defines.push("#define VELOCITY");
  127312. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  127313. }
  127314. // Bones
  127315. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  127316. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  127317. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  127318. if (mesh.numBoneInfluencers > 4) {
  127319. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  127320. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  127321. }
  127322. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  127323. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  127324. }
  127325. else {
  127326. defines.push("#define NUM_BONE_INFLUENCERS 0");
  127327. }
  127328. // Instances
  127329. if (useInstances) {
  127330. defines.push("#define INSTANCES");
  127331. attribs.push("world0");
  127332. attribs.push("world1");
  127333. attribs.push("world2");
  127334. attribs.push("world3");
  127335. }
  127336. // Setup textures count
  127337. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  127338. // Get correct effect
  127339. var join = defines.join("\n");
  127340. if (this._cachedDefines !== join) {
  127341. this._cachedDefines = join;
  127342. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorldViewProjection"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2 });
  127343. }
  127344. return this._effect.isReady();
  127345. };
  127346. /**
  127347. * Gets the current underlying G Buffer.
  127348. * @returns the buffer
  127349. */
  127350. GeometryBufferRenderer.prototype.getGBuffer = function () {
  127351. return this._multiRenderTarget;
  127352. };
  127353. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  127354. /**
  127355. * Gets the number of samples used to render the buffer (anti aliasing).
  127356. */
  127357. get: function () {
  127358. return this._multiRenderTarget.samples;
  127359. },
  127360. /**
  127361. * Sets the number of samples used to render the buffer (anti aliasing).
  127362. */
  127363. set: function (value) {
  127364. this._multiRenderTarget.samples = value;
  127365. },
  127366. enumerable: true,
  127367. configurable: true
  127368. });
  127369. /**
  127370. * Disposes the renderer and frees up associated resources.
  127371. */
  127372. GeometryBufferRenderer.prototype.dispose = function () {
  127373. this.getGBuffer().dispose();
  127374. };
  127375. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  127376. var _this = this;
  127377. var engine = this._scene.getEngine();
  127378. var count = 2;
  127379. if (this._enablePosition) {
  127380. this._positionIndex = count;
  127381. count++;
  127382. }
  127383. if (this._enableVelocity) {
  127384. this._velocityIndex = count;
  127385. count++;
  127386. }
  127387. 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 });
  127388. if (!this.isSupported) {
  127389. return;
  127390. }
  127391. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  127392. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  127393. this._multiRenderTarget.refreshRate = 1;
  127394. this._multiRenderTarget.renderParticles = false;
  127395. this._multiRenderTarget.renderList = null;
  127396. // set default depth value to 1.0 (far away)
  127397. this._multiRenderTarget.onClearObservable.add(function (engine) {
  127398. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  127399. });
  127400. // Custom render function
  127401. var renderSubMesh = function (subMesh) {
  127402. var mesh = subMesh.getRenderingMesh();
  127403. var scene = _this._scene;
  127404. var engine = scene.getEngine();
  127405. var material = subMesh.getMaterial();
  127406. if (!material) {
  127407. return;
  127408. }
  127409. // Velocity
  127410. if (!_this._previousTransformationMatrices[mesh.uniqueId]) {
  127411. _this._previousTransformationMatrices[mesh.uniqueId] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  127412. }
  127413. // Culling
  127414. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  127415. // Managing instances
  127416. var batch = mesh._getInstancesRenderList(subMesh._id);
  127417. if (batch.mustReturn) {
  127418. return;
  127419. }
  127420. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  127421. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  127422. engine.enableEffect(_this._effect);
  127423. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  127424. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  127425. _this._effect.setMatrix("view", scene.getViewMatrix());
  127426. // Alpha test
  127427. if (material && material.needAlphaTesting()) {
  127428. var alphaTexture = material.getAlphaTestTexture();
  127429. if (alphaTexture) {
  127430. _this._effect.setTexture("diffuseSampler", alphaTexture);
  127431. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  127432. }
  127433. }
  127434. // Bones
  127435. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  127436. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  127437. }
  127438. // Velocity
  127439. _this._effect.setMatrix("previousWorldViewProjection", _this._previousTransformationMatrices[mesh.uniqueId]);
  127440. // Draw
  127441. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  127442. }
  127443. // Velocity
  127444. _this._previousTransformationMatrices[mesh.uniqueId] = mesh.getWorldMatrix().multiply(_this._scene.getTransformMatrix());
  127445. };
  127446. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  127447. var index;
  127448. if (depthOnlySubMeshes.length) {
  127449. engine.setColorWrite(false);
  127450. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  127451. renderSubMesh(depthOnlySubMeshes.data[index]);
  127452. }
  127453. engine.setColorWrite(true);
  127454. }
  127455. for (index = 0; index < opaqueSubMeshes.length; index++) {
  127456. renderSubMesh(opaqueSubMeshes.data[index]);
  127457. }
  127458. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  127459. renderSubMesh(alphaTestSubMeshes.data[index]);
  127460. }
  127461. };
  127462. };
  127463. /**
  127464. * Constant used to retrieve the position texture index in the G-Buffer textures array
  127465. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  127466. */
  127467. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  127468. /**
  127469. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  127470. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  127471. */
  127472. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  127473. /** @hidden */
  127474. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  127475. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("GeometryBufferRendererSceneComponent");
  127476. };
  127477. return GeometryBufferRenderer;
  127478. }());
  127479. /***/ }),
  127480. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  127481. /*!***********************************************************!*\
  127482. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  127483. \***********************************************************/
  127484. /*! exports provided: GeometryBufferRendererSceneComponent */
  127485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127486. "use strict";
  127487. __webpack_require__.r(__webpack_exports__);
  127488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  127489. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  127490. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  127491. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  127492. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  127493. get: function () {
  127494. this._geometryBufferRenderer;
  127495. },
  127496. set: function (value) {
  127497. if (value && value.isSupported) {
  127498. this._geometryBufferRenderer = value;
  127499. }
  127500. },
  127501. enumerable: true,
  127502. configurable: true
  127503. });
  127504. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  127505. if (ratio === void 0) { ratio = 1; }
  127506. if (this._geometryBufferRenderer) {
  127507. return this._geometryBufferRenderer;
  127508. }
  127509. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  127510. if (!this._geometryBufferRenderer.isSupported) {
  127511. this._geometryBufferRenderer = null;
  127512. }
  127513. return this._geometryBufferRenderer;
  127514. };
  127515. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  127516. if (!this._geometryBufferRenderer) {
  127517. return;
  127518. }
  127519. this._geometryBufferRenderer.dispose();
  127520. this._geometryBufferRenderer = null;
  127521. };
  127522. /**
  127523. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  127524. * in several rendering techniques.
  127525. */
  127526. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  127527. /**
  127528. * Creates a new instance of the component for the given scene
  127529. * @param scene Defines the scene to register the component in
  127530. */
  127531. function GeometryBufferRendererSceneComponent(scene) {
  127532. /**
  127533. * The component name helpful to identify the component in the list of scene components.
  127534. */
  127535. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  127536. this.scene = scene;
  127537. }
  127538. /**
  127539. * Registers the component in a given scene
  127540. */
  127541. GeometryBufferRendererSceneComponent.prototype.register = function () {
  127542. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  127543. };
  127544. /**
  127545. * Rebuilds the elements related to this component in case of
  127546. * context lost for instance.
  127547. */
  127548. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  127549. // Nothing to do for this component
  127550. };
  127551. /**
  127552. * Disposes the component and the associated ressources
  127553. */
  127554. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  127555. // Nothing to do for this component
  127556. };
  127557. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  127558. if (this.scene._geometryBufferRenderer) {
  127559. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  127560. }
  127561. };
  127562. return GeometryBufferRendererSceneComponent;
  127563. }());
  127564. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  127565. // Register the G Buffer component to the scene.
  127566. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  127567. if (!component) {
  127568. component = new GeometryBufferRendererSceneComponent(scene);
  127569. scene._addComponent(component);
  127570. }
  127571. };
  127572. /***/ }),
  127573. /***/ "./Rendering/index.ts":
  127574. /*!****************************!*\
  127575. !*** ./Rendering/index.ts ***!
  127576. \****************************/
  127577. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  127578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127579. "use strict";
  127580. __webpack_require__.r(__webpack_exports__);
  127581. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  127582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  127583. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  127584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  127585. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  127586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  127587. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  127588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  127589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  127590. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  127591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  127592. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  127593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  127594. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  127595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  127596. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  127597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  127598. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  127599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  127600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  127601. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  127602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  127603. /***/ }),
  127604. /***/ "./Rendering/outlineRenderer.ts":
  127605. /*!**************************************!*\
  127606. !*** ./Rendering/outlineRenderer.ts ***!
  127607. \**************************************/
  127608. /*! exports provided: OutlineRenderer */
  127609. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127610. "use strict";
  127611. __webpack_require__.r(__webpack_exports__);
  127612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return OutlineRenderer; });
  127613. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  127614. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  127615. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  127616. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  127617. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  127618. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  127619. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  127620. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  127621. /**
  127622. * Gets the outline renderer associated with the scene
  127623. * @returns a OutlineRenderer
  127624. */
  127625. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  127626. if (!this._outlineRenderer) {
  127627. this._outlineRenderer = new OutlineRenderer(this);
  127628. }
  127629. return this._outlineRenderer;
  127630. };
  127631. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  127632. get: function () {
  127633. return this._renderOutline;
  127634. },
  127635. set: function (value) {
  127636. if (value) {
  127637. // Lazy Load the component.
  127638. this.getScene().getOutlineRenderer();
  127639. }
  127640. this._renderOutline = value;
  127641. },
  127642. enumerable: true,
  127643. configurable: true
  127644. });
  127645. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  127646. get: function () {
  127647. return this._renderOverlay;
  127648. },
  127649. set: function (value) {
  127650. if (value) {
  127651. // Lazy Load the component.
  127652. this.getScene().getOutlineRenderer();
  127653. }
  127654. this._renderOverlay = value;
  127655. },
  127656. enumerable: true,
  127657. configurable: true
  127658. });
  127659. /**
  127660. * This class is responsible to draw bothe outline/overlay of meshes.
  127661. * It should not be used directly but through the available method on mesh.
  127662. */
  127663. var OutlineRenderer = /** @class */ (function () {
  127664. /**
  127665. * Instantiates a new outline renderer. (There could be only one per scene).
  127666. * @param scene Defines the scene it belongs to
  127667. */
  127668. function OutlineRenderer(scene) {
  127669. /**
  127670. * The name of the component. Each component must have a unique name.
  127671. */
  127672. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  127673. /**
  127674. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  127675. */
  127676. this.zOffset = 1;
  127677. this.scene = scene;
  127678. this._engine = scene.getEngine();
  127679. this.scene._addComponent(this);
  127680. }
  127681. /**
  127682. * Register the component to one instance of a scene.
  127683. */
  127684. OutlineRenderer.prototype.register = function () {
  127685. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  127686. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  127687. };
  127688. /**
  127689. * Rebuilds the elements related to this component in case of
  127690. * context lost for instance.
  127691. */
  127692. OutlineRenderer.prototype.rebuild = function () {
  127693. // Nothing to do here.
  127694. };
  127695. /**
  127696. * Disposes the component and the associated ressources.
  127697. */
  127698. OutlineRenderer.prototype.dispose = function () {
  127699. // Nothing to do here.
  127700. };
  127701. /**
  127702. * Renders the outline in the canvas.
  127703. * @param subMesh Defines the sumesh to render
  127704. * @param batch Defines the batch of meshes in case of instances
  127705. * @param useOverlay Defines if the rendering is for the overlay or the outline
  127706. */
  127707. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  127708. var _this = this;
  127709. if (useOverlay === void 0) { useOverlay = false; }
  127710. var scene = this.scene;
  127711. var engine = scene.getEngine();
  127712. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  127713. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  127714. return;
  127715. }
  127716. var mesh = subMesh.getRenderingMesh();
  127717. var material = subMesh.getMaterial();
  127718. if (!material || !scene.activeCamera) {
  127719. return;
  127720. }
  127721. engine.enableEffect(this._effect);
  127722. // Logarithmic depth
  127723. if (material.useLogarithmicDepth) {
  127724. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  127725. }
  127726. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  127727. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  127728. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  127729. // Bones
  127730. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  127731. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  127732. }
  127733. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  127734. // Alpha test
  127735. if (material && material.needAlphaTesting()) {
  127736. var alphaTexture = material.getAlphaTestTexture();
  127737. if (alphaTexture) {
  127738. this._effect.setTexture("diffuseSampler", alphaTexture);
  127739. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  127740. }
  127741. }
  127742. engine.setZOffset(-this.zOffset);
  127743. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  127744. engine.setZOffset(0);
  127745. };
  127746. /**
  127747. * Returns whether or not the outline renderer is ready for a given submesh.
  127748. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  127749. * @param subMesh Defines the submesh to check readyness for
  127750. * @param useInstances Defines wheter wee are trying to render instances or not
  127751. * @returns true if ready otherwise false
  127752. */
  127753. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  127754. var defines = [];
  127755. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  127756. var mesh = subMesh.getMesh();
  127757. var material = subMesh.getMaterial();
  127758. if (material) {
  127759. // Alpha test
  127760. if (material.needAlphaTesting()) {
  127761. defines.push("#define ALPHATEST");
  127762. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  127763. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  127764. defines.push("#define UV1");
  127765. }
  127766. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  127767. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  127768. defines.push("#define UV2");
  127769. }
  127770. }
  127771. //Logarithmic depth
  127772. if (material.useLogarithmicDepth) {
  127773. defines.push("#define LOGARITHMICDEPTH");
  127774. }
  127775. }
  127776. // Bones
  127777. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  127778. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  127779. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  127780. if (mesh.numBoneInfluencers > 4) {
  127781. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  127782. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  127783. }
  127784. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  127785. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  127786. }
  127787. else {
  127788. defines.push("#define NUM_BONE_INFLUENCERS 0");
  127789. }
  127790. // Instances
  127791. if (useInstances) {
  127792. defines.push("#define INSTANCES");
  127793. attribs.push("world0");
  127794. attribs.push("world1");
  127795. attribs.push("world2");
  127796. attribs.push("world3");
  127797. }
  127798. // Get correct effect
  127799. var join = defines.join("\n");
  127800. if (this._cachedDefines !== join) {
  127801. this._cachedDefines = join;
  127802. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant"], ["diffuseSampler"], join);
  127803. }
  127804. return this._effect.isReady();
  127805. };
  127806. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  127807. // Outline - step 1
  127808. this._savedDepthWrite = this._engine.getDepthWrite();
  127809. if (mesh.renderOutline) {
  127810. var material = subMesh.getMaterial();
  127811. if (material && material.needAlphaBlending) {
  127812. this._engine.cacheStencilState();
  127813. // Draw only to stencil buffer for the original mesh
  127814. // The resulting stencil buffer will be used so the outline is not visible inside the mesh when the mesh is transparent
  127815. this._engine.setDepthWrite(false);
  127816. this._engine.setColorWrite(false);
  127817. this._engine.setStencilBuffer(true);
  127818. this._engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].REPLACE);
  127819. this._engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALWAYS);
  127820. this._engine.setStencilMask(OutlineRenderer._StencilReference);
  127821. this._engine.setStencilFunctionReference(OutlineRenderer._StencilReference);
  127822. this.render(subMesh, batch, /* This sets offset to 0 */ true);
  127823. this._engine.setColorWrite(true);
  127824. this._engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].NOTEQUAL);
  127825. }
  127826. // Draw the outline using the above stencil if needed to avoid drawing within the mesh
  127827. this._engine.setDepthWrite(false);
  127828. this.render(subMesh, batch);
  127829. this._engine.setDepthWrite(this._savedDepthWrite);
  127830. if (material && material.needAlphaBlending) {
  127831. this._engine.restoreStencilState();
  127832. }
  127833. }
  127834. };
  127835. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  127836. // Outline - step 2
  127837. if (mesh.renderOutline && this._savedDepthWrite) {
  127838. this._engine.setDepthWrite(true);
  127839. this._engine.setColorWrite(false);
  127840. this.render(subMesh, batch);
  127841. this._engine.setColorWrite(true);
  127842. }
  127843. // Overlay
  127844. if (mesh.renderOverlay) {
  127845. var currentMode = this._engine.getAlphaMode();
  127846. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  127847. this.render(subMesh, batch, true);
  127848. this._engine.setAlphaMode(currentMode);
  127849. }
  127850. };
  127851. /**
  127852. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  127853. */
  127854. OutlineRenderer._StencilReference = 0x04;
  127855. return OutlineRenderer;
  127856. }());
  127857. /***/ }),
  127858. /***/ "./Rendering/renderingGroup.ts":
  127859. /*!*************************************!*\
  127860. !*** ./Rendering/renderingGroup.ts ***!
  127861. \*************************************/
  127862. /*! exports provided: RenderingGroup */
  127863. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127864. "use strict";
  127865. __webpack_require__.r(__webpack_exports__);
  127866. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  127867. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  127868. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  127869. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  127870. /**
  127871. * This represents the object necessary to create a rendering group.
  127872. * This is exclusively used and created by the rendering manager.
  127873. * To modify the behavior, you use the available helpers in your scene or meshes.
  127874. * @hidden
  127875. */
  127876. var RenderingGroup = /** @class */ (function () {
  127877. /**
  127878. * Creates a new rendering group.
  127879. * @param index The rendering group index
  127880. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  127881. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  127882. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  127883. */
  127884. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  127885. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  127886. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  127887. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  127888. this.index = index;
  127889. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  127890. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  127891. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  127892. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  127893. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  127894. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  127895. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  127896. this._scene = scene;
  127897. this.opaqueSortCompareFn = opaqueSortCompareFn;
  127898. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  127899. this.transparentSortCompareFn = transparentSortCompareFn;
  127900. }
  127901. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  127902. /**
  127903. * Set the opaque sort comparison function.
  127904. * If null the sub meshes will be render in the order they were created
  127905. */
  127906. set: function (value) {
  127907. this._opaqueSortCompareFn = value;
  127908. if (value) {
  127909. this._renderOpaque = this.renderOpaqueSorted;
  127910. }
  127911. else {
  127912. this._renderOpaque = RenderingGroup.renderUnsorted;
  127913. }
  127914. },
  127915. enumerable: true,
  127916. configurable: true
  127917. });
  127918. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  127919. /**
  127920. * Set the alpha test sort comparison function.
  127921. * If null the sub meshes will be render in the order they were created
  127922. */
  127923. set: function (value) {
  127924. this._alphaTestSortCompareFn = value;
  127925. if (value) {
  127926. this._renderAlphaTest = this.renderAlphaTestSorted;
  127927. }
  127928. else {
  127929. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  127930. }
  127931. },
  127932. enumerable: true,
  127933. configurable: true
  127934. });
  127935. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  127936. /**
  127937. * Set the transparent sort comparison function.
  127938. * If null the sub meshes will be render in the order they were created
  127939. */
  127940. set: function (value) {
  127941. if (value) {
  127942. this._transparentSortCompareFn = value;
  127943. }
  127944. else {
  127945. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  127946. }
  127947. this._renderTransparent = this.renderTransparentSorted;
  127948. },
  127949. enumerable: true,
  127950. configurable: true
  127951. });
  127952. /**
  127953. * Render all the sub meshes contained in the group.
  127954. * @param customRenderFunction Used to override the default render behaviour of the group.
  127955. * @returns true if rendered some submeshes.
  127956. */
  127957. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  127958. if (customRenderFunction) {
  127959. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  127960. return;
  127961. }
  127962. var engine = this._scene.getEngine();
  127963. // Depth only
  127964. if (this._depthOnlySubMeshes.length !== 0) {
  127965. engine.setColorWrite(false);
  127966. this._renderAlphaTest(this._depthOnlySubMeshes);
  127967. engine.setColorWrite(true);
  127968. }
  127969. // Opaque
  127970. if (this._opaqueSubMeshes.length !== 0) {
  127971. this._renderOpaque(this._opaqueSubMeshes);
  127972. }
  127973. // Alpha test
  127974. if (this._alphaTestSubMeshes.length !== 0) {
  127975. this._renderAlphaTest(this._alphaTestSubMeshes);
  127976. }
  127977. var stencilState = engine.getStencilBuffer();
  127978. engine.setStencilBuffer(false);
  127979. // Sprites
  127980. if (renderSprites) {
  127981. this._renderSprites();
  127982. }
  127983. // Particles
  127984. if (renderParticles) {
  127985. this._renderParticles(activeMeshes);
  127986. }
  127987. if (this.onBeforeTransparentRendering) {
  127988. this.onBeforeTransparentRendering();
  127989. }
  127990. // Transparent
  127991. if (this._transparentSubMeshes.length !== 0) {
  127992. this._renderTransparent(this._transparentSubMeshes);
  127993. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  127994. }
  127995. // Set back stencil to false in case it changes before the edge renderer.
  127996. engine.setStencilBuffer(false);
  127997. // Edges
  127998. if (this._edgesRenderers.length) {
  127999. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  128000. this._edgesRenderers.data[edgesRendererIndex].render();
  128001. }
  128002. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  128003. }
  128004. // Restore Stencil state.
  128005. engine.setStencilBuffer(stencilState);
  128006. };
  128007. /**
  128008. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  128009. * @param subMeshes The submeshes to render
  128010. */
  128011. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  128012. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  128013. };
  128014. /**
  128015. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  128016. * @param subMeshes The submeshes to render
  128017. */
  128018. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  128019. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  128020. };
  128021. /**
  128022. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  128023. * @param subMeshes The submeshes to render
  128024. */
  128025. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  128026. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  128027. };
  128028. /**
  128029. * Renders the submeshes in a specified order.
  128030. * @param subMeshes The submeshes to sort before render
  128031. * @param sortCompareFn The comparison function use to sort
  128032. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  128033. * @param transparent Specifies to activate blending if true
  128034. */
  128035. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  128036. var subIndex = 0;
  128037. var subMesh;
  128038. var cameraPosition = camera ? camera.globalPosition : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  128039. for (; subIndex < subMeshes.length; subIndex++) {
  128040. subMesh = subMeshes.data[subIndex];
  128041. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  128042. subMesh._distanceToCamera = subMesh.getBoundingInfo().boundingSphere.centerWorld.subtract(cameraPosition).length();
  128043. }
  128044. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  128045. if (sortCompareFn) {
  128046. sortedArray.sort(sortCompareFn);
  128047. }
  128048. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  128049. subMesh = sortedArray[subIndex];
  128050. if (transparent) {
  128051. var material = subMesh.getMaterial();
  128052. if (material && material.needDepthPrePass) {
  128053. var engine = material.getScene().getEngine();
  128054. engine.setColorWrite(false);
  128055. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  128056. subMesh.render(false);
  128057. engine.setColorWrite(true);
  128058. }
  128059. }
  128060. subMesh.render(transparent);
  128061. }
  128062. };
  128063. /**
  128064. * Renders the submeshes in the order they were dispatched (no sort applied).
  128065. * @param subMeshes The submeshes to render
  128066. */
  128067. RenderingGroup.renderUnsorted = function (subMeshes) {
  128068. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  128069. var submesh = subMeshes.data[subIndex];
  128070. submesh.render(false);
  128071. }
  128072. };
  128073. /**
  128074. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  128075. * are rendered back to front if in the same alpha index.
  128076. *
  128077. * @param a The first submesh
  128078. * @param b The second submesh
  128079. * @returns The result of the comparison
  128080. */
  128081. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  128082. // Alpha index first
  128083. if (a._alphaIndex > b._alphaIndex) {
  128084. return 1;
  128085. }
  128086. if (a._alphaIndex < b._alphaIndex) {
  128087. return -1;
  128088. }
  128089. // Then distance to camera
  128090. return RenderingGroup.backToFrontSortCompare(a, b);
  128091. };
  128092. /**
  128093. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  128094. * are rendered back to front.
  128095. *
  128096. * @param a The first submesh
  128097. * @param b The second submesh
  128098. * @returns The result of the comparison
  128099. */
  128100. RenderingGroup.backToFrontSortCompare = function (a, b) {
  128101. // Then distance to camera
  128102. if (a._distanceToCamera < b._distanceToCamera) {
  128103. return 1;
  128104. }
  128105. if (a._distanceToCamera > b._distanceToCamera) {
  128106. return -1;
  128107. }
  128108. return 0;
  128109. };
  128110. /**
  128111. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  128112. * are rendered front to back (prevent overdraw).
  128113. *
  128114. * @param a The first submesh
  128115. * @param b The second submesh
  128116. * @returns The result of the comparison
  128117. */
  128118. RenderingGroup.frontToBackSortCompare = function (a, b) {
  128119. // Then distance to camera
  128120. if (a._distanceToCamera < b._distanceToCamera) {
  128121. return -1;
  128122. }
  128123. if (a._distanceToCamera > b._distanceToCamera) {
  128124. return 1;
  128125. }
  128126. return 0;
  128127. };
  128128. /**
  128129. * Resets the different lists of submeshes to prepare a new frame.
  128130. */
  128131. RenderingGroup.prototype.prepare = function () {
  128132. this._opaqueSubMeshes.reset();
  128133. this._transparentSubMeshes.reset();
  128134. this._alphaTestSubMeshes.reset();
  128135. this._depthOnlySubMeshes.reset();
  128136. this._particleSystems.reset();
  128137. this._spriteManagers.reset();
  128138. this._edgesRenderers.reset();
  128139. };
  128140. RenderingGroup.prototype.dispose = function () {
  128141. this._opaqueSubMeshes.dispose();
  128142. this._transparentSubMeshes.dispose();
  128143. this._alphaTestSubMeshes.dispose();
  128144. this._depthOnlySubMeshes.dispose();
  128145. this._particleSystems.dispose();
  128146. this._spriteManagers.dispose();
  128147. this._edgesRenderers.dispose();
  128148. };
  128149. /**
  128150. * Inserts the submesh in its correct queue depending on its material.
  128151. * @param subMesh The submesh to dispatch
  128152. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  128153. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  128154. */
  128155. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  128156. // Get mesh and materials if not provided
  128157. if (mesh === undefined) {
  128158. mesh = subMesh.getMesh();
  128159. }
  128160. if (material === undefined) {
  128161. material = subMesh.getMaterial();
  128162. }
  128163. if (material === null || material === undefined) {
  128164. return;
  128165. }
  128166. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  128167. this._transparentSubMeshes.push(subMesh);
  128168. }
  128169. else if (material.needAlphaTesting()) { // Alpha test
  128170. if (material.needDepthPrePass) {
  128171. this._depthOnlySubMeshes.push(subMesh);
  128172. }
  128173. this._alphaTestSubMeshes.push(subMesh);
  128174. }
  128175. else {
  128176. if (material.needDepthPrePass) {
  128177. this._depthOnlySubMeshes.push(subMesh);
  128178. }
  128179. this._opaqueSubMeshes.push(subMesh); // Opaque
  128180. }
  128181. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  128182. this._edgesRenderers.push(mesh._edgesRenderer);
  128183. }
  128184. };
  128185. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  128186. this._spriteManagers.push(spriteManager);
  128187. };
  128188. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  128189. this._particleSystems.push(particleSystem);
  128190. };
  128191. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  128192. if (this._particleSystems.length === 0) {
  128193. return;
  128194. }
  128195. // Particles
  128196. var activeCamera = this._scene.activeCamera;
  128197. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  128198. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  128199. var particleSystem = this._particleSystems.data[particleIndex];
  128200. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  128201. continue;
  128202. }
  128203. var emitter = particleSystem.emitter;
  128204. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  128205. this._scene._activeParticles.addCount(particleSystem.render(), false);
  128206. }
  128207. }
  128208. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  128209. };
  128210. RenderingGroup.prototype._renderSprites = function () {
  128211. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  128212. return;
  128213. }
  128214. // Sprites
  128215. var activeCamera = this._scene.activeCamera;
  128216. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  128217. for (var id = 0; id < this._spriteManagers.length; id++) {
  128218. var spriteManager = this._spriteManagers.data[id];
  128219. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  128220. spriteManager.render();
  128221. }
  128222. }
  128223. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  128224. };
  128225. return RenderingGroup;
  128226. }());
  128227. /***/ }),
  128228. /***/ "./Rendering/renderingManager.ts":
  128229. /*!***************************************!*\
  128230. !*** ./Rendering/renderingManager.ts ***!
  128231. \***************************************/
  128232. /*! exports provided: RenderingGroupInfo, RenderingManager */
  128233. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128234. "use strict";
  128235. __webpack_require__.r(__webpack_exports__);
  128236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  128237. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  128238. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  128239. /**
  128240. * This class is used by the onRenderingGroupObservable
  128241. */
  128242. var RenderingGroupInfo = /** @class */ (function () {
  128243. function RenderingGroupInfo() {
  128244. }
  128245. return RenderingGroupInfo;
  128246. }());
  128247. /**
  128248. * This is the manager responsible of all the rendering for meshes sprites and particles.
  128249. * It is enable to manage the different groups as well as the different necessary sort functions.
  128250. * This should not be used directly aside of the few static configurations
  128251. */
  128252. var RenderingManager = /** @class */ (function () {
  128253. /**
  128254. * Instantiates a new rendering group for a particular scene
  128255. * @param scene Defines the scene the groups belongs to
  128256. */
  128257. function RenderingManager(scene) {
  128258. /**
  128259. * @hidden
  128260. */
  128261. this._useSceneAutoClearSetup = false;
  128262. this._renderingGroups = new Array();
  128263. this._autoClearDepthStencil = {};
  128264. this._customOpaqueSortCompareFn = {};
  128265. this._customAlphaTestSortCompareFn = {};
  128266. this._customTransparentSortCompareFn = {};
  128267. this._renderingGroupInfo = new RenderingGroupInfo();
  128268. this._scene = scene;
  128269. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  128270. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  128271. }
  128272. }
  128273. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  128274. if (depth === void 0) { depth = true; }
  128275. if (stencil === void 0) { stencil = true; }
  128276. if (this._depthStencilBufferAlreadyCleaned) {
  128277. return;
  128278. }
  128279. this._scene.getEngine().clear(null, false, depth, stencil);
  128280. this._depthStencilBufferAlreadyCleaned = true;
  128281. };
  128282. /**
  128283. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  128284. * @hidden
  128285. */
  128286. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  128287. // Update the observable context (not null as it only goes away on dispose)
  128288. var info = this._renderingGroupInfo;
  128289. info.scene = this._scene;
  128290. info.camera = this._scene.activeCamera;
  128291. // Dispatch sprites
  128292. if (this._scene.spriteManagers && renderSprites) {
  128293. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  128294. var manager = this._scene.spriteManagers[index];
  128295. this.dispatchSprites(manager);
  128296. }
  128297. }
  128298. // Render
  128299. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  128300. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  128301. var renderingGroup = this._renderingGroups[index];
  128302. if (!renderingGroup) {
  128303. continue;
  128304. }
  128305. var renderingGroupMask = Math.pow(2, index);
  128306. info.renderingGroupId = index;
  128307. // Before Observable
  128308. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  128309. // Clear depth/stencil if needed
  128310. if (RenderingManager.AUTOCLEAR) {
  128311. var autoClear = this._useSceneAutoClearSetup ?
  128312. this._scene.getAutoClearDepthStencilSetup(index) :
  128313. this._autoClearDepthStencil[index];
  128314. if (autoClear && autoClear.autoClear) {
  128315. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  128316. }
  128317. }
  128318. // Render
  128319. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  128320. var step = _a[_i];
  128321. step.action(index);
  128322. }
  128323. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  128324. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  128325. var step = _c[_b];
  128326. step.action(index);
  128327. }
  128328. // After Observable
  128329. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  128330. }
  128331. };
  128332. /**
  128333. * Resets the different information of the group to prepare a new frame
  128334. * @hidden
  128335. */
  128336. RenderingManager.prototype.reset = function () {
  128337. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  128338. var renderingGroup = this._renderingGroups[index];
  128339. if (renderingGroup) {
  128340. renderingGroup.prepare();
  128341. }
  128342. }
  128343. };
  128344. /**
  128345. * Dispose and release the group and its associated resources.
  128346. * @hidden
  128347. */
  128348. RenderingManager.prototype.dispose = function () {
  128349. this.freeRenderingGroups();
  128350. this._renderingGroups.length = 0;
  128351. this._renderingGroupInfo = null;
  128352. };
  128353. /**
  128354. * Clear the info related to rendering groups preventing retention points during dispose.
  128355. */
  128356. RenderingManager.prototype.freeRenderingGroups = function () {
  128357. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  128358. var renderingGroup = this._renderingGroups[index];
  128359. if (renderingGroup) {
  128360. renderingGroup.dispose();
  128361. }
  128362. }
  128363. };
  128364. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  128365. if (this._renderingGroups[renderingGroupId] === undefined) {
  128366. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  128367. }
  128368. };
  128369. /**
  128370. * Add a sprite manager to the rendering manager in order to render it this frame.
  128371. * @param spriteManager Define the sprite manager to render
  128372. */
  128373. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  128374. var renderingGroupId = spriteManager.renderingGroupId || 0;
  128375. this._prepareRenderingGroup(renderingGroupId);
  128376. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  128377. };
  128378. /**
  128379. * Add a particle system to the rendering manager in order to render it this frame.
  128380. * @param particleSystem Define the particle system to render
  128381. */
  128382. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  128383. var renderingGroupId = particleSystem.renderingGroupId || 0;
  128384. this._prepareRenderingGroup(renderingGroupId);
  128385. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  128386. };
  128387. /**
  128388. * Add a submesh to the manager in order to render it this frame
  128389. * @param subMesh The submesh to dispatch
  128390. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  128391. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  128392. */
  128393. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  128394. if (mesh === undefined) {
  128395. mesh = subMesh.getMesh();
  128396. }
  128397. var renderingGroupId = mesh.renderingGroupId || 0;
  128398. this._prepareRenderingGroup(renderingGroupId);
  128399. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  128400. };
  128401. /**
  128402. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  128403. * This allowed control for front to back rendering or reversly depending of the special needs.
  128404. *
  128405. * @param renderingGroupId The rendering group id corresponding to its index
  128406. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  128407. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  128408. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  128409. */
  128410. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  128411. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  128412. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  128413. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  128414. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  128415. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  128416. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  128417. if (this._renderingGroups[renderingGroupId]) {
  128418. var group = this._renderingGroups[renderingGroupId];
  128419. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  128420. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  128421. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  128422. }
  128423. };
  128424. /**
  128425. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  128426. *
  128427. * @param renderingGroupId The rendering group id corresponding to its index
  128428. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128429. * @param depth Automatically clears depth between groups if true and autoClear is true.
  128430. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  128431. */
  128432. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  128433. if (depth === void 0) { depth = true; }
  128434. if (stencil === void 0) { stencil = true; }
  128435. this._autoClearDepthStencil[renderingGroupId] = {
  128436. autoClear: autoClearDepthStencil,
  128437. depth: depth,
  128438. stencil: stencil
  128439. };
  128440. };
  128441. /**
  128442. * Gets the current auto clear configuration for one rendering group of the rendering
  128443. * manager.
  128444. * @param index the rendering group index to get the information for
  128445. * @returns The auto clear setup for the requested rendering group
  128446. */
  128447. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  128448. return this._autoClearDepthStencil[index];
  128449. };
  128450. /**
  128451. * The max id used for rendering groups (not included)
  128452. */
  128453. RenderingManager.MAX_RENDERINGGROUPS = 4;
  128454. /**
  128455. * The min id used for rendering groups (included)
  128456. */
  128457. RenderingManager.MIN_RENDERINGGROUPS = 0;
  128458. /**
  128459. * Used to globally prevent autoclearing scenes.
  128460. */
  128461. RenderingManager.AUTOCLEAR = true;
  128462. return RenderingManager;
  128463. }());
  128464. /***/ }),
  128465. /***/ "./Rendering/utilityLayerRenderer.ts":
  128466. /*!*******************************************!*\
  128467. !*** ./Rendering/utilityLayerRenderer.ts ***!
  128468. \*******************************************/
  128469. /*! exports provided: UtilityLayerRenderer */
  128470. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128471. "use strict";
  128472. __webpack_require__.r(__webpack_exports__);
  128473. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  128474. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  128475. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  128476. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  128477. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  128478. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  128479. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  128480. /**
  128481. * Renders a layer on top of an existing scene
  128482. */
  128483. var UtilityLayerRenderer = /** @class */ (function () {
  128484. /**
  128485. * Instantiates a UtilityLayerRenderer
  128486. * @param originalScene the original scene that will be rendered on top of
  128487. * @param handleEvents boolean indicating if the utility layer should handle events
  128488. */
  128489. function UtilityLayerRenderer(
  128490. /** the original scene that will be rendered on top of */
  128491. originalScene, handleEvents) {
  128492. if (handleEvents === void 0) { handleEvents = true; }
  128493. var _this = this;
  128494. this.originalScene = originalScene;
  128495. this._pointerCaptures = {};
  128496. this._lastPointerEvents = {};
  128497. this._sharedGizmoLight = null;
  128498. /**
  128499. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  128500. */
  128501. this.pickUtilitySceneFirst = true;
  128502. /**
  128503. * If the utility layer should automatically be rendered on top of existing scene
  128504. */
  128505. this.shouldRender = true;
  128506. /**
  128507. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  128508. */
  128509. this.onlyCheckPointerDownEvents = true;
  128510. /**
  128511. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  128512. */
  128513. this.processAllEvents = false;
  128514. /**
  128515. * Observable raised when the pointer move from the utility layer scene to the main scene
  128516. */
  128517. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  128518. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  128519. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine());
  128520. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  128521. this.utilityLayerScene._allowPostProcessClearColor = false;
  128522. originalScene.getEngine().scenes.pop();
  128523. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  128524. this.utilityLayerScene.detachControl();
  128525. if (handleEvents) {
  128526. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  128527. if (!_this.utilityLayerScene.activeCamera) {
  128528. return;
  128529. }
  128530. if (!_this.processAllEvents) {
  128531. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  128532. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  128533. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  128534. return;
  128535. }
  128536. }
  128537. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  128538. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  128539. var pointerEvent = (prePointerInfo.event);
  128540. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  128541. _this._pointerCaptures[pointerEvent.pointerId] = false;
  128542. return;
  128543. }
  128544. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  128545. if (!prePointerInfo.ray && utilityScenePick) {
  128546. prePointerInfo.ray = utilityScenePick.ray;
  128547. }
  128548. // always fire the prepointer oversvable
  128549. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  128550. // allow every non pointer down event to flow to the utility layer
  128551. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  128552. if (!prePointerInfo.skipOnPointerObservable) {
  128553. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  128554. }
  128555. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  128556. _this._pointerCaptures[pointerEvent.pointerId] = false;
  128557. }
  128558. return;
  128559. }
  128560. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  128561. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  128562. if (utilityScenePick && utilityScenePick.hit) {
  128563. if (!prePointerInfo.skipOnPointerObservable) {
  128564. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  128565. }
  128566. prePointerInfo.skipOnPointerObservable = true;
  128567. }
  128568. }
  128569. else {
  128570. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  128571. var pointerEvent_1 = (prePointerInfo.event);
  128572. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  128573. if (originalScenePick && utilityScenePick) {
  128574. // No pick in utility scene
  128575. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  128576. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  128577. // We touched an utility mesh present in the main scene
  128578. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  128579. prePointerInfo.skipOnPointerObservable = true;
  128580. }
  128581. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  128582. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  128583. }
  128584. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  128585. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  128586. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  128587. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  128588. }
  128589. }
  128590. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  128591. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  128592. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  128593. // If a previous utility layer set this, do not unset this
  128594. if (!prePointerInfo.skipOnPointerObservable) {
  128595. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  128596. }
  128597. }
  128598. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  128599. // We have a pick in both scenes but main is closer than utility
  128600. // We touched an utility mesh present in the main scene
  128601. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  128602. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  128603. prePointerInfo.skipOnPointerObservable = true;
  128604. }
  128605. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  128606. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  128607. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  128608. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  128609. }
  128610. }
  128611. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  128612. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  128613. }
  128614. }
  128615. }
  128616. });
  128617. // As a newly added utility layer will be rendered over the screen last, it's pointer events should be processed first
  128618. if (this._originalPointerObserver) {
  128619. originalScene.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver);
  128620. }
  128621. }
  128622. // Render directly on top of existing scene without clearing
  128623. this.utilityLayerScene.autoClear = false;
  128624. this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
  128625. if (_this.shouldRender) {
  128626. _this.render();
  128627. }
  128628. });
  128629. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  128630. _this.dispose();
  128631. });
  128632. this._updateCamera();
  128633. }
  128634. /**
  128635. * @hidden
  128636. * Light which used by gizmos to get light shading
  128637. */
  128638. UtilityLayerRenderer.prototype._getSharedGizmoLight = function () {
  128639. if (!this._sharedGizmoLight) {
  128640. this._sharedGizmoLight = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]("shared gizmo light", new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](0, 1, 0), this.utilityLayerScene);
  128641. this._sharedGizmoLight.intensity = 2;
  128642. this._sharedGizmoLight.groundColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].Gray();
  128643. }
  128644. return this._sharedGizmoLight;
  128645. };
  128646. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  128647. /**
  128648. * 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)
  128649. */
  128650. get: function () {
  128651. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  128652. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  128653. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  128654. UtilityLayerRenderer._DefaultUtilityLayer = null;
  128655. });
  128656. }
  128657. return UtilityLayerRenderer._DefaultUtilityLayer;
  128658. },
  128659. enumerable: true,
  128660. configurable: true
  128661. });
  128662. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  128663. /**
  128664. * 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)
  128665. */
  128666. get: function () {
  128667. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  128668. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  128669. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  128670. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  128671. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  128672. });
  128673. }
  128674. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  128675. },
  128676. enumerable: true,
  128677. configurable: true
  128678. });
  128679. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  128680. if (!prePointerInfo.skipOnPointerObservable) {
  128681. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  128682. this._lastPointerEvents[pointerEvent.pointerId] = true;
  128683. }
  128684. };
  128685. /**
  128686. * Renders the utility layers scene on top of the original scene
  128687. */
  128688. UtilityLayerRenderer.prototype.render = function () {
  128689. this._updateCamera();
  128690. if (this.utilityLayerScene.activeCamera) {
  128691. // Set the camera's scene to utility layers scene
  128692. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  128693. var camera = this.utilityLayerScene.activeCamera;
  128694. camera._scene = this.utilityLayerScene;
  128695. if (camera.leftCamera) {
  128696. camera.leftCamera._scene = this.utilityLayerScene;
  128697. }
  128698. if (camera.rightCamera) {
  128699. camera.rightCamera._scene = this.utilityLayerScene;
  128700. }
  128701. this.utilityLayerScene.render(false);
  128702. // Reset camera's scene back to original
  128703. camera._scene = oldScene;
  128704. if (camera.leftCamera) {
  128705. camera.leftCamera._scene = oldScene;
  128706. }
  128707. if (camera.rightCamera) {
  128708. camera.rightCamera._scene = oldScene;
  128709. }
  128710. }
  128711. };
  128712. /**
  128713. * Disposes of the renderer
  128714. */
  128715. UtilityLayerRenderer.prototype.dispose = function () {
  128716. this.onPointerOutObservable.clear();
  128717. if (this._afterRenderObserver) {
  128718. this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver);
  128719. }
  128720. if (this._sceneDisposeObserver) {
  128721. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  128722. }
  128723. if (this._originalPointerObserver) {
  128724. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  128725. }
  128726. this.utilityLayerScene.dispose();
  128727. };
  128728. UtilityLayerRenderer.prototype._updateCamera = function () {
  128729. if (this.originalScene.activeCameras.length > 1) {
  128730. this.utilityLayerScene.activeCamera = this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1];
  128731. }
  128732. else {
  128733. this.utilityLayerScene.activeCamera = this.originalScene.activeCamera;
  128734. }
  128735. };
  128736. UtilityLayerRenderer._DefaultUtilityLayer = null;
  128737. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  128738. return UtilityLayerRenderer;
  128739. }());
  128740. /***/ }),
  128741. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  128742. /*!*****************************************************************!*\
  128743. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  128744. \*****************************************************************/
  128745. /*! exports provided: backgroundFragmentDeclaration */
  128746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128747. "use strict";
  128748. __webpack_require__.r(__webpack_exports__);
  128749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  128750. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128751. var name = 'backgroundFragmentDeclaration';
  128752. 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";
  128753. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128754. /** @hidden */
  128755. var backgroundFragmentDeclaration = { name: name, shader: shader };
  128756. /***/ }),
  128757. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  128758. /*!************************************************************!*\
  128759. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  128760. \************************************************************/
  128761. /*! exports provided: backgroundUboDeclaration */
  128762. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128763. "use strict";
  128764. __webpack_require__.r(__webpack_exports__);
  128765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  128766. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128767. var name = 'backgroundUboDeclaration';
  128768. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec4 vPrimaryColor;\nuniform vec4 vPrimaryColorShadow;\nuniform vec2 vDiffuseInfos;\nuniform vec2 vReflectionInfos;\nuniform mat4 diffuseMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\nuniform float pointSize;\nuniform float shadowLevel;\nuniform float alpha;\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};";
  128769. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128770. /** @hidden */
  128771. var backgroundUboDeclaration = { name: name, shader: shader };
  128772. /***/ }),
  128773. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  128774. /*!***************************************************************!*\
  128775. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  128776. \***************************************************************/
  128777. /*! exports provided: backgroundVertexDeclaration */
  128778. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128779. "use strict";
  128780. __webpack_require__.r(__webpack_exports__);
  128781. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  128782. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128783. var name = 'backgroundVertexDeclaration';
  128784. 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";
  128785. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128786. /** @hidden */
  128787. var backgroundVertexDeclaration = { name: name, shader: shader };
  128788. /***/ }),
  128789. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  128790. /*!****************************************************!*\
  128791. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  128792. \****************************************************/
  128793. /*! exports provided: bonesDeclaration */
  128794. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128795. "use strict";
  128796. __webpack_require__.r(__webpack_exports__);
  128797. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  128798. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128799. var name = 'bonesDeclaration';
  128800. 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";
  128801. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128802. /** @hidden */
  128803. var bonesDeclaration = { name: name, shader: shader };
  128804. /***/ }),
  128805. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  128806. /*!***********************************************!*\
  128807. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  128808. \***********************************************/
  128809. /*! exports provided: bonesVertex */
  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__, "bonesVertex", function() { return bonesVertex; });
  128814. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128815. var name = 'bonesVertex';
  128816. 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";
  128817. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128818. /** @hidden */
  128819. var bonesVertex = { name: name, shader: shader };
  128820. /***/ }),
  128821. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  128822. /*!************************************************!*\
  128823. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  128824. \************************************************/
  128825. /*! exports provided: bumpFragment */
  128826. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128827. "use strict";
  128828. __webpack_require__.r(__webpack_exports__);
  128829. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  128830. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128831. var name = 'bumpFragment';
  128832. 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";
  128833. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128834. /** @hidden */
  128835. var bumpFragment = { name: name, shader: shader };
  128836. /***/ }),
  128837. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  128838. /*!*********************************************************!*\
  128839. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  128840. \*********************************************************/
  128841. /*! exports provided: bumpFragmentFunctions */
  128842. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128843. "use strict";
  128844. __webpack_require__.r(__webpack_exports__);
  128845. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  128846. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128847. var name = 'bumpFragmentFunctions';
  128848. 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";
  128849. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128850. /** @hidden */
  128851. var bumpFragmentFunctions = { name: name, shader: shader };
  128852. /***/ }),
  128853. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  128854. /*!**********************************************!*\
  128855. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  128856. \**********************************************/
  128857. /*! exports provided: bumpVertex */
  128858. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128859. "use strict";
  128860. __webpack_require__.r(__webpack_exports__);
  128861. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertex", function() { return bumpVertex; });
  128862. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128863. var name = 'bumpVertex';
  128864. 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";
  128865. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128866. /** @hidden */
  128867. var bumpVertex = { name: name, shader: shader };
  128868. /***/ }),
  128869. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  128870. /*!*********************************************************!*\
  128871. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  128872. \*********************************************************/
  128873. /*! exports provided: bumpVertexDeclaration */
  128874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128875. "use strict";
  128876. __webpack_require__.r(__webpack_exports__);
  128877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  128878. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128879. var name = 'bumpVertexDeclaration';
  128880. var shader = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  128881. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128882. /** @hidden */
  128883. var bumpVertexDeclaration = { name: name, shader: shader };
  128884. /***/ }),
  128885. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  128886. /*!*****************************************************!*\
  128887. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  128888. \*****************************************************/
  128889. /*! exports provided: clipPlaneFragment */
  128890. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128891. "use strict";
  128892. __webpack_require__.r(__webpack_exports__);
  128893. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  128894. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128895. var name = 'clipPlaneFragment';
  128896. 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";
  128897. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128898. /** @hidden */
  128899. var clipPlaneFragment = { name: name, shader: shader };
  128900. /***/ }),
  128901. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  128902. /*!****************************************************************!*\
  128903. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  128904. \****************************************************************/
  128905. /*! exports provided: clipPlaneFragmentDeclaration */
  128906. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128907. "use strict";
  128908. __webpack_require__.r(__webpack_exports__);
  128909. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  128910. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128911. var name = 'clipPlaneFragmentDeclaration';
  128912. 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";
  128913. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128914. /** @hidden */
  128915. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  128916. /***/ }),
  128917. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  128918. /*!*****************************************************************!*\
  128919. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  128920. \*****************************************************************/
  128921. /*! exports provided: clipPlaneFragmentDeclaration2 */
  128922. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128923. "use strict";
  128924. __webpack_require__.r(__webpack_exports__);
  128925. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  128926. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128927. var name = 'clipPlaneFragmentDeclaration2';
  128928. 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";
  128929. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128930. /** @hidden */
  128931. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  128932. /***/ }),
  128933. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  128934. /*!***************************************************!*\
  128935. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  128936. \***************************************************/
  128937. /*! exports provided: clipPlaneVertex */
  128938. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128939. "use strict";
  128940. __webpack_require__.r(__webpack_exports__);
  128941. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  128942. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128943. var name = 'clipPlaneVertex';
  128944. 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";
  128945. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128946. /** @hidden */
  128947. var clipPlaneVertex = { name: name, shader: shader };
  128948. /***/ }),
  128949. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  128950. /*!**************************************************************!*\
  128951. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  128952. \**************************************************************/
  128953. /*! exports provided: clipPlaneVertexDeclaration */
  128954. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128955. "use strict";
  128956. __webpack_require__.r(__webpack_exports__);
  128957. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  128958. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128959. var name = 'clipPlaneVertexDeclaration';
  128960. 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";
  128961. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128962. /** @hidden */
  128963. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  128964. /***/ }),
  128965. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  128966. /*!***************************************************************!*\
  128967. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  128968. \***************************************************************/
  128969. /*! exports provided: clipPlaneVertexDeclaration2 */
  128970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128971. "use strict";
  128972. __webpack_require__.r(__webpack_exports__);
  128973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  128974. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128975. var name = 'clipPlaneVertexDeclaration2';
  128976. 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";
  128977. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128978. /** @hidden */
  128979. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  128980. /***/ }),
  128981. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  128982. /*!**************************************************************!*\
  128983. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  128984. \**************************************************************/
  128985. /*! exports provided: defaultFragmentDeclaration */
  128986. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128987. "use strict";
  128988. __webpack_require__.r(__webpack_exports__);
  128989. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  128990. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  128991. var name = 'defaultFragmentDeclaration';
  128992. var shader = "uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\nuniform float visibility;\n\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#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";
  128993. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  128994. /** @hidden */
  128995. var defaultFragmentDeclaration = { name: name, shader: shader };
  128996. /***/ }),
  128997. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  128998. /*!*********************************************************!*\
  128999. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  129000. \*********************************************************/
  129001. /*! exports provided: defaultUboDeclaration */
  129002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129003. "use strict";
  129004. __webpack_require__.r(__webpack_exports__);
  129005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  129006. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129007. var name = 'defaultUboDeclaration';
  129008. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor;\nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix;\nvec2 vTangentSpaceParams;\nfloat pointSize;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nfloat visibility;\nvec4 vDiffuseColor;\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};\n";
  129009. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129010. /** @hidden */
  129011. var defaultUboDeclaration = { name: name, shader: shader };
  129012. /***/ }),
  129013. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  129014. /*!************************************************************!*\
  129015. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  129016. \************************************************************/
  129017. /*! exports provided: defaultVertexDeclaration */
  129018. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129019. "use strict";
  129020. __webpack_require__.r(__webpack_exports__);
  129021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  129022. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129023. var name = 'defaultVertexDeclaration';
  129024. 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";
  129025. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129026. /** @hidden */
  129027. var defaultVertexDeclaration = { name: name, shader: shader };
  129028. /***/ }),
  129029. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  129030. /*!************************************************!*\
  129031. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  129032. \************************************************/
  129033. /*! exports provided: depthPrePass */
  129034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129035. "use strict";
  129036. __webpack_require__.r(__webpack_exports__);
  129037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  129038. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129039. var name = 'depthPrePass';
  129040. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  129041. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129042. /** @hidden */
  129043. var depthPrePass = { name: name, shader: shader };
  129044. /***/ }),
  129045. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  129046. /*!***********************************************!*\
  129047. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  129048. \***********************************************/
  129049. /*! exports provided: fogFragment */
  129050. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129051. "use strict";
  129052. __webpack_require__.r(__webpack_exports__);
  129053. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  129054. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129055. var name = 'fogFragment';
  129056. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  129057. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129058. /** @hidden */
  129059. var fogFragment = { name: name, shader: shader };
  129060. /***/ }),
  129061. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  129062. /*!**********************************************************!*\
  129063. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  129064. \**********************************************************/
  129065. /*! exports provided: fogFragmentDeclaration */
  129066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129067. "use strict";
  129068. __webpack_require__.r(__webpack_exports__);
  129069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  129070. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129071. var name = 'fogFragmentDeclaration';
  129072. 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";
  129073. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129074. /** @hidden */
  129075. var fogFragmentDeclaration = { name: name, shader: shader };
  129076. /***/ }),
  129077. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  129078. /*!*********************************************!*\
  129079. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  129080. \*********************************************/
  129081. /*! exports provided: fogVertex */
  129082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129083. "use strict";
  129084. __webpack_require__.r(__webpack_exports__);
  129085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  129086. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129087. var name = 'fogVertex';
  129088. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  129089. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129090. /** @hidden */
  129091. var fogVertex = { name: name, shader: shader };
  129092. /***/ }),
  129093. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  129094. /*!********************************************************!*\
  129095. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  129096. \********************************************************/
  129097. /*! exports provided: fogVertexDeclaration */
  129098. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129099. "use strict";
  129100. __webpack_require__.r(__webpack_exports__);
  129101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  129102. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129103. var name = 'fogVertexDeclaration';
  129104. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  129105. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129106. /** @hidden */
  129107. var fogVertexDeclaration = { name: name, shader: shader };
  129108. /***/ }),
  129109. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  129110. /*!***************************************************!*\
  129111. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  129112. \***************************************************/
  129113. /*! exports provided: fresnelFunction */
  129114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129115. "use strict";
  129116. __webpack_require__.r(__webpack_exports__);
  129117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  129118. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129119. var name = 'fresnelFunction';
  129120. 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";
  129121. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129122. /** @hidden */
  129123. var fresnelFunction = { name: name, shader: shader };
  129124. /***/ }),
  129125. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  129126. /*!******************************************************!*\
  129127. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  129128. \******************************************************/
  129129. /*! exports provided: harmonicsFunctions */
  129130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129131. "use strict";
  129132. __webpack_require__.r(__webpack_exports__);
  129133. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  129134. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129135. var name = 'harmonicsFunctions';
  129136. 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";
  129137. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129138. /** @hidden */
  129139. var harmonicsFunctions = { name: name, shader: shader };
  129140. /***/ }),
  129141. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  129142. /*!***************************************************!*\
  129143. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  129144. \***************************************************/
  129145. /*! exports provided: helperFunctions */
  129146. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129147. "use strict";
  129148. __webpack_require__.r(__webpack_exports__);
  129149. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "helperFunctions", function() { return helperFunctions; });
  129150. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129151. var name = 'helperFunctions';
  129152. 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}";
  129153. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129154. /** @hidden */
  129155. var helperFunctions = { name: name, shader: shader };
  129156. /***/ }),
  129157. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  129158. /*!**************************************************************!*\
  129159. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  129160. \**************************************************************/
  129161. /*! exports provided: imageProcessingDeclaration */
  129162. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129163. "use strict";
  129164. __webpack_require__.r(__webpack_exports__);
  129165. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  129166. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129167. var name = 'imageProcessingDeclaration';
  129168. 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";
  129169. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129170. /** @hidden */
  129171. var imageProcessingDeclaration = { name: name, shader: shader };
  129172. /***/ }),
  129173. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  129174. /*!************************************************************!*\
  129175. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  129176. \************************************************************/
  129177. /*! exports provided: imageProcessingFunctions */
  129178. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129179. "use strict";
  129180. __webpack_require__.r(__webpack_exports__);
  129181. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  129182. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129183. var name = 'imageProcessingFunctions';
  129184. 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}";
  129185. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129186. /** @hidden */
  129187. var imageProcessingFunctions = { name: name, shader: shader };
  129188. /***/ }),
  129189. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  129190. /*!********************************************************!*\
  129191. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  129192. \********************************************************/
  129193. /*! exports provided: instancesDeclaration */
  129194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129195. "use strict";
  129196. __webpack_require__.r(__webpack_exports__);
  129197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  129198. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129199. var name = 'instancesDeclaration';
  129200. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  129201. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129202. /** @hidden */
  129203. var instancesDeclaration = { name: name, shader: shader };
  129204. /***/ }),
  129205. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  129206. /*!***************************************************!*\
  129207. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  129208. \***************************************************/
  129209. /*! exports provided: instancesVertex */
  129210. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129211. "use strict";
  129212. __webpack_require__.r(__webpack_exports__);
  129213. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  129214. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129215. var name = 'instancesVertex';
  129216. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  129217. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129218. /** @hidden */
  129219. var instancesVertex = { name: name, shader: shader };
  129220. /***/ }),
  129221. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  129222. /*!******************************************************!*\
  129223. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  129224. \******************************************************/
  129225. /*! exports provided: kernelBlurFragment */
  129226. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129227. "use strict";
  129228. __webpack_require__.r(__webpack_exports__);
  129229. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  129230. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129231. var name = 'kernelBlurFragment';
  129232. 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";
  129233. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129234. /** @hidden */
  129235. var kernelBlurFragment = { name: name, shader: shader };
  129236. /***/ }),
  129237. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  129238. /*!*******************************************************!*\
  129239. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  129240. \*******************************************************/
  129241. /*! exports provided: kernelBlurFragment2 */
  129242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129243. "use strict";
  129244. __webpack_require__.r(__webpack_exports__);
  129245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  129246. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129247. var name = 'kernelBlurFragment2';
  129248. 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";
  129249. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129250. /** @hidden */
  129251. var kernelBlurFragment2 = { name: name, shader: shader };
  129252. /***/ }),
  129253. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  129254. /*!****************************************************************!*\
  129255. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  129256. \****************************************************************/
  129257. /*! exports provided: kernelBlurVaryingDeclaration */
  129258. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129259. "use strict";
  129260. __webpack_require__.r(__webpack_exports__);
  129261. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  129262. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129263. var name = 'kernelBlurVaryingDeclaration';
  129264. var shader = "varying vec2 sampleCoord{X};";
  129265. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129266. /** @hidden */
  129267. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  129268. /***/ }),
  129269. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  129270. /*!****************************************************!*\
  129271. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  129272. \****************************************************/
  129273. /*! exports provided: kernelBlurVertex */
  129274. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129275. "use strict";
  129276. __webpack_require__.r(__webpack_exports__);
  129277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  129278. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129279. var name = 'kernelBlurVertex';
  129280. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  129281. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129282. /** @hidden */
  129283. var kernelBlurVertex = { name: name, shader: shader };
  129284. /***/ }),
  129285. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  129286. /*!*************************************************!*\
  129287. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  129288. \*************************************************/
  129289. /*! exports provided: lightFragment */
  129290. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129291. "use strict";
  129292. __webpack_require__.r(__webpack_exports__);
  129293. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  129294. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129295. var name = 'lightFragment';
  129296. var shader = "#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n\n#ifdef SPOTLIGHT{X}\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(POINTLIGHT{X})\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(HEMILIGHT{X})\npreInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(DIRLIGHT{X})\npreInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#endif\npreInfo.NdotV=NdotV;\n\n#ifdef SPOTLIGHT{X}\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\npreInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\npreInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\n#elif defined(POINTLIGHT{X})\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\n#else\npreInfo.attenuation=1.0;\n#endif\n\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=roughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightDiffuse.a,preInfo.lightDistance);\n#endif\n\n#ifdef HEMILIGHT{X}\ninfo.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);\n#elif defined(SS_TRANSLUCENCY)\ninfo.diffuse=computeDiffuseAndTransmittedLighting(preInfo,light{X}.vLightDiffuse.rgb,transmittance);\n#else\ninfo.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);\n#endif\n\n#ifdef SPECULARTERM\n#ifdef ANISOTROPIC\ninfo.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicTangent,anisotropicBitangent,anisotropy,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#else\ninfo.specular=computeSpecularLighting(preInfo,normalW,specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n#endif\n\n#ifdef SHEEN\n#ifdef SHEEN_LINKWITHALBEDO\n\npreInfo.roughness=sheenIntensity;\n#endif\ninfo.sheen=computeSheenLighting(preInfo,normalW,sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n\n#ifdef CLEARCOAT\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=clearCoatRoughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(clearCoatRoughness,light{X}.vLightDiffuse.a,preInfo.lightDistance);\n#endif\ninfo.clearCoat=computeClearCoatLighting(preInfo,clearCoatNormalW,clearCoatAARoughnessFactors.x,clearCoatIntensity,light{X}.vLightDiffuse.rgb);\n#ifdef CLEARCOAT_TINT\n\nabsorption=computeClearCoatLightingAbsorption(clearCoatNdotVRefract,preInfo.L,clearCoatNormalW,clearCoatColor,clearCoatThickness,clearCoatIntensity);\ninfo.diffuse*=absorption;\n#ifdef SPECULARTERM\ninfo.specular*=absorption;\n#endif\n#endif\n\ninfo.diffuse*=info.clearCoat.w;\n#ifdef SPECULARTERM\ninfo.specular*=info.clearCoat.w*info.clearCoat.w;\n#endif\n#ifdef SHEEN\ninfo.sheen*=info.clearCoat.w*info.clearCoat.w;\n#endif\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,glossiness);\n#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\ninfo.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCLOSEESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPOISSON{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;\nshadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\n#ifndef SHADOWONLY\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#ifdef CLEARCOAT\n#ifndef LIGHTMAPNOSPECULAR{X}\nclearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor;\n#endif\n#endif\n#ifdef SHEEN\n#ifndef LIGHTMAPNOSPECULAR{X}\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#ifdef CLEARCOAT\nclearCoatBase+=info.clearCoat.rgb*shadow;\n#endif\n#ifdef SHEEN\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#endif\n#endif";
  129297. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129298. /** @hidden */
  129299. var lightFragment = { name: name, shader: shader };
  129300. /***/ }),
  129301. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  129302. /*!************************************************************!*\
  129303. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  129304. \************************************************************/
  129305. /*! exports provided: lightFragmentDeclaration */
  129306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129307. "use strict";
  129308. __webpack_require__.r(__webpack_exports__);
  129309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  129310. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129311. var name = 'lightFragmentDeclaration';
  129312. 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";
  129313. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129314. /** @hidden */
  129315. var lightFragmentDeclaration = { name: name, shader: shader };
  129316. /***/ }),
  129317. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  129318. /*!*******************************************************!*\
  129319. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  129320. \*******************************************************/
  129321. /*! exports provided: lightUboDeclaration */
  129322. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129323. "use strict";
  129324. __webpack_require__.r(__webpack_exports__);
  129325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  129326. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129327. var name = 'lightUboDeclaration';
  129328. 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";
  129329. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129330. /** @hidden */
  129331. var lightUboDeclaration = { name: name, shader: shader };
  129332. /***/ }),
  129333. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  129334. /*!***********************************************************!*\
  129335. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  129336. \***********************************************************/
  129337. /*! exports provided: lightsFragmentFunctions */
  129338. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129339. "use strict";
  129340. __webpack_require__.r(__webpack_exports__);
  129341. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  129342. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129343. var name = 'lightsFragmentFunctions';
  129344. 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}";
  129345. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129346. /** @hidden */
  129347. var lightsFragmentFunctions = { name: name, shader: shader };
  129348. /***/ }),
  129349. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  129350. /*!*******************************************************!*\
  129351. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  129352. \*******************************************************/
  129353. /*! exports provided: logDepthDeclaration */
  129354. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129355. "use strict";
  129356. __webpack_require__.r(__webpack_exports__);
  129357. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  129358. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129359. var name = 'logDepthDeclaration';
  129360. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  129361. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129362. /** @hidden */
  129363. var logDepthDeclaration = { name: name, shader: shader };
  129364. /***/ }),
  129365. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  129366. /*!****************************************************!*\
  129367. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  129368. \****************************************************/
  129369. /*! exports provided: logDepthFragment */
  129370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129371. "use strict";
  129372. __webpack_require__.r(__webpack_exports__);
  129373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  129374. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129375. var name = 'logDepthFragment';
  129376. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  129377. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129378. /** @hidden */
  129379. var logDepthFragment = { name: name, shader: shader };
  129380. /***/ }),
  129381. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  129382. /*!**************************************************!*\
  129383. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  129384. \**************************************************/
  129385. /*! exports provided: logDepthVertex */
  129386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129387. "use strict";
  129388. __webpack_require__.r(__webpack_exports__);
  129389. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  129390. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129391. var name = 'logDepthVertex';
  129392. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  129393. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129394. /** @hidden */
  129395. var logDepthVertex = { name: name, shader: shader };
  129396. /***/ }),
  129397. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  129398. /*!******************************************************!*\
  129399. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  129400. \******************************************************/
  129401. /*! exports provided: morphTargetsVertex */
  129402. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129403. "use strict";
  129404. __webpack_require__.r(__webpack_exports__);
  129405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  129406. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129407. var name = 'morphTargetsVertex';
  129408. 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";
  129409. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129410. /** @hidden */
  129411. var morphTargetsVertex = { name: name, shader: shader };
  129412. /***/ }),
  129413. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  129414. /*!*****************************************************************!*\
  129415. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  129416. \*****************************************************************/
  129417. /*! exports provided: morphTargetsVertexDeclaration */
  129418. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129419. "use strict";
  129420. __webpack_require__.r(__webpack_exports__);
  129421. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  129422. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129423. var name = 'morphTargetsVertexDeclaration';
  129424. 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";
  129425. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129426. /** @hidden */
  129427. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  129428. /***/ }),
  129429. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  129430. /*!***********************************************************************!*\
  129431. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  129432. \***********************************************************************/
  129433. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  129434. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129435. "use strict";
  129436. __webpack_require__.r(__webpack_exports__);
  129437. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  129438. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129439. var name = 'morphTargetsVertexGlobalDeclaration';
  129440. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  129441. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129442. /** @hidden */
  129443. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  129444. /***/ }),
  129445. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  129446. /*!**********************************************************!*\
  129447. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  129448. \**********************************************************/
  129449. /*! exports provided: mrtFragmentDeclaration */
  129450. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129451. "use strict";
  129452. __webpack_require__.r(__webpack_exports__);
  129453. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  129454. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129455. var name = 'mrtFragmentDeclaration';
  129456. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  129457. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129458. /** @hidden */
  129459. var mrtFragmentDeclaration = { name: name, shader: shader };
  129460. /***/ }),
  129461. /***/ "./Shaders/ShadersInclude/pbrBRDFFunctions.ts":
  129462. /*!****************************************************!*\
  129463. !*** ./Shaders/ShadersInclude/pbrBRDFFunctions.ts ***!
  129464. \****************************************************/
  129465. /*! exports provided: pbrBRDFFunctions */
  129466. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129467. "use strict";
  129468. __webpack_require__.r(__webpack_exports__);
  129469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrBRDFFunctions", function() { return pbrBRDFFunctions; });
  129470. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129471. var name = 'pbrBRDFFunctions';
  129472. var shader = "\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\n\n\n\n#ifdef MS_BRDF_ENERGY_CONSERVATION\n\n\nvec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\nreturn 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);\n}\n#endif\n#ifdef ENVIRONMENTBRDF\nvec3 getBRDFLookup(float NdotV,float perceptualRoughness,sampler2D brdfSampler) {\n\nvec2 UV=vec2(NdotV,perceptualRoughness);\n\nvec4 brdfLookup=texture2D(brdfSampler,UV);\n#ifdef ENVIRONMENTBRDF_RGBD\nbrdfLookup.rgb=fromRGBD(brdfLookup.rgba);\n#endif\nreturn brdfLookup.rgb;\n}\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\n#ifdef BRDF_V_HEIGHT_CORRELATED\nvec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);\n#else\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#endif\nreturn reflectance;\n}\n#endif\n#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)\nvec3 getReflectanceFromAnalyticalBRDFLookup_Jones(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\n}\n#endif\n#if defined(SHEEN) && defined(REFLECTION)\n\nvec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {\nvec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;\nreturn sheenEnvironmentReflectance;\n}\n#endif\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\nfloat fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\n#ifdef CLEARCOAT\n\n\n\n\n\nvec3 getR0RemappedForClearCoat(vec3 f0) {\n#ifdef CLEARCOAT_DEFAULTIOR\n#ifdef MOBILE\nreturn saturate(f0*(f0*0.526868+0.529324)-0.0482256);\n#else\nreturn saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);\n#endif\n#else\nvec3 s=sqrt(f0);\nvec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);\nreturn t*t;\n#endif\n}\n#endif\n\n\n\n\n\n\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\n\n\n\nfloat a2=square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\n#ifdef SHEEN\n\nfloat normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)\n{\nfloat invR=1./alphaG;\nfloat cos2h=NdotH*NdotH;\nfloat sin2h=1.-cos2h;\nreturn (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);\n}\n#endif\n#ifdef ANISOTROPIC\n\n\nfloat normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {\nfloat a2=alphaTB.x*alphaTB.y;\nvec3 v=vec3(alphaTB.y*TdotH,alphaTB.x*BdotH,a2*NdotH);\nfloat v2=dot(v,v);\nfloat w2=a2/v2;\nreturn a2*w2*w2*RECIPROCAL_PI;\n}\n#endif\n\n\n\n\n#ifdef BRDF_V_HEIGHT_CORRELATED\n\n\n\nfloat smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {\n#ifdef MOBILE\n\nfloat GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);\nfloat GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);\nreturn 0.5/(GGXV+GGXL);\n#else\nfloat a2=alphaG*alphaG;\nfloat GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);\nfloat GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);\nreturn 0.5/(GGXV+GGXL);\n#endif\n}\n#else\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfloat smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)\n{\n#ifdef MOBILE\n\nreturn 1.0/(dot+alphaG+(1.0-alphaG)*dot ));\n#else\nfloat alphaSquared=alphaG*alphaG;\nreturn 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));\n#endif\n}\nfloat smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)\n{\nfloat visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);\n\nreturn visibility;\n}\n#endif\n#ifdef ANISOTROPIC\n\n\nfloat smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {\nfloat lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));\nfloat lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));\nfloat v=0.5/(lambdaV+lambdaL);\nreturn v;\n}\n#endif\n#ifdef CLEARCOAT\nfloat visibility_Kelemen(float VdotH) {\n\n\n\nreturn 0.25/(VdotH*VdotH);\n}\n#endif\n#ifdef SHEEN\n\n\n\nfloat visibility_Ashikhmin(float NdotL,float NdotV)\n{\nreturn 1./(4.*(NdotL+NdotV-NdotL*NdotV));\n}\n#endif\n\n\n\n\n\n\n\nfloat diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {\n\n\nfloat diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));\nfloat diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel/PI;\n}\n#ifdef SS_TRANSLUCENCY\n\n\nvec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance,float thickness) {\nvec3 S=1./maxEps(diffusionDistance);\nvec3 temp=exp((-0.333333333*thickness)*S);\nreturn tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);\n}\n\n\nfloat computeWrappedDiffuseNdotL(float NdotL,float w) {\nfloat t=1.0+w;\nfloat invt2=1.0/square(t);\nreturn saturate((NdotL+w)*invt2);\n}\n#endif\n";
  129473. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129474. /** @hidden */
  129475. var pbrBRDFFunctions = { name: name, shader: shader };
  129476. /***/ }),
  129477. /***/ "./Shaders/ShadersInclude/pbrDebug.ts":
  129478. /*!********************************************!*\
  129479. !*** ./Shaders/ShadersInclude/pbrDebug.ts ***!
  129480. \********************************************/
  129481. /*! exports provided: pbrDebug */
  129482. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129483. "use strict";
  129484. __webpack_require__.r(__webpack_exports__);
  129485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDebug", function() { return pbrDebug; });
  129486. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129487. var name = 'pbrDebug';
  129488. 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#elif DEBUGMODE == 31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)\ngl_FragColor.rgb=thicknessMap.rgb;\n\n#elif DEBUGMODE == 40 && defined(SS_REFRACTION)\n\ngl_FragColor.rgb=environmentRefraction.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 41 && defined(REFLECTION)\ngl_FragColor.rgb=environmentRadiance.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 42 && defined(CLEARCOAT) && defined(REFLECTION)\ngl_FragColor.rgb=environmentClearCoatRadiance;\n#define DEBUGMODE_GAMMA\n\n#elif DEBUGMODE == 50\ngl_FragColor.rgb=diffuseBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 51 && defined(SPECULARTERM)\ngl_FragColor.rgb=specularBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 52 && defined(CLEARCOAT)\ngl_FragColor.rgb=clearCoatBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 53 && defined(SHEEN)\ngl_FragColor.rgb=sheenBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 54 && defined(REFLECTION)\ngl_FragColor.rgb=environmentIrradiance.rgb;\n#define DEBUGMODE_GAMMA\n\n#elif DEBUGMODE == 60\ngl_FragColor.rgb=surfaceAlbedo.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 61\ngl_FragColor.rgb=specularEnvironmentR0;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 62\ngl_FragColor.rgb=vec3(roughness);\n#elif DEBUGMODE == 63\ngl_FragColor.rgb=vec3(alphaG);\n#elif DEBUGMODE == 64\ngl_FragColor.rgb=vec3(NdotV);\n#elif DEBUGMODE == 65 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)\ngl_FragColor.rgb=clearCoatColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 66 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearCoatRoughness);\n#elif DEBUGMODE == 67 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearCoatNdotV);\n#elif DEBUGMODE == 68 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)\ngl_FragColor.rgb=transmittance;\n#elif DEBUGMODE == 69 && defined(SUBSURFACE) && defined(SS_REFRACTION)\ngl_FragColor.rgb=refractionTransmittance;\n\n#elif DEBUGMODE == 70 && defined(RADIANCEOCCLUSION)\ngl_FragColor.rgb=vec3(seo);\n#elif DEBUGMODE == 71 && defined(HORIZONOCCLUSION)\ngl_FragColor.rgb=vec3(eho);\n#elif DEBUGMODE == 72 && defined(MS_BRDF_ENERGY_CONSERVATION)\ngl_FragColor.rgb=vec3(energyConservationFactor);\n#elif DEBUGMODE == 73 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=specularEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 74 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=clearCoatEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 75 && defined(SHEEN) && defined(REFLECTION)\ngl_FragColor.rgb=sheenEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 76 && defined(ALPHABLEND)\ngl_FragColor.rgb=vec3(luminanceOverAlpha);\n#elif DEBUGMODE == 77\ngl_FragColor.rgb=vec3(alpha);\n#endif\ngl_FragColor.rgb*=vDebugMode.y;\n#ifdef DEBUGMODE_NORMALIZE\ngl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;\n#endif\n#ifdef DEBUGMODE_GAMMA\ngl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);\n#endif\ngl_FragColor.a=1.0;\n#endif";
  129489. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129490. /** @hidden */
  129491. var pbrDebug = { name: name, shader: shader };
  129492. /***/ }),
  129493. /***/ "./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts":
  129494. /*!*********************************************************************!*\
  129495. !*** ./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts ***!
  129496. \*********************************************************************/
  129497. /*! exports provided: pbrDirectLightingFalloffFunctions */
  129498. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129499. "use strict";
  129500. __webpack_require__.r(__webpack_exports__);
  129501. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingFalloffFunctions", function() { return pbrDirectLightingFalloffFunctions; });
  129502. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129503. var name = 'pbrDirectLightingFalloffFunctions';
  129504. 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}";
  129505. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129506. /** @hidden */
  129507. var pbrDirectLightingFalloffFunctions = { name: name, shader: shader };
  129508. /***/ }),
  129509. /***/ "./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts":
  129510. /*!**************************************************************!*\
  129511. !*** ./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts ***!
  129512. \**************************************************************/
  129513. /*! exports provided: pbrDirectLightingFunctions */
  129514. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129515. "use strict";
  129516. __webpack_require__.r(__webpack_exports__);
  129517. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingFunctions", function() { return pbrDirectLightingFunctions; });
  129518. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129519. var name = 'pbrDirectLightingFunctions';
  129520. var shader = "#define CLEARCOATREFLECTANCE90 1.0\n\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef CLEARCOAT\n\n\nvec4 clearCoat;\n#endif\n#ifdef SHEEN\nvec3 sheen;\n#endif\n};\n\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=saturate(lightRoughness+roughness);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nvec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {\nreturn mix(groundColor,lightColor,info.NdotL);\n}\nvec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {\nfloat diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*info.attenuation*info.NdotL*lightColor;\n}\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn toLinearSpace(textureColor);\n}\n#ifdef SS_TRANSLUCENCY\nvec3 computeDiffuseAndTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {\nfloat NdotL=absEps(info.NdotLUnclamped);\n\nfloat wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);\n\nfloat trAdapt=step(0.,info.NdotLUnclamped);\nvec3 transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt);\nfloat diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;\n}\n#endif\n#ifdef SPECULARTERM\nvec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\n#ifdef BRDF_V_HEIGHT_CORRELATED\nfloat visibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);\n#else\nfloat visibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);\n#endif\nvec3 specTerm=fresnel*distribution*visibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef ANISOTROPIC\nvec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat TdotH=dot(T,info.H);\nfloat BdotH=dot(B,info.H);\nfloat TdotV=dot(T,V);\nfloat BdotV=dot(B,V);\nfloat TdotL=dot(T,info.L);\nfloat BdotL=dot(B,info.L);\nfloat alphaG=convertRoughnessToAverageSlope(info.roughness);\nvec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);\nalphaTB=max(alphaTB,square(geometricRoughnessFactor));\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);\nfloat visibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);\nvec3 specTerm=fresnel*distribution*visibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef CLEARCOAT\nvec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {\nfloat NccdotL=saturateEps(dot(Ncc,info.L));\nfloat NccdotH=saturateEps(dot(Ncc,info.H));\nfloat clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\nfloat fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnel*=clearCoatIntensity;\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);\nfloat visibility=visibility_Kelemen(info.VdotH);\nfloat clearCoatTerm=fresnel*distribution*visibility;\nreturn vec4(\nclearCoatTerm*info.attenuation*NccdotL*lightColor,\n1.0-fresnel\n);\n}\nvec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);\nfloat NdotLRefract=saturateEps(dot(Ncc,LRefract));\nvec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\nreturn absorption;\n}\n#endif\n#ifdef SHEEN\nvec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n\n\nvec3 fresnel=reflectance0;\nfloat distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);\nfloat visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);\nvec3 sheenTerm=fresnel*distribution*visibility;\nreturn sheenTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n";
  129521. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129522. /** @hidden */
  129523. var pbrDirectLightingFunctions = { name: name, shader: shader };
  129524. /***/ }),
  129525. /***/ "./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts":
  129526. /*!*******************************************************************!*\
  129527. !*** ./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts ***!
  129528. \*******************************************************************/
  129529. /*! exports provided: pbrDirectLightingSetupFunctions */
  129530. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129531. "use strict";
  129532. __webpack_require__.r(__webpack_exports__);
  129533. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrDirectLightingSetupFunctions", function() { return pbrDirectLightingSetupFunctions; });
  129534. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129535. var name = 'pbrDirectLightingSetupFunctions';
  129536. var shader = "\nstruct preLightingInfo\n{\n\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat lightDistance;\n\nfloat attenuation;\n\nvec3 L;\nvec3 H;\nfloat NdotV;\nfloat NdotLUnclamped;\nfloat NdotL;\nfloat VdotH;\nfloat roughness;\n};\npreLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\n\nresult.lightDistance=sqrt(result.lightDistanceSquared);\n\nresult.L=normalize(result.lightOffset);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\nresult.NdotLUnclamped=dot(N,result.L);\nresult.NdotL=saturateEps(result.NdotLUnclamped);\nreturn result;\n}\npreLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightDistance=length(-lightData.xyz);\n\nresult.L=normalize(-lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\nresult.NdotLUnclamped=dot(N,result.L);\nresult.NdotL=saturateEps(result.NdotLUnclamped);\nreturn result;\n}\npreLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\n\nresult.NdotL=dot(N,lightData.xyz)*0.5+0.5;\nresult.NdotL=saturateEps(result.NdotL);\nresult.NdotLUnclamped=result.NdotL;\n#ifdef SPECULARTERM\nresult.L=normalize(lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\n#endif\nreturn result;\n}";
  129537. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129538. /** @hidden */
  129539. var pbrDirectLightingSetupFunctions = { name: name, shader: shader };
  129540. /***/ }),
  129541. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  129542. /*!**********************************************************!*\
  129543. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  129544. \**********************************************************/
  129545. /*! exports provided: pbrFragmentDeclaration */
  129546. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129547. "use strict";
  129548. __webpack_require__.r(__webpack_exports__);
  129549. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  129550. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129551. var name = 'pbrFragmentDeclaration';
  129552. var shader = "uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\n\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n\n#ifdef CLEARCOAT\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\n#ifdef CLEARCOAT_TEXTURE\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n#endif\n\n#ifdef ANISOTROPIC\nuniform vec3 vAnisotropy;\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n\n#ifdef SHEEN\nuniform vec4 vSheenColor;\n#ifdef SHEEN_TEXTURE\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n#endif\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;;\n#endif\nuniform vec2 vThicknessParam;\nuniform vec3 vDiffusionDistance;\nuniform vec4 vTintColor;\nuniform vec3 vSubSurfaceIntensity;\n#endif";
  129553. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129554. /** @hidden */
  129555. var pbrFragmentDeclaration = { name: name, shader: shader };
  129556. /***/ }),
  129557. /***/ "./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts":
  129558. /*!***************************************************************!*\
  129559. !*** ./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts ***!
  129560. \***************************************************************/
  129561. /*! exports provided: pbrFragmentExtraDeclaration */
  129562. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129563. "use strict";
  129564. __webpack_require__.r(__webpack_exports__);
  129565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentExtraDeclaration", function() { return pbrFragmentExtraDeclaration; });
  129566. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129567. var name = 'pbrFragmentExtraDeclaration';
  129568. 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";
  129569. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129570. /** @hidden */
  129571. var pbrFragmentExtraDeclaration = { name: name, shader: shader };
  129572. /***/ }),
  129573. /***/ "./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts":
  129574. /*!******************************************************************!*\
  129575. !*** ./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts ***!
  129576. \******************************************************************/
  129577. /*! exports provided: pbrFragmentSamplersDeclaration */
  129578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129579. "use strict";
  129580. __webpack_require__.r(__webpack_exports__);
  129581. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentSamplersDeclaration", function() { return pbrFragmentSamplersDeclaration; });
  129582. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129583. var name = 'pbrFragmentSamplersDeclaration';
  129584. var shader = "#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\n#if CLEARCOAT_TEXTUREDIRECTUV == 1\n#define vClearCoatUV vMainUV1\n#elif CLEARCOAT_TEXTUREDIRECTUV == 2\n#define vClearCoatUV vMainUV2\n#else\nvarying vec2 vClearCoatUV;\n#endif\nuniform sampler2D clearCoatSampler;\n#endif\n#ifdef CLEARCOAT_BUMP\n#if CLEARCOAT_BUMPDIRECTUV == 1\n#define vClearCoatBumpUV vMainUV1\n#elif CLEARCOAT_BUMPDIRECTUV == 2\n#define vClearCoatBumpUV vMainUV2\n#else\nvarying vec2 vClearCoatBumpUV;\n#endif\nuniform sampler2D clearCoatBumpSampler;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\n#if CLEARCOAT_TINT_TEXTUREDIRECTUV == 1\n#define vClearCoatTintUV vMainUV1\n#elif CLEARCOAT_TINT_TEXTUREDIRECTUV == 2\n#define vClearCoatTintUV vMainUV2\n#else\nvarying vec2 vClearCoatTintUV;\n#endif\nuniform sampler2D clearCoatTintSampler;\n#endif\n#endif\n#ifdef SHEEN\n#ifdef SHEEN_TEXTURE\n#if SHEEN_TEXTUREDIRECTUV == 1\n#define vSheenUV vMainUV1\n#elif SHEEN_TEXTUREDIRECTUV == 2\n#define vSheenUV vMainUV2\n#else\nvarying vec2 vSheenUV;\n#endif\nuniform sampler2D sheenSampler;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\n#if ANISOTROPIC_TEXTUREDIRECTUV == 1\n#define vAnisotropyUV vMainUV1\n#elif ANISOTROPIC_TEXTUREDIRECTUV == 2\n#define vAnisotropyUV vMainUV2\n#else\nvarying vec2 vAnisotropyUV;\n#endif\nuniform sampler2D anisotropySampler;\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\n#ifdef SS_REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\n#if SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 1\n#define vThicknessUV vMainUV1\n#elif SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 2\n#define vThicknessUV vMainUV2\n#else\nvarying vec2 vThicknessUV;\n#endif\nuniform sampler2D thicknessSampler;\n#endif\n#endif";
  129585. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129586. /** @hidden */
  129587. var pbrFragmentSamplersDeclaration = { name: name, shader: shader };
  129588. /***/ }),
  129589. /***/ "./Shaders/ShadersInclude/pbrHelperFunctions.ts":
  129590. /*!******************************************************!*\
  129591. !*** ./Shaders/ShadersInclude/pbrHelperFunctions.ts ***!
  129592. \******************************************************/
  129593. /*! exports provided: pbrHelperFunctions */
  129594. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129595. "use strict";
  129596. __webpack_require__.r(__webpack_exports__);
  129597. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrHelperFunctions", function() { return pbrHelperFunctions; });
  129598. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129599. var name = 'pbrHelperFunctions';
  129600. var shader = "\n#define RECIPROCAL_PI2 0.15915494\n#define RECIPROCAL_PI 0.31830988618\n\n#define MINIMUMVARIANCE 0.0005\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nreturn square(roughness)+MINIMUMVARIANCE;\n}\nfloat fresnelGrazingReflectance(float reflectance0) {\n\n\nfloat reflectance90=saturate(reflectance0*25.0);\nreturn reflectance90;\n}\nvec2 getAARoughnessFactors(vec3 normalVector) {\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalVector.xyz);\nvec3 nDfdy=dFdy(normalVector.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\n\nfloat geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);\n\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\n\ngeometricAlphaGFactor*=0.75;\nreturn vec2(geometricRoughnessFactor,geometricAlphaGFactor);\n#else\nreturn vec2(0.);\n#endif\n}\n#ifdef ANISOTROPIC\n\n\nvec2 getAnisotropicRoughness(float alphaG,float anisotropy) {\nfloat alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);\nfloat alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);\nreturn vec2(alphaT,alphaB);\n}\n\n\nvec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) {\nvec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;\nvec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);\nvec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);\nvec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));\nreturn anisotropicNormal;\n\n}\n#endif\n#if defined(CLEARCOAT) || defined(SS_REFRACTION)\n\n\n\nvec3 cocaLambert(vec3 alpha,float distance) {\nreturn exp(-alpha*distance);\n}\n\nvec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {\nreturn cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));\n}\n\nvec3 computeColorAtDistanceInMedia(vec3 color,float distance) {\nreturn -log(color)/distance;\n}\nvec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 clearCoatAbsorption=mix(vec3(1.0),\ncocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),\nclearCoatIntensity);\nreturn clearCoatAbsorption;\n}\n#endif\n\n\n\n\n#ifdef MICROSURFACEAUTOMATIC\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n#endif";
  129601. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129602. /** @hidden */
  129603. var pbrHelperFunctions = { name: name, shader: shader };
  129604. /***/ }),
  129605. /***/ "./Shaders/ShadersInclude/pbrIBLFunctions.ts":
  129606. /*!***************************************************!*\
  129607. !*** ./Shaders/ShadersInclude/pbrIBLFunctions.ts ***!
  129608. \***************************************************/
  129609. /*! exports provided: pbrIBLFunctions */
  129610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129611. "use strict";
  129612. __webpack_require__.r(__webpack_exports__);
  129613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrIBLFunctions", function() { return pbrIBLFunctions; });
  129614. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129615. var name = 'pbrIBLFunctions';
  129616. var shader = "#if defined(REFLECTION) || defined(SS_REFRACTION)\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {\nfloat microsurfaceAverageSlopeTexels=microsurfaceAverageSlope*cubeMapDimensionPixels;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn saturate(square(temp)-1.0+ambientOcclusion);\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=saturate(1.0+1.1*dot(reflection,normal));\nreturn square(temp);\n}\n#endif\n\n\n\n\n#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)\n\n\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\n\n\n\n\n\n\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nreturn getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);\n}\n#endif";
  129617. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129618. /** @hidden */
  129619. var pbrIBLFunctions = { name: name, shader: shader };
  129620. /***/ }),
  129621. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  129622. /*!*****************************************************!*\
  129623. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  129624. \*****************************************************/
  129625. /*! exports provided: pbrUboDeclaration */
  129626. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129627. "use strict";
  129628. __webpack_require__.r(__webpack_exports__);
  129629. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  129630. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129631. var name = 'pbrUboDeclaration';
  129632. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec2 vAlbedoInfos;\nuniform vec4 vAmbientInfos;\nuniform vec2 vOpacityInfos;\nuniform vec2 vEmissiveInfos;\nuniform vec2 vLightmapInfos;\nuniform vec3 vReflectivityInfos;\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform vec2 vReflectionInfos;\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\nuniform vec3 vBumpInfos;\nuniform mat4 albedoMatrix;\nuniform mat4 ambientMatrix;\nuniform mat4 opacityMatrix;\nuniform mat4 emissiveMatrix;\nuniform mat4 lightmapMatrix;\nuniform mat4 reflectivityMatrix;\nuniform mat4 microSurfaceSamplerMatrix;\nuniform mat4 bumpMatrix;\nuniform vec2 vTangentSpaceParams;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float pointSize;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\nuniform vec3 vAnisotropy;\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\nuniform vec4 vSheenColor;\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;\nuniform vec2 vThicknessParam;\nuniform vec3 vDiffusionDistance;\nuniform vec4 vTintColor;\nuniform vec3 vSubSurfaceIntensity;\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};";
  129633. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129634. /** @hidden */
  129635. var pbrUboDeclaration = { name: name, shader: shader };
  129636. /***/ }),
  129637. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  129638. /*!********************************************************!*\
  129639. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  129640. \********************************************************/
  129641. /*! exports provided: pbrVertexDeclaration */
  129642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129643. "use strict";
  129644. __webpack_require__.r(__webpack_exports__);
  129645. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  129646. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129647. var name = 'pbrVertexDeclaration';
  129648. var shader = "uniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef ALBEDO\nuniform mat4 albedoMatrix;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\nuniform mat4 reflectivityMatrix;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform mat4 microSurfaceSamplerMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\n#endif\n\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n\n#ifdef SHEEN\n#ifdef SHEEN_TEXTURE\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n#endif\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;;\n#endif\n#endif\n";
  129649. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129650. /** @hidden */
  129651. var pbrVertexDeclaration = { name: name, shader: shader };
  129652. /***/ }),
  129653. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  129654. /*!****************************************************!*\
  129655. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  129656. \****************************************************/
  129657. /*! exports provided: pointCloudVertex */
  129658. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129659. "use strict";
  129660. __webpack_require__.r(__webpack_exports__);
  129661. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pointCloudVertex", function() { return pointCloudVertex; });
  129662. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129663. var name = 'pointCloudVertex';
  129664. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  129665. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129666. /** @hidden */
  129667. var pointCloudVertex = { name: name, shader: shader };
  129668. /***/ }),
  129669. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  129670. /*!******************************************************!*\
  129671. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  129672. \******************************************************/
  129673. /*! exports provided: reflectionFunction */
  129674. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129675. "use strict";
  129676. __webpack_require__.r(__webpack_exports__);
  129677. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reflectionFunction", function() { return reflectionFunction; });
  129678. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129679. var name = 'reflectionFunction';
  129680. 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}";
  129681. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129682. /** @hidden */
  129683. var reflectionFunction = { name: name, shader: shader };
  129684. /***/ }),
  129685. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  129686. /*!************************************************************!*\
  129687. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  129688. \************************************************************/
  129689. /*! exports provided: shadowsFragmentFunctions */
  129690. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129691. "use strict";
  129692. __webpack_require__.r(__webpack_exports__);
  129693. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  129694. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129695. var name = 'shadowsFragmentFunctions';
  129696. 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";
  129697. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129698. /** @hidden */
  129699. var shadowsFragmentFunctions = { name: name, shader: shader };
  129700. /***/ }),
  129701. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  129702. /*!*************************************************!*\
  129703. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  129704. \*************************************************/
  129705. /*! exports provided: shadowsVertex */
  129706. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129707. "use strict";
  129708. __webpack_require__.r(__webpack_exports__);
  129709. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  129710. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  129711. var name = 'shadowsVertex';
  129712. 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";
  129713. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  129714. /** @hidden */
  129715. var shadowsVertex = { name: name, shader: shader };
  129716. /***/ }),
  129717. /***/ "./Shaders/anaglyph.fragment.ts":
  129718. /*!**************************************!*\
  129719. !*** ./Shaders/anaglyph.fragment.ts ***!
  129720. \**************************************/
  129721. /*! exports provided: anaglyphPixelShader */
  129722. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129723. "use strict";
  129724. __webpack_require__.r(__webpack_exports__);
  129725. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  129726. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129727. var name = 'anaglyphPixelShader';
  129728. 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}";
  129729. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129730. /** @hidden */
  129731. var anaglyphPixelShader = { name: name, shader: shader };
  129732. /***/ }),
  129733. /***/ "./Shaders/background.fragment.ts":
  129734. /*!****************************************!*\
  129735. !*** ./Shaders/background.fragment.ts ***!
  129736. \****************************************/
  129737. /*! exports provided: backgroundPixelShader */
  129738. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129739. "use strict";
  129740. __webpack_require__.r(__webpack_exports__);
  129741. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  129742. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129743. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  129744. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  129745. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  129746. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  129747. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  129748. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  129749. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129750. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  129751. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  129752. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  129753. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  129754. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  129755. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  129756. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  129757. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  129758. var name = 'backgroundPixelShader';
  129759. 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";
  129760. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129761. /** @hidden */
  129762. var backgroundPixelShader = { name: name, shader: shader };
  129763. /***/ }),
  129764. /***/ "./Shaders/background.vertex.ts":
  129765. /*!**************************************!*\
  129766. !*** ./Shaders/background.vertex.ts ***!
  129767. \**************************************/
  129768. /*! exports provided: backgroundVertexShader */
  129769. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129770. "use strict";
  129771. __webpack_require__.r(__webpack_exports__);
  129772. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  129773. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129774. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  129775. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  129776. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129777. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  129778. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  129779. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  129780. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  129781. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  129782. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  129783. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  129784. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  129785. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  129786. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  129787. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  129788. var name = 'backgroundVertexShader';
  129789. var shader = "precision highp float;\n#include<__decl__backgroundVertex>\n#include<helperFunctions>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n} else {\ngl_Position=viewProjectionR*finalWorld*vec4(position,1.0);\n}\n#else\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#endif\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normal);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));\n#ifdef EQUIRECTANGULAR_RELFECTION_FOV\nmat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));\nvec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));\nif (fFovMultiplier<=1.0) {\nvDirectionW=normalize(segment);\n} else {\nvDirectionW=normalize(vDirectionW+(vDirectionW-segment));\n}\n#endif\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  129790. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129791. /** @hidden */
  129792. var backgroundVertexShader = { name: name, shader: shader };
  129793. /***/ }),
  129794. /***/ "./Shaders/blackAndWhite.fragment.ts":
  129795. /*!*******************************************!*\
  129796. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  129797. \*******************************************/
  129798. /*! exports provided: blackAndWhitePixelShader */
  129799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129800. "use strict";
  129801. __webpack_require__.r(__webpack_exports__);
  129802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  129803. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129804. var name = 'blackAndWhitePixelShader';
  129805. 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}";
  129806. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129807. /** @hidden */
  129808. var blackAndWhitePixelShader = { name: name, shader: shader };
  129809. /***/ }),
  129810. /***/ "./Shaders/bloomMerge.fragment.ts":
  129811. /*!****************************************!*\
  129812. !*** ./Shaders/bloomMerge.fragment.ts ***!
  129813. \****************************************/
  129814. /*! exports provided: bloomMergePixelShader */
  129815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129816. "use strict";
  129817. __webpack_require__.r(__webpack_exports__);
  129818. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  129819. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129820. var name = 'bloomMergePixelShader';
  129821. 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";
  129822. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129823. /** @hidden */
  129824. var bloomMergePixelShader = { name: name, shader: shader };
  129825. /***/ }),
  129826. /***/ "./Shaders/chromaticAberration.fragment.ts":
  129827. /*!*************************************************!*\
  129828. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  129829. \*************************************************/
  129830. /*! exports provided: chromaticAberrationPixelShader */
  129831. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129832. "use strict";
  129833. __webpack_require__.r(__webpack_exports__);
  129834. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  129835. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129836. var name = 'chromaticAberrationPixelShader';
  129837. 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}";
  129838. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129839. /** @hidden */
  129840. var chromaticAberrationPixelShader = { name: name, shader: shader };
  129841. /***/ }),
  129842. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  129843. /*!***********************************************!*\
  129844. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  129845. \***********************************************/
  129846. /*! exports provided: circleOfConfusionPixelShader */
  129847. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129848. "use strict";
  129849. __webpack_require__.r(__webpack_exports__);
  129850. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  129851. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129852. var name = 'circleOfConfusionPixelShader';
  129853. 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";
  129854. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129855. /** @hidden */
  129856. var circleOfConfusionPixelShader = { name: name, shader: shader };
  129857. /***/ }),
  129858. /***/ "./Shaders/color.fragment.ts":
  129859. /*!***********************************!*\
  129860. !*** ./Shaders/color.fragment.ts ***!
  129861. \***********************************/
  129862. /*! exports provided: colorPixelShader */
  129863. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129864. "use strict";
  129865. __webpack_require__.r(__webpack_exports__);
  129866. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  129867. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129868. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  129869. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  129870. var name = 'colorPixelShader';
  129871. 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}";
  129872. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129873. /** @hidden */
  129874. var colorPixelShader = { name: name, shader: shader };
  129875. /***/ }),
  129876. /***/ "./Shaders/color.vertex.ts":
  129877. /*!*********************************!*\
  129878. !*** ./Shaders/color.vertex.ts ***!
  129879. \*********************************/
  129880. /*! exports provided: colorVertexShader */
  129881. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129882. "use strict";
  129883. __webpack_require__.r(__webpack_exports__);
  129884. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  129885. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129886. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  129887. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  129888. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  129889. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  129890. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  129891. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  129892. var name = 'colorVertexShader';
  129893. 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}";
  129894. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129895. /** @hidden */
  129896. var colorVertexShader = { name: name, shader: shader };
  129897. /***/ }),
  129898. /***/ "./Shaders/colorCorrection.fragment.ts":
  129899. /*!*********************************************!*\
  129900. !*** ./Shaders/colorCorrection.fragment.ts ***!
  129901. \*********************************************/
  129902. /*! exports provided: colorCorrectionPixelShader */
  129903. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129904. "use strict";
  129905. __webpack_require__.r(__webpack_exports__);
  129906. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  129907. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129908. var name = 'colorCorrectionPixelShader';
  129909. 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}";
  129910. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129911. /** @hidden */
  129912. var colorCorrectionPixelShader = { name: name, shader: shader };
  129913. /***/ }),
  129914. /***/ "./Shaders/convolution.fragment.ts":
  129915. /*!*****************************************!*\
  129916. !*** ./Shaders/convolution.fragment.ts ***!
  129917. \*****************************************/
  129918. /*! exports provided: convolutionPixelShader */
  129919. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129920. "use strict";
  129921. __webpack_require__.r(__webpack_exports__);
  129922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  129923. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129924. var name = 'convolutionPixelShader';
  129925. 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}";
  129926. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129927. /** @hidden */
  129928. var convolutionPixelShader = { name: name, shader: shader };
  129929. /***/ }),
  129930. /***/ "./Shaders/default.fragment.ts":
  129931. /*!*************************************!*\
  129932. !*** ./Shaders/default.fragment.ts ***!
  129933. \*************************************/
  129934. /*! exports provided: defaultPixelShader */
  129935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129936. "use strict";
  129937. __webpack_require__.r(__webpack_exports__);
  129938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultPixelShader", function() { return defaultPixelShader; });
  129939. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129940. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  129941. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  129942. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129943. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  129944. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  129945. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  129946. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  129947. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  129948. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  129949. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  129950. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  129951. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  129952. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  129953. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  129954. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  129955. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  129956. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  129957. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  129958. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  129959. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  129960. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  129961. var name = 'defaultPixelShader';
  129962. var shader = "#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\n#if SPECULARDIRECTUV == 1\n#define vSpecularUV vMainUV1\n#elif SPECULARDIRECTUV == 2\n#define vSpecularUV vMainUV2\n#else\nvarying vec2 vSpecularUV;\n#endif\nuniform sampler2D specularSampler;\n#endif\n#ifdef ALPHATEST\nuniform float alphaCutOff;\n#endif\n\n#include<fresnelFunction>\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#ifdef ALPHATEST\nif (baseColor.a<alphaCutOff)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n\nvec3 refractionColor=vec3(0.,0.,0.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0) {\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb;\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords).rgb;\n#endif\n#ifdef IS_REFRACTION_LINEAR\nrefractionColor=toGammaSpace(refractionColor);\n#endif\nrefractionColor*=vRefractionInfos.x;\n#endif\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias).rgb;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb;\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords).rgb;\n#endif\n#ifdef IS_REFLECTION_LINEAR\nreflectionColor=toGammaSpace(reflectionColor);\n#endif\nreflectionColor*=vReflectionInfos.x;\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+emissiveColor+refractionColor,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+refractionColor,alpha);\n#endif\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\ncolor.rgb=max(color.rgb,0.);\n#include<logDepthFragment>\n#include<fogFragment>\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\ncolor.a*=visibility;\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\ngl_FragColor=color;\n}\n";
  129963. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  129964. /** @hidden */
  129965. var defaultPixelShader = { name: name, shader: shader };
  129966. /***/ }),
  129967. /***/ "./Shaders/default.vertex.ts":
  129968. /*!***********************************!*\
  129969. !*** ./Shaders/default.vertex.ts ***!
  129970. \***********************************/
  129971. /*! exports provided: defaultVertexShader */
  129972. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  129973. "use strict";
  129974. __webpack_require__.r(__webpack_exports__);
  129975. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexShader", function() { return defaultVertexShader; });
  129976. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  129977. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  129978. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  129979. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  129980. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  129981. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  129982. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  129983. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  129984. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  129985. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  129986. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  129987. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  129988. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  129989. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  129990. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  129991. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  129992. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  129993. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  129994. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  129995. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  129996. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  129997. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  129998. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  129999. var name = 'defaultVertexShader';
  130000. var shader = "#include<__decl__defaultVertex>\n\n#define CUSTOM_VERTEX_BEGIN\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nvarying vec2 vSpecularUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n} else {\ngl_Position=viewProjectionR*finalWorld*vec4(positionUpdated,1.0);\n}\n#else\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#endif\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include<pointCloudVertex>\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}\n";
  130001. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130002. /** @hidden */
  130003. var defaultVertexShader = { name: name, shader: shader };
  130004. /***/ }),
  130005. /***/ "./Shaders/depth.fragment.ts":
  130006. /*!***********************************!*\
  130007. !*** ./Shaders/depth.fragment.ts ***!
  130008. \***********************************/
  130009. /*! exports provided: depthPixelShader */
  130010. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130011. "use strict";
  130012. __webpack_require__.r(__webpack_exports__);
  130013. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  130014. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130015. var name = 'depthPixelShader';
  130016. 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}";
  130017. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130018. /** @hidden */
  130019. var depthPixelShader = { name: name, shader: shader };
  130020. /***/ }),
  130021. /***/ "./Shaders/depth.vertex.ts":
  130022. /*!*********************************!*\
  130023. !*** ./Shaders/depth.vertex.ts ***!
  130024. \*********************************/
  130025. /*! exports provided: depthVertexShader */
  130026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130027. "use strict";
  130028. __webpack_require__.r(__webpack_exports__);
  130029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  130030. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130031. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130032. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130033. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130034. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130035. var name = 'depthVertexShader';
  130036. 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}";
  130037. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130038. /** @hidden */
  130039. var depthVertexShader = { name: name, shader: shader };
  130040. /***/ }),
  130041. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  130042. /*!******************************************!*\
  130043. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  130044. \******************************************/
  130045. /*! exports provided: depthBoxBlurPixelShader */
  130046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130047. "use strict";
  130048. __webpack_require__.r(__webpack_exports__);
  130049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  130050. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130051. var name = 'depthBoxBlurPixelShader';
  130052. 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}";
  130053. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130054. /** @hidden */
  130055. var depthBoxBlurPixelShader = { name: name, shader: shader };
  130056. /***/ }),
  130057. /***/ "./Shaders/depthOfField.fragment.ts":
  130058. /*!******************************************!*\
  130059. !*** ./Shaders/depthOfField.fragment.ts ***!
  130060. \******************************************/
  130061. /*! exports provided: depthOfFieldPixelShader */
  130062. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130063. "use strict";
  130064. __webpack_require__.r(__webpack_exports__);
  130065. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  130066. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130067. var name = 'depthOfFieldPixelShader';
  130068. 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";
  130069. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130070. /** @hidden */
  130071. var depthOfFieldPixelShader = { name: name, shader: shader };
  130072. /***/ }),
  130073. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  130074. /*!***********************************************!*\
  130075. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  130076. \***********************************************/
  130077. /*! exports provided: depthOfFieldMergePixelShader */
  130078. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130079. "use strict";
  130080. __webpack_require__.r(__webpack_exports__);
  130081. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  130082. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130083. var name = 'depthOfFieldMergePixelShader';
  130084. 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";
  130085. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130086. /** @hidden */
  130087. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  130088. /***/ }),
  130089. /***/ "./Shaders/displayPass.fragment.ts":
  130090. /*!*****************************************!*\
  130091. !*** ./Shaders/displayPass.fragment.ts ***!
  130092. \*****************************************/
  130093. /*! exports provided: displayPassPixelShader */
  130094. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130095. "use strict";
  130096. __webpack_require__.r(__webpack_exports__);
  130097. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  130098. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130099. var name = 'displayPassPixelShader';
  130100. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  130101. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130102. /** @hidden */
  130103. var displayPassPixelShader = { name: name, shader: shader };
  130104. /***/ }),
  130105. /***/ "./Shaders/extractHighlights.fragment.ts":
  130106. /*!***********************************************!*\
  130107. !*** ./Shaders/extractHighlights.fragment.ts ***!
  130108. \***********************************************/
  130109. /*! exports provided: extractHighlightsPixelShader */
  130110. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130111. "use strict";
  130112. __webpack_require__.r(__webpack_exports__);
  130113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  130114. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130115. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130116. var name = 'extractHighlightsPixelShader';
  130117. 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}";
  130118. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130119. /** @hidden */
  130120. var extractHighlightsPixelShader = { name: name, shader: shader };
  130121. /***/ }),
  130122. /***/ "./Shaders/filter.fragment.ts":
  130123. /*!************************************!*\
  130124. !*** ./Shaders/filter.fragment.ts ***!
  130125. \************************************/
  130126. /*! exports provided: filterPixelShader */
  130127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130128. "use strict";
  130129. __webpack_require__.r(__webpack_exports__);
  130130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterPixelShader", function() { return filterPixelShader; });
  130131. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130132. var name = 'filterPixelShader';
  130133. 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}";
  130134. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130135. /** @hidden */
  130136. var filterPixelShader = { name: name, shader: shader };
  130137. /***/ }),
  130138. /***/ "./Shaders/fxaa.fragment.ts":
  130139. /*!**********************************!*\
  130140. !*** ./Shaders/fxaa.fragment.ts ***!
  130141. \**********************************/
  130142. /*! exports provided: fxaaPixelShader */
  130143. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130144. "use strict";
  130145. __webpack_require__.r(__webpack_exports__);
  130146. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  130147. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130148. var name = 'fxaaPixelShader';
  130149. 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}";
  130150. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130151. /** @hidden */
  130152. var fxaaPixelShader = { name: name, shader: shader };
  130153. /***/ }),
  130154. /***/ "./Shaders/fxaa.vertex.ts":
  130155. /*!********************************!*\
  130156. !*** ./Shaders/fxaa.vertex.ts ***!
  130157. \********************************/
  130158. /*! exports provided: fxaaVertexShader */
  130159. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130160. "use strict";
  130161. __webpack_require__.r(__webpack_exports__);
  130162. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  130163. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130164. var name = 'fxaaVertexShader';
  130165. 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}";
  130166. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130167. /** @hidden */
  130168. var fxaaVertexShader = { name: name, shader: shader };
  130169. /***/ }),
  130170. /***/ "./Shaders/geometry.fragment.ts":
  130171. /*!**************************************!*\
  130172. !*** ./Shaders/geometry.fragment.ts ***!
  130173. \**************************************/
  130174. /*! exports provided: geometryPixelShader */
  130175. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130176. "use strict";
  130177. __webpack_require__.r(__webpack_exports__);
  130178. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryPixelShader", function() { return geometryPixelShader; });
  130179. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130180. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  130181. var name = 'geometryPixelShader';
  130182. 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}";
  130183. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130184. /** @hidden */
  130185. var geometryPixelShader = { name: name, shader: shader };
  130186. /***/ }),
  130187. /***/ "./Shaders/geometry.vertex.ts":
  130188. /*!************************************!*\
  130189. !*** ./Shaders/geometry.vertex.ts ***!
  130190. \************************************/
  130191. /*! exports provided: geometryVertexShader */
  130192. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130193. "use strict";
  130194. __webpack_require__.r(__webpack_exports__);
  130195. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  130196. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130197. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130198. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130199. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130200. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130201. var name = 'geometryVertexShader';
  130202. 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}";
  130203. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130204. /** @hidden */
  130205. var geometryVertexShader = { name: name, shader: shader };
  130206. /***/ }),
  130207. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  130208. /*!*************************************************!*\
  130209. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  130210. \*************************************************/
  130211. /*! exports provided: glowBlurPostProcessPixelShader */
  130212. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130213. "use strict";
  130214. __webpack_require__.r(__webpack_exports__);
  130215. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  130216. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130217. var name = 'glowBlurPostProcessPixelShader';
  130218. 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}";
  130219. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130220. /** @hidden */
  130221. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  130222. /***/ }),
  130223. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  130224. /*!***********************************************!*\
  130225. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  130226. \***********************************************/
  130227. /*! exports provided: glowMapGenerationPixelShader */
  130228. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130229. "use strict";
  130230. __webpack_require__.r(__webpack_exports__);
  130231. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  130232. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130233. var name = 'glowMapGenerationPixelShader';
  130234. 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}";
  130235. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130236. /** @hidden */
  130237. var glowMapGenerationPixelShader = { name: name, shader: shader };
  130238. /***/ }),
  130239. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  130240. /*!*********************************************!*\
  130241. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  130242. \*********************************************/
  130243. /*! exports provided: glowMapGenerationVertexShader */
  130244. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130245. "use strict";
  130246. __webpack_require__.r(__webpack_exports__);
  130247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  130248. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130249. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130250. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  130251. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  130252. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130253. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  130254. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130255. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130256. var name = 'glowMapGenerationVertexShader';
  130257. 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}";
  130258. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130259. /** @hidden */
  130260. var glowMapGenerationVertexShader = { name: name, shader: shader };
  130261. /***/ }),
  130262. /***/ "./Shaders/glowMapMerge.fragment.ts":
  130263. /*!******************************************!*\
  130264. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  130265. \******************************************/
  130266. /*! exports provided: glowMapMergePixelShader */
  130267. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130268. "use strict";
  130269. __webpack_require__.r(__webpack_exports__);
  130270. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  130271. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130272. var name = 'glowMapMergePixelShader';
  130273. 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}";
  130274. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130275. /** @hidden */
  130276. var glowMapMergePixelShader = { name: name, shader: shader };
  130277. /***/ }),
  130278. /***/ "./Shaders/glowMapMerge.vertex.ts":
  130279. /*!****************************************!*\
  130280. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  130281. \****************************************/
  130282. /*! exports provided: glowMapMergeVertexShader */
  130283. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130284. "use strict";
  130285. __webpack_require__.r(__webpack_exports__);
  130286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  130287. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130288. var name = 'glowMapMergeVertexShader';
  130289. 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}";
  130290. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130291. /** @hidden */
  130292. var glowMapMergeVertexShader = { name: name, shader: shader };
  130293. /***/ }),
  130294. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  130295. /*!************************************************!*\
  130296. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  130297. \************************************************/
  130298. /*! exports provided: gpuRenderParticlesPixelShader */
  130299. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130300. "use strict";
  130301. __webpack_require__.r(__webpack_exports__);
  130302. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  130303. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130304. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  130305. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  130306. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130307. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  130308. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  130309. var name = 'gpuRenderParticlesPixelShader';
  130310. 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";
  130311. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130312. /** @hidden */
  130313. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  130314. /***/ }),
  130315. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  130316. /*!**********************************************!*\
  130317. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  130318. \**********************************************/
  130319. /*! exports provided: gpuRenderParticlesVertexShader */
  130320. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130321. "use strict";
  130322. __webpack_require__.r(__webpack_exports__);
  130323. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  130324. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130325. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  130326. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  130327. var name = 'gpuRenderParticlesVertexShader';
  130328. 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}";
  130329. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130330. /** @hidden */
  130331. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  130332. /***/ }),
  130333. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  130334. /*!************************************************!*\
  130335. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  130336. \************************************************/
  130337. /*! exports provided: gpuUpdateParticlesPixelShader */
  130338. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130339. "use strict";
  130340. __webpack_require__.r(__webpack_exports__);
  130341. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  130342. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130343. var name = 'gpuUpdateParticlesPixelShader';
  130344. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  130345. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130346. /** @hidden */
  130347. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  130348. /***/ }),
  130349. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  130350. /*!**********************************************!*\
  130351. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  130352. \**********************************************/
  130353. /*! exports provided: gpuUpdateParticlesVertexShader */
  130354. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130355. "use strict";
  130356. __webpack_require__.r(__webpack_exports__);
  130357. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  130358. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130359. var name = 'gpuUpdateParticlesVertexShader';
  130360. 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}";
  130361. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130362. /** @hidden */
  130363. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  130364. /***/ }),
  130365. /***/ "./Shaders/grain.fragment.ts":
  130366. /*!***********************************!*\
  130367. !*** ./Shaders/grain.fragment.ts ***!
  130368. \***********************************/
  130369. /*! exports provided: grainPixelShader */
  130370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130371. "use strict";
  130372. __webpack_require__.r(__webpack_exports__);
  130373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  130374. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130375. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130376. var name = 'grainPixelShader';
  130377. 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}";
  130378. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130379. /** @hidden */
  130380. var grainPixelShader = { name: name, shader: shader };
  130381. /***/ }),
  130382. /***/ "./Shaders/highlights.fragment.ts":
  130383. /*!****************************************!*\
  130384. !*** ./Shaders/highlights.fragment.ts ***!
  130385. \****************************************/
  130386. /*! exports provided: highlightsPixelShader */
  130387. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130388. "use strict";
  130389. __webpack_require__.r(__webpack_exports__);
  130390. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  130391. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130392. var name = 'highlightsPixelShader';
  130393. 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}";
  130394. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130395. /** @hidden */
  130396. var highlightsPixelShader = { name: name, shader: shader };
  130397. /***/ }),
  130398. /***/ "./Shaders/imageProcessing.fragment.ts":
  130399. /*!*********************************************!*\
  130400. !*** ./Shaders/imageProcessing.fragment.ts ***!
  130401. \*********************************************/
  130402. /*! exports provided: imageProcessingPixelShader */
  130403. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130404. "use strict";
  130405. __webpack_require__.r(__webpack_exports__);
  130406. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  130407. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130408. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  130409. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130410. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  130411. var name = 'imageProcessingPixelShader';
  130412. 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}";
  130413. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130414. /** @hidden */
  130415. var imageProcessingPixelShader = { name: name, shader: shader };
  130416. /***/ }),
  130417. /***/ "./Shaders/kernelBlur.fragment.ts":
  130418. /*!****************************************!*\
  130419. !*** ./Shaders/kernelBlur.fragment.ts ***!
  130420. \****************************************/
  130421. /*! exports provided: kernelBlurPixelShader */
  130422. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130423. "use strict";
  130424. __webpack_require__.r(__webpack_exports__);
  130425. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  130426. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130427. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  130428. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  130429. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  130430. var name = 'kernelBlurPixelShader';
  130431. 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}";
  130432. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130433. /** @hidden */
  130434. var kernelBlurPixelShader = { name: name, shader: shader };
  130435. /***/ }),
  130436. /***/ "./Shaders/kernelBlur.vertex.ts":
  130437. /*!**************************************!*\
  130438. !*** ./Shaders/kernelBlur.vertex.ts ***!
  130439. \**************************************/
  130440. /*! exports provided: kernelBlurVertexShader */
  130441. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130442. "use strict";
  130443. __webpack_require__.r(__webpack_exports__);
  130444. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  130445. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130446. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  130447. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  130448. var name = 'kernelBlurVertexShader';
  130449. 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}";
  130450. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130451. /** @hidden */
  130452. var kernelBlurVertexShader = { name: name, shader: shader };
  130453. /***/ }),
  130454. /***/ "./Shaders/layer.fragment.ts":
  130455. /*!***********************************!*\
  130456. !*** ./Shaders/layer.fragment.ts ***!
  130457. \***********************************/
  130458. /*! exports provided: layerPixelShader */
  130459. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130460. "use strict";
  130461. __webpack_require__.r(__webpack_exports__);
  130462. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  130463. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130464. var name = 'layerPixelShader';
  130465. 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}";
  130466. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130467. /** @hidden */
  130468. var layerPixelShader = { name: name, shader: shader };
  130469. /***/ }),
  130470. /***/ "./Shaders/layer.vertex.ts":
  130471. /*!*********************************!*\
  130472. !*** ./Shaders/layer.vertex.ts ***!
  130473. \*********************************/
  130474. /*! exports provided: layerVertexShader */
  130475. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130476. "use strict";
  130477. __webpack_require__.r(__webpack_exports__);
  130478. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  130479. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130480. var name = 'layerVertexShader';
  130481. 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}";
  130482. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130483. /** @hidden */
  130484. var layerVertexShader = { name: name, shader: shader };
  130485. /***/ }),
  130486. /***/ "./Shaders/lensFlare.fragment.ts":
  130487. /*!***************************************!*\
  130488. !*** ./Shaders/lensFlare.fragment.ts ***!
  130489. \***************************************/
  130490. /*! exports provided: lensFlarePixelShader */
  130491. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130492. "use strict";
  130493. __webpack_require__.r(__webpack_exports__);
  130494. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  130495. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130496. var name = 'lensFlarePixelShader';
  130497. 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}";
  130498. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130499. /** @hidden */
  130500. var lensFlarePixelShader = { name: name, shader: shader };
  130501. /***/ }),
  130502. /***/ "./Shaders/lensFlare.vertex.ts":
  130503. /*!*************************************!*\
  130504. !*** ./Shaders/lensFlare.vertex.ts ***!
  130505. \*************************************/
  130506. /*! exports provided: lensFlareVertexShader */
  130507. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130508. "use strict";
  130509. __webpack_require__.r(__webpack_exports__);
  130510. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  130511. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130512. var name = 'lensFlareVertexShader';
  130513. 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}";
  130514. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130515. /** @hidden */
  130516. var lensFlareVertexShader = { name: name, shader: shader };
  130517. /***/ }),
  130518. /***/ "./Shaders/lensHighlights.fragment.ts":
  130519. /*!********************************************!*\
  130520. !*** ./Shaders/lensHighlights.fragment.ts ***!
  130521. \********************************************/
  130522. /*! exports provided: lensHighlightsPixelShader */
  130523. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130524. "use strict";
  130525. __webpack_require__.r(__webpack_exports__);
  130526. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  130527. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130528. var name = 'lensHighlightsPixelShader';
  130529. 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}";
  130530. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130531. /** @hidden */
  130532. var lensHighlightsPixelShader = { name: name, shader: shader };
  130533. /***/ }),
  130534. /***/ "./Shaders/line.fragment.ts":
  130535. /*!**********************************!*\
  130536. !*** ./Shaders/line.fragment.ts ***!
  130537. \**********************************/
  130538. /*! exports provided: linePixelShader */
  130539. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130540. "use strict";
  130541. __webpack_require__.r(__webpack_exports__);
  130542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  130543. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130544. var name = 'linePixelShader';
  130545. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  130546. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130547. /** @hidden */
  130548. var linePixelShader = { name: name, shader: shader };
  130549. /***/ }),
  130550. /***/ "./Shaders/line.vertex.ts":
  130551. /*!********************************!*\
  130552. !*** ./Shaders/line.vertex.ts ***!
  130553. \********************************/
  130554. /*! exports provided: lineVertexShader */
  130555. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130556. "use strict";
  130557. __webpack_require__.r(__webpack_exports__);
  130558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  130559. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130560. var name = 'lineVertexShader';
  130561. 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}";
  130562. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130563. /** @hidden */
  130564. var lineVertexShader = { name: name, shader: shader };
  130565. /***/ }),
  130566. /***/ "./Shaders/motionBlur.fragment.ts":
  130567. /*!****************************************!*\
  130568. !*** ./Shaders/motionBlur.fragment.ts ***!
  130569. \****************************************/
  130570. /*! exports provided: motionBlurPixelShader */
  130571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130572. "use strict";
  130573. __webpack_require__.r(__webpack_exports__);
  130574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  130575. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130576. var name = 'motionBlurPixelShader';
  130577. 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";
  130578. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130579. /** @hidden */
  130580. var motionBlurPixelShader = { name: name, shader: shader };
  130581. /***/ }),
  130582. /***/ "./Shaders/noise.fragment.ts":
  130583. /*!***********************************!*\
  130584. !*** ./Shaders/noise.fragment.ts ***!
  130585. \***********************************/
  130586. /*! exports provided: noisePixelShader */
  130587. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130588. "use strict";
  130589. __webpack_require__.r(__webpack_exports__);
  130590. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noisePixelShader", function() { return noisePixelShader; });
  130591. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130592. var name = 'noisePixelShader';
  130593. 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";
  130594. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130595. /** @hidden */
  130596. var noisePixelShader = { name: name, shader: shader };
  130597. /***/ }),
  130598. /***/ "./Shaders/outline.fragment.ts":
  130599. /*!*************************************!*\
  130600. !*** ./Shaders/outline.fragment.ts ***!
  130601. \*************************************/
  130602. /*! exports provided: outlinePixelShader */
  130603. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130604. "use strict";
  130605. __webpack_require__.r(__webpack_exports__);
  130606. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlinePixelShader", function() { return outlinePixelShader; });
  130607. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130608. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  130609. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  130610. var name = 'outlinePixelShader';
  130611. 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}";
  130612. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130613. /** @hidden */
  130614. var outlinePixelShader = { name: name, shader: shader };
  130615. /***/ }),
  130616. /***/ "./Shaders/outline.vertex.ts":
  130617. /*!***********************************!*\
  130618. !*** ./Shaders/outline.vertex.ts ***!
  130619. \***********************************/
  130620. /*! exports provided: outlineVertexShader */
  130621. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130622. "use strict";
  130623. __webpack_require__.r(__webpack_exports__);
  130624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  130625. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130626. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130627. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130628. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  130629. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130630. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130631. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  130632. var name = 'outlineVertexShader';
  130633. 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";
  130634. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130635. /** @hidden */
  130636. var outlineVertexShader = { name: name, shader: shader };
  130637. /***/ }),
  130638. /***/ "./Shaders/particles.fragment.ts":
  130639. /*!***************************************!*\
  130640. !*** ./Shaders/particles.fragment.ts ***!
  130641. \***************************************/
  130642. /*! exports provided: particlesPixelShader */
  130643. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130644. "use strict";
  130645. __webpack_require__.r(__webpack_exports__);
  130646. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  130647. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130648. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  130649. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  130650. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130651. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  130652. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  130653. var name = 'particlesPixelShader';
  130654. 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}";
  130655. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130656. /** @hidden */
  130657. var particlesPixelShader = { name: name, shader: shader };
  130658. /***/ }),
  130659. /***/ "./Shaders/particles.vertex.ts":
  130660. /*!*************************************!*\
  130661. !*** ./Shaders/particles.vertex.ts ***!
  130662. \*************************************/
  130663. /*! exports provided: particlesVertexShader */
  130664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130665. "use strict";
  130666. __webpack_require__.r(__webpack_exports__);
  130667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesVertexShader", function() { return particlesVertexShader; });
  130668. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130669. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  130670. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  130671. var name = 'particlesVertexShader';
  130672. 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}";
  130673. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130674. /** @hidden */
  130675. var particlesVertexShader = { name: name, shader: shader };
  130676. /***/ }),
  130677. /***/ "./Shaders/pass.fragment.ts":
  130678. /*!**********************************!*\
  130679. !*** ./Shaders/pass.fragment.ts ***!
  130680. \**********************************/
  130681. /*! exports provided: passPixelShader */
  130682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130683. "use strict";
  130684. __webpack_require__.r(__webpack_exports__);
  130685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  130686. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130687. var name = 'passPixelShader';
  130688. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  130689. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130690. /** @hidden */
  130691. var passPixelShader = { name: name, shader: shader };
  130692. /***/ }),
  130693. /***/ "./Shaders/passCube.fragment.ts":
  130694. /*!**************************************!*\
  130695. !*** ./Shaders/passCube.fragment.ts ***!
  130696. \**************************************/
  130697. /*! exports provided: passCubePixelShader */
  130698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130699. "use strict";
  130700. __webpack_require__.r(__webpack_exports__);
  130701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  130702. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130703. var name = 'passCubePixelShader';
  130704. 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}";
  130705. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130706. /** @hidden */
  130707. var passCubePixelShader = { name: name, shader: shader };
  130708. /***/ }),
  130709. /***/ "./Shaders/pbr.fragment.ts":
  130710. /*!*********************************!*\
  130711. !*** ./Shaders/pbr.fragment.ts ***!
  130712. \*********************************/
  130713. /*! exports provided: pbrPixelShader */
  130714. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130715. "use strict";
  130716. __webpack_require__.r(__webpack_exports__);
  130717. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  130718. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130719. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  130720. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  130721. /* harmony import */ var _ShadersInclude_pbrFragmentExtraDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentExtraDeclaration */ "./Shaders/ShadersInclude/pbrFragmentExtraDeclaration.ts");
  130722. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  130723. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  130724. /* harmony import */ var _ShadersInclude_pbrFragmentSamplersDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentSamplersDeclaration */ "./Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.ts");
  130725. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  130726. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  130727. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  130728. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  130729. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130730. /* harmony import */ var _ShadersInclude_pbrHelperFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrHelperFunctions */ "./Shaders/ShadersInclude/pbrHelperFunctions.ts");
  130731. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  130732. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  130733. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  130734. /* harmony import */ var _ShadersInclude_pbrDirectLightingSetupFunctions__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingSetupFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingSetupFunctions.ts");
  130735. /* harmony import */ var _ShadersInclude_pbrDirectLightingFalloffFunctions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingFalloffFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions.ts");
  130736. /* harmony import */ var _ShadersInclude_pbrBRDFFunctions__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/pbrBRDFFunctions */ "./Shaders/ShadersInclude/pbrBRDFFunctions.ts");
  130737. /* harmony import */ var _ShadersInclude_pbrDirectLightingFunctions__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/pbrDirectLightingFunctions */ "./Shaders/ShadersInclude/pbrDirectLightingFunctions.ts");
  130738. /* harmony import */ var _ShadersInclude_pbrIBLFunctions__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/pbrIBLFunctions */ "./Shaders/ShadersInclude/pbrIBLFunctions.ts");
  130739. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  130740. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  130741. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  130742. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  130743. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  130744. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  130745. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  130746. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  130747. /* harmony import */ var _ShadersInclude_pbrDebug__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./ShadersInclude/pbrDebug */ "./Shaders/ShadersInclude/pbrDebug.ts");
  130748. var name = 'pbrPixelShader';
  130749. var shader = "#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\n#include<__decl__pbrFragment>\n#include<pbrFragmentExtraDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<pbrFragmentSamplersDeclaration>\n#include<imageProcessingDeclaration>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n\n#include<helperFunctions>\n#include<pbrHelperFunctions>\n#include<imageProcessingFunctions>\n#include<shadowsFragmentFunctions>\n#include<harmonicsFunctions>\n#include<pbrDirectLightingSetupFunctions>\n#include<pbrDirectLightingFalloffFunctions>\n#include<pbrBRDFFunctions>\n#include<pbrDirectLightingFunctions>\n#include<pbrIBLFunctions>\n#include<bumpFragmentFunctions>\n#ifdef REFLECTION\n#include<reflectionFunction>\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\n\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\n\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\n#ifdef CLEARCOAT\n\nvec3 clearCoatNormalW=normalW;\n#endif\n#include<bumpFragment>\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nnormalW*=sign(dot(normalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\nsurfaceAlbedo*=vAlbedoInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALBEDO\n\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\n#include<depthPrePass>\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\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 SS_REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\n#ifdef ANISOTROPIC\nvec3 refractionVector=refract(-viewDirectionW,anisotropicNormal,vRefractionInfos.y);\n#else\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#endif\n#ifdef SS_REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef SS_REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#endif\n#ifdef SS_LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef SS_LODINREFRACTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\n#else\nfloat requestedRefractionLOD=refractionLOD;\n#endif\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);\n#else\nfloat lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);\nif(lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords),\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n}else{\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords),\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef SS_RGBDREFRACTION\nenvironmentRefraction.rgb=fromRGBD(environmentRefraction);\n#endif\n#ifdef SS_GAMMAREFRACTION\nenvironmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);\n#endif\n\nenvironmentRefraction.rgb*=vRefractionInfos.x;\n#endif\n\n#ifdef REFLECTION\nvec4 environmentRadiance=vec4(0.,0.,0.,0.);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\n#ifdef ANISOTROPIC\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicNormal);\n#else\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,requestedReflectionLOD);\n#else\nfloat lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 environmentSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSpecularMid,\nlodReflectionNormalizedDoubled\n);\n}else{\nenvironmentRadiance=mix(\nenvironmentSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\n\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\n#ifdef ANISOTROPIC\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicNormal,0)).xyz;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\nenvironmentIrradiance=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\nsheenIntensity*=(1.-reflectance);\n\nsheenColor*=sheenIntensity;\n#endif\n\n#if defined(REFLECTION)\nfloat sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);\n#ifdef SPECULARAA\n\nsheenAlphaG+=AARoughnessFactors.y;\n#endif\nvec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);\n\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat sheenReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,sheenAlphaG,NdotVUnclamped);\n#else\nfloat sheenReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,sheenAlphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nsheenReflectionLOD=sheenReflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nenvironmentSheenRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,sheenReflectionLOD);\n#else\nfloat lodSheenReflectionNormalized=saturate(sheenReflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodSheenReflectionNormalizedDoubled=lodSheenReflectionNormalized*2.0;\nvec4 environmentSheenMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodSheenReflectionNormalizedDoubled<1.0){\nenvironmentSheenRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSheenMid,\nlodSheenReflectionNormalizedDoubled\n);\n}else{\nenvironmentSheenRadiance=mix(\nenvironmentSheenMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodSheenReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentSheenRadiance.rgb=fromRGBD(environmentSheenRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentSheenRadiance.rgb=toLinearSpace(environmentSheenRadiance.rgb);\n#endif\n\nenvironmentSheenRadiance.rgb*=vReflectionInfos.x;\nenvironmentSheenRadiance.rgb*=vReflectionColor.rgb;\n#endif\n#endif\n\n#ifdef CLEARCOAT\n\nfloat clearCoatIntensity=vClearCoatParams.x;\nfloat clearCoatRoughness=vClearCoatParams.y;\n#ifdef CLEARCOAT_TEXTURE\nvec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;\nclearCoatIntensity*=clearCoatMapData.x;\nclearCoatRoughness*=clearCoatMapData.y;\n#endif\n#ifdef CLEARCOAT_TINT\nvec3 clearCoatColor=vClearCoatTintParams.rgb;\nfloat clearCoatThickness=vClearCoatTintParams.a;\n#ifdef CLEARCOAT_TINT_TEXTURE\nvec4 clearCoatTintMapData=texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset);\nclearCoatColor*=toLinearSpace(clearCoatTintMapData.rgb);\nclearCoatThickness*=clearCoatTintMapData.a;\n#endif\nclearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);\n#endif\n\n\n\n\nvec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);\nspecularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);\n#ifdef CLEARCOAT_BUMP\n#ifdef NORMALXYSCALE\nfloat clearCoatNormalScale=1.0;\n#else\nfloat clearCoatNormalScale=vClearCoatBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBNClearCoat=vTBN;\n#else\nmat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,vClearCoatBumpUV,vClearCoatTangentSpaceParams);\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nclearCoatNormalW=normalize(texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset).xyz*2.0-1.0);\nclearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);\n#else\nclearCoatNormalW=perturbNormal(TBN,vClearCoatBumpUV+uvOffset,clearCoatBumpSampler,vClearCoatBumpInfos.y);\n#endif\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nclearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nclearCoatNormalW=gl_FrontFacing ? clearCoatNormalW : -clearCoatNormalW;\n#endif\n\nvec2 clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);\n\nfloat clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);\n\nfloat clearCoatNdotV=absEps(clearCoatNdotVUnclamped);\n\n#if defined(REFLECTION)\nfloat clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\n#ifdef SPECULARAA\n\nclearCoatAlphaG+=clearCoatAARoughnessFactors.y;\n#endif\nvec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);\nvec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nclearCoatReflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 clearCoatReflectionCoords=clearCoatReflectionVector;\n#else\nvec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nclearCoatReflectionCoords/=clearCoatReflectionVector.z;\n#endif\nclearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat clearCoatReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,clearCoatAlphaG,clearCoatNdotVUnclamped);\n#else\nfloat clearCoatReflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,clearCoatAlphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nclearCoatReflectionLOD=clearCoatReflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nfloat requestedClearCoatReflectionLOD=clearCoatReflectionLOD;\nenvironmentClearCoatRadiance=sampleReflectionLod(reflectionSampler,clearCoatReflectionCoords,requestedClearCoatReflectionLOD);\n#else\nfloat lodClearCoatReflectionNormalized=saturate(clearCoatReflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodClearCoatReflectionNormalizedDoubled=lodClearCoatReflectionNormalized*2.0;\nvec4 environmentClearCoatMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodClearCoatReflectionNormalizedDoubled<1.0){\nenvironmentClearCoatRadiance=mix(\nsampleReflection(reflectionSamplerHigh,clearCoatReflectionCoords),\nenvironmentClearCoatMid,\nlodClearCoatReflectionNormalizedDoubled\n);\n}else{\nenvironmentClearCoatRadiance=mix(\nenvironmentClearCoatMid,\nsampleReflection(reflectionSamplerLow,clearCoatReflectionCoords),\nlodClearCoatReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentClearCoatRadiance.rgb=fromRGBD(environmentClearCoatRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentClearCoatRadiance.rgb=toLinearSpace(environmentClearCoatRadiance.rgb);\n#endif\n#ifdef CLEARCOAT_TINT\n\nvec3 clearCoatVRefract=-refract(vPositionW,clearCoatNormalW,vClearCoatRefractionParams.y);\n\nfloat clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));\nvec3 absorption=vec3(0.);\n#endif\n\nenvironmentClearCoatRadiance.rgb*=vReflectionInfos.x;\nenvironmentClearCoatRadiance.rgb*=vReflectionColor.rgb;\n#endif\n#endif\n\n#if defined(ENVIRONMENTBRDF)\n\nvec3 environmentBrdf=getBRDFLookup(NdotV,roughness,environmentBrdfSampler);\n#ifdef MS_BRDF_ENERGY_CONSERVATION\nvec3 energyConservationFactor=getEnergyConservationFactor(specularEnvironmentR0,environmentBrdf);\n#endif\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nfloat refractionIntensity=vSubSurfaceIntensity.x;\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\nrefractionIntensity*=(1.0-alpha);\n\nalpha=1.0;\n#endif\n#endif\n#ifdef SS_TRANSLUCENCY\nfloat translucencyIntensity=vSubSurfaceIntensity.y;\n#endif\n#ifdef SS_SCATTERING\nfloat scatteringIntensity=vSubSurfaceIntensity.z;\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nvec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset);\nfloat thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;\n#ifdef SS_MASK_FROM_THICKNESS_TEXTURE\n#ifdef SS_REFRACTION\nrefractionIntensity*=thicknessMap.g;\n#endif\n#ifdef SS_TRANSLUCENCY\ntranslucencyIntensity*=thicknessMap.b;\n#endif\n#ifdef SS_SCATTERING\nscatteringIntensity*=thicknessMap.a;\n#endif\n#endif\n#else\nfloat thickness=vThicknessParam.y;\n#endif\n#ifdef SS_TRANSLUCENCY\nthickness=maxEps(thickness);\nvec3 transmittance=transmittanceBRDF_Burley(vTintColor.rgb,vDiffusionDistance,thickness);\ntransmittance*=translucencyIntensity;\n#endif\n#endif\n\n\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef CLEARCOAT\nvec3 clearCoatBase=vec3(0.,0.,0.);\n#endif\n#ifdef SHEEN\nvec3 sheenBase=vec3(0.,0.,0.);\n#endif\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb;\n#ifdef GAMMALIGHTMAP\nlightmapColor=toLinearSpace(lightmapColor);\n#endif\nlightmapColor*=vLightmapInfos.y;\n#endif\n\npreLightingInfo preInfo;\nlightingInfo info;\nfloat shadow=1.;\n#include<lightFragment>[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\nvec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(specularEnvironmentR0,environmentBrdf);\n#ifdef RADIANCEOCCLUSION\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#if defined(SHEEN) && defined(REFLECTION)\nvec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentBrdf);\n#ifdef RADIANCEOCCLUSION\nsheenEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nsheenEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#endif\n\n#ifdef CLEARCOAT\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness,environmentBrdfSampler);\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);\n#ifdef RADIANCEOCCLUSION\nfloat clearCoatSeo=environmentRadianceOcclusion(ambientMonochrome,clearCoatNdotVUnclamped);\nclearCoatEnvironmentReflectance*=clearCoatSeo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW);\nclearCoatEnvironmentReflectance*=clearCoatEho;\n#endif\n#endif\n#endif\n#else\n\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));\n#endif\nclearCoatEnvironmentReflectance*=clearCoatIntensity;\n#ifdef CLEARCOAT_TINT\n\nabsorption=computeClearCoatAbsorption(clearCoatNdotVRefract,clearCoatNdotVRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\n#ifdef REFLECTION\nenvironmentIrradiance*=absorption;\n#endif\n#ifdef SHEEN\nsheenEnvironmentReflectance*=absorption;\n#endif\nspecularEnvironmentReflectance*=absorption;\n#endif\n\nfloat fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnelIBLClearCoat*=clearCoatIntensity;\nfloat conservationFactor=(1.-fresnelIBLClearCoat);\n#ifdef REFLECTION\nenvironmentIrradiance*=conservationFactor;\n#endif\n#ifdef SHEEN\nsheenEnvironmentReflectance*=(conservationFactor*conservationFactor);\n#endif\nspecularEnvironmentReflectance*=(conservationFactor*conservationFactor);\n#endif\n\n#ifdef SS_REFRACTION\nvec3 refractionTransmittance=vec3(refractionIntensity);\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nvec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);\n\n\n\n\n\nrefractionTransmittance*=cocaLambert(volumeAlbedo,thickness);\n#elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)\n\nfloat maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);\nvec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo);\n\nenvironmentRefraction.rgb*=volumeAlbedo;\n#else\n\n#endif\n\nsurfaceAlbedo*=(1.-refractionIntensity);\n\nenvironmentIrradiance*=(1.-refractionIntensity);\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity);\n\nrefractionTransmittance*=1.0-specularEnvironmentReflectance;\n#endif\n\n#if defined(REFLECTION) && defined(USESPHERICALFROMREFLECTIONMAP) && defined(SS_TRANSLUCENCY)\n#if defined(USESPHERICALINVERTEX)\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\n#endif\nvec3 refractionIrradiance=environmentIrradianceJones(-irradianceVector);\nrefractionIrradiance*=transmittance;\n#endif\n\n\n\n#ifndef METALLICWORKFLOW\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n#endif\n\n#ifdef REFLECTION\nvec3 finalIrradiance=environmentIrradiance;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(SS_TRANSLUCENCY)\nfinalIrradiance+=refractionIrradiance;\n#endif\nfinalIrradiance*=surfaceAlbedo.rgb;\n#endif\n\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\n\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalSpecularScaled*=energyConservationFactor;\n#endif\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance.rgb;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalRadianceScaled*=energyConservationFactor;\n#endif\n#endif\n\n#ifdef SS_REFRACTION\nvec3 finalRefraction=environmentRefraction.rgb;\nfinalRefraction*=refractionTransmittance;\n#endif\n\n#ifdef CLEARCOAT\nvec3 finalClearCoat=clearCoatBase;\nfinalClearCoat=max(finalClearCoat,0.0);\n\nvec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalClearCoatScaled*=energyConservationFactor;\n#endif\n\n#ifdef REFLECTION\nvec3 finalClearCoatRadiance=environmentClearCoatRadiance.rgb;\nfinalClearCoatRadiance*=clearCoatEnvironmentReflectance;\n\nvec3 finalClearCoatRadianceScaled=finalClearCoatRadiance*vLightingIntensity.z;\n#endif\n#ifdef SS_REFRACTION\nfinalRefraction*=(conservationFactor*conservationFactor);\n#ifdef CLEARCOAT_TINT\nfinalRefraction*=absorption;\n#endif\n#endif\n#endif\n\n#ifdef SHEEN\nvec3 finalSheen=sheenBase*sheenColor;\nfinalSheen=max(finalSheen,0.0);\nvec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;\n\n\n\n\n\n#ifdef REFLECTION\nvec3 finalSheenRadiance=environmentSheenRadiance.rgb;\nfinalSheenRadiance*=sheenEnvironmentReflectance;\n\nvec3 finalSheenRadianceScaled=finalSheenRadiance*vLightingIntensity.z;\n#endif\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#if defined(CLEARCOAT)\nluminanceOverAlpha+=getLuminance(finalClearCoatRadianceScaled);\n#endif\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalClearCoatScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);\n#endif\n#endif\n#endif\n\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n\nvec3 finalAmbient=vAmbientColor;\nfinalAmbient*=surfaceAlbedo.rgb;\n\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\nfinalEmissive*=vEmissiveInfos.y;\n#endif\n\n#ifdef AMBIENT\nvec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),ambientOcclusionColor,vAmbientInfos.w);\n#else\nvec3 ambientOcclusionForDirectDiffuse=ambientOcclusionColor;\n#endif\n\n\n\nvec4 finalColor=vec4(\nfinalAmbient*ambientOcclusionColor +\nfinalDiffuse*ambientOcclusionForDirectDiffuse*vLightingIntensity.x +\n#ifndef UNLIT\n#ifdef REFLECTION\nfinalIrradiance*ambientOcclusionColor*vLightingIntensity.z +\n#endif\n#ifdef SPECULARTERM\n\n\nfinalSpecularScaled +\n#endif\n#ifdef CLEARCOAT\n\n\nfinalClearCoatScaled +\n#endif\n#ifdef SHEEN\n\n\nfinalSheenScaled +\n#endif\n#ifdef REFLECTION\n\n\nfinalRadianceScaled +\n#ifdef CLEARCOAT\n\n\nfinalClearCoatRadianceScaled +\n#endif\n#ifdef SHEEN\n\n\nfinalSheenRadianceScaled +\n#endif\n#endif\n#ifdef SS_REFRACTION\nfinalRefraction*vLightingIntensity.z +\n#endif\n#endif\nfinalEmissive*vLightingIntensity.y,\nalpha);\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\n\nfinalColor=max(finalColor,0.0);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#else\n\nfinalColor=applyImageProcessing(finalColor);\n#endif\nfinalColor.a*=visibility;\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\ngl_FragColor=finalColor;\n#include<pbrDebug>\n}\n";
  130750. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130751. /** @hidden */
  130752. var pbrPixelShader = { name: name, shader: shader };
  130753. /***/ }),
  130754. /***/ "./Shaders/pbr.vertex.ts":
  130755. /*!*******************************!*\
  130756. !*** ./Shaders/pbr.vertex.ts ***!
  130757. \*******************************/
  130758. /*! exports provided: pbrVertexShader */
  130759. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130760. "use strict";
  130761. __webpack_require__.r(__webpack_exports__);
  130762. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  130763. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130764. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  130765. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  130766. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130767. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130768. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130769. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  130770. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  130771. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  130772. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  130773. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  130774. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  130775. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  130776. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  130777. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  130778. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  130779. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130780. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130781. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  130782. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  130783. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  130784. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  130785. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  130786. var name = 'pbrVertexShader';
  130787. var shader = "precision highp float;\n#include<__decl__pbrVertex>\n#define CUSTOM_VERTEX_BEGIN\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatUV;\n#endif\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\nvarying vec2 vClearCoatBumpUV;\n#endif\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatTintUV;\n#endif\n#endif\n#ifdef SHEEN\n#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0\nvarying vec2 vSheenUV;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0\nvarying vec2 vAnisotropyUV;\n#endif\n#endif\n#ifdef SUBSURFACE\n#if defined(SS_THICKNESSANDMASK_TEXTURE) && SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 0\nvarying vec2 vThicknessUV;\n#endif\n#endif\n\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nvarying vec4 vClipSpacePosition;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#include<harmonicsFunctions>\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(positionUpdated,1.0)).xyz;\n#else\nvPositionUVW=positionUpdated;\n#endif\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n} else {\ngl_Position=viewProjectionR*finalWorld*vec4(positionUpdated,1.0);\n}\n#else\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#endif\n#if DEBUGMODE>0\nvClipSpacePosition=gl_Position;\n#endif\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=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#ifdef SUBSURFACE\n#if defined(SS_THICKNESSANDMASK_TEXTURE) && SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 0\nif (vThicknessInfos.x == 0.)\n{\nvThicknessUV=vec2(thicknessMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvThicknessUV=vec2(thicknessMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n\n#include<bumpVertex>\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}";
  130788. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130789. /** @hidden */
  130790. var pbrVertexShader = { name: name, shader: shader };
  130791. /***/ }),
  130792. /***/ "./Shaders/postprocess.vertex.ts":
  130793. /*!***************************************!*\
  130794. !*** ./Shaders/postprocess.vertex.ts ***!
  130795. \***************************************/
  130796. /*! exports provided: postprocessVertexShader */
  130797. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130798. "use strict";
  130799. __webpack_require__.r(__webpack_exports__);
  130800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  130801. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130802. var name = 'postprocessVertexShader';
  130803. 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}";
  130804. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130805. /** @hidden */
  130806. var postprocessVertexShader = { name: name, shader: shader };
  130807. /***/ }),
  130808. /***/ "./Shaders/procedural.vertex.ts":
  130809. /*!**************************************!*\
  130810. !*** ./Shaders/procedural.vertex.ts ***!
  130811. \**************************************/
  130812. /*! exports provided: proceduralVertexShader */
  130813. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130814. "use strict";
  130815. __webpack_require__.r(__webpack_exports__);
  130816. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  130817. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130818. var name = 'proceduralVertexShader';
  130819. 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}";
  130820. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130821. /** @hidden */
  130822. var proceduralVertexShader = { name: name, shader: shader };
  130823. /***/ }),
  130824. /***/ "./Shaders/refraction.fragment.ts":
  130825. /*!****************************************!*\
  130826. !*** ./Shaders/refraction.fragment.ts ***!
  130827. \****************************************/
  130828. /*! exports provided: refractionPixelShader */
  130829. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130830. "use strict";
  130831. __webpack_require__.r(__webpack_exports__);
  130832. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  130833. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130834. var name = 'refractionPixelShader';
  130835. 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}";
  130836. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130837. /** @hidden */
  130838. var refractionPixelShader = { name: name, shader: shader };
  130839. /***/ }),
  130840. /***/ "./Shaders/rgbdDecode.fragment.ts":
  130841. /*!****************************************!*\
  130842. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  130843. \****************************************/
  130844. /*! exports provided: rgbdDecodePixelShader */
  130845. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130846. "use strict";
  130847. __webpack_require__.r(__webpack_exports__);
  130848. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  130849. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130850. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130851. var name = 'rgbdDecodePixelShader';
  130852. 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}";
  130853. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130854. /** @hidden */
  130855. var rgbdDecodePixelShader = { name: name, shader: shader };
  130856. /***/ }),
  130857. /***/ "./Shaders/rgbdEncode.fragment.ts":
  130858. /*!****************************************!*\
  130859. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  130860. \****************************************/
  130861. /*! exports provided: rgbdEncodePixelShader */
  130862. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130863. "use strict";
  130864. __webpack_require__.r(__webpack_exports__);
  130865. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  130866. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130867. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130868. var name = 'rgbdEncodePixelShader';
  130869. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  130870. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130871. /** @hidden */
  130872. var rgbdEncodePixelShader = { name: name, shader: shader };
  130873. /***/ }),
  130874. /***/ "./Shaders/shadowMap.fragment.ts":
  130875. /*!***************************************!*\
  130876. !*** ./Shaders/shadowMap.fragment.ts ***!
  130877. \***************************************/
  130878. /*! exports provided: shadowMapPixelShader */
  130879. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130880. "use strict";
  130881. __webpack_require__.r(__webpack_exports__);
  130882. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  130883. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130884. var name = 'shadowMapPixelShader';
  130885. 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}";
  130886. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130887. /** @hidden */
  130888. var shadowMapPixelShader = { name: name, shader: shader };
  130889. /***/ }),
  130890. /***/ "./Shaders/shadowMap.vertex.ts":
  130891. /*!*************************************!*\
  130892. !*** ./Shaders/shadowMap.vertex.ts ***!
  130893. \*************************************/
  130894. /*! exports provided: shadowMapVertexShader */
  130895. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130896. "use strict";
  130897. __webpack_require__.r(__webpack_exports__);
  130898. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  130899. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130900. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  130901. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  130902. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  130903. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  130904. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  130905. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  130906. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  130907. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  130908. var name = 'shadowMapVertexShader';
  130909. 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}";
  130910. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130911. /** @hidden */
  130912. var shadowMapVertexShader = { name: name, shader: shader };
  130913. /***/ }),
  130914. /***/ "./Shaders/sharpen.fragment.ts":
  130915. /*!*************************************!*\
  130916. !*** ./Shaders/sharpen.fragment.ts ***!
  130917. \*************************************/
  130918. /*! exports provided: sharpenPixelShader */
  130919. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130920. "use strict";
  130921. __webpack_require__.r(__webpack_exports__);
  130922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  130923. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130924. var name = 'sharpenPixelShader';
  130925. 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}";
  130926. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130927. /** @hidden */
  130928. var sharpenPixelShader = { name: name, shader: shader };
  130929. /***/ }),
  130930. /***/ "./Shaders/sprites.fragment.ts":
  130931. /*!*************************************!*\
  130932. !*** ./Shaders/sprites.fragment.ts ***!
  130933. \*************************************/
  130934. /*! exports provided: spritesPixelShader */
  130935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130936. "use strict";
  130937. __webpack_require__.r(__webpack_exports__);
  130938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  130939. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130940. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  130941. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  130942. var name = 'spritesPixelShader';
  130943. 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}";
  130944. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130945. /** @hidden */
  130946. var spritesPixelShader = { name: name, shader: shader };
  130947. /***/ }),
  130948. /***/ "./Shaders/sprites.vertex.ts":
  130949. /*!***********************************!*\
  130950. !*** ./Shaders/sprites.vertex.ts ***!
  130951. \***********************************/
  130952. /*! exports provided: spritesVertexShader */
  130953. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130954. "use strict";
  130955. __webpack_require__.r(__webpack_exports__);
  130956. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  130957. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130958. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  130959. var name = 'spritesVertexShader';
  130960. 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}";
  130961. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130962. /** @hidden */
  130963. var spritesVertexShader = { name: name, shader: shader };
  130964. /***/ }),
  130965. /***/ "./Shaders/ssao.fragment.ts":
  130966. /*!**********************************!*\
  130967. !*** ./Shaders/ssao.fragment.ts ***!
  130968. \**********************************/
  130969. /*! exports provided: ssaoPixelShader */
  130970. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130971. "use strict";
  130972. __webpack_require__.r(__webpack_exports__);
  130973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  130974. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130975. var name = 'ssaoPixelShader';
  130976. 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";
  130977. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130978. /** @hidden */
  130979. var ssaoPixelShader = { name: name, shader: shader };
  130980. /***/ }),
  130981. /***/ "./Shaders/ssao2.fragment.ts":
  130982. /*!***********************************!*\
  130983. !*** ./Shaders/ssao2.fragment.ts ***!
  130984. \***********************************/
  130985. /*! exports provided: ssao2PixelShader */
  130986. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  130987. "use strict";
  130988. __webpack_require__.r(__webpack_exports__);
  130989. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  130990. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  130991. var name = 'ssao2PixelShader';
  130992. 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";
  130993. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  130994. /** @hidden */
  130995. var ssao2PixelShader = { name: name, shader: shader };
  130996. /***/ }),
  130997. /***/ "./Shaders/ssaoCombine.fragment.ts":
  130998. /*!*****************************************!*\
  130999. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  131000. \*****************************************/
  131001. /*! exports provided: ssaoCombinePixelShader */
  131002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131003. "use strict";
  131004. __webpack_require__.r(__webpack_exports__);
  131005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  131006. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131007. var name = 'ssaoCombinePixelShader';
  131008. 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";
  131009. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131010. /** @hidden */
  131011. var ssaoCombinePixelShader = { name: name, shader: shader };
  131012. /***/ }),
  131013. /***/ "./Shaders/standard.fragment.ts":
  131014. /*!**************************************!*\
  131015. !*** ./Shaders/standard.fragment.ts ***!
  131016. \**************************************/
  131017. /*! exports provided: standardPixelShader */
  131018. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131019. "use strict";
  131020. __webpack_require__.r(__webpack_exports__);
  131021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  131022. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131023. var name = 'standardPixelShader';
  131024. var shader = "uniform sampler2D textureSampler;\nvarying vec2 vUV;\n#if defined(PASS_POST_PROCESS)\nvoid main(void)\n{\nvec4 color=texture2D(textureSampler,vUV);\ngl_FragColor=color;\n}\n#endif\n#if defined(DOWN_SAMPLE_X4)\nuniform vec2 dsOffsets[16];\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+dsOffsets[0]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[1]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[2]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[3]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[4]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[5]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[6]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[7]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[8]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[9]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[10]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[11]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[12]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[13]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[14]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[15]);\naverage/=16.0;\ngl_FragColor=average;\n}\n#endif\n#if defined(BRIGHT_PASS)\nuniform vec2 dsOffsets[4];\nuniform float brightThreshold;\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));\naverage*=0.25;\nfloat luminance=length(average.rgb);\nif (luminance<brightThreshold) {\naverage=vec4(0.0,0.0,0.0,1.0);\n}\ngl_FragColor=average;\n}\n#endif\n#if defined(TEXTURE_ADDER)\nuniform sampler2D otherSampler;\nuniform sampler2D lensSampler;\nuniform float exposure;\nvoid main(void)\n{\nvec3 colour=texture2D(textureSampler,vUV).rgb;\ncolour*=exposure;\nvec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);\nvec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);\ncolour=retColor*retColor;\ncolour+=colour*texture2D(lensSampler,vUV).rgb;\nvec4 finalColor=vec4(colour.rgb,1.0)+texture2D(otherSampler,vUV);\ngl_FragColor=finalColor;\n}\n#endif\n#if defined(VLS)\n#define PI 3.1415926535897932384626433832795\nuniform mat4 shadowViewProjection;\nuniform mat4 lightWorld;\nuniform vec3 cameraPosition;\nuniform vec3 sunDirection;\nuniform vec3 sunColor;\nuniform vec2 depthValues;\nuniform float scatteringCoefficient;\nuniform float scatteringPower;\nuniform sampler2D shadowMapSampler;\nuniform sampler2D positionSampler;\nfloat computeScattering(float lightDotView)\n{\nfloat result=1.0-scatteringCoefficient*scatteringCoefficient;\nresult/=(4.0*PI*pow(1.0+scatteringCoefficient*scatteringCoefficient-(2.0*scatteringCoefficient)*lightDotView,1.5));\nreturn result;\n}\nvoid main(void)\n{\n\nvec3 worldPos=texture2D(positionSampler,vUV).rgb;\nvec3 startPosition=cameraPosition;\nvec3 rayVector=worldPos-startPosition;\nfloat rayLength=length(rayVector);\nvec3 rayDirection=rayVector/rayLength;\nfloat stepLength=rayLength/NB_STEPS;\nvec3 stepL=rayDirection*stepLength;\nvec3 currentPosition=startPosition;\nvec3 accumFog=vec3(0.0);\nfor (int i=0; i<int(NB_STEPS); i++)\n{\nvec4 worldInShadowCameraSpace=shadowViewProjection*vec4(currentPosition,1.0);\nfloat depthMetric=(worldInShadowCameraSpace.z+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depthMetric,0.0,1.0);\nworldInShadowCameraSpace.xyz/=worldInShadowCameraSpace.w;\nworldInShadowCameraSpace.xyz=0.5*worldInShadowCameraSpace.xyz+vec3(0.5);\nfloat shadowMapValue=texture2D(shadowMapSampler,worldInShadowCameraSpace.xy).r;\nif (shadowMapValue>shadowPixelDepth)\naccumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection));\ncurrentPosition+=stepL;\n}\naccumFog/=NB_STEPS;\nvec3 color=accumFog*scatteringPower;\ngl_FragColor=vec4(color*exp(color) ,1.0);\n}\n#endif\n#if defined(VLSMERGE)\nuniform sampler2D originalSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV);\n}\n#endif\n#if defined(LUMINANCE)\nuniform vec2 lumOffsets[4];\nvoid main()\n{\nfloat average=0.0;\nvec4 color=vec4(0.0);\nfloat maximum=-1e20;\nvec3 weight=vec3(0.299,0.587,0.114);\nfor (int i=0; i<4; i++)\n{\ncolor=texture2D(textureSampler,vUV+ lumOffsets[i]);\n\nfloat GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));\n\n#ifdef WEIGHTED_AVERAGE\nfloat GreyValue=dot(color.rgb,weight);\n#endif\n#ifdef BRIGHTNESS\nfloat GreyValue=max(color.r,max(color.g,color.b));\n#endif\n#ifdef HSL_COMPONENT\nfloat GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)));\n#endif\n#ifdef MAGNITUDE\nfloat GreyValue=length(color.rgb);\n#endif\nmaximum=max(maximum,GreyValue);\naverage+=(0.25*log(1e-5+GreyValue));\n}\naverage=exp(average);\ngl_FragColor=vec4(average,maximum,0.0,1.0);\n}\n#endif\n#if defined(LUMINANCE_DOWN_SAMPLE)\nuniform vec2 dsOffsets[9];\nuniform float halfDestPixelSize;\n#ifdef FINAL_DOWN_SAMPLER\nvec4 pack(float value) {\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(value*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\n#endif\nvoid main()\n{\nvec4 color=vec4(0.0);\nfloat average=0.0;\nfor (int i=0; i<9; i++)\n{\ncolor=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);\naverage+=color.r;\n}\naverage/=9.0;\n#ifdef FINAL_DOWN_SAMPLER\ngl_FragColor=pack(average);\n#else\ngl_FragColor=vec4(average,average,0.0,1.0);\n#endif\n}\n#endif\n#if defined(HDR)\nuniform sampler2D textureAdderSampler;\nuniform float averageLuminance;\nvoid main()\n{\nvec4 color=texture2D(textureAdderSampler,vUV);\n#ifndef AUTO_EXPOSURE\nvec4 adjustedColor=color/averageLuminance;\ncolor=adjustedColor;\ncolor.a=1.0;\n#endif\ngl_FragColor=color;\n}\n#endif\n#if defined(LENS_FLARE)\n#define GHOSTS 3\nuniform sampler2D lensColorSampler;\nuniform float strength;\nuniform float ghostDispersal;\nuniform float haloWidth;\nuniform vec2 resolution;\nuniform float distortionStrength;\nfloat hash(vec2 p)\n{\nfloat h=dot(p,vec2(127.1,311.7));\nreturn -1.0+2.0*fract(sin(h)*43758.5453123);\n}\nfloat noise(in vec2 p)\n{\nvec2 i=floor(p);\nvec2 f=fract(p);\nvec2 u=f*f*(3.0-2.0*f);\nreturn mix(mix(hash(i+vec2(0.0,0.0)),\nhash(i+vec2(1.0,0.0)),u.x),\nmix(hash(i+vec2(0.0,1.0)),\nhash(i+vec2(1.0,1.0)),u.x),u.y);\n}\nfloat fbm(vec2 p)\n{\nfloat f=0.0;\nf+=0.5000*noise(p); p*=2.02;\nf+=0.2500*noise(p); p*=2.03;\nf+=0.1250*noise(p); p*=2.01;\nf+=0.0625*noise(p); p*=2.04;\nf/=0.9375;\nreturn f;\n}\nvec3 pattern(vec2 uv)\n{\nvec2 p=-1.0+2.0*uv;\nfloat p2=dot(p,p);\nfloat f=fbm(vec2(15.0*p2))/2.0;\nfloat r=0.2+0.6*sin(12.5*length(uv-vec2(0.5)));\nfloat g=0.2+0.6*sin(20.5*length(uv-vec2(0.5)));\nfloat b=0.2+0.6*sin(17.2*length(uv-vec2(0.5)));\nreturn (1.0-f)*vec3(r,g,b);\n}\nfloat luminance(vec3 color)\n{\nreturn dot(color.rgb,vec3(0.2126,0.7152,0.0722));\n}\nvec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion)\n{\nreturn vec4(\ntexture2D(tex,texcoord+direction*distortion.r).r,\ntexture2D(tex,texcoord+direction*distortion.g).g,\ntexture2D(tex,texcoord+direction*distortion.b).b,\n1.0\n);\n}\nvoid main(void)\n{\nvec2 uv=-vUV+vec2(1.0);\nvec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal;\nvec2 texelSize=1.0/resolution;\nvec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength);\nvec4 result=vec4(0.0);\nfloat ghostIndice=1.0;\nfor (int i=0; i<GHOSTS; ++i)\n{\nvec2 offset=fract(uv+ghostDir*ghostIndice);\nfloat weight=length(vec2(0.5)-offset)/length(vec2(0.5));\nweight=pow(1.0-weight,10.0);\nresult+=textureDistorted(textureSampler,offset,normalize(ghostDir),distortion)*weight*strength;\nghostIndice+=1.0;\n}\nvec2 haloVec=normalize(ghostDir)*haloWidth;\nfloat weight=length(vec2(0.5)-fract(uv+haloVec))/length(vec2(0.5));\nweight=pow(1.0-weight,10.0);\nresult+=textureDistorted(textureSampler,fract(uv+haloVec),normalize(ghostDir),distortion)*weight*strength;\nresult*=texture2D(lensColorSampler,vec2(length(vec2(0.5)-uv)/length(vec2(0.5))));\ngl_FragColor=result;\n}\n#endif\n#if defined(LENS_FLARE_COMPOSE)\nuniform sampler2D otherSampler;\nuniform sampler2D lensDirtSampler;\nuniform sampler2D lensStarSampler;\nuniform mat4 lensStarMatrix;\nvoid main(void)\n{\nvec2 lensFlareCoords=(lensStarMatrix*vec4(vUV,1.0,1.0)).xy;\nvec4 lensMod=texture2D(lensDirtSampler,vUV);\nlensMod+=texture2D(lensStarSampler,vUV);\nvec4 result=texture2D(textureSampler,vUV)*lensMod;\ngl_FragColor=texture2D(otherSampler,vUV)+result;\n}\n#endif\n#if defined(DEPTH_OF_FIELD)\nuniform sampler2D otherSampler;\nuniform sampler2D depthSampler;\nuniform float distance;\nvoid main(void)\n{\nvec4 sharp=texture2D(otherSampler,vUV);\nvec4 blur=texture2D(textureSampler,vUV);\nfloat dist=clamp(texture2D(depthSampler,vUV).r*distance,0.0,1.0);\nfloat factor=0.0;\nif (dist<0.05)\nfactor=1.0;\nelse if (dist<0.1)\nfactor=20.0*(0.1-dist);\nelse if (dist<0.5)\nfactor=0.0;\nelse\nfactor=2.0*(dist-0.5);\nfactor=clamp(factor,0.0,0.90);\ngl_FragColor=mix(sharp,blur,factor);\n}\n#endif\n#if defined(MOTION_BLUR)\nuniform mat4 inverseViewProjection;\nuniform mat4 prevViewProjection;\nuniform vec2 screenSize;\nuniform float motionScale;\nuniform float motionStrength;\nuniform sampler2D depthSampler;\nvoid main(void)\n{\nvec2 texelSize=1.0/screenSize;\nfloat depth=texture2D(depthSampler,vUV).r;\nvec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);\ncpos=cpos*inverseViewProjection;\nvec4 ppos=cpos*prevViewProjection;\nppos.xyz/=ppos.w;\nppos.xy=ppos.xy*0.5+0.5;\nvec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;\nfloat speed=length(velocity/texelSize);\nint nSamples=int(clamp(speed,1.0,MAX_MOTION_SAMPLES));\nvec4 result=texture2D(textureSampler,vUV);\nfor (int i=1; i<int(MAX_MOTION_SAMPLES); ++i) {\nif (i>=nSamples)\nbreak;\nvec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);\nresult+=texture2D(textureSampler,offset1);\n}\ngl_FragColor=result/float(nSamples);\n}\n#endif\n";
  131025. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131026. /** @hidden */
  131027. var standardPixelShader = { name: name, shader: shader };
  131028. /***/ }),
  131029. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  131030. /*!***************************************************!*\
  131031. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  131032. \***************************************************/
  131033. /*! exports provided: stereoscopicInterlacePixelShader */
  131034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131035. "use strict";
  131036. __webpack_require__.r(__webpack_exports__);
  131037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  131038. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131039. var name = 'stereoscopicInterlacePixelShader';
  131040. 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}";
  131041. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131042. /** @hidden */
  131043. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  131044. /***/ }),
  131045. /***/ "./Shaders/tonemap.fragment.ts":
  131046. /*!*************************************!*\
  131047. !*** ./Shaders/tonemap.fragment.ts ***!
  131048. \*************************************/
  131049. /*! exports provided: tonemapPixelShader */
  131050. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131051. "use strict";
  131052. __webpack_require__.r(__webpack_exports__);
  131053. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  131054. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131055. var name = 'tonemapPixelShader';
  131056. 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}";
  131057. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131058. /** @hidden */
  131059. var tonemapPixelShader = { name: name, shader: shader };
  131060. /***/ }),
  131061. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  131062. /*!*******************************************************!*\
  131063. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  131064. \*******************************************************/
  131065. /*! exports provided: volumetricLightScatteringPixelShader */
  131066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131067. "use strict";
  131068. __webpack_require__.r(__webpack_exports__);
  131069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  131070. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131071. var name = 'volumetricLightScatteringPixelShader';
  131072. 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";
  131073. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131074. /** @hidden */
  131075. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  131076. /***/ }),
  131077. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  131078. /*!***********************************************************!*\
  131079. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  131080. \***********************************************************/
  131081. /*! exports provided: volumetricLightScatteringPassPixelShader */
  131082. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131083. "use strict";
  131084. __webpack_require__.r(__webpack_exports__);
  131085. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  131086. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131087. var name = 'volumetricLightScatteringPassPixelShader';
  131088. 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";
  131089. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131090. /** @hidden */
  131091. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  131092. /***/ }),
  131093. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  131094. /*!****************************************************!*\
  131095. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  131096. \****************************************************/
  131097. /*! exports provided: vrDistortionCorrectionPixelShader */
  131098. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131099. "use strict";
  131100. __webpack_require__.r(__webpack_exports__);
  131101. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  131102. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131103. var name = 'vrDistortionCorrectionPixelShader';
  131104. 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}";
  131105. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131106. /** @hidden */
  131107. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  131108. /***/ }),
  131109. /***/ "./Shaders/vrMultiviewToSingleview.fragment.ts":
  131110. /*!*****************************************************!*\
  131111. !*** ./Shaders/vrMultiviewToSingleview.fragment.ts ***!
  131112. \*****************************************************/
  131113. /*! exports provided: vrMultiviewToSingleviewPixelShader */
  131114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131115. "use strict";
  131116. __webpack_require__.r(__webpack_exports__);
  131117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrMultiviewToSingleviewPixelShader", function() { return vrMultiviewToSingleviewPixelShader; });
  131118. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  131119. var name = 'vrMultiviewToSingleviewPixelShader';
  131120. var shader = "#ifdef GL_ES\nprecision mediump sampler2DArray;\n#endif\nvarying vec2 vUV;\nuniform sampler2DArray multiviewSampler;\nuniform int imageIndex;\nvoid main(void)\n{\ngl_FragColor=texture(multiviewSampler,vec3(vUV,imageIndex));\n}";
  131121. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  131122. /** @hidden */
  131123. var vrMultiviewToSingleviewPixelShader = { name: name, shader: shader };
  131124. /***/ }),
  131125. /***/ "./Sprites/index.ts":
  131126. /*!**************************!*\
  131127. !*** ./Sprites/index.ts ***!
  131128. \**************************/
  131129. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  131130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131131. "use strict";
  131132. __webpack_require__.r(__webpack_exports__);
  131133. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  131134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  131135. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  131136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  131137. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  131138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  131139. /***/ }),
  131140. /***/ "./Sprites/sprite.ts":
  131141. /*!***************************!*\
  131142. !*** ./Sprites/sprite.ts ***!
  131143. \***************************/
  131144. /*! exports provided: Sprite */
  131145. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131146. "use strict";
  131147. __webpack_require__.r(__webpack_exports__);
  131148. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  131149. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  131150. /**
  131151. * Class used to represent a sprite
  131152. * @see http://doc.babylonjs.com/babylon101/sprites
  131153. */
  131154. var Sprite = /** @class */ (function () {
  131155. /**
  131156. * Creates a new Sprite
  131157. * @param name defines the name
  131158. * @param manager defines the manager
  131159. */
  131160. function Sprite(
  131161. /** defines the name */
  131162. name, manager) {
  131163. this.name = name;
  131164. /** Gets or sets the main color */
  131165. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  131166. /** Gets or sets the width */
  131167. this.width = 1.0;
  131168. /** Gets or sets the height */
  131169. this.height = 1.0;
  131170. /** Gets or sets rotation angle */
  131171. this.angle = 0;
  131172. /** Gets or sets the cell index in the sprite sheet */
  131173. this.cellIndex = 0;
  131174. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  131175. this.invertU = 0;
  131176. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  131177. this.invertV = 0;
  131178. /** Gets the list of attached animations */
  131179. this.animations = new Array();
  131180. /** Gets or sets a boolean indicating if the sprite can be picked */
  131181. this.isPickable = false;
  131182. this._animationStarted = false;
  131183. this._loopAnimation = false;
  131184. this._fromIndex = 0;
  131185. this._toIndex = 0;
  131186. this._delay = 0;
  131187. this._direction = 1;
  131188. this._time = 0;
  131189. /**
  131190. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  131191. */
  131192. this.isVisible = true;
  131193. this._manager = manager;
  131194. this._manager.sprites.push(this);
  131195. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  131196. }
  131197. Object.defineProperty(Sprite.prototype, "size", {
  131198. /**
  131199. * Gets or sets the sprite size
  131200. */
  131201. get: function () {
  131202. return this.width;
  131203. },
  131204. set: function (value) {
  131205. this.width = value;
  131206. this.height = value;
  131207. },
  131208. enumerable: true,
  131209. configurable: true
  131210. });
  131211. /**
  131212. * Starts an animation
  131213. * @param from defines the initial key
  131214. * @param to defines the end key
  131215. * @param loop defines if the animation must loop
  131216. * @param delay defines the start delay (in ms)
  131217. * @param onAnimationEnd defines a callback to call when animation ends
  131218. */
  131219. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  131220. this._fromIndex = from;
  131221. this._toIndex = to;
  131222. this._loopAnimation = loop;
  131223. this._delay = delay;
  131224. this._animationStarted = true;
  131225. this._direction = from < to ? 1 : -1;
  131226. this.cellIndex = from;
  131227. this._time = 0;
  131228. this._onAnimationEnd = onAnimationEnd;
  131229. };
  131230. /** Stops current animation (if any) */
  131231. Sprite.prototype.stopAnimation = function () {
  131232. this._animationStarted = false;
  131233. };
  131234. /** @hidden */
  131235. Sprite.prototype._animate = function (deltaTime) {
  131236. if (!this._animationStarted) {
  131237. return;
  131238. }
  131239. this._time += deltaTime;
  131240. if (this._time > this._delay) {
  131241. this._time = this._time % this._delay;
  131242. this.cellIndex += this._direction;
  131243. if (this.cellIndex > this._toIndex) {
  131244. if (this._loopAnimation) {
  131245. this.cellIndex = this._fromIndex;
  131246. }
  131247. else {
  131248. this.cellIndex = this._toIndex;
  131249. this._animationStarted = false;
  131250. if (this._onAnimationEnd) {
  131251. this._onAnimationEnd();
  131252. }
  131253. if (this.disposeWhenFinishedAnimating) {
  131254. this.dispose();
  131255. }
  131256. }
  131257. }
  131258. }
  131259. };
  131260. /** Release associated resources */
  131261. Sprite.prototype.dispose = function () {
  131262. for (var i = 0; i < this._manager.sprites.length; i++) {
  131263. if (this._manager.sprites[i] == this) {
  131264. this._manager.sprites.splice(i, 1);
  131265. }
  131266. }
  131267. };
  131268. return Sprite;
  131269. }());
  131270. /***/ }),
  131271. /***/ "./Sprites/spriteManager.ts":
  131272. /*!**********************************!*\
  131273. !*** ./Sprites/spriteManager.ts ***!
  131274. \**********************************/
  131275. /*! exports provided: SpriteManager */
  131276. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131277. "use strict";
  131278. __webpack_require__.r(__webpack_exports__);
  131279. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  131280. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  131281. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  131282. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  131283. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  131284. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  131285. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  131286. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  131287. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  131288. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  131289. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  131290. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  131291. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  131292. /**
  131293. * Class used to manage multiple sprites on the same spritesheet
  131294. * @see http://doc.babylonjs.com/babylon101/sprites
  131295. */
  131296. var SpriteManager = /** @class */ (function () {
  131297. /**
  131298. * Creates a new sprite manager
  131299. * @param name defines the manager's name
  131300. * @param imgUrl defines the sprite sheet url
  131301. * @param capacity defines the maximum allowed number of sprites
  131302. * @param cellSize defines the size of a sprite cell
  131303. * @param scene defines the hosting scene
  131304. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  131305. * @param samplingMode defines the smapling mode to use with spritesheet
  131306. */
  131307. function SpriteManager(
  131308. /** defines the manager's name */
  131309. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  131310. if (epsilon === void 0) { epsilon = 0.01; }
  131311. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  131312. this.name = name;
  131313. /** Gets the list of sprites */
  131314. this.sprites = new Array();
  131315. /** Gets or sets the rendering group id (0 by default) */
  131316. this.renderingGroupId = 0;
  131317. /** Gets or sets camera layer mask */
  131318. this.layerMask = 0x0FFFFFFF;
  131319. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  131320. this.fogEnabled = true;
  131321. /** Gets or sets a boolean indicating if the sprites are pickable */
  131322. this.isPickable = false;
  131323. /**
  131324. * An event triggered when the manager is disposed.
  131325. */
  131326. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  131327. this._vertexBuffers = {};
  131328. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  131329. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  131330. }
  131331. this._capacity = capacity;
  131332. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  131333. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  131334. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  131335. if (cellSize.width && cellSize.height) {
  131336. this.cellWidth = cellSize.width;
  131337. this.cellHeight = cellSize.height;
  131338. }
  131339. else if (cellSize !== undefined) {
  131340. this.cellWidth = cellSize;
  131341. this.cellHeight = cellSize;
  131342. }
  131343. else {
  131344. return;
  131345. }
  131346. this._epsilon = epsilon;
  131347. this._scene = scene;
  131348. this._scene.spriteManagers.push(this);
  131349. var indices = [];
  131350. var index = 0;
  131351. for (var count = 0; count < capacity; count++) {
  131352. indices.push(index);
  131353. indices.push(index + 1);
  131354. indices.push(index + 2);
  131355. indices.push(index);
  131356. indices.push(index + 2);
  131357. indices.push(index + 3);
  131358. index += 4;
  131359. }
  131360. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  131361. // VBO
  131362. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  131363. this._vertexData = new Float32Array(capacity * 16 * 4);
  131364. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  131365. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  131366. var options = this._buffer.createVertexBuffer("options", 4, 4);
  131367. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  131368. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  131369. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  131370. this._vertexBuffers["options"] = options;
  131371. this._vertexBuffers["cellInfo"] = cellInfo;
  131372. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  131373. // Effects
  131374. 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"], "");
  131375. 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");
  131376. }
  131377. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  131378. /**
  131379. * Callback called when the manager is disposed
  131380. */
  131381. set: function (callback) {
  131382. if (this._onDisposeObserver) {
  131383. this.onDisposeObservable.remove(this._onDisposeObserver);
  131384. }
  131385. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  131386. },
  131387. enumerable: true,
  131388. configurable: true
  131389. });
  131390. Object.defineProperty(SpriteManager.prototype, "texture", {
  131391. /**
  131392. * Gets or sets the spritesheet texture
  131393. */
  131394. get: function () {
  131395. return this._spriteTexture;
  131396. },
  131397. set: function (value) {
  131398. this._spriteTexture = value;
  131399. },
  131400. enumerable: true,
  131401. configurable: true
  131402. });
  131403. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  131404. var arrayOffset = index * 16;
  131405. if (offsetX === 0) {
  131406. offsetX = this._epsilon;
  131407. }
  131408. else if (offsetX === 1) {
  131409. offsetX = 1 - this._epsilon;
  131410. }
  131411. if (offsetY === 0) {
  131412. offsetY = this._epsilon;
  131413. }
  131414. else if (offsetY === 1) {
  131415. offsetY = 1 - this._epsilon;
  131416. }
  131417. this._vertexData[arrayOffset] = sprite.position.x;
  131418. this._vertexData[arrayOffset + 1] = sprite.position.y;
  131419. this._vertexData[arrayOffset + 2] = sprite.position.z;
  131420. this._vertexData[arrayOffset + 3] = sprite.angle;
  131421. this._vertexData[arrayOffset + 4] = sprite.width;
  131422. this._vertexData[arrayOffset + 5] = sprite.height;
  131423. this._vertexData[arrayOffset + 6] = offsetX;
  131424. this._vertexData[arrayOffset + 7] = offsetY;
  131425. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  131426. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  131427. var offset = (sprite.cellIndex / rowSize) >> 0;
  131428. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  131429. this._vertexData[arrayOffset + 11] = offset;
  131430. // Color
  131431. this._vertexData[arrayOffset + 12] = sprite.color.r;
  131432. this._vertexData[arrayOffset + 13] = sprite.color.g;
  131433. this._vertexData[arrayOffset + 14] = sprite.color.b;
  131434. this._vertexData[arrayOffset + 15] = sprite.color.a;
  131435. };
  131436. /**
  131437. * Intersects the sprites with a ray
  131438. * @param ray defines the ray to intersect with
  131439. * @param camera defines the current active camera
  131440. * @param predicate defines a predicate used to select candidate sprites
  131441. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  131442. * @returns null if no hit or a PickingInfo
  131443. */
  131444. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  131445. var count = Math.min(this._capacity, this.sprites.length);
  131446. var min = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  131447. var max = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  131448. var distance = Number.MAX_VALUE;
  131449. var currentSprite = null;
  131450. var pickedPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  131451. var cameraSpacePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  131452. var cameraView = camera.getViewMatrix();
  131453. for (var index = 0; index < count; index++) {
  131454. var sprite = this.sprites[index];
  131455. if (!sprite) {
  131456. continue;
  131457. }
  131458. if (predicate) {
  131459. if (!predicate(sprite)) {
  131460. continue;
  131461. }
  131462. }
  131463. else if (!sprite.isPickable) {
  131464. continue;
  131465. }
  131466. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  131467. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  131468. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  131469. if (ray.intersectsBoxMinMax(min, max)) {
  131470. var currentDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  131471. if (distance > currentDistance) {
  131472. distance = currentDistance;
  131473. currentSprite = sprite;
  131474. if (fastCheck) {
  131475. break;
  131476. }
  131477. }
  131478. }
  131479. }
  131480. if (currentSprite) {
  131481. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  131482. cameraView.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  131483. result.hit = true;
  131484. result.pickedSprite = currentSprite;
  131485. result.distance = distance;
  131486. // Get picked point
  131487. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  131488. direction.copyFrom(ray.direction);
  131489. direction.normalize();
  131490. direction.scaleInPlace(distance);
  131491. ray.origin.addToRef(direction, pickedPoint);
  131492. result.pickedPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(pickedPoint, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  131493. return result;
  131494. }
  131495. return null;
  131496. };
  131497. /**
  131498. * Render all child sprites
  131499. */
  131500. SpriteManager.prototype.render = function () {
  131501. // Check
  131502. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture
  131503. || !this._spriteTexture.isReady() || !this.sprites.length) {
  131504. return;
  131505. }
  131506. var engine = this._scene.getEngine();
  131507. var baseSize = this._spriteTexture.getBaseSize();
  131508. // Sprites
  131509. var deltaTime = engine.getDeltaTime();
  131510. var max = Math.min(this._capacity, this.sprites.length);
  131511. var rowSize = baseSize.width / this.cellWidth;
  131512. var offset = 0;
  131513. var noSprite = true;
  131514. for (var index = 0; index < max; index++) {
  131515. var sprite = this.sprites[index];
  131516. if (!sprite || !sprite.isVisible) {
  131517. continue;
  131518. }
  131519. noSprite = false;
  131520. sprite._animate(deltaTime);
  131521. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  131522. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  131523. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  131524. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  131525. }
  131526. if (noSprite) {
  131527. return;
  131528. }
  131529. this._buffer.update(this._vertexData);
  131530. // Render
  131531. var effect = this._effectBase;
  131532. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  131533. effect = this._effectFog;
  131534. }
  131535. engine.enableEffect(effect);
  131536. var viewMatrix = this._scene.getViewMatrix();
  131537. effect.setTexture("diffuseSampler", this._spriteTexture);
  131538. effect.setMatrix("view", viewMatrix);
  131539. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  131540. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  131541. // Fog
  131542. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  131543. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  131544. effect.setColor3("vFogColor", this._scene.fogColor);
  131545. }
  131546. // VBOs
  131547. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  131548. // Draw order
  131549. engine.setDepthFunctionToLessOrEqual();
  131550. effect.setBool("alphaTest", true);
  131551. engine.setColorWrite(false);
  131552. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  131553. engine.setColorWrite(true);
  131554. effect.setBool("alphaTest", false);
  131555. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  131556. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  131557. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  131558. };
  131559. /**
  131560. * Release associated resources
  131561. */
  131562. SpriteManager.prototype.dispose = function () {
  131563. if (this._buffer) {
  131564. this._buffer.dispose();
  131565. this._buffer = null;
  131566. }
  131567. if (this._indexBuffer) {
  131568. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  131569. this._indexBuffer = null;
  131570. }
  131571. if (this._spriteTexture) {
  131572. this._spriteTexture.dispose();
  131573. this._spriteTexture = null;
  131574. }
  131575. // Remove from scene
  131576. var index = this._scene.spriteManagers.indexOf(this);
  131577. this._scene.spriteManagers.splice(index, 1);
  131578. // Callback
  131579. this.onDisposeObservable.notifyObservers(this);
  131580. this.onDisposeObservable.clear();
  131581. };
  131582. return SpriteManager;
  131583. }());
  131584. /***/ }),
  131585. /***/ "./Sprites/spriteSceneComponent.ts":
  131586. /*!*****************************************!*\
  131587. !*** ./Sprites/spriteSceneComponent.ts ***!
  131588. \*****************************************/
  131589. /*! exports provided: SpriteSceneComponent */
  131590. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131591. "use strict";
  131592. __webpack_require__.r(__webpack_exports__);
  131593. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  131594. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  131595. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  131596. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  131597. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  131598. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  131599. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  131600. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  131601. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  131602. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  131603. return null;
  131604. }
  131605. var pickingInfo = null;
  131606. if (!camera) {
  131607. if (!this.activeCamera) {
  131608. return null;
  131609. }
  131610. camera = this.activeCamera;
  131611. }
  131612. if (this.spriteManagers.length > 0) {
  131613. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  131614. var spriteManager = this.spriteManagers[spriteIndex];
  131615. if (!spriteManager.isPickable) {
  131616. continue;
  131617. }
  131618. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  131619. if (!result || !result.hit) {
  131620. continue;
  131621. }
  131622. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  131623. continue;
  131624. }
  131625. pickingInfo = result;
  131626. if (fastCheck) {
  131627. break;
  131628. }
  131629. }
  131630. }
  131631. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  131632. };
  131633. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  131634. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  131635. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  131636. };
  131637. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  131638. if (!this._tempSpritePickingRay) {
  131639. return null;
  131640. }
  131641. if (!camera) {
  131642. if (!this.activeCamera) {
  131643. return null;
  131644. }
  131645. camera = this.activeCamera;
  131646. }
  131647. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  131648. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  131649. };
  131650. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  131651. if (this._pointerOverSprite === sprite) {
  131652. return;
  131653. }
  131654. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  131655. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  131656. }
  131657. this._pointerOverSprite = sprite;
  131658. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  131659. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  131660. }
  131661. };
  131662. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  131663. return this._pointerOverSprite;
  131664. };
  131665. /**
  131666. * Defines the sprite scene component responsible to manage sprites
  131667. * in a given scene.
  131668. */
  131669. var SpriteSceneComponent = /** @class */ (function () {
  131670. /**
  131671. * Creates a new instance of the component for the given scene
  131672. * @param scene Defines the scene to register the component in
  131673. */
  131674. function SpriteSceneComponent(scene) {
  131675. /**
  131676. * The component name helpfull to identify the component in the list of scene components.
  131677. */
  131678. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  131679. this.scene = scene;
  131680. this.scene.spriteManagers = new Array();
  131681. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  131682. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  131683. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  131684. this._spritePredicate = function (sprite) {
  131685. if (!sprite.actionManager) {
  131686. return false;
  131687. }
  131688. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  131689. };
  131690. }
  131691. /**
  131692. * Registers the component in a given scene
  131693. */
  131694. SpriteSceneComponent.prototype.register = function () {
  131695. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  131696. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  131697. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  131698. };
  131699. /**
  131700. * Rebuilds the elements related to this component in case of
  131701. * context lost for instance.
  131702. */
  131703. SpriteSceneComponent.prototype.rebuild = function () {
  131704. /** Nothing to do for sprites */
  131705. };
  131706. /**
  131707. * Disposes the component and the associated ressources.
  131708. */
  131709. SpriteSceneComponent.prototype.dispose = function () {
  131710. this.scene.onBeforeSpritesRenderingObservable.clear();
  131711. this.scene.onAfterSpritesRenderingObservable.clear();
  131712. var spriteManagers = this.scene.spriteManagers;
  131713. while (spriteManagers.length) {
  131714. spriteManagers[0].dispose();
  131715. }
  131716. };
  131717. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  131718. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  131719. if (result) {
  131720. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  131721. }
  131722. return result;
  131723. };
  131724. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  131725. var scene = this.scene;
  131726. if (isMeshPicked) {
  131727. scene.setPointerOverSprite(null);
  131728. }
  131729. else {
  131730. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  131731. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  131732. scene.setPointerOverSprite(pickResult.pickedSprite);
  131733. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  131734. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  131735. }
  131736. else {
  131737. canvas.style.cursor = scene.hoverCursor;
  131738. }
  131739. }
  131740. else {
  131741. scene.setPointerOverSprite(null);
  131742. }
  131743. }
  131744. return pickResult;
  131745. };
  131746. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  131747. var scene = this.scene;
  131748. scene._pickedDownSprite = null;
  131749. if (scene.spriteManagers.length > 0) {
  131750. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  131751. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  131752. if (pickResult.pickedSprite.actionManager) {
  131753. scene._pickedDownSprite = pickResult.pickedSprite;
  131754. switch (evt.button) {
  131755. case 0:
  131756. 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));
  131757. break;
  131758. case 1:
  131759. 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));
  131760. break;
  131761. case 2:
  131762. 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));
  131763. break;
  131764. }
  131765. if (pickResult.pickedSprite.actionManager) {
  131766. 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));
  131767. }
  131768. }
  131769. }
  131770. }
  131771. return pickResult;
  131772. };
  131773. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  131774. var scene = this.scene;
  131775. if (scene.spriteManagers.length > 0) {
  131776. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  131777. if (spritePickResult) {
  131778. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  131779. if (spritePickResult.pickedSprite.actionManager) {
  131780. 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));
  131781. if (spritePickResult.pickedSprite.actionManager) {
  131782. if (!this.scene._isPointerSwiping()) {
  131783. 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));
  131784. }
  131785. }
  131786. }
  131787. }
  131788. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  131789. 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));
  131790. }
  131791. }
  131792. }
  131793. return pickResult;
  131794. };
  131795. return SpriteSceneComponent;
  131796. }());
  131797. /***/ }),
  131798. /***/ "./States/alphaCullingState.ts":
  131799. /*!*************************************!*\
  131800. !*** ./States/alphaCullingState.ts ***!
  131801. \*************************************/
  131802. /*! exports provided: _AlphaState */
  131803. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131804. "use strict";
  131805. __webpack_require__.r(__webpack_exports__);
  131806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  131807. /**
  131808. * @hidden
  131809. **/
  131810. var _AlphaState = /** @class */ (function () {
  131811. /**
  131812. * Initializes the state.
  131813. */
  131814. function _AlphaState() {
  131815. this._isAlphaBlendDirty = false;
  131816. this._isBlendFunctionParametersDirty = false;
  131817. this._isBlendEquationParametersDirty = false;
  131818. this._isBlendConstantsDirty = false;
  131819. this._alphaBlend = false;
  131820. this._blendFunctionParameters = new Array(4);
  131821. this._blendEquationParameters = new Array(2);
  131822. this._blendConstants = new Array(4);
  131823. this.reset();
  131824. }
  131825. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  131826. get: function () {
  131827. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  131828. },
  131829. enumerable: true,
  131830. configurable: true
  131831. });
  131832. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  131833. get: function () {
  131834. return this._alphaBlend;
  131835. },
  131836. set: function (value) {
  131837. if (this._alphaBlend === value) {
  131838. return;
  131839. }
  131840. this._alphaBlend = value;
  131841. this._isAlphaBlendDirty = true;
  131842. },
  131843. enumerable: true,
  131844. configurable: true
  131845. });
  131846. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  131847. if (this._blendConstants[0] === r &&
  131848. this._blendConstants[1] === g &&
  131849. this._blendConstants[2] === b &&
  131850. this._blendConstants[3] === a) {
  131851. return;
  131852. }
  131853. this._blendConstants[0] = r;
  131854. this._blendConstants[1] = g;
  131855. this._blendConstants[2] = b;
  131856. this._blendConstants[3] = a;
  131857. this._isBlendConstantsDirty = true;
  131858. };
  131859. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  131860. if (this._blendFunctionParameters[0] === value0 &&
  131861. this._blendFunctionParameters[1] === value1 &&
  131862. this._blendFunctionParameters[2] === value2 &&
  131863. this._blendFunctionParameters[3] === value3) {
  131864. return;
  131865. }
  131866. this._blendFunctionParameters[0] = value0;
  131867. this._blendFunctionParameters[1] = value1;
  131868. this._blendFunctionParameters[2] = value2;
  131869. this._blendFunctionParameters[3] = value3;
  131870. this._isBlendFunctionParametersDirty = true;
  131871. };
  131872. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  131873. if (this._blendEquationParameters[0] === rgb &&
  131874. this._blendEquationParameters[1] === alpha) {
  131875. return;
  131876. }
  131877. this._blendEquationParameters[0] = rgb;
  131878. this._blendEquationParameters[1] = alpha;
  131879. this._isBlendEquationParametersDirty = true;
  131880. };
  131881. _AlphaState.prototype.reset = function () {
  131882. this._alphaBlend = false;
  131883. this._blendFunctionParameters[0] = null;
  131884. this._blendFunctionParameters[1] = null;
  131885. this._blendFunctionParameters[2] = null;
  131886. this._blendFunctionParameters[3] = null;
  131887. this._blendEquationParameters[0] = null;
  131888. this._blendEquationParameters[1] = null;
  131889. this._blendConstants[0] = null;
  131890. this._blendConstants[1] = null;
  131891. this._blendConstants[2] = null;
  131892. this._blendConstants[3] = null;
  131893. this._isAlphaBlendDirty = true;
  131894. this._isBlendFunctionParametersDirty = false;
  131895. this._isBlendEquationParametersDirty = false;
  131896. this._isBlendConstantsDirty = false;
  131897. };
  131898. _AlphaState.prototype.apply = function (gl) {
  131899. if (!this.isDirty) {
  131900. return;
  131901. }
  131902. // Alpha blend
  131903. if (this._isAlphaBlendDirty) {
  131904. if (this._alphaBlend) {
  131905. gl.enable(gl.BLEND);
  131906. }
  131907. else {
  131908. gl.disable(gl.BLEND);
  131909. }
  131910. this._isAlphaBlendDirty = false;
  131911. }
  131912. // Alpha function
  131913. if (this._isBlendFunctionParametersDirty) {
  131914. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  131915. this._isBlendFunctionParametersDirty = false;
  131916. }
  131917. // Alpha equation
  131918. if (this._isBlendEquationParametersDirty) {
  131919. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  131920. this._isBlendEquationParametersDirty = false;
  131921. }
  131922. // Constants
  131923. if (this._isBlendConstantsDirty) {
  131924. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  131925. this._isBlendConstantsDirty = false;
  131926. }
  131927. };
  131928. return _AlphaState;
  131929. }());
  131930. /***/ }),
  131931. /***/ "./States/depthCullingState.ts":
  131932. /*!*************************************!*\
  131933. !*** ./States/depthCullingState.ts ***!
  131934. \*************************************/
  131935. /*! exports provided: _DepthCullingState */
  131936. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  131937. "use strict";
  131938. __webpack_require__.r(__webpack_exports__);
  131939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  131940. /**
  131941. * @hidden
  131942. **/
  131943. var _DepthCullingState = /** @class */ (function () {
  131944. /**
  131945. * Initializes the state.
  131946. */
  131947. function _DepthCullingState() {
  131948. this._isDepthTestDirty = false;
  131949. this._isDepthMaskDirty = false;
  131950. this._isDepthFuncDirty = false;
  131951. this._isCullFaceDirty = false;
  131952. this._isCullDirty = false;
  131953. this._isZOffsetDirty = false;
  131954. this._isFrontFaceDirty = false;
  131955. this.reset();
  131956. }
  131957. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  131958. get: function () {
  131959. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  131960. },
  131961. enumerable: true,
  131962. configurable: true
  131963. });
  131964. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  131965. get: function () {
  131966. return this._zOffset;
  131967. },
  131968. set: function (value) {
  131969. if (this._zOffset === value) {
  131970. return;
  131971. }
  131972. this._zOffset = value;
  131973. this._isZOffsetDirty = true;
  131974. },
  131975. enumerable: true,
  131976. configurable: true
  131977. });
  131978. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  131979. get: function () {
  131980. return this._cullFace;
  131981. },
  131982. set: function (value) {
  131983. if (this._cullFace === value) {
  131984. return;
  131985. }
  131986. this._cullFace = value;
  131987. this._isCullFaceDirty = true;
  131988. },
  131989. enumerable: true,
  131990. configurable: true
  131991. });
  131992. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  131993. get: function () {
  131994. return this._cull;
  131995. },
  131996. set: function (value) {
  131997. if (this._cull === value) {
  131998. return;
  131999. }
  132000. this._cull = value;
  132001. this._isCullDirty = true;
  132002. },
  132003. enumerable: true,
  132004. configurable: true
  132005. });
  132006. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  132007. get: function () {
  132008. return this._depthFunc;
  132009. },
  132010. set: function (value) {
  132011. if (this._depthFunc === value) {
  132012. return;
  132013. }
  132014. this._depthFunc = value;
  132015. this._isDepthFuncDirty = true;
  132016. },
  132017. enumerable: true,
  132018. configurable: true
  132019. });
  132020. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  132021. get: function () {
  132022. return this._depthMask;
  132023. },
  132024. set: function (value) {
  132025. if (this._depthMask === value) {
  132026. return;
  132027. }
  132028. this._depthMask = value;
  132029. this._isDepthMaskDirty = true;
  132030. },
  132031. enumerable: true,
  132032. configurable: true
  132033. });
  132034. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  132035. get: function () {
  132036. return this._depthTest;
  132037. },
  132038. set: function (value) {
  132039. if (this._depthTest === value) {
  132040. return;
  132041. }
  132042. this._depthTest = value;
  132043. this._isDepthTestDirty = true;
  132044. },
  132045. enumerable: true,
  132046. configurable: true
  132047. });
  132048. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  132049. get: function () {
  132050. return this._frontFace;
  132051. },
  132052. set: function (value) {
  132053. if (this._frontFace === value) {
  132054. return;
  132055. }
  132056. this._frontFace = value;
  132057. this._isFrontFaceDirty = true;
  132058. },
  132059. enumerable: true,
  132060. configurable: true
  132061. });
  132062. _DepthCullingState.prototype.reset = function () {
  132063. this._depthMask = true;
  132064. this._depthTest = true;
  132065. this._depthFunc = null;
  132066. this._cullFace = null;
  132067. this._cull = null;
  132068. this._zOffset = 0;
  132069. this._frontFace = null;
  132070. this._isDepthTestDirty = true;
  132071. this._isDepthMaskDirty = true;
  132072. this._isDepthFuncDirty = false;
  132073. this._isCullFaceDirty = false;
  132074. this._isCullDirty = false;
  132075. this._isZOffsetDirty = false;
  132076. this._isFrontFaceDirty = false;
  132077. };
  132078. _DepthCullingState.prototype.apply = function (gl) {
  132079. if (!this.isDirty) {
  132080. return;
  132081. }
  132082. // Cull
  132083. if (this._isCullDirty) {
  132084. if (this.cull) {
  132085. gl.enable(gl.CULL_FACE);
  132086. }
  132087. else {
  132088. gl.disable(gl.CULL_FACE);
  132089. }
  132090. this._isCullDirty = false;
  132091. }
  132092. // Cull face
  132093. if (this._isCullFaceDirty) {
  132094. gl.cullFace(this.cullFace);
  132095. this._isCullFaceDirty = false;
  132096. }
  132097. // Depth mask
  132098. if (this._isDepthMaskDirty) {
  132099. gl.depthMask(this.depthMask);
  132100. this._isDepthMaskDirty = false;
  132101. }
  132102. // Depth test
  132103. if (this._isDepthTestDirty) {
  132104. if (this.depthTest) {
  132105. gl.enable(gl.DEPTH_TEST);
  132106. }
  132107. else {
  132108. gl.disable(gl.DEPTH_TEST);
  132109. }
  132110. this._isDepthTestDirty = false;
  132111. }
  132112. // Depth func
  132113. if (this._isDepthFuncDirty) {
  132114. gl.depthFunc(this.depthFunc);
  132115. this._isDepthFuncDirty = false;
  132116. }
  132117. // zOffset
  132118. if (this._isZOffsetDirty) {
  132119. if (this.zOffset) {
  132120. gl.enable(gl.POLYGON_OFFSET_FILL);
  132121. gl.polygonOffset(this.zOffset, 0);
  132122. }
  132123. else {
  132124. gl.disable(gl.POLYGON_OFFSET_FILL);
  132125. }
  132126. this._isZOffsetDirty = false;
  132127. }
  132128. // Front face
  132129. if (this._isFrontFaceDirty) {
  132130. gl.frontFace(this.frontFace);
  132131. this._isFrontFaceDirty = false;
  132132. }
  132133. };
  132134. return _DepthCullingState;
  132135. }());
  132136. /***/ }),
  132137. /***/ "./States/index.ts":
  132138. /*!*************************!*\
  132139. !*** ./States/index.ts ***!
  132140. \*************************/
  132141. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  132142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132143. "use strict";
  132144. __webpack_require__.r(__webpack_exports__);
  132145. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  132146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  132147. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  132148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  132149. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  132150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  132151. /***/ }),
  132152. /***/ "./States/stencilState.ts":
  132153. /*!********************************!*\
  132154. !*** ./States/stencilState.ts ***!
  132155. \********************************/
  132156. /*! exports provided: _StencilState */
  132157. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132158. "use strict";
  132159. __webpack_require__.r(__webpack_exports__);
  132160. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _StencilState; });
  132161. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  132162. /**
  132163. * @hidden
  132164. **/
  132165. var _StencilState = /** @class */ (function () {
  132166. function _StencilState() {
  132167. this._isStencilTestDirty = false;
  132168. this._isStencilMaskDirty = false;
  132169. this._isStencilFuncDirty = false;
  132170. this._isStencilOpDirty = false;
  132171. this.reset();
  132172. }
  132173. Object.defineProperty(_StencilState.prototype, "isDirty", {
  132174. get: function () {
  132175. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  132176. },
  132177. enumerable: true,
  132178. configurable: true
  132179. });
  132180. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  132181. get: function () {
  132182. return this._stencilFunc;
  132183. },
  132184. set: function (value) {
  132185. if (this._stencilFunc === value) {
  132186. return;
  132187. }
  132188. this._stencilFunc = value;
  132189. this._isStencilFuncDirty = true;
  132190. },
  132191. enumerable: true,
  132192. configurable: true
  132193. });
  132194. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  132195. get: function () {
  132196. return this._stencilFuncRef;
  132197. },
  132198. set: function (value) {
  132199. if (this._stencilFuncRef === value) {
  132200. return;
  132201. }
  132202. this._stencilFuncRef = value;
  132203. this._isStencilFuncDirty = true;
  132204. },
  132205. enumerable: true,
  132206. configurable: true
  132207. });
  132208. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  132209. get: function () {
  132210. return this._stencilFuncMask;
  132211. },
  132212. set: function (value) {
  132213. if (this._stencilFuncMask === value) {
  132214. return;
  132215. }
  132216. this._stencilFuncMask = value;
  132217. this._isStencilFuncDirty = true;
  132218. },
  132219. enumerable: true,
  132220. configurable: true
  132221. });
  132222. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  132223. get: function () {
  132224. return this._stencilOpStencilFail;
  132225. },
  132226. set: function (value) {
  132227. if (this._stencilOpStencilFail === value) {
  132228. return;
  132229. }
  132230. this._stencilOpStencilFail = value;
  132231. this._isStencilOpDirty = true;
  132232. },
  132233. enumerable: true,
  132234. configurable: true
  132235. });
  132236. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  132237. get: function () {
  132238. return this._stencilOpDepthFail;
  132239. },
  132240. set: function (value) {
  132241. if (this._stencilOpDepthFail === value) {
  132242. return;
  132243. }
  132244. this._stencilOpDepthFail = value;
  132245. this._isStencilOpDirty = true;
  132246. },
  132247. enumerable: true,
  132248. configurable: true
  132249. });
  132250. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  132251. get: function () {
  132252. return this._stencilOpStencilDepthPass;
  132253. },
  132254. set: function (value) {
  132255. if (this._stencilOpStencilDepthPass === value) {
  132256. return;
  132257. }
  132258. this._stencilOpStencilDepthPass = value;
  132259. this._isStencilOpDirty = true;
  132260. },
  132261. enumerable: true,
  132262. configurable: true
  132263. });
  132264. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  132265. get: function () {
  132266. return this._stencilMask;
  132267. },
  132268. set: function (value) {
  132269. if (this._stencilMask === value) {
  132270. return;
  132271. }
  132272. this._stencilMask = value;
  132273. this._isStencilMaskDirty = true;
  132274. },
  132275. enumerable: true,
  132276. configurable: true
  132277. });
  132278. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  132279. get: function () {
  132280. return this._stencilTest;
  132281. },
  132282. set: function (value) {
  132283. if (this._stencilTest === value) {
  132284. return;
  132285. }
  132286. this._stencilTest = value;
  132287. this._isStencilTestDirty = true;
  132288. },
  132289. enumerable: true,
  132290. configurable: true
  132291. });
  132292. _StencilState.prototype.reset = function () {
  132293. this._stencilTest = false;
  132294. this._stencilMask = 0xFF;
  132295. this._stencilFunc = _StencilState.ALWAYS;
  132296. this._stencilFuncRef = 1;
  132297. this._stencilFuncMask = 0xFF;
  132298. this._stencilOpStencilFail = _StencilState.KEEP;
  132299. this._stencilOpDepthFail = _StencilState.KEEP;
  132300. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  132301. this._isStencilTestDirty = true;
  132302. this._isStencilMaskDirty = true;
  132303. this._isStencilFuncDirty = true;
  132304. this._isStencilOpDirty = true;
  132305. };
  132306. _StencilState.prototype.apply = function (gl) {
  132307. if (!this.isDirty) {
  132308. return;
  132309. }
  132310. // Stencil test
  132311. if (this._isStencilTestDirty) {
  132312. if (this.stencilTest) {
  132313. gl.enable(gl.STENCIL_TEST);
  132314. }
  132315. else {
  132316. gl.disable(gl.STENCIL_TEST);
  132317. }
  132318. this._isStencilTestDirty = false;
  132319. }
  132320. // Stencil mask
  132321. if (this._isStencilMaskDirty) {
  132322. gl.stencilMask(this.stencilMask);
  132323. this._isStencilMaskDirty = false;
  132324. }
  132325. // Stencil func
  132326. if (this._isStencilFuncDirty) {
  132327. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  132328. this._isStencilFuncDirty = false;
  132329. }
  132330. // Stencil op
  132331. if (this._isStencilOpDirty) {
  132332. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  132333. this._isStencilOpDirty = false;
  132334. }
  132335. };
  132336. /** 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 */
  132337. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  132338. /** Passed to stencilOperation to specify that stencil value must be kept */
  132339. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  132340. /** Passed to stencilOperation to specify that stencil value must be replaced */
  132341. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  132342. return _StencilState;
  132343. }());
  132344. /***/ }),
  132345. /***/ "./abstractScene.ts":
  132346. /*!**************************!*\
  132347. !*** ./abstractScene.ts ***!
  132348. \**************************/
  132349. /*! exports provided: AbstractScene */
  132350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132351. "use strict";
  132352. __webpack_require__.r(__webpack_exports__);
  132353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  132354. /**
  132355. * Base class of the scene acting as a container for the different elements composing a scene.
  132356. * This class is dynamically extended by the different components of the scene increasing
  132357. * flexibility and reducing coupling
  132358. */
  132359. var AbstractScene = /** @class */ (function () {
  132360. function AbstractScene() {
  132361. /**
  132362. * Gets the list of root nodes (ie. nodes with no parent)
  132363. */
  132364. this.rootNodes = new Array();
  132365. /** All of the cameras added to this scene
  132366. * @see http://doc.babylonjs.com/babylon101/cameras
  132367. */
  132368. this.cameras = new Array();
  132369. /**
  132370. * All of the lights added to this scene
  132371. * @see http://doc.babylonjs.com/babylon101/lights
  132372. */
  132373. this.lights = new Array();
  132374. /**
  132375. * All of the (abstract) meshes added to this scene
  132376. */
  132377. this.meshes = new Array();
  132378. /**
  132379. * The list of skeletons added to the scene
  132380. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  132381. */
  132382. this.skeletons = new Array();
  132383. /**
  132384. * All of the particle systems added to this scene
  132385. * @see http://doc.babylonjs.com/babylon101/particles
  132386. */
  132387. this.particleSystems = new Array();
  132388. /**
  132389. * Gets a list of Animations associated with the scene
  132390. */
  132391. this.animations = [];
  132392. /**
  132393. * All of the animation groups added to this scene
  132394. * @see http://doc.babylonjs.com/how_to/group
  132395. */
  132396. this.animationGroups = new Array();
  132397. /**
  132398. * All of the multi-materials added to this scene
  132399. * @see http://doc.babylonjs.com/how_to/multi_materials
  132400. */
  132401. this.multiMaterials = new Array();
  132402. /**
  132403. * All of the materials added to this scene
  132404. * In the context of a Scene, it is not supposed to be modified manually.
  132405. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  132406. * Note also that the order of the Material wihin the array is not significant and might change.
  132407. * @see http://doc.babylonjs.com/babylon101/materials
  132408. */
  132409. this.materials = new Array();
  132410. /**
  132411. * The list of morph target managers added to the scene
  132412. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  132413. */
  132414. this.morphTargetManagers = new Array();
  132415. /**
  132416. * The list of geometries used in the scene.
  132417. */
  132418. this.geometries = new Array();
  132419. /**
  132420. * All of the tranform nodes added to this scene
  132421. * In the context of a Scene, it is not supposed to be modified manually.
  132422. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  132423. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  132424. * @see http://doc.babylonjs.com/how_to/transformnode
  132425. */
  132426. this.transformNodes = new Array();
  132427. /**
  132428. * ActionManagers available on the scene.
  132429. */
  132430. this.actionManagers = new Array();
  132431. /**
  132432. * Textures to keep.
  132433. */
  132434. this.textures = new Array();
  132435. /**
  132436. * Environment texture for the scene
  132437. */
  132438. this.environmentTexture = null;
  132439. }
  132440. /**
  132441. * Adds a parser in the list of available ones
  132442. * @param name Defines the name of the parser
  132443. * @param parser Defines the parser to add
  132444. */
  132445. AbstractScene.AddParser = function (name, parser) {
  132446. this._BabylonFileParsers[name] = parser;
  132447. };
  132448. /**
  132449. * Gets a general parser from the list of avaialble ones
  132450. * @param name Defines the name of the parser
  132451. * @returns the requested parser or null
  132452. */
  132453. AbstractScene.GetParser = function (name) {
  132454. if (this._BabylonFileParsers[name]) {
  132455. return this._BabylonFileParsers[name];
  132456. }
  132457. return null;
  132458. };
  132459. /**
  132460. * Adds n individual parser in the list of available ones
  132461. * @param name Defines the name of the parser
  132462. * @param parser Defines the parser to add
  132463. */
  132464. AbstractScene.AddIndividualParser = function (name, parser) {
  132465. this._IndividualBabylonFileParsers[name] = parser;
  132466. };
  132467. /**
  132468. * Gets an individual parser from the list of avaialble ones
  132469. * @param name Defines the name of the parser
  132470. * @returns the requested parser or null
  132471. */
  132472. AbstractScene.GetIndividualParser = function (name) {
  132473. if (this._IndividualBabylonFileParsers[name]) {
  132474. return this._IndividualBabylonFileParsers[name];
  132475. }
  132476. return null;
  132477. };
  132478. /**
  132479. * Parser json data and populate both a scene and its associated container object
  132480. * @param jsonData Defines the data to parse
  132481. * @param scene Defines the scene to parse the data for
  132482. * @param container Defines the container attached to the parsing sequence
  132483. * @param rootUrl Defines the root url of the data
  132484. */
  132485. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  132486. for (var parserName in this._BabylonFileParsers) {
  132487. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  132488. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  132489. }
  132490. }
  132491. };
  132492. /**
  132493. * Stores the list of available parsers in the application.
  132494. */
  132495. AbstractScene._BabylonFileParsers = {};
  132496. /**
  132497. * Stores the list of available individual parsers in the application.
  132498. */
  132499. AbstractScene._IndividualBabylonFileParsers = {};
  132500. return AbstractScene;
  132501. }());
  132502. /***/ }),
  132503. /***/ "./assetContainer.ts":
  132504. /*!***************************!*\
  132505. !*** ./assetContainer.ts ***!
  132506. \***************************/
  132507. /*! exports provided: KeepAssets, AssetContainer */
  132508. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132509. "use strict";
  132510. __webpack_require__.r(__webpack_exports__);
  132511. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return KeepAssets; });
  132512. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  132513. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  132514. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  132515. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  132516. /**
  132517. * Set of assets to keep when moving a scene into an asset container.
  132518. */
  132519. var KeepAssets = /** @class */ (function (_super) {
  132520. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  132521. function KeepAssets() {
  132522. return _super !== null && _super.apply(this, arguments) || this;
  132523. }
  132524. return KeepAssets;
  132525. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  132526. /**
  132527. * Container with a set of assets that can be added or removed from a scene.
  132528. */
  132529. var AssetContainer = /** @class */ (function (_super) {
  132530. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  132531. /**
  132532. * Instantiates an AssetContainer.
  132533. * @param scene The scene the AssetContainer belongs to.
  132534. */
  132535. function AssetContainer(scene) {
  132536. var _this = _super.call(this) || this;
  132537. _this.scene = scene;
  132538. _this["sounds"] = [];
  132539. _this["effectLayers"] = [];
  132540. _this["layers"] = [];
  132541. _this["lensFlareSystems"] = [];
  132542. _this["proceduralTextures"] = [];
  132543. _this["reflectionProbes"] = [];
  132544. return _this;
  132545. }
  132546. /**
  132547. * Adds all the assets from the container to the scene.
  132548. */
  132549. AssetContainer.prototype.addAllToScene = function () {
  132550. var _this = this;
  132551. this.cameras.forEach(function (o) {
  132552. _this.scene.addCamera(o);
  132553. });
  132554. this.lights.forEach(function (o) {
  132555. _this.scene.addLight(o);
  132556. });
  132557. this.meshes.forEach(function (o) {
  132558. _this.scene.addMesh(o);
  132559. });
  132560. this.skeletons.forEach(function (o) {
  132561. _this.scene.addSkeleton(o);
  132562. });
  132563. this.animations.forEach(function (o) {
  132564. _this.scene.addAnimation(o);
  132565. });
  132566. this.animationGroups.forEach(function (o) {
  132567. _this.scene.addAnimationGroup(o);
  132568. });
  132569. this.multiMaterials.forEach(function (o) {
  132570. _this.scene.addMultiMaterial(o);
  132571. });
  132572. this.materials.forEach(function (o) {
  132573. _this.scene.addMaterial(o);
  132574. });
  132575. this.morphTargetManagers.forEach(function (o) {
  132576. _this.scene.addMorphTargetManager(o);
  132577. });
  132578. this.geometries.forEach(function (o) {
  132579. _this.scene.addGeometry(o);
  132580. });
  132581. this.transformNodes.forEach(function (o) {
  132582. _this.scene.addTransformNode(o);
  132583. });
  132584. this.actionManagers.forEach(function (o) {
  132585. _this.scene.addActionManager(o);
  132586. });
  132587. this.textures.forEach(function (o) {
  132588. _this.scene.addTexture(o);
  132589. });
  132590. this.reflectionProbes.forEach(function (o) {
  132591. _this.scene.addReflectionProbe(o);
  132592. });
  132593. if (this.environmentTexture) {
  132594. this.scene.environmentTexture = this.environmentTexture;
  132595. }
  132596. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  132597. var component = _a[_i];
  132598. component.addFromContainer(this);
  132599. }
  132600. };
  132601. /**
  132602. * Removes all the assets in the container from the scene
  132603. */
  132604. AssetContainer.prototype.removeAllFromScene = function () {
  132605. var _this = this;
  132606. this.cameras.forEach(function (o) {
  132607. _this.scene.removeCamera(o);
  132608. });
  132609. this.lights.forEach(function (o) {
  132610. _this.scene.removeLight(o);
  132611. });
  132612. this.meshes.forEach(function (o) {
  132613. _this.scene.removeMesh(o);
  132614. });
  132615. this.skeletons.forEach(function (o) {
  132616. _this.scene.removeSkeleton(o);
  132617. });
  132618. this.animations.forEach(function (o) {
  132619. _this.scene.removeAnimation(o);
  132620. });
  132621. this.animationGroups.forEach(function (o) {
  132622. _this.scene.removeAnimationGroup(o);
  132623. });
  132624. this.multiMaterials.forEach(function (o) {
  132625. _this.scene.removeMultiMaterial(o);
  132626. });
  132627. this.materials.forEach(function (o) {
  132628. _this.scene.removeMaterial(o);
  132629. });
  132630. this.morphTargetManagers.forEach(function (o) {
  132631. _this.scene.removeMorphTargetManager(o);
  132632. });
  132633. this.geometries.forEach(function (o) {
  132634. _this.scene.removeGeometry(o);
  132635. });
  132636. this.transformNodes.forEach(function (o) {
  132637. _this.scene.removeTransformNode(o);
  132638. });
  132639. this.actionManagers.forEach(function (o) {
  132640. _this.scene.removeActionManager(o);
  132641. });
  132642. this.textures.forEach(function (o) {
  132643. _this.scene.removeTexture(o);
  132644. });
  132645. this.reflectionProbes.forEach(function (o) {
  132646. _this.scene.removeReflectionProbe(o);
  132647. });
  132648. if (this.environmentTexture === this.scene.environmentTexture) {
  132649. this.scene.environmentTexture = null;
  132650. }
  132651. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  132652. var component = _a[_i];
  132653. component.removeFromContainer(this);
  132654. }
  132655. };
  132656. /**
  132657. * Disposes all the assets in the container
  132658. */
  132659. AssetContainer.prototype.dispose = function () {
  132660. this.cameras.forEach(function (o) {
  132661. o.dispose();
  132662. });
  132663. this.cameras = [];
  132664. this.lights.forEach(function (o) {
  132665. o.dispose();
  132666. });
  132667. this.lights = [];
  132668. this.meshes.forEach(function (o) {
  132669. o.dispose();
  132670. });
  132671. this.meshes = [];
  132672. this.skeletons.forEach(function (o) {
  132673. o.dispose();
  132674. });
  132675. this.skeletons = [];
  132676. this.animationGroups.forEach(function (o) {
  132677. o.dispose();
  132678. });
  132679. this.animationGroups = [];
  132680. this.multiMaterials.forEach(function (o) {
  132681. o.dispose();
  132682. });
  132683. this.multiMaterials = [];
  132684. this.materials.forEach(function (o) {
  132685. o.dispose();
  132686. });
  132687. this.materials = [];
  132688. this.geometries.forEach(function (o) {
  132689. o.dispose();
  132690. });
  132691. this.geometries = [];
  132692. this.transformNodes.forEach(function (o) {
  132693. o.dispose();
  132694. });
  132695. this.transformNodes = [];
  132696. this.actionManagers.forEach(function (o) {
  132697. o.dispose();
  132698. });
  132699. this.actionManagers = [];
  132700. this.textures.forEach(function (o) {
  132701. o.dispose();
  132702. });
  132703. this.textures = [];
  132704. this.reflectionProbes.forEach(function (o) {
  132705. o.dispose();
  132706. });
  132707. this.reflectionProbes = [];
  132708. if (this.environmentTexture) {
  132709. this.environmentTexture.dispose();
  132710. this.environmentTexture = null;
  132711. }
  132712. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  132713. var component = _a[_i];
  132714. component.removeFromContainer(this, true);
  132715. }
  132716. };
  132717. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  132718. if (!sourceAssets) {
  132719. return;
  132720. }
  132721. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  132722. var asset = sourceAssets_1[_i];
  132723. var move = true;
  132724. if (keepAssets) {
  132725. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  132726. var keepAsset = keepAssets_1[_a];
  132727. if (asset === keepAsset) {
  132728. move = false;
  132729. break;
  132730. }
  132731. }
  132732. }
  132733. if (move) {
  132734. targetAssets.push(asset);
  132735. }
  132736. }
  132737. };
  132738. /**
  132739. * Removes all the assets contained in the scene and adds them to the container.
  132740. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  132741. */
  132742. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  132743. if (keepAssets === undefined) {
  132744. keepAssets = new KeepAssets();
  132745. }
  132746. for (var key in this) {
  132747. if (this.hasOwnProperty(key)) {
  132748. this[key] = this[key] || [];
  132749. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  132750. }
  132751. }
  132752. this.removeAllFromScene();
  132753. };
  132754. /**
  132755. * 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.
  132756. * @returns the root mesh
  132757. */
  132758. AssetContainer.prototype.createRootMesh = function () {
  132759. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  132760. this.meshes.forEach(function (m) {
  132761. if (!m.parent) {
  132762. rootMesh.addChild(m);
  132763. }
  132764. });
  132765. this.meshes.unshift(rootMesh);
  132766. return rootMesh;
  132767. };
  132768. return AssetContainer;
  132769. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  132770. /***/ }),
  132771. /***/ "./index.ts":
  132772. /*!******************!*\
  132773. !*** ./index.ts ***!
  132774. \******************/
  132775. /*! exports provided: AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, EquiRectangularCubeTexture, HDRCubeTexture, InternalTexture, MirrorTexture, MultiRenderTarget, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, 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, LinesBuilder, PlaneBuilder, MorphTarget, MorphTargetManager, Database, BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEventOptions, PhysicsUpdraftEventOptions, PhysicsVortexEventOptions, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, VRMultiviewToSingleviewPostProcess, ReflectionProbe, BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer, Sprite, SpriteManager, SpriteSceneComponent, _AlphaState, _DepthCullingState, _StencilState, AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, EquiRectangularCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsMatrix, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, MeshExploder, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, WebRequest, InspectableType, 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, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRMaterialDefines, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, DiscBuilder, RibbonBuilder, HemisphereBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  132776. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132777. "use strict";
  132778. __webpack_require__.r(__webpack_exports__);
  132779. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  132780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  132781. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  132782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  132783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  132784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  132785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  132786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  132787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  132788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  132789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  132790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  132791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  132792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  132793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  132794. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  132795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  132796. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  132797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  132798. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  132799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  132800. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  132801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  132802. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  132803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  132804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  132805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  132806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  132807. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  132808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  132809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  132810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  132811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  132812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  132813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  132814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  132815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  132816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  132817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  132818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  132819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  132820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  132821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  132822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  132823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  132824. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  132825. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  132826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  132827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  132828. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  132829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  132830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  132831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  132832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  132833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  132834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  132835. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  132836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  132837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  132838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  132839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  132840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  132841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  132842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  132843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  132844. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  132845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  132846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  132847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  132848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  132849. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  132850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  132851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  132852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  132853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  132854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  132855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  132856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  132857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  132858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  132859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  132860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  132861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  132862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  132863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  132864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  132865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  132866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  132867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  132868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  132869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  132870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  132871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  132872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  132873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  132874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraKeyboardMoveInput"]; });
  132875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraMouseWheelInput"]; });
  132876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCameraPointersInput"]; });
  132877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  132878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  132879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  132880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  132881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  132882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  132883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  132884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  132885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  132886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  132887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  132888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  132889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  132890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  132891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  132892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  132893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  132894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  132895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OnAfterEnteringVRObservableEvent", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["OnAfterEnteringVRObservableEvent"]; });
  132896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  132897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  132898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  132899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  132900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  132901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  132902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  132903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  132904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  132905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  132906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  132907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  132908. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  132909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  132910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["DefaultCollisionCoordinator"]; });
  132911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  132912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  132913. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  132914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  132915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  132916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  132917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  132918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  132919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  132920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  132921. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  132922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  132923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  132924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  132925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  132926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  132927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  132928. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  132929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  132930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  132931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  132932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  132933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  132934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  132935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  132936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  132937. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  132938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  132939. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  132940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  132941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  132942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  132943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  132944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  132945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  132946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  132947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  132948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  132949. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  132950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  132951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  132952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  132953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  132954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  132955. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  132956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  132957. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  132958. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  132959. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  132960. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  132961. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  132962. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  132963. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  132964. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  132965. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  132966. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  132967. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  132968. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  132969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  132970. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  132971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  132972. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  132973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  132974. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  132975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  132976. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  132977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  132978. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["LightGizmo"]; });
  132979. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  132980. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  132981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  132982. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  132983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  132984. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  132985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  132986. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  132987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  132988. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  132989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  132990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  132991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  132992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  132993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  132994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  132995. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  132996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  132997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  132998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  132999. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  133000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  133001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  133002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  133003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  133004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  133005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  133006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  133007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  133008. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  133009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  133010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  133011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  133012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  133013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  133014. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  133015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  133016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  133017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  133018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  133019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  133020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  133021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  133022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  133023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  133024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  133025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  133026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  133027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  133028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  133029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  133030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  133031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  133032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EquiRectangularCubeTexture"]; });
  133033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  133034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  133035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  133036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  133037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  133038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  133039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  133040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  133041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  133042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterialDefines"]; });
  133043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  133044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  133045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  133046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  133047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  133048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  133049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  133050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  133051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  133052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  133053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  133054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  133055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  133056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  133057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  133058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  133059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  133060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  133061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  133062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  133063. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  133064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  133065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  133066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  133067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  133068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  133069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  133070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  133071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  133072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  133073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  133074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  133075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  133076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  133077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  133078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  133079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  133080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  133081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  133082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  133083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  133084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  133085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  133086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  133087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  133088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  133089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  133090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Tmp"]; });
  133091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  133092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  133093. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  133094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  133095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  133096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  133097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  133098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  133099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  133100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TrailMesh"]; });
  133101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  133102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  133103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  133104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  133105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  133106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  133107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  133108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  133109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  133110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  133111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  133112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  133113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  133114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  133115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  133116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  133117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  133118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  133119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxBuilder"]; });
  133120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereBuilder"]; });
  133121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderBuilder"]; });
  133122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesBuilder"]; });
  133123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneBuilder"]; });
  133124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  133125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscBuilder"]; });
  133126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonBuilder"]; });
  133127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["HemisphereBuilder"]; });
  133128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusBuilder"]; });
  133129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotBuilder"]; });
  133130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonBuilder"]; });
  133131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["ShapeBuilder"]; });
  133132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LatheBuilder"]; });
  133133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundBuilder"]; });
  133134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TubeBuilder"]; });
  133135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolyhedronBuilder"]; });
  133136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["IcoSphereBuilder"]; });
  133137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DecalBuilder"]; });
  133138. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  133139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  133140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  133141. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./node */ "./node.ts");
  133142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_25__["Node"]; });
  133143. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  133144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_26__["Database"]; });
  133145. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  133146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BaseParticleSystem"]; });
  133147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["GPUParticleSystem"]; });
  133148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["Particle"]; });
  133149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleHelper"]; });
  133150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystem"]; });
  133151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["_IDoNeedToBeInTheBuild"]; });
  133152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystemSet"]; });
  133153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticle"]; });
  133154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ModelShape"]; });
  133155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["DepthSortedParticle"]; });
  133156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticleSystem"]; });
  133157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitterType"]; });
  133158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitter"]; });
  133159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BoxParticleEmitter"]; });
  133160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ConeParticleEmitter"]; });
  133161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderParticleEmitter"]; });
  133162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderDirectedParticleEmitter"]; });
  133163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["HemisphericParticleEmitter"]; });
  133164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["PointParticleEmitter"]; });
  133165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereParticleEmitter"]; });
  133166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereDirectedParticleEmitter"]; });
  133167. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  133168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngine"]; });
  133169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngineSceneComponent"]; });
  133170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsHelper"]; });
  133171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialExplosionEventOptions"]; });
  133172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftEventOptions"]; });
  133173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEventOptions", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsVortexEventOptions"]; });
  133174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialImpulseFalloff"]; });
  133175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftMode"]; });
  133176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsImpostor"]; });
  133177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsJoint"]; });
  133178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["DistanceJoint"]; });
  133179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["MotorEnabledJoint"]; });
  133180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["HingeJoint"]; });
  133181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["Hinge2Joint"]; });
  133182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["CannonJSPlugin"]; });
  133183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["AmmoJSPlugin"]; });
  133184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["OimoJSPlugin"]; });
  133185. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  133186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["AnaglyphPostProcess"]; });
  133187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlackAndWhitePostProcess"]; });
  133188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomEffect"]; });
  133189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomMergePostProcess"]; });
  133190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlurPostProcess"]; });
  133191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ChromaticAberrationPostProcess"]; });
  133192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["CircleOfConfusionPostProcess"]; });
  133193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ColorCorrectionPostProcess"]; });
  133194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ConvolutionPostProcess"]; });
  133195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldBlurPostProcess"]; });
  133196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffectBlurLevel"]; });
  133197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffect"]; });
  133198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcessOptions"]; });
  133199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcess"]; });
  133200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DisplayPassPostProcess"]; });
  133201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ExtractHighlightsPostProcess"]; });
  133202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FilterPostProcess"]; });
  133203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FxaaPostProcess"]; });
  133204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["GrainPostProcess"]; });
  133205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["HighlightsPostProcess"]; });
  133206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ImageProcessingPostProcess"]; });
  133207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["MotionBlurPostProcess"]; });
  133208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassPostProcess"]; });
  133209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassCubePostProcess"]; });
  133210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcess"]; });
  133211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessManager"]; });
  133212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["RefractionPostProcess"]; });
  133213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SharpenPostProcess"]; });
  133214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StereoscopicInterlacePostProcess"]; });
  133215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemappingOperator"]; });
  133216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemapPostProcess"]; });
  133217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VolumetricLightScatteringPostProcess"]; });
  133218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  133219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRMultiviewToSingleviewPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRMultiviewToSingleviewPostProcess"]; });
  133220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderEffect"]; });
  133221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipeline"]; });
  133222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManager"]; });
  133223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManagerSceneComponent"]; });
  133224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DefaultRenderingPipeline"]; });
  133225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["LensRenderingPipeline"]; });
  133226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAO2RenderingPipeline"]; });
  133227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAORenderingPipeline"]; });
  133228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StandardRenderingPipeline"]; });
  133229. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  133230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_30__["ReflectionProbe"]; });
  133231. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  133232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["BoundingBoxRenderer"]; });
  133233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRenderer"]; });
  133234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRendererSceneComponent"]; });
  133235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["EdgesRenderer"]; });
  133236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["LineEdgesRenderer"]; });
  133237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRenderer"]; });
  133238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRendererSceneComponent"]; });
  133239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["OutlineRenderer"]; });
  133240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroup"]; });
  133241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroupInfo"]; });
  133242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingManager"]; });
  133243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["UtilityLayerRenderer"]; });
  133244. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  133245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_32__["Scene"]; });
  133246. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  133247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["SceneComponentConstants"]; });
  133248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["Stage"]; });
  133249. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  133250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["Sprite"]; });
  133251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteManager"]; });
  133252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteSceneComponent"]; });
  133253. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  133254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_AlphaState"]; });
  133255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_DepthCullingState"]; });
  133256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_StencilState"]; });
  133257. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  133258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AndOrNotEvaluator"]; });
  133259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetTaskState"]; });
  133260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AbstractAssetTask"]; });
  133261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsProgressEvent"]; });
  133262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshAssetTask"]; });
  133263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextFileAssetTask"]; });
  133264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["BinaryFileAssetTask"]; });
  133265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ImageAssetTask"]; });
  133266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureAssetTask"]; });
  133267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeTextureAssetTask"]; });
  133268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRCubeTextureAssetTask"]; });
  133269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EquiRectangularCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EquiRectangularCubeTextureAssetTask"]; });
  133270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsManager"]; });
  133271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DDSTools"]; });
  133272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["expandToProperty"]; });
  133273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serialize"]; });
  133274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsTexture"]; });
  133275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor3"]; });
  133276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsFresnelParameters"]; });
  133277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector2"]; });
  133278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector3"]; });
  133279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMeshReference"]; });
  133280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColorCurves"]; });
  133281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor4"]; });
  133282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsImageProcessingConfiguration"]; });
  133283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsQuaternion"]; });
  133284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMatrix", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMatrix"]; });
  133285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsCameraReference"]; });
  133286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SerializationHelper"]; });
  133287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Deferred"]; });
  133288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EnvironmentTextureTools"]; });
  133289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshExploder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshExploder"]; });
  133290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInput"]; });
  133291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["KhronosTextureContainer"]; });
  133292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EventState"]; });
  133293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observer"]; });
  133294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MultiObserver"]; });
  133295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observable"]; });
  133296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerformanceMonitor"]; });
  133297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RollingAverage"]; });
  133298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PromisePolyfill"]; });
  133299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimization"]; });
  133300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureOptimization"]; });
  133301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HardwareScalingOptimization"]; });
  133302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ShadowsOptimization"]; });
  133303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PostProcessesOptimization"]; });
  133304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LensFlaresOptimization"]; });
  133305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CustomOptimization"]; });
  133306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ParticlesOptimization"]; });
  133307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RenderTargetsOptimization"]; });
  133308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MergeMeshesOptimization"]; });
  133309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizerOptions"]; });
  133310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizer"]; });
  133311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneSerializer"]; });
  133312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArray"]; });
  133313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArrayNoDuplicate"]; });
  133314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["StringDictionary"]; });
  133315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tags"]; });
  133316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureTools"]; });
  133317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TGATools"]; });
  133318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ColorGradient"]; });
  133319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Color3Gradient"]; });
  133320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FactorGradient"]; });
  133321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LoadFileError"]; });
  133322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  133323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tools"]; });
  133324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerfCounter"]; });
  133325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["className"]; });
  133326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AsyncLoop"]; });
  133327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VideoRecorder"]; });
  133328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["JoystickAxis"]; });
  133329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VirtualJoystick"]; });
  133330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WorkerPool"]; });
  133331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Logger"]; });
  133332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["_TypeStore"]; });
  133333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInputStore"]; });
  133334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DeepCopier"]; });
  133335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PivotTools"]; });
  133336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PrecisionDate"]; });
  133337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ScreenshotTools"]; });
  133338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebRequest", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WebRequest"]; });
  133339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InspectableType", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["InspectableType"]; });
  133340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeMapToSphericalPolynomialTools"]; });
  133341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRTools"]; });
  133342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PanoramaToCubeMapTools"]; });
  133343. /***/ }),
  133344. /***/ "./node.ts":
  133345. /*!*****************!*\
  133346. !*** ./node.ts ***!
  133347. \*****************/
  133348. /*! exports provided: Node */
  133349. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  133350. "use strict";
  133351. __webpack_require__.r(__webpack_exports__);
  133352. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  133353. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  133354. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  133355. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  133356. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  133357. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  133358. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  133359. /**
  133360. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  133361. */
  133362. var Node = /** @class */ (function () {
  133363. /**
  133364. * Creates a new Node
  133365. * @param name the name and id to be given to this node
  133366. * @param scene the scene this node will be added to
  133367. * @param addToRootNodes the node will be added to scene.rootNodes
  133368. */
  133369. function Node(name, scene, addToRootNodes) {
  133370. if (scene === void 0) { scene = null; }
  133371. if (addToRootNodes === void 0) { addToRootNodes = true; }
  133372. /**
  133373. * Gets or sets a string used to store user defined state for the node
  133374. */
  133375. this.state = "";
  133376. /**
  133377. * Gets or sets an object used to store user defined information for the node
  133378. */
  133379. this.metadata = null;
  133380. /**
  133381. * For internal use only. Please do not use.
  133382. */
  133383. this.reservedDataStore = null;
  133384. /**
  133385. * Gets or sets a boolean used to define if the node must be serialized
  133386. */
  133387. this.doNotSerialize = false;
  133388. /** @hidden */
  133389. this._isDisposed = false;
  133390. /**
  133391. * Gets a list of Animations associated with the node
  133392. */
  133393. this.animations = new Array();
  133394. this._ranges = {};
  133395. this._isEnabled = true;
  133396. this._isParentEnabled = true;
  133397. this._isReady = true;
  133398. /** @hidden */
  133399. this._currentRenderId = -1;
  133400. this._parentUpdateId = -1;
  133401. this._childUpdateId = -1;
  133402. /** @hidden */
  133403. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  133404. /** @hidden */
  133405. this._worldMatrixDeterminant = 0;
  133406. /** @hidden */
  133407. this._worldMatrixDeterminantIsDirty = true;
  133408. /** @hidden */
  133409. this._sceneRootNodesIndex = -1;
  133410. this._animationPropertiesOverride = null;
  133411. /** @hidden */
  133412. this._isNode = true;
  133413. /**
  133414. * An event triggered when the mesh is disposed
  133415. */
  133416. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  133417. // Behaviors
  133418. this._behaviors = new Array();
  133419. this.name = name;
  133420. this.id = name;
  133421. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  133422. this.uniqueId = this._scene.getUniqueId();
  133423. this._initCache();
  133424. if (addToRootNodes) {
  133425. this.addToSceneRootNodes();
  133426. }
  133427. }
  133428. /**
  133429. * Add a new node constructor
  133430. * @param type defines the type name of the node to construct
  133431. * @param constructorFunc defines the constructor function
  133432. */
  133433. Node.AddNodeConstructor = function (type, constructorFunc) {
  133434. this._NodeConstructors[type] = constructorFunc;
  133435. };
  133436. /**
  133437. * Returns a node constructor based on type name
  133438. * @param type defines the type name
  133439. * @param name defines the new node name
  133440. * @param scene defines the hosting scene
  133441. * @param options defines optional options to transmit to constructors
  133442. * @returns the new constructor or null
  133443. */
  133444. Node.Construct = function (type, name, scene, options) {
  133445. var constructorFunc = this._NodeConstructors[type];
  133446. if (!constructorFunc) {
  133447. return null;
  133448. }
  133449. return constructorFunc(name, scene, options);
  133450. };
  133451. /**
  133452. * Gets a boolean indicating if the node has been disposed
  133453. * @returns true if the node was disposed
  133454. */
  133455. Node.prototype.isDisposed = function () {
  133456. return this._isDisposed;
  133457. };
  133458. Object.defineProperty(Node.prototype, "parent", {
  133459. get: function () {
  133460. return this._parentNode;
  133461. },
  133462. /**
  133463. * Gets or sets the parent of the node (without keeping the current position in the scene)
  133464. * @see https://doc.babylonjs.com/how_to/parenting
  133465. */
  133466. set: function (parent) {
  133467. if (this._parentNode === parent) {
  133468. return;
  133469. }
  133470. var previousParentNode = this._parentNode;
  133471. // Remove self from list of children of parent
  133472. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  133473. var index = this._parentNode._children.indexOf(this);
  133474. if (index !== -1) {
  133475. this._parentNode._children.splice(index, 1);
  133476. }
  133477. if (!parent && !this._isDisposed) {
  133478. this.addToSceneRootNodes();
  133479. }
  133480. }
  133481. // Store new parent
  133482. this._parentNode = parent;
  133483. // Add as child to new parent
  133484. if (this._parentNode) {
  133485. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  133486. this._parentNode._children = new Array();
  133487. }
  133488. this._parentNode._children.push(this);
  133489. if (!previousParentNode) {
  133490. this.removeFromSceneRootNodes();
  133491. }
  133492. }
  133493. // Enabled state
  133494. this._syncParentEnabledState();
  133495. },
  133496. enumerable: true,
  133497. configurable: true
  133498. });
  133499. Node.prototype.addToSceneRootNodes = function () {
  133500. if (this._sceneRootNodesIndex === -1) {
  133501. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  133502. this._scene.rootNodes.push(this);
  133503. }
  133504. };
  133505. Node.prototype.removeFromSceneRootNodes = function () {
  133506. if (this._sceneRootNodesIndex !== -1) {
  133507. var rootNodes = this._scene.rootNodes;
  133508. var lastIdx = rootNodes.length - 1;
  133509. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  133510. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  133511. this._scene.rootNodes.pop();
  133512. this._sceneRootNodesIndex = -1;
  133513. }
  133514. };
  133515. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  133516. /**
  133517. * Gets or sets the animation properties override
  133518. */
  133519. get: function () {
  133520. if (!this._animationPropertiesOverride) {
  133521. return this._scene.animationPropertiesOverride;
  133522. }
  133523. return this._animationPropertiesOverride;
  133524. },
  133525. set: function (value) {
  133526. this._animationPropertiesOverride = value;
  133527. },
  133528. enumerable: true,
  133529. configurable: true
  133530. });
  133531. /**
  133532. * Gets a string idenfifying the name of the class
  133533. * @returns "Node" string
  133534. */
  133535. Node.prototype.getClassName = function () {
  133536. return "Node";
  133537. };
  133538. Object.defineProperty(Node.prototype, "onDispose", {
  133539. /**
  133540. * Sets a callback that will be raised when the node will be disposed
  133541. */
  133542. set: function (callback) {
  133543. if (this._onDisposeObserver) {
  133544. this.onDisposeObservable.remove(this._onDisposeObserver);
  133545. }
  133546. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  133547. },
  133548. enumerable: true,
  133549. configurable: true
  133550. });
  133551. /**
  133552. * Gets the scene of the node
  133553. * @returns a scene
  133554. */
  133555. Node.prototype.getScene = function () {
  133556. return this._scene;
  133557. };
  133558. /**
  133559. * Gets the engine of the node
  133560. * @returns a Engine
  133561. */
  133562. Node.prototype.getEngine = function () {
  133563. return this._scene.getEngine();
  133564. };
  133565. /**
  133566. * Attach a behavior to the node
  133567. * @see http://doc.babylonjs.com/features/behaviour
  133568. * @param behavior defines the behavior to attach
  133569. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  133570. * @returns the current Node
  133571. */
  133572. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  133573. var _this = this;
  133574. if (attachImmediately === void 0) { attachImmediately = false; }
  133575. var index = this._behaviors.indexOf(behavior);
  133576. if (index !== -1) {
  133577. return this;
  133578. }
  133579. behavior.init();
  133580. if (this._scene.isLoading && !attachImmediately) {
  133581. // We defer the attach when the scene will be loaded
  133582. this._scene.onDataLoadedObservable.addOnce(function () {
  133583. behavior.attach(_this);
  133584. });
  133585. }
  133586. else {
  133587. behavior.attach(this);
  133588. }
  133589. this._behaviors.push(behavior);
  133590. return this;
  133591. };
  133592. /**
  133593. * Remove an attached behavior
  133594. * @see http://doc.babylonjs.com/features/behaviour
  133595. * @param behavior defines the behavior to attach
  133596. * @returns the current Node
  133597. */
  133598. Node.prototype.removeBehavior = function (behavior) {
  133599. var index = this._behaviors.indexOf(behavior);
  133600. if (index === -1) {
  133601. return this;
  133602. }
  133603. this._behaviors[index].detach();
  133604. this._behaviors.splice(index, 1);
  133605. return this;
  133606. };
  133607. Object.defineProperty(Node.prototype, "behaviors", {
  133608. /**
  133609. * Gets the list of attached behaviors
  133610. * @see http://doc.babylonjs.com/features/behaviour
  133611. */
  133612. get: function () {
  133613. return this._behaviors;
  133614. },
  133615. enumerable: true,
  133616. configurable: true
  133617. });
  133618. /**
  133619. * Gets an attached behavior by name
  133620. * @param name defines the name of the behavior to look for
  133621. * @see http://doc.babylonjs.com/features/behaviour
  133622. * @returns null if behavior was not found else the requested behavior
  133623. */
  133624. Node.prototype.getBehaviorByName = function (name) {
  133625. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  133626. var behavior = _a[_i];
  133627. if (behavior.name === name) {
  133628. return behavior;
  133629. }
  133630. }
  133631. return null;
  133632. };
  133633. /**
  133634. * Returns the latest update of the World matrix
  133635. * @returns a Matrix
  133636. */
  133637. Node.prototype.getWorldMatrix = function () {
  133638. if (this._currentRenderId !== this._scene.getRenderId()) {
  133639. this.computeWorldMatrix();
  133640. }
  133641. return this._worldMatrix;
  133642. };
  133643. /** @hidden */
  133644. Node.prototype._getWorldMatrixDeterminant = function () {
  133645. if (this._worldMatrixDeterminantIsDirty) {
  133646. this._worldMatrixDeterminantIsDirty = false;
  133647. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  133648. }
  133649. return this._worldMatrixDeterminant;
  133650. };
  133651. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  133652. /**
  133653. * Returns directly the latest state of the mesh World matrix.
  133654. * A Matrix is returned.
  133655. */
  133656. get: function () {
  133657. return this._worldMatrix;
  133658. },
  133659. enumerable: true,
  133660. configurable: true
  133661. });
  133662. // override it in derived class if you add new variables to the cache
  133663. // and call the parent class method
  133664. /** @hidden */
  133665. Node.prototype._initCache = function () {
  133666. this._cache = {};
  133667. this._cache.parent = undefined;
  133668. };
  133669. /** @hidden */
  133670. Node.prototype.updateCache = function (force) {
  133671. if (!force && this.isSynchronized()) {
  133672. return;
  133673. }
  133674. this._cache.parent = this.parent;
  133675. this._updateCache();
  133676. };
  133677. /** @hidden */
  133678. Node.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  133679. if (initialCall === void 0) { initialCall = true; }
  133680. if (!this.parent) {
  133681. return null;
  133682. }
  133683. return this.parent._getActionManagerForTrigger(trigger, false);
  133684. };
  133685. // override it in derived class if you add new variables to the cache
  133686. // and call the parent class method if !ignoreParentClass
  133687. /** @hidden */
  133688. Node.prototype._updateCache = function (ignoreParentClass) {
  133689. };
  133690. // override it in derived class if you add new variables to the cache
  133691. /** @hidden */
  133692. Node.prototype._isSynchronized = function () {
  133693. return true;
  133694. };
  133695. /** @hidden */
  133696. Node.prototype._markSyncedWithParent = function () {
  133697. if (this._parentNode) {
  133698. this._parentUpdateId = this._parentNode._childUpdateId;
  133699. }
  133700. };
  133701. /** @hidden */
  133702. Node.prototype.isSynchronizedWithParent = function () {
  133703. if (!this._parentNode) {
  133704. return true;
  133705. }
  133706. if (this._parentUpdateId !== this._parentNode._childUpdateId) {
  133707. return false;
  133708. }
  133709. return this._parentNode.isSynchronized();
  133710. };
  133711. /** @hidden */
  133712. Node.prototype.isSynchronized = function () {
  133713. if (this._cache.parent != this._parentNode) {
  133714. this._cache.parent = this._parentNode;
  133715. return false;
  133716. }
  133717. if (this._parentNode && !this.isSynchronizedWithParent()) {
  133718. return false;
  133719. }
  133720. return this._isSynchronized();
  133721. };
  133722. /**
  133723. * Is this node ready to be used/rendered
  133724. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  133725. * @return true if the node is ready
  133726. */
  133727. Node.prototype.isReady = function (completeCheck) {
  133728. if (completeCheck === void 0) { completeCheck = false; }
  133729. return this._isReady;
  133730. };
  133731. /**
  133732. * Is this node enabled?
  133733. * 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
  133734. * @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
  133735. * @return whether this node (and its parent) is enabled
  133736. */
  133737. Node.prototype.isEnabled = function (checkAncestors) {
  133738. if (checkAncestors === void 0) { checkAncestors = true; }
  133739. if (checkAncestors === false) {
  133740. return this._isEnabled;
  133741. }
  133742. if (!this._isEnabled) {
  133743. return false;
  133744. }
  133745. return this._isParentEnabled;
  133746. };
  133747. /** @hidden */
  133748. Node.prototype._syncParentEnabledState = function () {
  133749. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  133750. if (this._children) {
  133751. this._children.forEach(function (c) {
  133752. c._syncParentEnabledState(); // Force children to update accordingly
  133753. });
  133754. }
  133755. };
  133756. /**
  133757. * Set the enabled state of this node
  133758. * @param value defines the new enabled state
  133759. */
  133760. Node.prototype.setEnabled = function (value) {
  133761. this._isEnabled = value;
  133762. this._syncParentEnabledState();
  133763. };
  133764. /**
  133765. * Is this node a descendant of the given node?
  133766. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  133767. * @param ancestor defines the parent node to inspect
  133768. * @returns a boolean indicating if this node is a descendant of the given node
  133769. */
  133770. Node.prototype.isDescendantOf = function (ancestor) {
  133771. if (this.parent) {
  133772. if (this.parent === ancestor) {
  133773. return true;
  133774. }
  133775. return this.parent.isDescendantOf(ancestor);
  133776. }
  133777. return false;
  133778. };
  133779. /** @hidden */
  133780. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  133781. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  133782. if (!this._children) {
  133783. return;
  133784. }
  133785. for (var index = 0; index < this._children.length; index++) {
  133786. var item = this._children[index];
  133787. if (!predicate || predicate(item)) {
  133788. results.push(item);
  133789. }
  133790. if (!directDescendantsOnly) {
  133791. item._getDescendants(results, false, predicate);
  133792. }
  133793. }
  133794. };
  133795. /**
  133796. * Will return all nodes that have this node as ascendant
  133797. * @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
  133798. * @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
  133799. * @return all children nodes of all types
  133800. */
  133801. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  133802. var results = new Array();
  133803. this._getDescendants(results, directDescendantsOnly, predicate);
  133804. return results;
  133805. };
  133806. /**
  133807. * Get all child-meshes of this node
  133808. * @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)
  133809. * @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
  133810. * @returns an array of AbstractMesh
  133811. */
  133812. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  133813. var results = [];
  133814. this._getDescendants(results, directDescendantsOnly, function (node) {
  133815. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  133816. });
  133817. return results;
  133818. };
  133819. /**
  133820. * Get all direct children of this node
  133821. * @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
  133822. * @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)
  133823. * @returns an array of Node
  133824. */
  133825. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  133826. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  133827. return this.getDescendants(directDescendantsOnly, predicate);
  133828. };
  133829. /** @hidden */
  133830. Node.prototype._setReady = function (state) {
  133831. if (state === this._isReady) {
  133832. return;
  133833. }
  133834. if (!state) {
  133835. this._isReady = false;
  133836. return;
  133837. }
  133838. if (this.onReady) {
  133839. this.onReady(this);
  133840. }
  133841. this._isReady = true;
  133842. };
  133843. /**
  133844. * Get an animation by name
  133845. * @param name defines the name of the animation to look for
  133846. * @returns null if not found else the requested animation
  133847. */
  133848. Node.prototype.getAnimationByName = function (name) {
  133849. for (var i = 0; i < this.animations.length; i++) {
  133850. var animation = this.animations[i];
  133851. if (animation.name === name) {
  133852. return animation;
  133853. }
  133854. }
  133855. return null;
  133856. };
  133857. /**
  133858. * Creates an animation range for this node
  133859. * @param name defines the name of the range
  133860. * @param from defines the starting key
  133861. * @param to defines the end key
  133862. */
  133863. Node.prototype.createAnimationRange = function (name, from, to) {
  133864. // check name not already in use
  133865. if (!this._ranges[name]) {
  133866. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  133867. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  133868. if (this.animations[i]) {
  133869. this.animations[i].createRange(name, from, to);
  133870. }
  133871. }
  133872. }
  133873. };
  133874. /**
  133875. * Delete a specific animation range
  133876. * @param name defines the name of the range to delete
  133877. * @param deleteFrames defines if animation frames from the range must be deleted as well
  133878. */
  133879. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  133880. if (deleteFrames === void 0) { deleteFrames = true; }
  133881. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  133882. if (this.animations[i]) {
  133883. this.animations[i].deleteRange(name, deleteFrames);
  133884. }
  133885. }
  133886. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  133887. };
  133888. /**
  133889. * Get an animation range by name
  133890. * @param name defines the name of the animation range to look for
  133891. * @returns null if not found else the requested animation range
  133892. */
  133893. Node.prototype.getAnimationRange = function (name) {
  133894. return this._ranges[name];
  133895. };
  133896. /**
  133897. * Gets the list of all animation ranges defined on this node
  133898. * @returns an array
  133899. */
  133900. Node.prototype.getAnimationRanges = function () {
  133901. var animationRanges = [];
  133902. var name;
  133903. for (name in this._ranges) {
  133904. animationRanges.push(this._ranges[name]);
  133905. }
  133906. return animationRanges;
  133907. };
  133908. /**
  133909. * Will start the animation sequence
  133910. * @param name defines the range frames for animation sequence
  133911. * @param loop defines if the animation should loop (false by default)
  133912. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  133913. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  133914. * @returns the object created for this animation. If range does not exist, it will return null
  133915. */
  133916. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  133917. var range = this.getAnimationRange(name);
  133918. if (!range) {
  133919. return null;
  133920. }
  133921. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  133922. };
  133923. /**
  133924. * Serialize animation ranges into a JSON compatible object
  133925. * @returns serialization object
  133926. */
  133927. Node.prototype.serializeAnimationRanges = function () {
  133928. var serializationRanges = [];
  133929. for (var name in this._ranges) {
  133930. var localRange = this._ranges[name];
  133931. if (!localRange) {
  133932. continue;
  133933. }
  133934. var range = {};
  133935. range.name = name;
  133936. range.from = localRange.from;
  133937. range.to = localRange.to;
  133938. serializationRanges.push(range);
  133939. }
  133940. return serializationRanges;
  133941. };
  133942. /**
  133943. * Computes the world matrix of the node
  133944. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  133945. * @returns the world matrix
  133946. */
  133947. Node.prototype.computeWorldMatrix = function (force) {
  133948. if (!this._worldMatrix) {
  133949. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  133950. }
  133951. return this._worldMatrix;
  133952. };
  133953. /**
  133954. * Releases resources associated with this node.
  133955. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  133956. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  133957. */
  133958. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  133959. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  133960. this._isDisposed = true;
  133961. if (!doNotRecurse) {
  133962. var nodes = this.getDescendants(true);
  133963. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  133964. var node = nodes_1[_i];
  133965. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  133966. }
  133967. }
  133968. if (!this.parent) {
  133969. this.removeFromSceneRootNodes();
  133970. }
  133971. else {
  133972. this.parent = null;
  133973. }
  133974. // Callback
  133975. this.onDisposeObservable.notifyObservers(this);
  133976. this.onDisposeObservable.clear();
  133977. // Behaviors
  133978. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  133979. var behavior = _b[_a];
  133980. behavior.detach();
  133981. }
  133982. this._behaviors = [];
  133983. };
  133984. /**
  133985. * Parse animation range data from a serialization object and store them into a given node
  133986. * @param node defines where to store the animation ranges
  133987. * @param parsedNode defines the serialization object to read data from
  133988. * @param scene defines the hosting scene
  133989. */
  133990. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  133991. if (parsedNode.ranges) {
  133992. for (var index = 0; index < parsedNode.ranges.length; index++) {
  133993. var data = parsedNode.ranges[index];
  133994. node.createAnimationRange(data.name, data.from, data.to);
  133995. }
  133996. }
  133997. };
  133998. /** @hidden */
  133999. Node._AnimationRangeFactory = function (name, from, to) {
  134000. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AnimationRange");
  134001. };
  134002. Node._NodeConstructors = {};
  134003. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134004. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  134005. ], Node.prototype, "name", void 0);
  134006. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134007. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  134008. ], Node.prototype, "id", void 0);
  134009. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134010. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  134011. ], Node.prototype, "uniqueId", void 0);
  134012. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134013. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  134014. ], Node.prototype, "state", void 0);
  134015. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  134016. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  134017. ], Node.prototype, "metadata", void 0);
  134018. return Node;
  134019. }());
  134020. /***/ }),
  134021. /***/ "./scene.ts":
  134022. /*!******************!*\
  134023. !*** ./scene.ts ***!
  134024. \******************/
  134025. /*! exports provided: Scene */
  134026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  134027. "use strict";
  134028. __webpack_require__.r(__webpack_exports__);
  134029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  134030. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  134031. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  134032. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  134033. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  134034. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  134035. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  134036. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  134037. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  134038. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/transformNode */ "./Meshes/transformNode.ts");
  134039. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  134040. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  134041. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  134042. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  134043. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  134044. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  134045. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  134046. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Events/pointerEvents */ "./Events/pointerEvents.ts");
  134047. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  134048. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  134049. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  134050. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  134051. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  134052. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  134053. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  134054. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  134055. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  134056. /* harmony import */ var _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Actions/abstractActionManager */ "./Actions/abstractActionManager.ts");
  134057. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  134058. /** @hidden */
  134059. var ClickInfo = /** @class */ (function () {
  134060. function ClickInfo() {
  134061. this._singleClick = false;
  134062. this._doubleClick = false;
  134063. this._hasSwiped = false;
  134064. this._ignore = false;
  134065. }
  134066. Object.defineProperty(ClickInfo.prototype, "singleClick", {
  134067. get: function () {
  134068. return this._singleClick;
  134069. },
  134070. set: function (b) {
  134071. this._singleClick = b;
  134072. },
  134073. enumerable: true,
  134074. configurable: true
  134075. });
  134076. Object.defineProperty(ClickInfo.prototype, "doubleClick", {
  134077. get: function () {
  134078. return this._doubleClick;
  134079. },
  134080. set: function (b) {
  134081. this._doubleClick = b;
  134082. },
  134083. enumerable: true,
  134084. configurable: true
  134085. });
  134086. Object.defineProperty(ClickInfo.prototype, "hasSwiped", {
  134087. get: function () {
  134088. return this._hasSwiped;
  134089. },
  134090. set: function (b) {
  134091. this._hasSwiped = b;
  134092. },
  134093. enumerable: true,
  134094. configurable: true
  134095. });
  134096. Object.defineProperty(ClickInfo.prototype, "ignore", {
  134097. get: function () {
  134098. return this._ignore;
  134099. },
  134100. set: function (b) {
  134101. this._ignore = b;
  134102. },
  134103. enumerable: true,
  134104. configurable: true
  134105. });
  134106. return ClickInfo;
  134107. }());
  134108. /**
  134109. * Represents a scene to be rendered by the engine.
  134110. * @see http://doc.babylonjs.com/features/scene
  134111. */
  134112. var Scene = /** @class */ (function (_super) {
  134113. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  134114. /**
  134115. * Creates a new Scene
  134116. * @param engine defines the engine to use to render this scene
  134117. * @param options defines the scene options
  134118. */
  134119. function Scene(engine, options) {
  134120. var _this = _super.call(this) || this;
  134121. // Members
  134122. /** @hidden */
  134123. _this._isScene = true;
  134124. /**
  134125. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  134126. */
  134127. _this.autoClear = true;
  134128. /**
  134129. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  134130. */
  134131. _this.autoClearDepthAndStencil = true;
  134132. /**
  134133. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  134134. */
  134135. _this.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color4"](0.2, 0.2, 0.3, 1.0);
  134136. /**
  134137. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  134138. */
  134139. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0, 0, 0);
  134140. _this._forceWireframe = false;
  134141. _this._forcePointsCloud = false;
  134142. /**
  134143. * Gets or sets a boolean indicating if animations are enabled
  134144. */
  134145. _this.animationsEnabled = true;
  134146. _this._animationPropertiesOverride = null;
  134147. /**
  134148. * Gets or sets a boolean indicating if a constant deltatime has to be used
  134149. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  134150. */
  134151. _this.useConstantAnimationDeltaTime = false;
  134152. /**
  134153. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  134154. * Please note that it requires to run a ray cast through the scene on every frame
  134155. */
  134156. _this.constantlyUpdateMeshUnderPointer = false;
  134157. /**
  134158. * Defines the HTML cursor to use when hovering over interactive elements
  134159. */
  134160. _this.hoverCursor = "pointer";
  134161. /**
  134162. * Defines the HTML default cursor to use (empty by default)
  134163. */
  134164. _this.defaultCursor = "";
  134165. /**
  134166. * This is used to call preventDefault() on pointer down
  134167. * in order to block unwanted artifacts like system double clicks
  134168. */
  134169. _this.preventDefaultOnPointerDown = true;
  134170. /**
  134171. * This is used to call preventDefault() on pointer up
  134172. * in order to block unwanted artifacts like system double clicks
  134173. */
  134174. _this.preventDefaultOnPointerUp = true;
  134175. // Metadata
  134176. /**
  134177. * Gets or sets user defined metadata
  134178. */
  134179. _this.metadata = null;
  134180. /**
  134181. * For internal use only. Please do not use.
  134182. */
  134183. _this.reservedDataStore = null;
  134184. /**
  134185. * Use this array to add regular expressions used to disable offline support for specific urls
  134186. */
  134187. _this.disableOfflineSupportExceptionRules = new Array();
  134188. /**
  134189. * An event triggered when the scene is disposed.
  134190. */
  134191. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134192. _this._onDisposeObserver = null;
  134193. /**
  134194. * An event triggered before rendering the scene (right after animations and physics)
  134195. */
  134196. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134197. _this._onBeforeRenderObserver = null;
  134198. /**
  134199. * An event triggered after rendering the scene
  134200. */
  134201. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134202. _this._onAfterRenderObserver = null;
  134203. /**
  134204. * An event triggered before animating the scene
  134205. */
  134206. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134207. /**
  134208. * An event triggered after animations processing
  134209. */
  134210. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134211. /**
  134212. * An event triggered before draw calls are ready to be sent
  134213. */
  134214. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134215. /**
  134216. * An event triggered after draw calls have been sent
  134217. */
  134218. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134219. /**
  134220. * An event triggered when the scene is ready
  134221. */
  134222. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134223. /**
  134224. * An event triggered before rendering a camera
  134225. */
  134226. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134227. _this._onBeforeCameraRenderObserver = null;
  134228. /**
  134229. * An event triggered after rendering a camera
  134230. */
  134231. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134232. _this._onAfterCameraRenderObserver = null;
  134233. /**
  134234. * An event triggered when active meshes evaluation is about to start
  134235. */
  134236. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134237. /**
  134238. * An event triggered when active meshes evaluation is done
  134239. */
  134240. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134241. /**
  134242. * An event triggered when particles rendering is about to start
  134243. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  134244. */
  134245. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134246. /**
  134247. * An event triggered when particles rendering is done
  134248. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  134249. */
  134250. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134251. /**
  134252. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  134253. */
  134254. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134255. /**
  134256. * An event triggered when a camera is created
  134257. */
  134258. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134259. /**
  134260. * An event triggered when a camera is removed
  134261. */
  134262. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134263. /**
  134264. * An event triggered when a light is created
  134265. */
  134266. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134267. /**
  134268. * An event triggered when a light is removed
  134269. */
  134270. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134271. /**
  134272. * An event triggered when a geometry is created
  134273. */
  134274. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134275. /**
  134276. * An event triggered when a geometry is removed
  134277. */
  134278. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134279. /**
  134280. * An event triggered when a transform node is created
  134281. */
  134282. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134283. /**
  134284. * An event triggered when a transform node is removed
  134285. */
  134286. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134287. /**
  134288. * An event triggered when a mesh is created
  134289. */
  134290. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134291. /**
  134292. * An event triggered when a mesh is removed
  134293. */
  134294. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134295. /**
  134296. * An event triggered when a skeleton is created
  134297. */
  134298. _this.onNewSkeletonAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134299. /**
  134300. * An event triggered when a skeleton is removed
  134301. */
  134302. _this.onSkeletonRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134303. /**
  134304. * An event triggered when a material is created
  134305. */
  134306. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134307. /**
  134308. * An event triggered when a material is removed
  134309. */
  134310. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134311. /**
  134312. * An event triggered when a texture is created
  134313. */
  134314. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134315. /**
  134316. * An event triggered when a texture is removed
  134317. */
  134318. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134319. /**
  134320. * An event triggered when render targets are about to be rendered
  134321. * Can happen multiple times per frame.
  134322. */
  134323. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134324. /**
  134325. * An event triggered when render targets were rendered.
  134326. * Can happen multiple times per frame.
  134327. */
  134328. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134329. /**
  134330. * An event triggered before calculating deterministic simulation step
  134331. */
  134332. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134333. /**
  134334. * An event triggered after calculating deterministic simulation step
  134335. */
  134336. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134337. /**
  134338. * An event triggered when the activeCamera property is updated
  134339. */
  134340. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134341. /**
  134342. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  134343. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  134344. * 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)
  134345. */
  134346. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134347. /**
  134348. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  134349. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  134350. * 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)
  134351. */
  134352. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134353. /**
  134354. * This Observable will when a mesh has been imported into the scene.
  134355. */
  134356. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134357. // Animations
  134358. /** @hidden */
  134359. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  134360. /**
  134361. * 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).
  134362. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  134363. */
  134364. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134365. /**
  134366. * Observable event triggered each time an input event is received from the rendering canvas
  134367. */
  134368. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134369. _this._meshPickProceed = false;
  134370. _this._currentPickResult = null;
  134371. _this._previousPickResult = null;
  134372. _this._totalPointersPressed = 0;
  134373. _this._doubleClickOccured = false;
  134374. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  134375. _this.cameraToUseForPointers = null;
  134376. _this._pointerX = 0;
  134377. _this._pointerY = 0;
  134378. _this._startingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  134379. _this._previousStartingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  134380. _this._startingPointerTime = 0;
  134381. _this._previousStartingPointerTime = 0;
  134382. _this._pointerCaptures = {};
  134383. // Deterministic lockstep
  134384. _this._timeAccumulator = 0;
  134385. _this._currentStepId = 0;
  134386. _this._currentInternalStep = 0;
  134387. // Keyboard
  134388. /**
  134389. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  134390. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  134391. */
  134392. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134393. /**
  134394. * Observable event triggered each time an keyboard event is received from the hosting window
  134395. */
  134396. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  134397. // Coordinates system
  134398. _this._useRightHandedSystem = false;
  134399. // Fog
  134400. _this._fogEnabled = true;
  134401. _this._fogMode = Scene.FOGMODE_NONE;
  134402. /**
  134403. * Gets or sets the fog color to use
  134404. * @see http://doc.babylonjs.com/babylon101/environment#fog
  134405. * (Default is Color3(0.2, 0.2, 0.3))
  134406. */
  134407. _this.fogColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0.2, 0.2, 0.3);
  134408. /**
  134409. * Gets or sets the fog density to use
  134410. * @see http://doc.babylonjs.com/babylon101/environment#fog
  134411. * (Default is 0.1)
  134412. */
  134413. _this.fogDensity = 0.1;
  134414. /**
  134415. * Gets or sets the fog start distance to use
  134416. * @see http://doc.babylonjs.com/babylon101/environment#fog
  134417. * (Default is 0)
  134418. */
  134419. _this.fogStart = 0;
  134420. /**
  134421. * Gets or sets the fog end distance to use
  134422. * @see http://doc.babylonjs.com/babylon101/environment#fog
  134423. * (Default is 1000)
  134424. */
  134425. _this.fogEnd = 1000.0;
  134426. // Lights
  134427. _this._shadowsEnabled = true;
  134428. _this._lightsEnabled = true;
  134429. /** All of the active cameras added to this scene. */
  134430. _this.activeCameras = new Array();
  134431. // Textures
  134432. _this._texturesEnabled = true;
  134433. // Particles
  134434. /**
  134435. * Gets or sets a boolean indicating if particles are enabled on this scene
  134436. */
  134437. _this.particlesEnabled = true;
  134438. // Sprites
  134439. /**
  134440. * Gets or sets a boolean indicating if sprites are enabled on this scene
  134441. */
  134442. _this.spritesEnabled = true;
  134443. // Skeletons
  134444. _this._skeletonsEnabled = true;
  134445. // Lens flares
  134446. /**
  134447. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  134448. */
  134449. _this.lensFlaresEnabled = true;
  134450. // Collisions
  134451. /**
  134452. * Gets or sets a boolean indicating if collisions are enabled on this scene
  134453. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  134454. */
  134455. _this.collisionsEnabled = true;
  134456. /**
  134457. * Defines the gravity applied to this scene (used only for collisions)
  134458. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  134459. */
  134460. _this.gravity = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  134461. // Postprocesses
  134462. /**
  134463. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  134464. */
  134465. _this.postProcessesEnabled = true;
  134466. /**
  134467. * The list of postprocesses added to the scene
  134468. */
  134469. _this.postProcesses = new Array();
  134470. // Customs render targets
  134471. /**
  134472. * Gets or sets a boolean indicating if render targets are enabled on this scene
  134473. */
  134474. _this.renderTargetsEnabled = true;
  134475. /**
  134476. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  134477. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  134478. */
  134479. _this.dumpNextRenderTargets = false;
  134480. /**
  134481. * The list of user defined render targets added to the scene
  134482. */
  134483. _this.customRenderTargets = new Array();
  134484. /**
  134485. * Gets the list of meshes imported to the scene through SceneLoader
  134486. */
  134487. _this.importedMeshesFiles = new Array();
  134488. // Probes
  134489. /**
  134490. * Gets or sets a boolean indicating if probes are enabled on this scene
  134491. */
  134492. _this.probesEnabled = true;
  134493. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  134494. // Procedural textures
  134495. /**
  134496. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  134497. */
  134498. _this.proceduralTexturesEnabled = true;
  134499. // Performance counters
  134500. _this._totalVertices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  134501. /** @hidden */
  134502. _this._activeIndices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  134503. /** @hidden */
  134504. _this._activeParticles = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  134505. /** @hidden */
  134506. _this._activeBones = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  134507. /** @hidden */
  134508. _this._animationTime = 0;
  134509. /**
  134510. * Gets or sets a general scale for animation speed
  134511. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  134512. */
  134513. _this.animationTimeScale = 1;
  134514. _this._renderId = 0;
  134515. _this._frameId = 0;
  134516. _this._executeWhenReadyTimeoutId = -1;
  134517. _this._intermediateRendering = false;
  134518. _this._viewUpdateFlag = -1;
  134519. _this._projectionUpdateFlag = -1;
  134520. /** @hidden */
  134521. _this._toBeDisposed = new Array(256);
  134522. _this._activeRequests = new Array();
  134523. /** @hidden */
  134524. _this._pendingData = new Array();
  134525. _this._isDisposed = false;
  134526. /**
  134527. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  134528. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  134529. */
  134530. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  134531. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  134532. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  134533. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  134534. /** @hidden */
  134535. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  134536. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  134537. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  134538. /** @hidden */
  134539. _this._activeAnimatables = new Array();
  134540. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  134541. _this._wheelEventName = "";
  134542. /**
  134543. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  134544. * This is useful if there are more lights that the maximum simulteanous authorized
  134545. */
  134546. _this.requireLightSorting = false;
  134547. /**
  134548. * @hidden
  134549. * Backing store of defined scene components.
  134550. */
  134551. _this._components = [];
  134552. /**
  134553. * @hidden
  134554. * Backing store of defined scene components.
  134555. */
  134556. _this._serializableComponents = [];
  134557. /**
  134558. * List of components to register on the next registration step.
  134559. */
  134560. _this._transientComponents = [];
  134561. /**
  134562. * @hidden
  134563. * Defines the actions happening before camera updates.
  134564. */
  134565. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134566. /**
  134567. * @hidden
  134568. * Defines the actions happening before clear the canvas.
  134569. */
  134570. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134571. /**
  134572. * @hidden
  134573. * Defines the actions when collecting render targets for the frame.
  134574. */
  134575. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134576. /**
  134577. * @hidden
  134578. * Defines the actions happening for one camera in the frame.
  134579. */
  134580. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134581. /**
  134582. * @hidden
  134583. * Defines the actions happening during the per mesh ready checks.
  134584. */
  134585. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134586. /**
  134587. * @hidden
  134588. * Defines the actions happening before evaluate active mesh checks.
  134589. */
  134590. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134591. /**
  134592. * @hidden
  134593. * Defines the actions happening during the evaluate sub mesh checks.
  134594. */
  134595. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134596. /**
  134597. * @hidden
  134598. * Defines the actions happening during the active mesh stage.
  134599. */
  134600. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134601. /**
  134602. * @hidden
  134603. * Defines the actions happening during the per camera render target step.
  134604. */
  134605. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134606. /**
  134607. * @hidden
  134608. * Defines the actions happening just before the active camera is drawing.
  134609. */
  134610. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134611. /**
  134612. * @hidden
  134613. * Defines the actions happening just before a render target is drawing.
  134614. */
  134615. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134616. /**
  134617. * @hidden
  134618. * Defines the actions happening just before a rendering group is drawing.
  134619. */
  134620. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134621. /**
  134622. * @hidden
  134623. * Defines the actions happening just before a mesh is drawing.
  134624. */
  134625. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134626. /**
  134627. * @hidden
  134628. * Defines the actions happening just after a mesh has been drawn.
  134629. */
  134630. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134631. /**
  134632. * @hidden
  134633. * Defines the actions happening just after a rendering group has been drawn.
  134634. */
  134635. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134636. /**
  134637. * @hidden
  134638. * Defines the actions happening just after the active camera has been drawn.
  134639. */
  134640. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134641. /**
  134642. * @hidden
  134643. * Defines the actions happening just after a render target has been drawn.
  134644. */
  134645. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134646. /**
  134647. * @hidden
  134648. * Defines the actions happening just after rendering all cameras and computing intersections.
  134649. */
  134650. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134651. /**
  134652. * @hidden
  134653. * Defines the actions happening when a pointer move event happens.
  134654. */
  134655. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134656. /**
  134657. * @hidden
  134658. * Defines the actions happening when a pointer down event happens.
  134659. */
  134660. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134661. /**
  134662. * @hidden
  134663. * Defines the actions happening when a pointer up event happens.
  134664. */
  134665. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_21__["Stage"].Create();
  134666. /**
  134667. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  134668. */
  134669. _this.geometriesByUniqueId = null;
  134670. _this._defaultMeshCandidates = {
  134671. data: [],
  134672. length: 0
  134673. };
  134674. _this._defaultSubMeshCandidates = {
  134675. data: [],
  134676. length: 0
  134677. };
  134678. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  134679. _this._activeMeshesFrozen = false;
  134680. /** @hidden */
  134681. _this._allowPostProcessClearColor = true;
  134682. /**
  134683. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  134684. */
  134685. _this.getDeterministicFrameTime = function () {
  134686. return 1000.0 / 60.0; // frame time in ms
  134687. };
  134688. _this._blockMaterialDirtyMechanism = false;
  134689. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_25__["EngineStore"].LastCreatedEngine;
  134690. _this._engine.scenes.push(_this);
  134691. _this._uid = null;
  134692. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_20__["RenderingManager"](_this);
  134693. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_19__["PostProcessManager"]) {
  134694. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_19__["PostProcessManager"](_this);
  134695. }
  134696. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_23__["DomManagement"].IsWindowObjectExist()) {
  134697. _this.attachControl();
  134698. }
  134699. // Uniform Buffer
  134700. _this._createUbo();
  134701. // Default Image processing definition
  134702. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  134703. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]();
  134704. }
  134705. _this.setDefaultCandidateProviders();
  134706. if (options && options.useGeometryUniqueIdsMap === true) {
  134707. _this.geometriesByUniqueId = {};
  134708. }
  134709. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  134710. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  134711. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  134712. return _this;
  134713. }
  134714. /**
  134715. * Factory used to create the default material.
  134716. * @param name The name of the material to create
  134717. * @param scene The scene to create the material for
  134718. * @returns The default material
  134719. */
  134720. Scene.DefaultMaterialFactory = function (scene) {
  134721. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("StandardMaterial");
  134722. };
  134723. /**
  134724. * Factory used to create the a collision coordinator.
  134725. * @returns The collision coordinator
  134726. */
  134727. Scene.CollisionCoordinatorFactory = function () {
  134728. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("DefaultCollisionCoordinator");
  134729. };
  134730. Object.defineProperty(Scene.prototype, "environmentTexture", {
  134731. /**
  134732. * Texture used in all pbr material as the reflection texture.
  134733. * As in the majority of the scene they are the same (exception for multi room and so on),
  134734. * this is easier to reference from here than from all the materials.
  134735. */
  134736. get: function () {
  134737. return this._environmentTexture;
  134738. },
  134739. /**
  134740. * Texture used in all pbr material as the reflection texture.
  134741. * As in the majority of the scene they are the same (exception for multi room and so on),
  134742. * this is easier to set here than in all the materials.
  134743. */
  134744. set: function (value) {
  134745. if (this._environmentTexture === value) {
  134746. return;
  134747. }
  134748. this._environmentTexture = value;
  134749. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_TextureDirtyFlag);
  134750. },
  134751. enumerable: true,
  134752. configurable: true
  134753. });
  134754. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  134755. /**
  134756. * Default image processing configuration used either in the rendering
  134757. * Forward main pass or through the imageProcessingPostProcess if present.
  134758. * As in the majority of the scene they are the same (exception for multi camera),
  134759. * this is easier to reference from here than from all the materials and post process.
  134760. *
  134761. * No setter as we it is a shared configuration, you can set the values instead.
  134762. */
  134763. get: function () {
  134764. return this._imageProcessingConfiguration;
  134765. },
  134766. enumerable: true,
  134767. configurable: true
  134768. });
  134769. Object.defineProperty(Scene.prototype, "forceWireframe", {
  134770. get: function () {
  134771. return this._forceWireframe;
  134772. },
  134773. /**
  134774. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  134775. */
  134776. set: function (value) {
  134777. if (this._forceWireframe === value) {
  134778. return;
  134779. }
  134780. this._forceWireframe = value;
  134781. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  134782. },
  134783. enumerable: true,
  134784. configurable: true
  134785. });
  134786. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  134787. get: function () {
  134788. return this._forcePointsCloud;
  134789. },
  134790. /**
  134791. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  134792. */
  134793. set: function (value) {
  134794. if (this._forcePointsCloud === value) {
  134795. return;
  134796. }
  134797. this._forcePointsCloud = value;
  134798. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  134799. },
  134800. enumerable: true,
  134801. configurable: true
  134802. });
  134803. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  134804. /**
  134805. * Gets or sets the animation properties override
  134806. */
  134807. get: function () {
  134808. return this._animationPropertiesOverride;
  134809. },
  134810. set: function (value) {
  134811. this._animationPropertiesOverride = value;
  134812. },
  134813. enumerable: true,
  134814. configurable: true
  134815. });
  134816. Object.defineProperty(Scene.prototype, "onDispose", {
  134817. /** Sets a function to be executed when this scene is disposed. */
  134818. set: function (callback) {
  134819. if (this._onDisposeObserver) {
  134820. this.onDisposeObservable.remove(this._onDisposeObserver);
  134821. }
  134822. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  134823. },
  134824. enumerable: true,
  134825. configurable: true
  134826. });
  134827. Object.defineProperty(Scene.prototype, "beforeRender", {
  134828. /** Sets a function to be executed before rendering this scene */
  134829. set: function (callback) {
  134830. if (this._onBeforeRenderObserver) {
  134831. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  134832. }
  134833. if (callback) {
  134834. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  134835. }
  134836. },
  134837. enumerable: true,
  134838. configurable: true
  134839. });
  134840. Object.defineProperty(Scene.prototype, "afterRender", {
  134841. /** Sets a function to be executed after rendering this scene */
  134842. set: function (callback) {
  134843. if (this._onAfterRenderObserver) {
  134844. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  134845. }
  134846. if (callback) {
  134847. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  134848. }
  134849. },
  134850. enumerable: true,
  134851. configurable: true
  134852. });
  134853. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  134854. /** Sets a function to be executed before rendering a camera*/
  134855. set: function (callback) {
  134856. if (this._onBeforeCameraRenderObserver) {
  134857. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  134858. }
  134859. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  134860. },
  134861. enumerable: true,
  134862. configurable: true
  134863. });
  134864. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  134865. /** Sets a function to be executed after rendering a camera*/
  134866. set: function (callback) {
  134867. if (this._onAfterCameraRenderObserver) {
  134868. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  134869. }
  134870. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  134871. },
  134872. enumerable: true,
  134873. configurable: true
  134874. });
  134875. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  134876. /**
  134877. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  134878. */
  134879. get: function () {
  134880. return new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  134881. },
  134882. enumerable: true,
  134883. configurable: true
  134884. });
  134885. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  134886. get: function () {
  134887. return this._useRightHandedSystem;
  134888. },
  134889. /**
  134890. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  134891. */
  134892. set: function (value) {
  134893. if (this._useRightHandedSystem === value) {
  134894. return;
  134895. }
  134896. this._useRightHandedSystem = value;
  134897. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  134898. },
  134899. enumerable: true,
  134900. configurable: true
  134901. });
  134902. /**
  134903. * Sets the step Id used by deterministic lock step
  134904. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  134905. * @param newStepId defines the step Id
  134906. */
  134907. Scene.prototype.setStepId = function (newStepId) {
  134908. this._currentStepId = newStepId;
  134909. };
  134910. /**
  134911. * Gets the step Id used by deterministic lock step
  134912. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  134913. * @returns the step Id
  134914. */
  134915. Scene.prototype.getStepId = function () {
  134916. return this._currentStepId;
  134917. };
  134918. /**
  134919. * Gets the internal step used by deterministic lock step
  134920. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  134921. * @returns the internal step
  134922. */
  134923. Scene.prototype.getInternalStep = function () {
  134924. return this._currentInternalStep;
  134925. };
  134926. Object.defineProperty(Scene.prototype, "fogEnabled", {
  134927. get: function () {
  134928. return this._fogEnabled;
  134929. },
  134930. /**
  134931. * Gets or sets a boolean indicating if fog is enabled on this scene
  134932. * @see http://doc.babylonjs.com/babylon101/environment#fog
  134933. * (Default is true)
  134934. */
  134935. set: function (value) {
  134936. if (this._fogEnabled === value) {
  134937. return;
  134938. }
  134939. this._fogEnabled = value;
  134940. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  134941. },
  134942. enumerable: true,
  134943. configurable: true
  134944. });
  134945. Object.defineProperty(Scene.prototype, "fogMode", {
  134946. get: function () {
  134947. return this._fogMode;
  134948. },
  134949. /**
  134950. * Gets or sets the fog mode to use
  134951. * @see http://doc.babylonjs.com/babylon101/environment#fog
  134952. * | mode | value |
  134953. * | --- | --- |
  134954. * | FOGMODE_NONE | 0 |
  134955. * | FOGMODE_EXP | 1 |
  134956. * | FOGMODE_EXP2 | 2 |
  134957. * | FOGMODE_LINEAR | 3 |
  134958. */
  134959. set: function (value) {
  134960. if (this._fogMode === value) {
  134961. return;
  134962. }
  134963. this._fogMode = value;
  134964. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_MiscDirtyFlag);
  134965. },
  134966. enumerable: true,
  134967. configurable: true
  134968. });
  134969. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  134970. get: function () {
  134971. return this._shadowsEnabled;
  134972. },
  134973. /**
  134974. * Gets or sets a boolean indicating if shadows are enabled on this scene
  134975. */
  134976. set: function (value) {
  134977. if (this._shadowsEnabled === value) {
  134978. return;
  134979. }
  134980. this._shadowsEnabled = value;
  134981. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_LightDirtyFlag);
  134982. },
  134983. enumerable: true,
  134984. configurable: true
  134985. });
  134986. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  134987. get: function () {
  134988. return this._lightsEnabled;
  134989. },
  134990. /**
  134991. * Gets or sets a boolean indicating if lights are enabled on this scene
  134992. */
  134993. set: function (value) {
  134994. if (this._lightsEnabled === value) {
  134995. return;
  134996. }
  134997. this._lightsEnabled = value;
  134998. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_LightDirtyFlag);
  134999. },
  135000. enumerable: true,
  135001. configurable: true
  135002. });
  135003. Object.defineProperty(Scene.prototype, "activeCamera", {
  135004. /** Gets or sets the current active camera */
  135005. get: function () {
  135006. return this._activeCamera;
  135007. },
  135008. set: function (value) {
  135009. if (value === this._activeCamera) {
  135010. return;
  135011. }
  135012. this._activeCamera = value;
  135013. this.onActiveCameraChanged.notifyObservers(this);
  135014. },
  135015. enumerable: true,
  135016. configurable: true
  135017. });
  135018. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  135019. /** The default material used on meshes when no material is affected */
  135020. get: function () {
  135021. if (!this._defaultMaterial) {
  135022. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  135023. }
  135024. return this._defaultMaterial;
  135025. },
  135026. /** The default material used on meshes when no material is affected */
  135027. set: function (value) {
  135028. this._defaultMaterial = value;
  135029. },
  135030. enumerable: true,
  135031. configurable: true
  135032. });
  135033. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  135034. get: function () {
  135035. return this._texturesEnabled;
  135036. },
  135037. /**
  135038. * Gets or sets a boolean indicating if textures are enabled on this scene
  135039. */
  135040. set: function (value) {
  135041. if (this._texturesEnabled === value) {
  135042. return;
  135043. }
  135044. this._texturesEnabled = value;
  135045. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_TextureDirtyFlag);
  135046. },
  135047. enumerable: true,
  135048. configurable: true
  135049. });
  135050. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  135051. get: function () {
  135052. return this._skeletonsEnabled;
  135053. },
  135054. /**
  135055. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  135056. */
  135057. set: function (value) {
  135058. if (this._skeletonsEnabled === value) {
  135059. return;
  135060. }
  135061. this._skeletonsEnabled = value;
  135062. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_AttributesDirtyFlag);
  135063. },
  135064. enumerable: true,
  135065. configurable: true
  135066. });
  135067. Object.defineProperty(Scene.prototype, "collisionCoordinator", {
  135068. /** @hidden */
  135069. get: function () {
  135070. if (!this._collisionCoordinator) {
  135071. this._collisionCoordinator = Scene.CollisionCoordinatorFactory();
  135072. this._collisionCoordinator.init(this);
  135073. }
  135074. return this._collisionCoordinator;
  135075. },
  135076. enumerable: true,
  135077. configurable: true
  135078. });
  135079. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  135080. /**
  135081. * Gets the list of frustum planes (built from the active camera)
  135082. */
  135083. get: function () {
  135084. return this._frustumPlanes;
  135085. },
  135086. enumerable: true,
  135087. configurable: true
  135088. });
  135089. /**
  135090. * Registers the transient components if needed.
  135091. */
  135092. Scene.prototype._registerTransientComponents = function () {
  135093. // Register components that have been associated lately to the scene.
  135094. if (this._transientComponents.length > 0) {
  135095. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  135096. var component = _a[_i];
  135097. component.register();
  135098. }
  135099. this._transientComponents = [];
  135100. }
  135101. };
  135102. /**
  135103. * @hidden
  135104. * Add a component to the scene.
  135105. * Note that the ccomponent could be registered on th next frame if this is called after
  135106. * the register component stage.
  135107. * @param component Defines the component to add to the scene
  135108. */
  135109. Scene.prototype._addComponent = function (component) {
  135110. this._components.push(component);
  135111. this._transientComponents.push(component);
  135112. var serializableComponent = component;
  135113. if (serializableComponent.addFromContainer) {
  135114. this._serializableComponents.push(serializableComponent);
  135115. }
  135116. };
  135117. /**
  135118. * @hidden
  135119. * Gets a component from the scene.
  135120. * @param name defines the name of the component to retrieve
  135121. * @returns the component or null if not present
  135122. */
  135123. Scene.prototype._getComponent = function (name) {
  135124. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  135125. var component = _a[_i];
  135126. if (component.name === name) {
  135127. return component;
  135128. }
  135129. }
  135130. return null;
  135131. };
  135132. /**
  135133. * Gets a string idenfifying the name of the class
  135134. * @returns "Scene" string
  135135. */
  135136. Scene.prototype.getClassName = function () {
  135137. return "Scene";
  135138. };
  135139. /**
  135140. * @hidden
  135141. */
  135142. Scene.prototype._getDefaultMeshCandidates = function () {
  135143. this._defaultMeshCandidates.data = this.meshes;
  135144. this._defaultMeshCandidates.length = this.meshes.length;
  135145. return this._defaultMeshCandidates;
  135146. };
  135147. /**
  135148. * @hidden
  135149. */
  135150. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  135151. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  135152. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  135153. return this._defaultSubMeshCandidates;
  135154. };
  135155. /**
  135156. * Sets the default candidate providers for the scene.
  135157. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  135158. * and getCollidingSubMeshCandidates to their default function
  135159. */
  135160. Scene.prototype.setDefaultCandidateProviders = function () {
  135161. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  135162. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  135163. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  135164. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  135165. };
  135166. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  135167. /**
  135168. * Gets the mesh that is currently under the pointer
  135169. */
  135170. get: function () {
  135171. return this._pointerOverMesh;
  135172. },
  135173. enumerable: true,
  135174. configurable: true
  135175. });
  135176. Object.defineProperty(Scene.prototype, "pointerX", {
  135177. /**
  135178. * Gets or sets the current on-screen X position of the pointer
  135179. */
  135180. get: function () {
  135181. return this._pointerX;
  135182. },
  135183. set: function (value) {
  135184. this._pointerX = value;
  135185. },
  135186. enumerable: true,
  135187. configurable: true
  135188. });
  135189. Object.defineProperty(Scene.prototype, "pointerY", {
  135190. /**
  135191. * Gets or sets the current on-screen Y position of the pointer
  135192. */
  135193. get: function () {
  135194. return this._pointerY;
  135195. },
  135196. set: function (value) {
  135197. this._pointerY = value;
  135198. },
  135199. enumerable: true,
  135200. configurable: true
  135201. });
  135202. /**
  135203. * Gets the cached material (ie. the latest rendered one)
  135204. * @returns the cached material
  135205. */
  135206. Scene.prototype.getCachedMaterial = function () {
  135207. return this._cachedMaterial;
  135208. };
  135209. /**
  135210. * Gets the cached effect (ie. the latest rendered one)
  135211. * @returns the cached effect
  135212. */
  135213. Scene.prototype.getCachedEffect = function () {
  135214. return this._cachedEffect;
  135215. };
  135216. /**
  135217. * Gets the cached visibility state (ie. the latest rendered one)
  135218. * @returns the cached visibility state
  135219. */
  135220. Scene.prototype.getCachedVisibility = function () {
  135221. return this._cachedVisibility;
  135222. };
  135223. /**
  135224. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  135225. * @param material defines the current material
  135226. * @param effect defines the current effect
  135227. * @param visibility defines the current visibility state
  135228. * @returns true if one parameter is not cached
  135229. */
  135230. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  135231. if (visibility === void 0) { visibility = 1; }
  135232. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  135233. };
  135234. /**
  135235. * Gets the engine associated with the scene
  135236. * @returns an Engine
  135237. */
  135238. Scene.prototype.getEngine = function () {
  135239. return this._engine;
  135240. };
  135241. /**
  135242. * Gets the total number of vertices rendered per frame
  135243. * @returns the total number of vertices rendered per frame
  135244. */
  135245. Scene.prototype.getTotalVertices = function () {
  135246. return this._totalVertices.current;
  135247. };
  135248. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  135249. /**
  135250. * Gets the performance counter for total vertices
  135251. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  135252. */
  135253. get: function () {
  135254. return this._totalVertices;
  135255. },
  135256. enumerable: true,
  135257. configurable: true
  135258. });
  135259. /**
  135260. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  135261. * @returns the total number of active indices rendered per frame
  135262. */
  135263. Scene.prototype.getActiveIndices = function () {
  135264. return this._activeIndices.current;
  135265. };
  135266. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  135267. /**
  135268. * Gets the performance counter for active indices
  135269. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  135270. */
  135271. get: function () {
  135272. return this._activeIndices;
  135273. },
  135274. enumerable: true,
  135275. configurable: true
  135276. });
  135277. /**
  135278. * Gets the total number of active particles rendered per frame
  135279. * @returns the total number of active particles rendered per frame
  135280. */
  135281. Scene.prototype.getActiveParticles = function () {
  135282. return this._activeParticles.current;
  135283. };
  135284. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  135285. /**
  135286. * Gets the performance counter for active particles
  135287. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  135288. */
  135289. get: function () {
  135290. return this._activeParticles;
  135291. },
  135292. enumerable: true,
  135293. configurable: true
  135294. });
  135295. /**
  135296. * Gets the total number of active bones rendered per frame
  135297. * @returns the total number of active bones rendered per frame
  135298. */
  135299. Scene.prototype.getActiveBones = function () {
  135300. return this._activeBones.current;
  135301. };
  135302. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  135303. /**
  135304. * Gets the performance counter for active bones
  135305. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  135306. */
  135307. get: function () {
  135308. return this._activeBones;
  135309. },
  135310. enumerable: true,
  135311. configurable: true
  135312. });
  135313. /**
  135314. * Gets the array of active meshes
  135315. * @returns an array of AbstractMesh
  135316. */
  135317. Scene.prototype.getActiveMeshes = function () {
  135318. return this._activeMeshes;
  135319. };
  135320. /**
  135321. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  135322. * @returns a number
  135323. */
  135324. Scene.prototype.getAnimationRatio = function () {
  135325. return this._animationRatio !== undefined ? this._animationRatio : 1;
  135326. };
  135327. /**
  135328. * Gets an unique Id for the current render phase
  135329. * @returns a number
  135330. */
  135331. Scene.prototype.getRenderId = function () {
  135332. return this._renderId;
  135333. };
  135334. /**
  135335. * Gets an unique Id for the current frame
  135336. * @returns a number
  135337. */
  135338. Scene.prototype.getFrameId = function () {
  135339. return this._frameId;
  135340. };
  135341. /** Call this function if you want to manually increment the render Id*/
  135342. Scene.prototype.incrementRenderId = function () {
  135343. this._renderId++;
  135344. };
  135345. Scene.prototype._updatePointerPosition = function (evt) {
  135346. var canvasRect = this._engine.getRenderingCanvasClientRect();
  135347. if (!canvasRect) {
  135348. return;
  135349. }
  135350. this._pointerX = evt.clientX - canvasRect.left;
  135351. this._pointerY = evt.clientY - canvasRect.top;
  135352. this._unTranslatedPointerX = this._pointerX;
  135353. this._unTranslatedPointerY = this._pointerY;
  135354. };
  135355. Scene.prototype._createUbo = function () {
  135356. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_13__["UniformBuffer"](this._engine, undefined, true);
  135357. this._sceneUbo.addUniform("viewProjection", 16);
  135358. this._sceneUbo.addUniform("view", 16);
  135359. };
  135360. // Pointers handling
  135361. Scene.prototype._setRayOnPointerInfo = function (pointerInfo) {
  135362. if (pointerInfo.pickInfo && !pointerInfo.pickInfo._pickingUnavailable) {
  135363. if (!pointerInfo.pickInfo.ray) {
  135364. pointerInfo.pickInfo.ray = this.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), this.activeCamera);
  135365. }
  135366. }
  135367. };
  135368. /**
  135369. * Use this method to simulate a pointer move on a mesh
  135370. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  135371. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  135372. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  135373. * @returns the current scene
  135374. */
  135375. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  135376. var evt = new PointerEvent("pointermove", pointerEventInit);
  135377. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERMOVE)) {
  135378. return this;
  135379. }
  135380. return this._processPointerMove(pickResult, evt);
  135381. };
  135382. Scene.prototype._processPointerMove = function (pickResult, evt) {
  135383. var canvas = this._engine.getRenderingCanvas();
  135384. if (!canvas) {
  135385. return this;
  135386. }
  135387. // Restore pointer
  135388. canvas.style.cursor = this.defaultCursor;
  135389. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  135390. if (isMeshPicked) {
  135391. this.setPointerOverMesh(pickResult.pickedMesh);
  135392. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  135393. if (this._pointerOverMesh.actionManager.hoverCursor) {
  135394. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  135395. }
  135396. else {
  135397. canvas.style.cursor = this.hoverCursor;
  135398. }
  135399. }
  135400. }
  135401. else {
  135402. this.setPointerOverMesh(null);
  135403. }
  135404. for (var _i = 0, _a = this._pointerMoveStage; _i < _a.length; _i++) {
  135405. var step = _a[_i];
  135406. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  135407. }
  135408. if (pickResult) {
  135409. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERMOVE;
  135410. if (this.onPointerMove) {
  135411. this.onPointerMove(evt, pickResult, type);
  135412. }
  135413. if (this.onPointerObservable.hasObservers()) {
  135414. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerInfo"](type, evt, pickResult);
  135415. this._setRayOnPointerInfo(pi);
  135416. this.onPointerObservable.notifyObservers(pi, type);
  135417. }
  135418. }
  135419. return this;
  135420. };
  135421. Scene.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  135422. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  135423. if (pickResult) {
  135424. pi.ray = pickResult.ray;
  135425. }
  135426. this.onPrePointerObservable.notifyObservers(pi, type);
  135427. if (pi.skipOnPointerObservable) {
  135428. return true;
  135429. }
  135430. else {
  135431. return false;
  135432. }
  135433. };
  135434. /**
  135435. * Use this method to simulate a pointer down on a mesh
  135436. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  135437. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  135438. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  135439. * @returns the current scene
  135440. */
  135441. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  135442. var evt = new PointerEvent("pointerdown", pointerEventInit);
  135443. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOWN)) {
  135444. return this;
  135445. }
  135446. return this._processPointerDown(pickResult, evt);
  135447. };
  135448. Scene.prototype._processPointerDown = function (pickResult, evt) {
  135449. var _this = this;
  135450. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  135451. this._pickedDownMesh = pickResult.pickedMesh;
  135452. var actionManager = pickResult.pickedMesh.actionManager;
  135453. if (actionManager) {
  135454. if (actionManager.hasPickTriggers) {
  135455. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135456. switch (evt.button) {
  135457. case 0:
  135458. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135459. break;
  135460. case 1:
  135461. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135462. break;
  135463. case 2:
  135464. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135465. break;
  135466. }
  135467. }
  135468. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnLongPressTrigger)) {
  135469. window.setTimeout(function () {
  135470. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, function (mesh) { return (mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnLongPressTrigger) && mesh == _this._pickedDownMesh); }, false, _this.cameraToUseForPointers);
  135471. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  135472. if (_this._totalPointersPressed !== 0 &&
  135473. ((Date.now() - _this._startingPointerTime) > Scene.LongPressDelay) &&
  135474. !_this._isPointerSwiping()) {
  135475. _this._startingPointerTime = 0;
  135476. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135477. }
  135478. }
  135479. }, Scene.LongPressDelay);
  135480. }
  135481. }
  135482. }
  135483. else {
  135484. for (var _i = 0, _a = this._pointerDownStage; _i < _a.length; _i++) {
  135485. var step = _a[_i];
  135486. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  135487. }
  135488. }
  135489. if (pickResult) {
  135490. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOWN;
  135491. if (this.onPointerDown) {
  135492. this.onPointerDown(evt, pickResult, type);
  135493. }
  135494. if (this.onPointerObservable.hasObservers()) {
  135495. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerInfo"](type, evt, pickResult);
  135496. this._setRayOnPointerInfo(pi);
  135497. this.onPointerObservable.notifyObservers(pi, type);
  135498. }
  135499. }
  135500. return this;
  135501. };
  135502. /**
  135503. * Use this method to simulate a pointer up on a mesh
  135504. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  135505. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  135506. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  135507. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  135508. * @returns the current scene
  135509. */
  135510. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  135511. var evt = new PointerEvent("pointerup", pointerEventInit);
  135512. var clickInfo = new ClickInfo();
  135513. if (doubleTap) {
  135514. clickInfo.doubleClick = true;
  135515. }
  135516. else {
  135517. clickInfo.singleClick = true;
  135518. }
  135519. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERUP)) {
  135520. return this;
  135521. }
  135522. return this._processPointerUp(pickResult, evt, clickInfo);
  135523. };
  135524. Scene.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  135525. if (pickResult && pickResult && pickResult.pickedMesh) {
  135526. this._pickedUpMesh = pickResult.pickedMesh;
  135527. if (this._pickedDownMesh === this._pickedUpMesh) {
  135528. if (this.onPointerPick) {
  135529. this.onPointerPick(evt, pickResult);
  135530. }
  135531. if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
  135532. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERPICK;
  135533. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerInfo"](type_1, evt, pickResult);
  135534. this._setRayOnPointerInfo(pi);
  135535. this.onPointerObservable.notifyObservers(pi, type_1);
  135536. }
  135537. }
  135538. var actionManager = pickResult.pickedMesh._getActionManagerForTrigger();
  135539. if (actionManager && !clickInfo.ignore) {
  135540. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135541. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  135542. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135543. }
  135544. var doubleClickActionManager = pickResult.pickedMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger);
  135545. if (clickInfo.doubleClick && doubleClickActionManager) {
  135546. doubleClickActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  135547. }
  135548. }
  135549. }
  135550. else {
  135551. if (!clickInfo.ignore) {
  135552. for (var _i = 0, _a = this._pointerUpStage; _i < _a.length; _i++) {
  135553. var step = _a[_i];
  135554. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  135555. }
  135556. }
  135557. }
  135558. if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
  135559. var pickedDownActionManager = this._pickedDownMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickOutTrigger);
  135560. if (pickedDownActionManager) {
  135561. pickedDownActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  135562. }
  135563. }
  135564. var type = 0;
  135565. if (this.onPointerObservable.hasObservers()) {
  135566. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  135567. if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERTAP)) {
  135568. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERTAP;
  135569. }
  135570. else if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP)) {
  135571. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP;
  135572. }
  135573. if (type) {
  135574. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerInfo"](type, evt, pickResult);
  135575. this._setRayOnPointerInfo(pi);
  135576. this.onPointerObservable.notifyObservers(pi, type);
  135577. }
  135578. }
  135579. if (!clickInfo.ignore) {
  135580. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERUP;
  135581. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerInfo"](type, evt, pickResult);
  135582. this._setRayOnPointerInfo(pi);
  135583. this.onPointerObservable.notifyObservers(pi, type);
  135584. }
  135585. }
  135586. if (this.onPointerUp && !clickInfo.ignore) {
  135587. this.onPointerUp(evt, pickResult, type);
  135588. }
  135589. return this;
  135590. };
  135591. /**
  135592. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  135593. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  135594. * @returns true if the pointer was captured
  135595. */
  135596. Scene.prototype.isPointerCaptured = function (pointerId) {
  135597. if (pointerId === void 0) { pointerId = 0; }
  135598. return this._pointerCaptures[pointerId];
  135599. };
  135600. /** @hidden */
  135601. Scene.prototype._isPointerSwiping = function () {
  135602. return Math.abs(this._startingPointerPosition.x - this._pointerX) > Scene.DragMovementThreshold ||
  135603. Math.abs(this._startingPointerPosition.y - this._pointerY) > Scene.DragMovementThreshold;
  135604. };
  135605. /**
  135606. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  135607. * @param attachUp defines if you want to attach events to pointerup
  135608. * @param attachDown defines if you want to attach events to pointerdown
  135609. * @param attachMove defines if you want to attach events to pointermove
  135610. */
  135611. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  135612. var _this = this;
  135613. if (attachUp === void 0) { attachUp = true; }
  135614. if (attachDown === void 0) { attachDown = true; }
  135615. if (attachMove === void 0) { attachMove = true; }
  135616. this._initActionManager = function (act, clickInfo) {
  135617. if (!_this._meshPickProceed) {
  135618. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  135619. _this._currentPickResult = pickResult;
  135620. if (pickResult) {
  135621. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh.actionManager : null;
  135622. }
  135623. _this._meshPickProceed = true;
  135624. }
  135625. return act;
  135626. };
  135627. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  135628. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  135629. if ((Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay && !_this._doubleClickOccured) ||
  135630. btn !== _this._previousButtonPressed) {
  135631. _this._doubleClickOccured = false;
  135632. clickInfo.singleClick = true;
  135633. clickInfo.ignore = false;
  135634. cb(clickInfo, _this._currentPickResult);
  135635. }
  135636. };
  135637. this._initClickEvent = function (obs1, obs2, evt, cb) {
  135638. var clickInfo = new ClickInfo();
  135639. _this._currentPickResult = null;
  135640. var act = null;
  135641. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERPICK)
  135642. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERTAP)
  135643. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP);
  135644. if (!checkPicking && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"]) {
  135645. act = _this._initActionManager(act, clickInfo);
  135646. if (act) {
  135647. checkPicking = act.hasPickTriggers;
  135648. }
  135649. }
  135650. var needToIgnoreNext = false;
  135651. if (checkPicking) {
  135652. var btn = evt.button;
  135653. clickInfo.hasSwiped = _this._isPointerSwiping();
  135654. if (!clickInfo.hasSwiped) {
  135655. var checkSingleClickImmediately = !Scene.ExclusiveDoubleClickMode;
  135656. if (!checkSingleClickImmediately) {
  135657. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP) &&
  135658. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP);
  135659. if (checkSingleClickImmediately && !_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger)) {
  135660. act = _this._initActionManager(act, clickInfo);
  135661. if (act) {
  135662. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger);
  135663. }
  135664. }
  135665. }
  135666. if (checkSingleClickImmediately) {
  135667. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  135668. if (Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay ||
  135669. btn !== _this._previousButtonPressed) {
  135670. clickInfo.singleClick = true;
  135671. cb(clickInfo, _this._currentPickResult);
  135672. needToIgnoreNext = true;
  135673. }
  135674. }
  135675. // at least one double click is required to be check and exclusive double click is enabled
  135676. else {
  135677. // wait that no double click has been raised during the double click delay
  135678. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  135679. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), Scene.DoubleClickDelay);
  135680. }
  135681. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP) ||
  135682. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP);
  135683. if (!checkDoubleClick && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger)) {
  135684. act = _this._initActionManager(act, clickInfo);
  135685. if (act) {
  135686. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnDoublePickTrigger);
  135687. }
  135688. }
  135689. if (checkDoubleClick) {
  135690. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  135691. if (btn === _this._previousButtonPressed &&
  135692. Date.now() - _this._previousStartingPointerTime < Scene.DoubleClickDelay &&
  135693. !_this._doubleClickOccured) {
  135694. // pointer has not moved for 2 clicks, it's a double click
  135695. if (!clickInfo.hasSwiped &&
  135696. !_this._isPointerSwiping()) {
  135697. _this._previousStartingPointerTime = 0;
  135698. _this._doubleClickOccured = true;
  135699. clickInfo.doubleClick = true;
  135700. clickInfo.ignore = false;
  135701. if (Scene.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  135702. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  135703. }
  135704. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  135705. cb(clickInfo, _this._currentPickResult);
  135706. }
  135707. // if the two successive clicks are too far, it's just two simple clicks
  135708. else {
  135709. _this._doubleClickOccured = false;
  135710. _this._previousStartingPointerTime = _this._startingPointerTime;
  135711. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  135712. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  135713. _this._previousButtonPressed = btn;
  135714. if (Scene.ExclusiveDoubleClickMode) {
  135715. if (_this._previousDelayedSimpleClickTimeout) {
  135716. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  135717. }
  135718. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  135719. cb(clickInfo, _this._previousPickResult);
  135720. }
  135721. else {
  135722. cb(clickInfo, _this._currentPickResult);
  135723. }
  135724. }
  135725. needToIgnoreNext = true;
  135726. }
  135727. // just the first click of the double has been raised
  135728. else {
  135729. _this._doubleClickOccured = false;
  135730. _this._previousStartingPointerTime = _this._startingPointerTime;
  135731. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  135732. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  135733. _this._previousButtonPressed = btn;
  135734. }
  135735. }
  135736. }
  135737. }
  135738. if (!needToIgnoreNext) {
  135739. cb(clickInfo, _this._currentPickResult);
  135740. }
  135741. };
  135742. this._onPointerMove = function (evt) {
  135743. _this._updatePointerPosition(evt);
  135744. // PreObservable support
  135745. if (_this._checkPrePointerObservable(null, evt, evt.type === _this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERMOVE)) {
  135746. return;
  135747. }
  135748. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  135749. return;
  135750. }
  135751. if (!_this.pointerMovePredicate) {
  135752. _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)); };
  135753. }
  135754. // Meshes
  135755. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerMovePredicate, false, _this.cameraToUseForPointers);
  135756. _this._processPointerMove(pickResult, evt);
  135757. };
  135758. this._onPointerDown = function (evt) {
  135759. _this._totalPointersPressed++;
  135760. _this._pickedDownMesh = null;
  135761. _this._meshPickProceed = false;
  135762. _this._updatePointerPosition(evt);
  135763. if (_this.preventDefaultOnPointerDown && canvas) {
  135764. evt.preventDefault();
  135765. canvas.focus();
  135766. }
  135767. _this._startingPointerPosition.x = _this._pointerX;
  135768. _this._startingPointerPosition.y = _this._pointerY;
  135769. _this._startingPointerTime = Date.now();
  135770. // PreObservable support
  135771. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOWN)) {
  135772. return;
  135773. }
  135774. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  135775. return;
  135776. }
  135777. _this._pointerCaptures[evt.pointerId] = true;
  135778. if (!_this.pointerDownPredicate) {
  135779. _this.pointerDownPredicate = function (mesh) {
  135780. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (!_this.cameraToUseForPointers || (_this.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0);
  135781. };
  135782. }
  135783. // Meshes
  135784. _this._pickedDownMesh = null;
  135785. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  135786. _this._processPointerDown(pickResult, evt);
  135787. };
  135788. this._onPointerUp = function (evt) {
  135789. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  135790. return; // So we need to test it the pointer down was pressed before.
  135791. }
  135792. _this._totalPointersPressed--;
  135793. _this._pickedUpMesh = null;
  135794. _this._meshPickProceed = false;
  135795. _this._updatePointerPosition(evt);
  135796. if (_this.preventDefaultOnPointerUp && canvas) {
  135797. evt.preventDefault();
  135798. canvas.focus();
  135799. }
  135800. _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
  135801. // PreObservable support
  135802. if (_this.onPrePointerObservable.hasObservers()) {
  135803. if (!clickInfo.ignore) {
  135804. if (!clickInfo.hasSwiped) {
  135805. if (clickInfo.singleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERTAP)) {
  135806. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERTAP)) {
  135807. return;
  135808. }
  135809. }
  135810. if (clickInfo.doubleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP)) {
  135811. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERDOUBLETAP)) {
  135812. return;
  135813. }
  135814. }
  135815. }
  135816. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_16__["PointerEventTypes"].POINTERUP)) {
  135817. return;
  135818. }
  135819. }
  135820. }
  135821. if (!_this._pointerCaptures[evt.pointerId]) {
  135822. return;
  135823. }
  135824. _this._pointerCaptures[evt.pointerId] = false;
  135825. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  135826. return;
  135827. }
  135828. if (!_this.pointerUpPredicate) {
  135829. _this.pointerUpPredicate = function (mesh) {
  135830. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (!_this.cameraToUseForPointers || (_this.cameraToUseForPointers.layerMask & mesh.layerMask) !== 0);
  135831. };
  135832. }
  135833. // Meshes
  135834. if (!_this._meshPickProceed && (_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"] && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_26__["AbstractActionManager"].HasTriggers || _this.onPointerObservable.hasObservers())) {
  135835. _this._initActionManager(null, clickInfo);
  135836. }
  135837. if (!pickResult) {
  135838. pickResult = _this._currentPickResult;
  135839. }
  135840. _this._processPointerUp(pickResult, evt, clickInfo);
  135841. _this._previousPickResult = _this._currentPickResult;
  135842. });
  135843. };
  135844. this._onKeyDown = function (evt) {
  135845. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__["KeyboardEventTypes"].KEYDOWN;
  135846. if (_this.onPreKeyboardObservable.hasObservers()) {
  135847. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__["KeyboardInfoPre"](type, evt);
  135848. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  135849. if (pi.skipOnPointerObservable) {
  135850. return;
  135851. }
  135852. }
  135853. if (_this.onKeyboardObservable.hasObservers()) {
  135854. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__["KeyboardInfo"](type, evt);
  135855. _this.onKeyboardObservable.notifyObservers(pi, type);
  135856. }
  135857. if (_this.actionManager) {
  135858. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNewFromScene(_this, evt));
  135859. }
  135860. };
  135861. this._onKeyUp = function (evt) {
  135862. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__["KeyboardEventTypes"].KEYUP;
  135863. if (_this.onPreKeyboardObservable.hasObservers()) {
  135864. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__["KeyboardInfoPre"](type, evt);
  135865. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  135866. if (pi.skipOnPointerObservable) {
  135867. return;
  135868. }
  135869. }
  135870. if (_this.onKeyboardObservable.hasObservers()) {
  135871. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_17__["KeyboardInfo"](type, evt);
  135872. _this.onKeyboardObservable.notifyObservers(pi, type);
  135873. }
  135874. if (_this.actionManager) {
  135875. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNewFromScene(_this, evt));
  135876. }
  135877. };
  135878. var engine = this.getEngine();
  135879. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add(function () {
  135880. if (!canvas) {
  135881. return;
  135882. }
  135883. canvas.addEventListener("keydown", _this._onKeyDown, false);
  135884. canvas.addEventListener("keyup", _this._onKeyUp, false);
  135885. });
  135886. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  135887. if (!canvas) {
  135888. return;
  135889. }
  135890. canvas.removeEventListener("keydown", _this._onKeyDown);
  135891. canvas.removeEventListener("keyup", _this._onKeyUp);
  135892. });
  135893. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  135894. var canvas = this._engine.getRenderingCanvas();
  135895. if (!canvas) {
  135896. return;
  135897. }
  135898. if (attachMove) {
  135899. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  135900. // Wheel
  135901. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  135902. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  135903. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  135904. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  135905. }
  135906. if (attachDown) {
  135907. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  135908. }
  135909. if (attachUp) {
  135910. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  135911. }
  135912. canvas.tabIndex = 1;
  135913. };
  135914. /** Detaches all event handlers*/
  135915. Scene.prototype.detachControl = function () {
  135916. var engine = this.getEngine();
  135917. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  135918. var canvas = engine.getRenderingCanvas();
  135919. if (!canvas) {
  135920. return;
  135921. }
  135922. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  135923. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  135924. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  135925. if (this._onCanvasBlurObserver) {
  135926. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  135927. }
  135928. if (this._onCanvasFocusObserver) {
  135929. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  135930. }
  135931. // Wheel
  135932. canvas.removeEventListener(this._wheelEventName, this._onPointerMove);
  135933. // Keyboard
  135934. canvas.removeEventListener("keydown", this._onKeyDown);
  135935. canvas.removeEventListener("keyup", this._onKeyUp);
  135936. // Observables
  135937. this.onKeyboardObservable.clear();
  135938. this.onPreKeyboardObservable.clear();
  135939. this.onPointerObservable.clear();
  135940. this.onPrePointerObservable.clear();
  135941. // Cursor
  135942. canvas.style.cursor = this.defaultCursor;
  135943. };
  135944. /**
  135945. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  135946. * Delay loaded resources are not taking in account
  135947. * @return true if all required resources are ready
  135948. */
  135949. Scene.prototype.isReady = function () {
  135950. if (this._isDisposed) {
  135951. return false;
  135952. }
  135953. var index;
  135954. var engine = this.getEngine();
  135955. // Effects
  135956. if (!engine.areAllEffectsReady()) {
  135957. return false;
  135958. }
  135959. // Pending data
  135960. if (this._pendingData.length > 0) {
  135961. return false;
  135962. }
  135963. // Meshes
  135964. for (index = 0; index < this.meshes.length; index++) {
  135965. var mesh = this.meshes[index];
  135966. if (!mesh.isEnabled()) {
  135967. continue;
  135968. }
  135969. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  135970. continue;
  135971. }
  135972. if (!mesh.isReady(true)) {
  135973. return false;
  135974. }
  135975. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  135976. // Is Ready For Mesh
  135977. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  135978. var step = _a[_i];
  135979. if (!step.action(mesh, hardwareInstancedRendering)) {
  135980. return false;
  135981. }
  135982. }
  135983. }
  135984. // Geometries
  135985. for (index = 0; index < this.geometries.length; index++) {
  135986. var geometry = this.geometries[index];
  135987. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].DELAYLOADSTATE_LOADING) {
  135988. return false;
  135989. }
  135990. }
  135991. // Post-processes
  135992. if (this.activeCameras && this.activeCameras.length > 0) {
  135993. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  135994. var camera = _c[_b];
  135995. if (!camera.isReady(true)) {
  135996. return false;
  135997. }
  135998. }
  135999. }
  136000. else if (this.activeCamera) {
  136001. if (!this.activeCamera.isReady(true)) {
  136002. return false;
  136003. }
  136004. }
  136005. // Particles
  136006. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  136007. var particleSystem = _e[_d];
  136008. if (!particleSystem.isReady()) {
  136009. return false;
  136010. }
  136011. }
  136012. return true;
  136013. };
  136014. /** Resets all cached information relative to material (including effect and visibility) */
  136015. Scene.prototype.resetCachedMaterial = function () {
  136016. this._cachedMaterial = null;
  136017. this._cachedEffect = null;
  136018. this._cachedVisibility = null;
  136019. };
  136020. /**
  136021. * Registers a function to be called before every frame render
  136022. * @param func defines the function to register
  136023. */
  136024. Scene.prototype.registerBeforeRender = function (func) {
  136025. this.onBeforeRenderObservable.add(func);
  136026. };
  136027. /**
  136028. * Unregisters a function called before every frame render
  136029. * @param func defines the function to unregister
  136030. */
  136031. Scene.prototype.unregisterBeforeRender = function (func) {
  136032. this.onBeforeRenderObservable.removeCallback(func);
  136033. };
  136034. /**
  136035. * Registers a function to be called after every frame render
  136036. * @param func defines the function to register
  136037. */
  136038. Scene.prototype.registerAfterRender = function (func) {
  136039. this.onAfterRenderObservable.add(func);
  136040. };
  136041. /**
  136042. * Unregisters a function called after every frame render
  136043. * @param func defines the function to unregister
  136044. */
  136045. Scene.prototype.unregisterAfterRender = function (func) {
  136046. this.onAfterRenderObservable.removeCallback(func);
  136047. };
  136048. Scene.prototype._executeOnceBeforeRender = function (func) {
  136049. var _this = this;
  136050. var execFunc = function () {
  136051. func();
  136052. setTimeout(function () {
  136053. _this.unregisterBeforeRender(execFunc);
  136054. });
  136055. };
  136056. this.registerBeforeRender(execFunc);
  136057. };
  136058. /**
  136059. * The provided function will run before render once and will be disposed afterwards.
  136060. * A timeout delay can be provided so that the function will be executed in N ms.
  136061. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  136062. * @param func The function to be executed.
  136063. * @param timeout optional delay in ms
  136064. */
  136065. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  136066. var _this = this;
  136067. if (timeout !== undefined) {
  136068. setTimeout(function () {
  136069. _this._executeOnceBeforeRender(func);
  136070. }, timeout);
  136071. }
  136072. else {
  136073. this._executeOnceBeforeRender(func);
  136074. }
  136075. };
  136076. /** @hidden */
  136077. Scene.prototype._addPendingData = function (data) {
  136078. this._pendingData.push(data);
  136079. };
  136080. /** @hidden */
  136081. Scene.prototype._removePendingData = function (data) {
  136082. var wasLoading = this.isLoading;
  136083. var index = this._pendingData.indexOf(data);
  136084. if (index !== -1) {
  136085. this._pendingData.splice(index, 1);
  136086. }
  136087. if (wasLoading && !this.isLoading) {
  136088. this.onDataLoadedObservable.notifyObservers(this);
  136089. }
  136090. };
  136091. /**
  136092. * Returns the number of items waiting to be loaded
  136093. * @returns the number of items waiting to be loaded
  136094. */
  136095. Scene.prototype.getWaitingItemsCount = function () {
  136096. return this._pendingData.length;
  136097. };
  136098. Object.defineProperty(Scene.prototype, "isLoading", {
  136099. /**
  136100. * Returns a boolean indicating if the scene is still loading data
  136101. */
  136102. get: function () {
  136103. return this._pendingData.length > 0;
  136104. },
  136105. enumerable: true,
  136106. configurable: true
  136107. });
  136108. /**
  136109. * Registers a function to be executed when the scene is ready
  136110. * @param {Function} func - the function to be executed
  136111. */
  136112. Scene.prototype.executeWhenReady = function (func) {
  136113. var _this = this;
  136114. this.onReadyObservable.add(func);
  136115. if (this._executeWhenReadyTimeoutId !== -1) {
  136116. return;
  136117. }
  136118. this._executeWhenReadyTimeoutId = setTimeout(function () {
  136119. _this._checkIsReady();
  136120. }, 150);
  136121. };
  136122. /**
  136123. * Returns a promise that resolves when the scene is ready
  136124. * @returns A promise that resolves when the scene is ready
  136125. */
  136126. Scene.prototype.whenReadyAsync = function () {
  136127. var _this = this;
  136128. return new Promise(function (resolve) {
  136129. _this.executeWhenReady(function () {
  136130. resolve();
  136131. });
  136132. });
  136133. };
  136134. /** @hidden */
  136135. Scene.prototype._checkIsReady = function () {
  136136. var _this = this;
  136137. this._registerTransientComponents();
  136138. if (this.isReady()) {
  136139. this.onReadyObservable.notifyObservers(this);
  136140. this.onReadyObservable.clear();
  136141. this._executeWhenReadyTimeoutId = -1;
  136142. return;
  136143. }
  136144. this._executeWhenReadyTimeoutId = setTimeout(function () {
  136145. _this._checkIsReady();
  136146. }, 150);
  136147. };
  136148. Object.defineProperty(Scene.prototype, "animatables", {
  136149. /**
  136150. * Gets all animatable attached to the scene
  136151. */
  136152. get: function () {
  136153. return this._activeAnimatables;
  136154. },
  136155. enumerable: true,
  136156. configurable: true
  136157. });
  136158. /**
  136159. * Resets the last animation time frame.
  136160. * Useful to override when animations start running when loading a scene for the first time.
  136161. */
  136162. Scene.prototype.resetLastAnimationTimeFrame = function () {
  136163. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  136164. };
  136165. // Matrix
  136166. /**
  136167. * Gets the current view matrix
  136168. * @returns a Matrix
  136169. */
  136170. Scene.prototype.getViewMatrix = function () {
  136171. return this._viewMatrix;
  136172. };
  136173. /**
  136174. * Gets the current projection matrix
  136175. * @returns a Matrix
  136176. */
  136177. Scene.prototype.getProjectionMatrix = function () {
  136178. return this._projectionMatrix;
  136179. };
  136180. /**
  136181. * Gets the current transform matrix
  136182. * @returns a Matrix made of View * Projection
  136183. */
  136184. Scene.prototype.getTransformMatrix = function () {
  136185. return this._transformMatrix;
  136186. };
  136187. /**
  136188. * Sets the current transform matrix
  136189. * @param viewL defines the View matrix to use
  136190. * @param projectionL defines the Projection matrix to use
  136191. * @param viewR defines the right View matrix to use (if provided)
  136192. * @param projectionR defines the right Projection matrix to use (if provided)
  136193. */
  136194. Scene.prototype.setTransformMatrix = function (viewL, projectionL, viewR, projectionR) {
  136195. if (this._viewUpdateFlag === viewL.updateFlag && this._projectionUpdateFlag === projectionL.updateFlag) {
  136196. return;
  136197. }
  136198. this._viewUpdateFlag = viewL.updateFlag;
  136199. this._projectionUpdateFlag = projectionL.updateFlag;
  136200. this._viewMatrix = viewL;
  136201. this._projectionMatrix = projectionL;
  136202. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  136203. // Update frustum
  136204. if (!this._frustumPlanes) {
  136205. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanes(this._transformMatrix);
  136206. }
  136207. else {
  136208. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  136209. }
  136210. if (this._multiviewSceneUbo && this._multiviewSceneUbo.useUbo) {
  136211. this._updateMultiviewUbo(viewR, projectionR);
  136212. }
  136213. else if (this._sceneUbo.useUbo) {
  136214. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  136215. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  136216. this._sceneUbo.update();
  136217. }
  136218. };
  136219. /**
  136220. * Gets the uniform buffer used to store scene data
  136221. * @returns a UniformBuffer
  136222. */
  136223. Scene.prototype.getSceneUniformBuffer = function () {
  136224. return this._multiviewSceneUbo ? this._multiviewSceneUbo : this._sceneUbo;
  136225. };
  136226. /**
  136227. * Gets an unique (relatively to the current scene) Id
  136228. * @returns an unique number for the scene
  136229. */
  136230. Scene.prototype.getUniqueId = function () {
  136231. var result = Scene._uniqueIdCounter;
  136232. Scene._uniqueIdCounter++;
  136233. return result;
  136234. };
  136235. /**
  136236. * Add a mesh to the list of scene's meshes
  136237. * @param newMesh defines the mesh to add
  136238. * @param recursive if all child meshes should also be added to the scene
  136239. */
  136240. Scene.prototype.addMesh = function (newMesh, recursive) {
  136241. var _this = this;
  136242. if (recursive === void 0) { recursive = false; }
  136243. this.meshes.push(newMesh);
  136244. newMesh._resyncLightSources();
  136245. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  136246. if (recursive) {
  136247. newMesh.getChildMeshes().forEach(function (m) {
  136248. _this.addMesh(m);
  136249. });
  136250. }
  136251. };
  136252. /**
  136253. * Remove a mesh for the list of scene's meshes
  136254. * @param toRemove defines the mesh to remove
  136255. * @param recursive if all child meshes should also be removed from the scene
  136256. * @returns the index where the mesh was in the mesh list
  136257. */
  136258. Scene.prototype.removeMesh = function (toRemove, recursive) {
  136259. var _this = this;
  136260. if (recursive === void 0) { recursive = false; }
  136261. var index = this.meshes.indexOf(toRemove);
  136262. if (index !== -1) {
  136263. // Remove from the scene if mesh found
  136264. this.meshes[index] = this.meshes[this.meshes.length - 1];
  136265. this.meshes.pop();
  136266. }
  136267. this.onMeshRemovedObservable.notifyObservers(toRemove);
  136268. if (recursive) {
  136269. toRemove.getChildMeshes().forEach(function (m) {
  136270. _this.removeMesh(m);
  136271. });
  136272. }
  136273. return index;
  136274. };
  136275. /**
  136276. * Add a transform node to the list of scene's transform nodes
  136277. * @param newTransformNode defines the transform node to add
  136278. */
  136279. Scene.prototype.addTransformNode = function (newTransformNode) {
  136280. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  136281. this.transformNodes.push(newTransformNode);
  136282. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  136283. };
  136284. /**
  136285. * Remove a transform node for the list of scene's transform nodes
  136286. * @param toRemove defines the transform node to remove
  136287. * @returns the index where the transform node was in the transform node list
  136288. */
  136289. Scene.prototype.removeTransformNode = function (toRemove) {
  136290. var index = toRemove._indexInSceneTransformNodesArray;
  136291. if (index !== -1) {
  136292. if (index !== this.transformNodes.length - 1) {
  136293. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  136294. this.transformNodes[index] = lastNode;
  136295. lastNode._indexInSceneTransformNodesArray = index;
  136296. }
  136297. toRemove._indexInSceneTransformNodesArray = -1;
  136298. this.transformNodes.pop();
  136299. }
  136300. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  136301. return index;
  136302. };
  136303. /**
  136304. * Remove a skeleton for the list of scene's skeletons
  136305. * @param toRemove defines the skeleton to remove
  136306. * @returns the index where the skeleton was in the skeleton list
  136307. */
  136308. Scene.prototype.removeSkeleton = function (toRemove) {
  136309. var index = this.skeletons.indexOf(toRemove);
  136310. if (index !== -1) {
  136311. // Remove from the scene if found
  136312. this.skeletons.splice(index, 1);
  136313. this.onSkeletonRemovedObservable.notifyObservers(toRemove);
  136314. }
  136315. return index;
  136316. };
  136317. /**
  136318. * Remove a morph target for the list of scene's morph targets
  136319. * @param toRemove defines the morph target to remove
  136320. * @returns the index where the morph target was in the morph target list
  136321. */
  136322. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  136323. var index = this.morphTargetManagers.indexOf(toRemove);
  136324. if (index !== -1) {
  136325. // Remove from the scene if found
  136326. this.morphTargetManagers.splice(index, 1);
  136327. }
  136328. return index;
  136329. };
  136330. /**
  136331. * Remove a light for the list of scene's lights
  136332. * @param toRemove defines the light to remove
  136333. * @returns the index where the light was in the light list
  136334. */
  136335. Scene.prototype.removeLight = function (toRemove) {
  136336. var index = this.lights.indexOf(toRemove);
  136337. if (index !== -1) {
  136338. // Remove from meshes
  136339. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  136340. var mesh = _a[_i];
  136341. mesh._removeLightSource(toRemove);
  136342. }
  136343. // Remove from the scene if mesh found
  136344. this.lights.splice(index, 1);
  136345. this.sortLightsByPriority();
  136346. }
  136347. this.onLightRemovedObservable.notifyObservers(toRemove);
  136348. return index;
  136349. };
  136350. /**
  136351. * Remove a camera for the list of scene's cameras
  136352. * @param toRemove defines the camera to remove
  136353. * @returns the index where the camera was in the camera list
  136354. */
  136355. Scene.prototype.removeCamera = function (toRemove) {
  136356. var index = this.cameras.indexOf(toRemove);
  136357. if (index !== -1) {
  136358. // Remove from the scene if mesh found
  136359. this.cameras.splice(index, 1);
  136360. }
  136361. // Remove from activeCameras
  136362. var index2 = this.activeCameras.indexOf(toRemove);
  136363. if (index2 !== -1) {
  136364. // Remove from the scene if mesh found
  136365. this.activeCameras.splice(index2, 1);
  136366. }
  136367. // Reset the activeCamera
  136368. if (this.activeCamera === toRemove) {
  136369. if (this.cameras.length > 0) {
  136370. this.activeCamera = this.cameras[0];
  136371. }
  136372. else {
  136373. this.activeCamera = null;
  136374. }
  136375. }
  136376. this.onCameraRemovedObservable.notifyObservers(toRemove);
  136377. return index;
  136378. };
  136379. /**
  136380. * Remove a particle system for the list of scene's particle systems
  136381. * @param toRemove defines the particle system to remove
  136382. * @returns the index where the particle system was in the particle system list
  136383. */
  136384. Scene.prototype.removeParticleSystem = function (toRemove) {
  136385. var index = this.particleSystems.indexOf(toRemove);
  136386. if (index !== -1) {
  136387. this.particleSystems.splice(index, 1);
  136388. }
  136389. return index;
  136390. };
  136391. /**
  136392. * Remove a animation for the list of scene's animations
  136393. * @param toRemove defines the animation to remove
  136394. * @returns the index where the animation was in the animation list
  136395. */
  136396. Scene.prototype.removeAnimation = function (toRemove) {
  136397. var index = this.animations.indexOf(toRemove);
  136398. if (index !== -1) {
  136399. this.animations.splice(index, 1);
  136400. }
  136401. return index;
  136402. };
  136403. /**
  136404. * Removes the given animation group from this scene.
  136405. * @param toRemove The animation group to remove
  136406. * @returns The index of the removed animation group
  136407. */
  136408. Scene.prototype.removeAnimationGroup = function (toRemove) {
  136409. var index = this.animationGroups.indexOf(toRemove);
  136410. if (index !== -1) {
  136411. this.animationGroups.splice(index, 1);
  136412. }
  136413. return index;
  136414. };
  136415. /**
  136416. * Removes the given multi-material from this scene.
  136417. * @param toRemove The multi-material to remove
  136418. * @returns The index of the removed multi-material
  136419. */
  136420. Scene.prototype.removeMultiMaterial = function (toRemove) {
  136421. var index = this.multiMaterials.indexOf(toRemove);
  136422. if (index !== -1) {
  136423. this.multiMaterials.splice(index, 1);
  136424. }
  136425. return index;
  136426. };
  136427. /**
  136428. * Removes the given material from this scene.
  136429. * @param toRemove The material to remove
  136430. * @returns The index of the removed material
  136431. */
  136432. Scene.prototype.removeMaterial = function (toRemove) {
  136433. var index = toRemove._indexInSceneMaterialArray;
  136434. if (index !== -1 && index < this.materials.length) {
  136435. if (index !== this.materials.length - 1) {
  136436. var lastMaterial = this.materials[this.materials.length - 1];
  136437. this.materials[index] = lastMaterial;
  136438. lastMaterial._indexInSceneMaterialArray = index;
  136439. }
  136440. toRemove._indexInSceneMaterialArray = -1;
  136441. this.materials.pop();
  136442. }
  136443. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  136444. return index;
  136445. };
  136446. /**
  136447. * Removes the given action manager from this scene.
  136448. * @param toRemove The action manager to remove
  136449. * @returns The index of the removed action manager
  136450. */
  136451. Scene.prototype.removeActionManager = function (toRemove) {
  136452. var index = this.actionManagers.indexOf(toRemove);
  136453. if (index !== -1) {
  136454. this.actionManagers.splice(index, 1);
  136455. }
  136456. return index;
  136457. };
  136458. /**
  136459. * Removes the given texture from this scene.
  136460. * @param toRemove The texture to remove
  136461. * @returns The index of the removed texture
  136462. */
  136463. Scene.prototype.removeTexture = function (toRemove) {
  136464. var index = this.textures.indexOf(toRemove);
  136465. if (index !== -1) {
  136466. this.textures.splice(index, 1);
  136467. }
  136468. this.onTextureRemovedObservable.notifyObservers(toRemove);
  136469. return index;
  136470. };
  136471. /**
  136472. * Adds the given light to this scene
  136473. * @param newLight The light to add
  136474. */
  136475. Scene.prototype.addLight = function (newLight) {
  136476. this.lights.push(newLight);
  136477. this.sortLightsByPriority();
  136478. // Add light to all meshes (To support if the light is removed and then readded)
  136479. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  136480. var mesh = _a[_i];
  136481. if (mesh._lightSources.indexOf(newLight) === -1) {
  136482. mesh._lightSources.push(newLight);
  136483. mesh._resyncLightSources();
  136484. }
  136485. }
  136486. this.onNewLightAddedObservable.notifyObservers(newLight);
  136487. };
  136488. /**
  136489. * Sorts the list list based on light priorities
  136490. */
  136491. Scene.prototype.sortLightsByPriority = function () {
  136492. if (this.requireLightSorting) {
  136493. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_14__["Light"].CompareLightsPriority);
  136494. }
  136495. };
  136496. /**
  136497. * Adds the given camera to this scene
  136498. * @param newCamera The camera to add
  136499. */
  136500. Scene.prototype.addCamera = function (newCamera) {
  136501. this.cameras.push(newCamera);
  136502. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  136503. };
  136504. /**
  136505. * Adds the given skeleton to this scene
  136506. * @param newSkeleton The skeleton to add
  136507. */
  136508. Scene.prototype.addSkeleton = function (newSkeleton) {
  136509. this.skeletons.push(newSkeleton);
  136510. this.onNewSkeletonAddedObservable.notifyObservers(newSkeleton);
  136511. };
  136512. /**
  136513. * Adds the given particle system to this scene
  136514. * @param newParticleSystem The particle system to add
  136515. */
  136516. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  136517. this.particleSystems.push(newParticleSystem);
  136518. };
  136519. /**
  136520. * Adds the given animation to this scene
  136521. * @param newAnimation The animation to add
  136522. */
  136523. Scene.prototype.addAnimation = function (newAnimation) {
  136524. this.animations.push(newAnimation);
  136525. };
  136526. /**
  136527. * Adds the given animation group to this scene.
  136528. * @param newAnimationGroup The animation group to add
  136529. */
  136530. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  136531. this.animationGroups.push(newAnimationGroup);
  136532. };
  136533. /**
  136534. * Adds the given multi-material to this scene
  136535. * @param newMultiMaterial The multi-material to add
  136536. */
  136537. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  136538. this.multiMaterials.push(newMultiMaterial);
  136539. };
  136540. /**
  136541. * Adds the given material to this scene
  136542. * @param newMaterial The material to add
  136543. */
  136544. Scene.prototype.addMaterial = function (newMaterial) {
  136545. newMaterial._indexInSceneMaterialArray = this.materials.length;
  136546. this.materials.push(newMaterial);
  136547. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  136548. };
  136549. /**
  136550. * Adds the given morph target to this scene
  136551. * @param newMorphTargetManager The morph target to add
  136552. */
  136553. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  136554. this.morphTargetManagers.push(newMorphTargetManager);
  136555. };
  136556. /**
  136557. * Adds the given geometry to this scene
  136558. * @param newGeometry The geometry to add
  136559. */
  136560. Scene.prototype.addGeometry = function (newGeometry) {
  136561. if (this.geometriesByUniqueId) {
  136562. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  136563. }
  136564. this.geometries.push(newGeometry);
  136565. };
  136566. /**
  136567. * Adds the given action manager to this scene
  136568. * @param newActionManager The action manager to add
  136569. */
  136570. Scene.prototype.addActionManager = function (newActionManager) {
  136571. this.actionManagers.push(newActionManager);
  136572. };
  136573. /**
  136574. * Adds the given texture to this scene.
  136575. * @param newTexture The texture to add
  136576. */
  136577. Scene.prototype.addTexture = function (newTexture) {
  136578. this.textures.push(newTexture);
  136579. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  136580. };
  136581. /**
  136582. * Switch active camera
  136583. * @param newCamera defines the new active camera
  136584. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  136585. */
  136586. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  136587. if (attachControl === void 0) { attachControl = true; }
  136588. var canvas = this._engine.getRenderingCanvas();
  136589. if (!canvas) {
  136590. return;
  136591. }
  136592. if (this.activeCamera) {
  136593. this.activeCamera.detachControl(canvas);
  136594. }
  136595. this.activeCamera = newCamera;
  136596. if (attachControl) {
  136597. newCamera.attachControl(canvas);
  136598. }
  136599. };
  136600. /**
  136601. * sets the active camera of the scene using its ID
  136602. * @param id defines the camera's ID
  136603. * @return the new active camera or null if none found.
  136604. */
  136605. Scene.prototype.setActiveCameraByID = function (id) {
  136606. var camera = this.getCameraByID(id);
  136607. if (camera) {
  136608. this.activeCamera = camera;
  136609. return camera;
  136610. }
  136611. return null;
  136612. };
  136613. /**
  136614. * sets the active camera of the scene using its name
  136615. * @param name defines the camera's name
  136616. * @returns the new active camera or null if none found.
  136617. */
  136618. Scene.prototype.setActiveCameraByName = function (name) {
  136619. var camera = this.getCameraByName(name);
  136620. if (camera) {
  136621. this.activeCamera = camera;
  136622. return camera;
  136623. }
  136624. return null;
  136625. };
  136626. /**
  136627. * get an animation group using its name
  136628. * @param name defines the material's name
  136629. * @return the animation group or null if none found.
  136630. */
  136631. Scene.prototype.getAnimationGroupByName = function (name) {
  136632. for (var index = 0; index < this.animationGroups.length; index++) {
  136633. if (this.animationGroups[index].name === name) {
  136634. return this.animationGroups[index];
  136635. }
  136636. }
  136637. return null;
  136638. };
  136639. /**
  136640. * Get a material using its unique id
  136641. * @param uniqueId defines the material's unique id
  136642. * @return the material or null if none found.
  136643. */
  136644. Scene.prototype.getMaterialByUniqueID = function (uniqueId) {
  136645. for (var index = 0; index < this.materials.length; index++) {
  136646. if (this.materials[index].uniqueId === uniqueId) {
  136647. return this.materials[index];
  136648. }
  136649. }
  136650. return null;
  136651. };
  136652. /**
  136653. * get a material using its id
  136654. * @param id defines the material's ID
  136655. * @return the material or null if none found.
  136656. */
  136657. Scene.prototype.getMaterialByID = function (id) {
  136658. for (var index = 0; index < this.materials.length; index++) {
  136659. if (this.materials[index].id === id) {
  136660. return this.materials[index];
  136661. }
  136662. }
  136663. return null;
  136664. };
  136665. /**
  136666. * Gets a material using its name
  136667. * @param name defines the material's name
  136668. * @return the material or null if none found.
  136669. */
  136670. Scene.prototype.getMaterialByName = function (name) {
  136671. for (var index = 0; index < this.materials.length; index++) {
  136672. if (this.materials[index].name === name) {
  136673. return this.materials[index];
  136674. }
  136675. }
  136676. return null;
  136677. };
  136678. /**
  136679. * Gets a camera using its id
  136680. * @param id defines the id to look for
  136681. * @returns the camera or null if not found
  136682. */
  136683. Scene.prototype.getCameraByID = function (id) {
  136684. for (var index = 0; index < this.cameras.length; index++) {
  136685. if (this.cameras[index].id === id) {
  136686. return this.cameras[index];
  136687. }
  136688. }
  136689. return null;
  136690. };
  136691. /**
  136692. * Gets a camera using its unique id
  136693. * @param uniqueId defines the unique id to look for
  136694. * @returns the camera or null if not found
  136695. */
  136696. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  136697. for (var index = 0; index < this.cameras.length; index++) {
  136698. if (this.cameras[index].uniqueId === uniqueId) {
  136699. return this.cameras[index];
  136700. }
  136701. }
  136702. return null;
  136703. };
  136704. /**
  136705. * Gets a camera using its name
  136706. * @param name defines the camera's name
  136707. * @return the camera or null if none found.
  136708. */
  136709. Scene.prototype.getCameraByName = function (name) {
  136710. for (var index = 0; index < this.cameras.length; index++) {
  136711. if (this.cameras[index].name === name) {
  136712. return this.cameras[index];
  136713. }
  136714. }
  136715. return null;
  136716. };
  136717. /**
  136718. * Gets a bone using its id
  136719. * @param id defines the bone's id
  136720. * @return the bone or null if not found
  136721. */
  136722. Scene.prototype.getBoneByID = function (id) {
  136723. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  136724. var skeleton = this.skeletons[skeletonIndex];
  136725. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  136726. if (skeleton.bones[boneIndex].id === id) {
  136727. return skeleton.bones[boneIndex];
  136728. }
  136729. }
  136730. }
  136731. return null;
  136732. };
  136733. /**
  136734. * Gets a bone using its id
  136735. * @param name defines the bone's name
  136736. * @return the bone or null if not found
  136737. */
  136738. Scene.prototype.getBoneByName = function (name) {
  136739. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  136740. var skeleton = this.skeletons[skeletonIndex];
  136741. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  136742. if (skeleton.bones[boneIndex].name === name) {
  136743. return skeleton.bones[boneIndex];
  136744. }
  136745. }
  136746. }
  136747. return null;
  136748. };
  136749. /**
  136750. * Gets a light node using its name
  136751. * @param name defines the the light's name
  136752. * @return the light or null if none found.
  136753. */
  136754. Scene.prototype.getLightByName = function (name) {
  136755. for (var index = 0; index < this.lights.length; index++) {
  136756. if (this.lights[index].name === name) {
  136757. return this.lights[index];
  136758. }
  136759. }
  136760. return null;
  136761. };
  136762. /**
  136763. * Gets a light node using its id
  136764. * @param id defines the light's id
  136765. * @return the light or null if none found.
  136766. */
  136767. Scene.prototype.getLightByID = function (id) {
  136768. for (var index = 0; index < this.lights.length; index++) {
  136769. if (this.lights[index].id === id) {
  136770. return this.lights[index];
  136771. }
  136772. }
  136773. return null;
  136774. };
  136775. /**
  136776. * Gets a light node using its scene-generated unique ID
  136777. * @param uniqueId defines the light's unique id
  136778. * @return the light or null if none found.
  136779. */
  136780. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  136781. for (var index = 0; index < this.lights.length; index++) {
  136782. if (this.lights[index].uniqueId === uniqueId) {
  136783. return this.lights[index];
  136784. }
  136785. }
  136786. return null;
  136787. };
  136788. /**
  136789. * Gets a particle system by id
  136790. * @param id defines the particle system id
  136791. * @return the corresponding system or null if none found
  136792. */
  136793. Scene.prototype.getParticleSystemByID = function (id) {
  136794. for (var index = 0; index < this.particleSystems.length; index++) {
  136795. if (this.particleSystems[index].id === id) {
  136796. return this.particleSystems[index];
  136797. }
  136798. }
  136799. return null;
  136800. };
  136801. /**
  136802. * Gets a geometry using its ID
  136803. * @param id defines the geometry's id
  136804. * @return the geometry or null if none found.
  136805. */
  136806. Scene.prototype.getGeometryByID = function (id) {
  136807. for (var index = 0; index < this.geometries.length; index++) {
  136808. if (this.geometries[index].id === id) {
  136809. return this.geometries[index];
  136810. }
  136811. }
  136812. return null;
  136813. };
  136814. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  136815. if (this.geometriesByUniqueId) {
  136816. var index_1 = this.geometriesByUniqueId[uniqueId];
  136817. if (index_1 !== undefined) {
  136818. return this.geometries[index_1];
  136819. }
  136820. }
  136821. else {
  136822. for (var index = 0; index < this.geometries.length; index++) {
  136823. if (this.geometries[index].uniqueId === uniqueId) {
  136824. return this.geometries[index];
  136825. }
  136826. }
  136827. }
  136828. return null;
  136829. };
  136830. /**
  136831. * Add a new geometry to this scene
  136832. * @param geometry defines the geometry to be added to the scene.
  136833. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  136834. * @return a boolean defining if the geometry was added or not
  136835. */
  136836. Scene.prototype.pushGeometry = function (geometry, force) {
  136837. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  136838. return false;
  136839. }
  136840. this.addGeometry(geometry);
  136841. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  136842. return true;
  136843. };
  136844. /**
  136845. * Removes an existing geometry
  136846. * @param geometry defines the geometry to be removed from the scene
  136847. * @return a boolean defining if the geometry was removed or not
  136848. */
  136849. Scene.prototype.removeGeometry = function (geometry) {
  136850. var index;
  136851. if (this.geometriesByUniqueId) {
  136852. index = this.geometriesByUniqueId[geometry.uniqueId];
  136853. if (index === undefined) {
  136854. return false;
  136855. }
  136856. }
  136857. else {
  136858. index = this.geometries.indexOf(geometry);
  136859. if (index < 0) {
  136860. return false;
  136861. }
  136862. }
  136863. if (index !== this.geometries.length - 1) {
  136864. var lastGeometry = this.geometries[this.geometries.length - 1];
  136865. this.geometries[index] = lastGeometry;
  136866. if (this.geometriesByUniqueId) {
  136867. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  136868. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  136869. }
  136870. }
  136871. this.geometries.pop();
  136872. this.onGeometryRemovedObservable.notifyObservers(geometry);
  136873. return true;
  136874. };
  136875. /**
  136876. * Gets the list of geometries attached to the scene
  136877. * @returns an array of Geometry
  136878. */
  136879. Scene.prototype.getGeometries = function () {
  136880. return this.geometries;
  136881. };
  136882. /**
  136883. * Gets the first added mesh found of a given ID
  136884. * @param id defines the id to search for
  136885. * @return the mesh found or null if not found at all
  136886. */
  136887. Scene.prototype.getMeshByID = function (id) {
  136888. for (var index = 0; index < this.meshes.length; index++) {
  136889. if (this.meshes[index].id === id) {
  136890. return this.meshes[index];
  136891. }
  136892. }
  136893. return null;
  136894. };
  136895. /**
  136896. * Gets a list of meshes using their id
  136897. * @param id defines the id to search for
  136898. * @returns a list of meshes
  136899. */
  136900. Scene.prototype.getMeshesByID = function (id) {
  136901. return this.meshes.filter(function (m) {
  136902. return m.id === id;
  136903. });
  136904. };
  136905. /**
  136906. * Gets the first added transform node found of a given ID
  136907. * @param id defines the id to search for
  136908. * @return the found transform node or null if not found at all.
  136909. */
  136910. Scene.prototype.getTransformNodeByID = function (id) {
  136911. for (var index = 0; index < this.transformNodes.length; index++) {
  136912. if (this.transformNodes[index].id === id) {
  136913. return this.transformNodes[index];
  136914. }
  136915. }
  136916. return null;
  136917. };
  136918. /**
  136919. * Gets a transform node with its auto-generated unique id
  136920. * @param uniqueId efines the unique id to search for
  136921. * @return the found transform node or null if not found at all.
  136922. */
  136923. Scene.prototype.getTransformNodeByUniqueID = function (uniqueId) {
  136924. for (var index = 0; index < this.transformNodes.length; index++) {
  136925. if (this.transformNodes[index].uniqueId === uniqueId) {
  136926. return this.transformNodes[index];
  136927. }
  136928. }
  136929. return null;
  136930. };
  136931. /**
  136932. * Gets a list of transform nodes using their id
  136933. * @param id defines the id to search for
  136934. * @returns a list of transform nodes
  136935. */
  136936. Scene.prototype.getTransformNodesByID = function (id) {
  136937. return this.transformNodes.filter(function (m) {
  136938. return m.id === id;
  136939. });
  136940. };
  136941. /**
  136942. * Gets a mesh with its auto-generated unique id
  136943. * @param uniqueId defines the unique id to search for
  136944. * @return the found mesh or null if not found at all.
  136945. */
  136946. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  136947. for (var index = 0; index < this.meshes.length; index++) {
  136948. if (this.meshes[index].uniqueId === uniqueId) {
  136949. return this.meshes[index];
  136950. }
  136951. }
  136952. return null;
  136953. };
  136954. /**
  136955. * Gets a the last added mesh using a given id
  136956. * @param id defines the id to search for
  136957. * @return the found mesh or null if not found at all.
  136958. */
  136959. Scene.prototype.getLastMeshByID = function (id) {
  136960. for (var index = this.meshes.length - 1; index >= 0; index--) {
  136961. if (this.meshes[index].id === id) {
  136962. return this.meshes[index];
  136963. }
  136964. }
  136965. return null;
  136966. };
  136967. /**
  136968. * Gets a the last added node (Mesh, Camera, Light) using a given id
  136969. * @param id defines the id to search for
  136970. * @return the found node or null if not found at all
  136971. */
  136972. Scene.prototype.getLastEntryByID = function (id) {
  136973. var index;
  136974. for (index = this.meshes.length - 1; index >= 0; index--) {
  136975. if (this.meshes[index].id === id) {
  136976. return this.meshes[index];
  136977. }
  136978. }
  136979. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  136980. if (this.transformNodes[index].id === id) {
  136981. return this.transformNodes[index];
  136982. }
  136983. }
  136984. for (index = this.cameras.length - 1; index >= 0; index--) {
  136985. if (this.cameras[index].id === id) {
  136986. return this.cameras[index];
  136987. }
  136988. }
  136989. for (index = this.lights.length - 1; index >= 0; index--) {
  136990. if (this.lights[index].id === id) {
  136991. return this.lights[index];
  136992. }
  136993. }
  136994. return null;
  136995. };
  136996. /**
  136997. * Gets a node (Mesh, Camera, Light) using a given id
  136998. * @param id defines the id to search for
  136999. * @return the found node or null if not found at all
  137000. */
  137001. Scene.prototype.getNodeByID = function (id) {
  137002. var mesh = this.getMeshByID(id);
  137003. if (mesh) {
  137004. return mesh;
  137005. }
  137006. var transformNode = this.getTransformNodeByID(id);
  137007. if (transformNode) {
  137008. return transformNode;
  137009. }
  137010. var light = this.getLightByID(id);
  137011. if (light) {
  137012. return light;
  137013. }
  137014. var camera = this.getCameraByID(id);
  137015. if (camera) {
  137016. return camera;
  137017. }
  137018. var bone = this.getBoneByID(id);
  137019. if (bone) {
  137020. return bone;
  137021. }
  137022. return null;
  137023. };
  137024. /**
  137025. * Gets a node (Mesh, Camera, Light) using a given name
  137026. * @param name defines the name to search for
  137027. * @return the found node or null if not found at all.
  137028. */
  137029. Scene.prototype.getNodeByName = function (name) {
  137030. var mesh = this.getMeshByName(name);
  137031. if (mesh) {
  137032. return mesh;
  137033. }
  137034. var transformNode = this.getTransformNodeByName(name);
  137035. if (transformNode) {
  137036. return transformNode;
  137037. }
  137038. var light = this.getLightByName(name);
  137039. if (light) {
  137040. return light;
  137041. }
  137042. var camera = this.getCameraByName(name);
  137043. if (camera) {
  137044. return camera;
  137045. }
  137046. var bone = this.getBoneByName(name);
  137047. if (bone) {
  137048. return bone;
  137049. }
  137050. return null;
  137051. };
  137052. /**
  137053. * Gets a mesh using a given name
  137054. * @param name defines the name to search for
  137055. * @return the found mesh or null if not found at all.
  137056. */
  137057. Scene.prototype.getMeshByName = function (name) {
  137058. for (var index = 0; index < this.meshes.length; index++) {
  137059. if (this.meshes[index].name === name) {
  137060. return this.meshes[index];
  137061. }
  137062. }
  137063. return null;
  137064. };
  137065. /**
  137066. * Gets a transform node using a given name
  137067. * @param name defines the name to search for
  137068. * @return the found transform node or null if not found at all.
  137069. */
  137070. Scene.prototype.getTransformNodeByName = function (name) {
  137071. for (var index = 0; index < this.transformNodes.length; index++) {
  137072. if (this.transformNodes[index].name === name) {
  137073. return this.transformNodes[index];
  137074. }
  137075. }
  137076. return null;
  137077. };
  137078. /**
  137079. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  137080. * @param id defines the id to search for
  137081. * @return the found skeleton or null if not found at all.
  137082. */
  137083. Scene.prototype.getLastSkeletonByID = function (id) {
  137084. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  137085. if (this.skeletons[index].id === id) {
  137086. return this.skeletons[index];
  137087. }
  137088. }
  137089. return null;
  137090. };
  137091. /**
  137092. * Gets a skeleton using a given auto generated unique id
  137093. * @param uniqueId defines the unique id to search for
  137094. * @return the found skeleton or null if not found at all.
  137095. */
  137096. Scene.prototype.getSkeletonByUniqueId = function (uniqueId) {
  137097. for (var index = 0; index < this.skeletons.length; index++) {
  137098. if (this.skeletons[index].uniqueId === uniqueId) {
  137099. return this.skeletons[index];
  137100. }
  137101. }
  137102. return null;
  137103. };
  137104. /**
  137105. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  137106. * @param id defines the id to search for
  137107. * @return the found skeleton or null if not found at all.
  137108. */
  137109. Scene.prototype.getSkeletonById = function (id) {
  137110. for (var index = 0; index < this.skeletons.length; index++) {
  137111. if (this.skeletons[index].id === id) {
  137112. return this.skeletons[index];
  137113. }
  137114. }
  137115. return null;
  137116. };
  137117. /**
  137118. * Gets a skeleton using a given name
  137119. * @param name defines the name to search for
  137120. * @return the found skeleton or null if not found at all.
  137121. */
  137122. Scene.prototype.getSkeletonByName = function (name) {
  137123. for (var index = 0; index < this.skeletons.length; index++) {
  137124. if (this.skeletons[index].name === name) {
  137125. return this.skeletons[index];
  137126. }
  137127. }
  137128. return null;
  137129. };
  137130. /**
  137131. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  137132. * @param id defines the id to search for
  137133. * @return the found morph target manager or null if not found at all.
  137134. */
  137135. Scene.prototype.getMorphTargetManagerById = function (id) {
  137136. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  137137. if (this.morphTargetManagers[index].uniqueId === id) {
  137138. return this.morphTargetManagers[index];
  137139. }
  137140. }
  137141. return null;
  137142. };
  137143. /**
  137144. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  137145. * @param id defines the id to search for
  137146. * @return the found morph target or null if not found at all.
  137147. */
  137148. Scene.prototype.getMorphTargetById = function (id) {
  137149. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  137150. var morphTargetManager = this.morphTargetManagers[managerIndex];
  137151. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  137152. var target = morphTargetManager.getTarget(index);
  137153. if (target.id === id) {
  137154. return target;
  137155. }
  137156. }
  137157. }
  137158. return null;
  137159. };
  137160. /**
  137161. * Gets a boolean indicating if the given mesh is active
  137162. * @param mesh defines the mesh to look for
  137163. * @returns true if the mesh is in the active list
  137164. */
  137165. Scene.prototype.isActiveMesh = function (mesh) {
  137166. return (this._activeMeshes.indexOf(mesh) !== -1);
  137167. };
  137168. Object.defineProperty(Scene.prototype, "uid", {
  137169. /**
  137170. * Return a unique id as a string which can serve as an identifier for the scene
  137171. */
  137172. get: function () {
  137173. if (!this._uid) {
  137174. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  137175. }
  137176. return this._uid;
  137177. },
  137178. enumerable: true,
  137179. configurable: true
  137180. });
  137181. /**
  137182. * Add an externaly attached data from its key.
  137183. * This method call will fail and return false, if such key already exists.
  137184. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  137185. * @param key the unique key that identifies the data
  137186. * @param data the data object to associate to the key for this Engine instance
  137187. * @return true if no such key were already present and the data was added successfully, false otherwise
  137188. */
  137189. Scene.prototype.addExternalData = function (key, data) {
  137190. if (!this._externalData) {
  137191. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  137192. }
  137193. return this._externalData.add(key, data);
  137194. };
  137195. /**
  137196. * Get an externaly attached data from its key
  137197. * @param key the unique key that identifies the data
  137198. * @return the associated data, if present (can be null), or undefined if not present
  137199. */
  137200. Scene.prototype.getExternalData = function (key) {
  137201. if (!this._externalData) {
  137202. return null;
  137203. }
  137204. return this._externalData.get(key);
  137205. };
  137206. /**
  137207. * Get an externaly attached data from its key, create it using a factory if it's not already present
  137208. * @param key the unique key that identifies the data
  137209. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  137210. * @return the associated data, can be null if the factory returned null.
  137211. */
  137212. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  137213. if (!this._externalData) {
  137214. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  137215. }
  137216. return this._externalData.getOrAddWithFactory(key, factory);
  137217. };
  137218. /**
  137219. * Remove an externaly attached data from the Engine instance
  137220. * @param key the unique key that identifies the data
  137221. * @return true if the data was successfully removed, false if it doesn't exist
  137222. */
  137223. Scene.prototype.removeExternalData = function (key) {
  137224. return this._externalData.remove(key);
  137225. };
  137226. Scene.prototype._evaluateSubMesh = function (subMesh, mesh) {
  137227. if (this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  137228. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  137229. var step = _a[_i];
  137230. step.action(mesh, subMesh);
  137231. }
  137232. var material = subMesh.getMaterial();
  137233. if (material !== null && material !== undefined) {
  137234. // Render targets
  137235. if (material.hasRenderTargetTextures && material.getRenderTargetTextures !== undefined) {
  137236. if (this._processedMaterials.indexOf(material) === -1) {
  137237. this._processedMaterials.push(material);
  137238. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  137239. }
  137240. }
  137241. // Dispatch
  137242. this._activeIndices.addCount(subMesh.indexCount, false);
  137243. this._renderingManager.dispatch(subMesh, mesh, material);
  137244. }
  137245. }
  137246. };
  137247. /**
  137248. * Clear the processed materials smart array preventing retention point in material dispose.
  137249. */
  137250. Scene.prototype.freeProcessedMaterials = function () {
  137251. this._processedMaterials.dispose();
  137252. };
  137253. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  137254. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  137255. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  137256. * when disposing several meshes in a row or a hierarchy of meshes.
  137257. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  137258. */
  137259. get: function () {
  137260. return this._preventFreeActiveMeshesAndRenderingGroups;
  137261. },
  137262. set: function (value) {
  137263. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  137264. return;
  137265. }
  137266. if (value) {
  137267. this.freeActiveMeshes();
  137268. this.freeRenderingGroups();
  137269. }
  137270. this._preventFreeActiveMeshesAndRenderingGroups = value;
  137271. },
  137272. enumerable: true,
  137273. configurable: true
  137274. });
  137275. /**
  137276. * Clear the active meshes smart array preventing retention point in mesh dispose.
  137277. */
  137278. Scene.prototype.freeActiveMeshes = function () {
  137279. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  137280. return;
  137281. }
  137282. this._activeMeshes.dispose();
  137283. if (this.activeCamera && this.activeCamera._activeMeshes) {
  137284. this.activeCamera._activeMeshes.dispose();
  137285. }
  137286. if (this.activeCameras) {
  137287. for (var i = 0; i < this.activeCameras.length; i++) {
  137288. var activeCamera = this.activeCameras[i];
  137289. if (activeCamera && activeCamera._activeMeshes) {
  137290. activeCamera._activeMeshes.dispose();
  137291. }
  137292. }
  137293. }
  137294. };
  137295. /**
  137296. * Clear the info related to rendering groups preventing retention points during dispose.
  137297. */
  137298. Scene.prototype.freeRenderingGroups = function () {
  137299. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  137300. return;
  137301. }
  137302. if (this._renderingManager) {
  137303. this._renderingManager.freeRenderingGroups();
  137304. }
  137305. if (this.textures) {
  137306. for (var i = 0; i < this.textures.length; i++) {
  137307. var texture = this.textures[i];
  137308. if (texture && texture.renderList) {
  137309. texture.freeRenderingGroups();
  137310. }
  137311. }
  137312. }
  137313. };
  137314. /** @hidden */
  137315. Scene.prototype._isInIntermediateRendering = function () {
  137316. return this._intermediateRendering;
  137317. };
  137318. /**
  137319. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  137320. * @returns the current scene
  137321. */
  137322. Scene.prototype.freezeActiveMeshes = function () {
  137323. if (!this.activeCamera) {
  137324. return this;
  137325. }
  137326. if (!this._frustumPlanes) {
  137327. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  137328. }
  137329. this._evaluateActiveMeshes();
  137330. this._activeMeshesFrozen = true;
  137331. return this;
  137332. };
  137333. /**
  137334. * Use this function to restart evaluating active meshes on every frame
  137335. * @returns the current scene
  137336. */
  137337. Scene.prototype.unfreezeActiveMeshes = function () {
  137338. this._activeMeshesFrozen = false;
  137339. return this;
  137340. };
  137341. Scene.prototype._evaluateActiveMeshes = function () {
  137342. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  137343. return;
  137344. }
  137345. if (!this.activeCamera) {
  137346. return;
  137347. }
  137348. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  137349. this.activeCamera._activeMeshes.reset();
  137350. this._activeMeshes.reset();
  137351. this._renderingManager.reset();
  137352. this._processedMaterials.reset();
  137353. this._activeParticleSystems.reset();
  137354. this._activeSkeletons.reset();
  137355. this._softwareSkinnedMeshes.reset();
  137356. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  137357. var step = _a[_i];
  137358. step.action();
  137359. }
  137360. // Determine mesh candidates
  137361. var meshes = this.getActiveMeshCandidates();
  137362. // Check each mesh
  137363. var len = meshes.length;
  137364. for (var i = 0; i < len; i++) {
  137365. var mesh = meshes.data[i];
  137366. if (mesh.isBlocked) {
  137367. continue;
  137368. }
  137369. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  137370. if (!mesh.isReady() || !mesh.isEnabled()) {
  137371. continue;
  137372. }
  137373. mesh.computeWorldMatrix();
  137374. // Intersections
  137375. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  137376. this._meshesForIntersections.pushNoDuplicate(mesh);
  137377. }
  137378. // Switch to current LOD
  137379. var meshLOD = this.customLODSelector ? this.customLODSelector(mesh, this.activeCamera) : mesh.getLOD(this.activeCamera);
  137380. if (meshLOD === undefined || meshLOD === null) {
  137381. continue;
  137382. }
  137383. // Compute world matrix if LOD is billboard
  137384. if (meshLOD !== mesh && meshLOD.billboardMode !== _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_8__["TransformNode"].BILLBOARDMODE_NONE) {
  137385. meshLOD.computeWorldMatrix();
  137386. }
  137387. mesh._preActivate();
  137388. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  137389. this._activeMeshes.push(mesh);
  137390. this.activeCamera._activeMeshes.push(mesh);
  137391. mesh._activate(this._renderId);
  137392. if (meshLOD !== mesh) {
  137393. meshLOD._activate(this._renderId);
  137394. }
  137395. this._activeMesh(mesh, meshLOD);
  137396. }
  137397. }
  137398. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  137399. // Particle systems
  137400. if (this.particlesEnabled) {
  137401. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  137402. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  137403. var particleSystem = this.particleSystems[particleIndex];
  137404. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  137405. continue;
  137406. }
  137407. var emitter = particleSystem.emitter;
  137408. if (!emitter.position || emitter.isEnabled()) {
  137409. this._activeParticleSystems.push(particleSystem);
  137410. particleSystem.animate();
  137411. this._renderingManager.dispatchParticles(particleSystem);
  137412. }
  137413. }
  137414. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  137415. }
  137416. };
  137417. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  137418. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  137419. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  137420. mesh.skeleton.prepare();
  137421. }
  137422. if (!mesh.computeBonesUsingShaders) {
  137423. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  137424. }
  137425. }
  137426. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  137427. var step = _a[_i];
  137428. step.action(sourceMesh, mesh);
  137429. }
  137430. if (mesh !== undefined && mesh !== null
  137431. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  137432. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  137433. var len = subMeshes.length;
  137434. for (var i = 0; i < len; i++) {
  137435. var subMesh = subMeshes.data[i];
  137436. this._evaluateSubMesh(subMesh, mesh);
  137437. }
  137438. }
  137439. };
  137440. /**
  137441. * Update the transform matrix to update from the current active camera
  137442. * @param force defines a boolean used to force the update even if cache is up to date
  137443. */
  137444. Scene.prototype.updateTransformMatrix = function (force) {
  137445. if (!this.activeCamera) {
  137446. return;
  137447. }
  137448. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  137449. };
  137450. Scene.prototype._bindFrameBuffer = function () {
  137451. if (this.activeCamera && this.activeCamera._multiviewTexture) {
  137452. this.activeCamera._multiviewTexture._bindFrameBuffer();
  137453. }
  137454. else if (this.activeCamera && this.activeCamera.outputRenderTarget) {
  137455. var useMultiview = this.getEngine().getCaps().multiview && this.activeCamera.outputRenderTarget && this.activeCamera.outputRenderTarget.getViewCount() > 1;
  137456. if (useMultiview) {
  137457. this.activeCamera.outputRenderTarget._bindFrameBuffer();
  137458. }
  137459. else {
  137460. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  137461. if (internalTexture) {
  137462. this.getEngine().bindFramebuffer(internalTexture);
  137463. }
  137464. else {
  137465. _Misc_logger__WEBPACK_IMPORTED_MODULE_24__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  137466. }
  137467. }
  137468. }
  137469. else {
  137470. this.getEngine().restoreDefaultFramebuffer(); // Restore back buffer if needed
  137471. }
  137472. };
  137473. /** @hidden */
  137474. Scene.prototype._renderForCamera = function (camera, rigParent) {
  137475. if (camera && camera._skipRendering) {
  137476. return;
  137477. }
  137478. var engine = this._engine;
  137479. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  137480. this._activeCamera = camera;
  137481. if (!this.activeCamera) {
  137482. throw new Error("Active camera not set");
  137483. }
  137484. // Viewport
  137485. engine.setViewport(this.activeCamera.viewport);
  137486. // Camera
  137487. this.resetCachedMaterial();
  137488. this._renderId++;
  137489. var useMultiview = this.getEngine().getCaps().multiview && camera.outputRenderTarget && camera.outputRenderTarget.getViewCount() > 1;
  137490. if (useMultiview) {
  137491. this.setTransformMatrix(camera._rigCameras[0].getViewMatrix(), camera._rigCameras[0].getProjectionMatrix(), camera._rigCameras[1].getViewMatrix(), camera._rigCameras[1].getProjectionMatrix());
  137492. }
  137493. else {
  137494. this.updateTransformMatrix();
  137495. }
  137496. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  137497. // Meshes
  137498. this._evaluateActiveMeshes();
  137499. // Software skinning
  137500. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  137501. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  137502. mesh.applySkeleton(mesh.skeleton);
  137503. }
  137504. // Render targets
  137505. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  137506. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  137507. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  137508. }
  137509. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  137510. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  137511. }
  137512. // Collects render targets from external components.
  137513. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  137514. var step = _a[_i];
  137515. step.action(this._renderTargets);
  137516. }
  137517. if (this.renderTargetsEnabled) {
  137518. this._intermediateRendering = true;
  137519. if (this._renderTargets.length > 0) {
  137520. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  137521. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  137522. var renderTarget = this._renderTargets.data[renderIndex];
  137523. if (renderTarget._shouldRender()) {
  137524. this._renderId++;
  137525. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  137526. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  137527. }
  137528. }
  137529. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  137530. this._renderId++;
  137531. }
  137532. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  137533. var step = _c[_b];
  137534. step.action(this.activeCamera);
  137535. }
  137536. this._intermediateRendering = false;
  137537. // Restore framebuffer after rendering to targets
  137538. this._bindFrameBuffer();
  137539. }
  137540. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  137541. // Prepare Frame
  137542. if (this.postProcessManager && !camera._multiviewTexture) {
  137543. this.postProcessManager._prepareFrame();
  137544. }
  137545. // Before Camera Draw
  137546. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  137547. var step = _e[_d];
  137548. step.action(this.activeCamera);
  137549. }
  137550. // Render
  137551. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  137552. this._renderingManager.render(null, null, true, true);
  137553. this.onAfterDrawPhaseObservable.notifyObservers(this);
  137554. // After Camera Draw
  137555. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  137556. var step = _g[_f];
  137557. step.action(this.activeCamera);
  137558. }
  137559. // Finalize frame
  137560. if (this.postProcessManager && !camera._multiviewTexture) {
  137561. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  137562. }
  137563. // Reset some special arrays
  137564. this._renderTargets.reset();
  137565. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  137566. };
  137567. Scene.prototype._processSubCameras = function (camera) {
  137568. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_NONE || (camera.outputRenderTarget && camera.outputRenderTarget.getViewCount() > 1 && this.getEngine().getCaps().multiview)) {
  137569. this._renderForCamera(camera);
  137570. return;
  137571. }
  137572. if (camera._useMultiviewToSingleView) {
  137573. this._renderMultiviewToSingleView(camera);
  137574. }
  137575. else {
  137576. // rig cameras
  137577. for (var index = 0; index < camera._rigCameras.length; index++) {
  137578. this._renderForCamera(camera._rigCameras[index], camera);
  137579. }
  137580. }
  137581. // Use _activeCamera instead of activeCamera to avoid onActiveCameraChanged
  137582. this._activeCamera = camera;
  137583. this.setTransformMatrix(this._activeCamera.getViewMatrix(), this._activeCamera.getProjectionMatrix());
  137584. };
  137585. Scene.prototype._checkIntersections = function () {
  137586. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  137587. var sourceMesh = this._meshesForIntersections.data[index];
  137588. if (!sourceMesh.actionManager) {
  137589. continue;
  137590. }
  137591. for (var actionIndex = 0; sourceMesh.actionManager && actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  137592. var action = sourceMesh.actionManager.actions[actionIndex];
  137593. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger) {
  137594. var parameters = action.getTriggerParameter();
  137595. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_9__["AbstractMesh"] ? parameters : parameters.mesh;
  137596. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  137597. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  137598. if (areIntersecting && currentIntersectionInProgress === -1) {
  137599. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  137600. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  137601. sourceMesh._intersectionsInProgress.push(otherMesh);
  137602. }
  137603. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger) {
  137604. sourceMesh._intersectionsInProgress.push(otherMesh);
  137605. }
  137606. }
  137607. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  137608. //They intersected, and now they don't.
  137609. //is this trigger an exit trigger? execute an event.
  137610. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger) {
  137611. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  137612. }
  137613. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  137614. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  137615. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_9__["AbstractMesh"] ? parameter : parameter.mesh;
  137616. return otherMesh === parameterMesh;
  137617. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnIntersectionExitTrigger) {
  137618. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  137619. }
  137620. }
  137621. }
  137622. }
  137623. }
  137624. };
  137625. /** @hidden */
  137626. Scene.prototype._advancePhysicsEngineStep = function (step) {
  137627. // Do nothing. Code will be replaced if physics engine component is referenced
  137628. };
  137629. /** @hidden */
  137630. Scene.prototype._animate = function () {
  137631. // Nothing to do as long as Animatable have not been imported.
  137632. };
  137633. /**
  137634. * Render the scene
  137635. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  137636. */
  137637. Scene.prototype.render = function (updateCameras) {
  137638. if (updateCameras === void 0) { updateCameras = true; }
  137639. if (this.isDisposed) {
  137640. return;
  137641. }
  137642. this._frameId++;
  137643. // Register components that have been associated lately to the scene.
  137644. this._registerTransientComponents();
  137645. this._activeParticles.fetchNewFrame();
  137646. this._totalVertices.fetchNewFrame();
  137647. this._activeIndices.fetchNewFrame();
  137648. this._activeBones.fetchNewFrame();
  137649. this._meshesForIntersections.reset();
  137650. this.resetCachedMaterial();
  137651. this.onBeforeAnimationsObservable.notifyObservers(this);
  137652. // Actions
  137653. if (this.actionManager) {
  137654. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnEveryFrameTrigger);
  137655. }
  137656. if (this._engine.isDeterministicLockStep()) {
  137657. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  137658. var defaultFPS = (60.0 / 1000.0);
  137659. var defaultFrameTime = this.getDeterministicFrameTime();
  137660. var stepsTaken = 0;
  137661. var maxSubSteps = this._engine.getLockstepMaxSteps();
  137662. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  137663. internalSteps = Math.min(internalSteps, maxSubSteps);
  137664. do {
  137665. this.onBeforeStepObservable.notifyObservers(this);
  137666. // Animations
  137667. this._animationRatio = defaultFrameTime * defaultFPS;
  137668. this._animate();
  137669. this.onAfterAnimationsObservable.notifyObservers(this);
  137670. // Physics
  137671. this._advancePhysicsEngineStep(defaultFrameTime);
  137672. this.onAfterStepObservable.notifyObservers(this);
  137673. this._currentStepId++;
  137674. stepsTaken++;
  137675. deltaTime -= defaultFrameTime;
  137676. } while (deltaTime > 0 && stepsTaken < internalSteps);
  137677. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  137678. }
  137679. else {
  137680. // Animations
  137681. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  137682. this._animationRatio = deltaTime * (60.0 / 1000.0);
  137683. this._animate();
  137684. this.onAfterAnimationsObservable.notifyObservers(this);
  137685. // Physics
  137686. this._advancePhysicsEngineStep(deltaTime);
  137687. }
  137688. // Before camera update steps
  137689. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  137690. var step = _a[_i];
  137691. step.action();
  137692. }
  137693. // Update Cameras
  137694. if (updateCameras) {
  137695. if (this.activeCameras.length > 0) {
  137696. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  137697. var camera = this.activeCameras[cameraIndex];
  137698. camera.update();
  137699. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_NONE) {
  137700. // rig cameras
  137701. for (var index = 0; index < camera._rigCameras.length; index++) {
  137702. camera._rigCameras[index].update();
  137703. }
  137704. }
  137705. }
  137706. }
  137707. else if (this.activeCamera) {
  137708. this.activeCamera.update();
  137709. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_10__["Camera"].RIG_MODE_NONE) {
  137710. // rig cameras
  137711. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  137712. this.activeCamera._rigCameras[index].update();
  137713. }
  137714. }
  137715. }
  137716. }
  137717. // Before render
  137718. this.onBeforeRenderObservable.notifyObservers(this);
  137719. // Customs render targets
  137720. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  137721. var engine = this.getEngine();
  137722. var currentActiveCamera = this.activeCamera;
  137723. if (this.renderTargetsEnabled) {
  137724. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  137725. this._intermediateRendering = true;
  137726. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  137727. var renderTarget = this.customRenderTargets[customIndex];
  137728. if (renderTarget._shouldRender()) {
  137729. this._renderId++;
  137730. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  137731. if (!this.activeCamera) {
  137732. throw new Error("Active camera not set");
  137733. }
  137734. // Viewport
  137735. engine.setViewport(this.activeCamera.viewport);
  137736. // Camera
  137737. this.updateTransformMatrix();
  137738. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  137739. }
  137740. }
  137741. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  137742. this._intermediateRendering = false;
  137743. this._renderId++;
  137744. }
  137745. // Restore back buffer
  137746. this.activeCamera = currentActiveCamera;
  137747. this._bindFrameBuffer();
  137748. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  137749. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  137750. var step = _c[_b];
  137751. step.action();
  137752. }
  137753. // Clear
  137754. if (this.autoClearDepthAndStencil || this.autoClear) {
  137755. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  137756. }
  137757. // Collects render targets from external components.
  137758. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  137759. var step = _e[_d];
  137760. step.action(this._renderTargets);
  137761. }
  137762. // Multi-cameras?
  137763. if (this.activeCameras.length > 0) {
  137764. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  137765. if (cameraIndex > 0) {
  137766. this._engine.clear(null, false, true, true);
  137767. }
  137768. this._processSubCameras(this.activeCameras[cameraIndex]);
  137769. }
  137770. }
  137771. else {
  137772. if (!this.activeCamera) {
  137773. throw new Error("No camera defined");
  137774. }
  137775. this._processSubCameras(this.activeCamera);
  137776. }
  137777. // Intersection checks
  137778. this._checkIntersections();
  137779. // Executes the after render stage actions.
  137780. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  137781. var step = _g[_f];
  137782. step.action();
  137783. }
  137784. // After render
  137785. if (this.afterRender) {
  137786. this.afterRender();
  137787. }
  137788. this.onAfterRenderObservable.notifyObservers(this);
  137789. // Cleaning
  137790. if (this._toBeDisposed.length) {
  137791. for (var index = 0; index < this._toBeDisposed.length; index++) {
  137792. var data = this._toBeDisposed[index];
  137793. if (data) {
  137794. data.dispose();
  137795. }
  137796. }
  137797. this._toBeDisposed = [];
  137798. }
  137799. if (this.dumpNextRenderTargets) {
  137800. this.dumpNextRenderTargets = false;
  137801. }
  137802. this._activeBones.addCount(0, true);
  137803. this._activeIndices.addCount(0, true);
  137804. this._activeParticles.addCount(0, true);
  137805. };
  137806. /**
  137807. * Freeze all materials
  137808. * A frozen material will not be updatable but should be faster to render
  137809. */
  137810. Scene.prototype.freezeMaterials = function () {
  137811. for (var i = 0; i < this.materials.length; i++) {
  137812. this.materials[i].freeze();
  137813. }
  137814. };
  137815. /**
  137816. * Unfreeze all materials
  137817. * A frozen material will not be updatable but should be faster to render
  137818. */
  137819. Scene.prototype.unfreezeMaterials = function () {
  137820. for (var i = 0; i < this.materials.length; i++) {
  137821. this.materials[i].unfreeze();
  137822. }
  137823. };
  137824. /**
  137825. * Releases all held ressources
  137826. */
  137827. Scene.prototype.dispose = function () {
  137828. this.beforeRender = null;
  137829. this.afterRender = null;
  137830. this.skeletons = [];
  137831. this.morphTargetManagers = [];
  137832. this._transientComponents = [];
  137833. this._isReadyForMeshStage.clear();
  137834. this._beforeEvaluateActiveMeshStage.clear();
  137835. this._evaluateSubMeshStage.clear();
  137836. this._activeMeshStage.clear();
  137837. this._cameraDrawRenderTargetStage.clear();
  137838. this._beforeCameraDrawStage.clear();
  137839. this._beforeRenderTargetDrawStage.clear();
  137840. this._beforeRenderingGroupDrawStage.clear();
  137841. this._beforeRenderingMeshStage.clear();
  137842. this._afterRenderingMeshStage.clear();
  137843. this._afterRenderingGroupDrawStage.clear();
  137844. this._afterCameraDrawStage.clear();
  137845. this._afterRenderTargetDrawStage.clear();
  137846. this._afterRenderStage.clear();
  137847. this._beforeCameraUpdateStage.clear();
  137848. this._beforeClearStage.clear();
  137849. this._gatherRenderTargetsStage.clear();
  137850. this._gatherActiveCameraRenderTargetsStage.clear();
  137851. this._pointerMoveStage.clear();
  137852. this._pointerDownStage.clear();
  137853. this._pointerUpStage.clear();
  137854. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  137855. var component = _a[_i];
  137856. component.dispose();
  137857. }
  137858. this.importedMeshesFiles = new Array();
  137859. this.stopAllAnimations();
  137860. this.resetCachedMaterial();
  137861. // Smart arrays
  137862. if (this.activeCamera) {
  137863. this.activeCamera._activeMeshes.dispose();
  137864. this.activeCamera = null;
  137865. }
  137866. this._activeMeshes.dispose();
  137867. this._renderingManager.dispose();
  137868. this._processedMaterials.dispose();
  137869. this._activeParticleSystems.dispose();
  137870. this._activeSkeletons.dispose();
  137871. this._softwareSkinnedMeshes.dispose();
  137872. this._renderTargets.dispose();
  137873. this._registeredForLateAnimationBindings.dispose();
  137874. this._meshesForIntersections.dispose();
  137875. this._toBeDisposed = [];
  137876. // Abort active requests
  137877. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  137878. var request = _c[_b];
  137879. request.abort();
  137880. }
  137881. // Events
  137882. this.onDisposeObservable.notifyObservers(this);
  137883. this.onDisposeObservable.clear();
  137884. this.onBeforeRenderObservable.clear();
  137885. this.onAfterRenderObservable.clear();
  137886. this.onBeforeRenderTargetsRenderObservable.clear();
  137887. this.onAfterRenderTargetsRenderObservable.clear();
  137888. this.onAfterStepObservable.clear();
  137889. this.onBeforeStepObservable.clear();
  137890. this.onBeforeActiveMeshesEvaluationObservable.clear();
  137891. this.onAfterActiveMeshesEvaluationObservable.clear();
  137892. this.onBeforeParticlesRenderingObservable.clear();
  137893. this.onAfterParticlesRenderingObservable.clear();
  137894. this.onBeforeDrawPhaseObservable.clear();
  137895. this.onAfterDrawPhaseObservable.clear();
  137896. this.onBeforeAnimationsObservable.clear();
  137897. this.onAfterAnimationsObservable.clear();
  137898. this.onDataLoadedObservable.clear();
  137899. this.onBeforeRenderingGroupObservable.clear();
  137900. this.onAfterRenderingGroupObservable.clear();
  137901. this.onMeshImportedObservable.clear();
  137902. this.onBeforeCameraRenderObservable.clear();
  137903. this.onAfterCameraRenderObservable.clear();
  137904. this.onReadyObservable.clear();
  137905. this.onNewCameraAddedObservable.clear();
  137906. this.onCameraRemovedObservable.clear();
  137907. this.onNewLightAddedObservable.clear();
  137908. this.onLightRemovedObservable.clear();
  137909. this.onNewGeometryAddedObservable.clear();
  137910. this.onGeometryRemovedObservable.clear();
  137911. this.onNewTransformNodeAddedObservable.clear();
  137912. this.onTransformNodeRemovedObservable.clear();
  137913. this.onNewMeshAddedObservable.clear();
  137914. this.onMeshRemovedObservable.clear();
  137915. this.onNewSkeletonAddedObservable.clear();
  137916. this.onSkeletonRemovedObservable.clear();
  137917. this.onNewMaterialAddedObservable.clear();
  137918. this.onMaterialRemovedObservable.clear();
  137919. this.onNewTextureAddedObservable.clear();
  137920. this.onTextureRemovedObservable.clear();
  137921. this.onPrePointerObservable.clear();
  137922. this.onPointerObservable.clear();
  137923. this.onPreKeyboardObservable.clear();
  137924. this.onKeyboardObservable.clear();
  137925. this.onActiveCameraChanged.clear();
  137926. this.detachControl();
  137927. // Detach cameras
  137928. var canvas = this._engine.getRenderingCanvas();
  137929. if (canvas) {
  137930. var index;
  137931. for (index = 0; index < this.cameras.length; index++) {
  137932. this.cameras[index].detachControl(canvas);
  137933. }
  137934. }
  137935. // Release animation groups
  137936. while (this.animationGroups.length) {
  137937. this.animationGroups[0].dispose();
  137938. }
  137939. // Release lights
  137940. while (this.lights.length) {
  137941. this.lights[0].dispose();
  137942. }
  137943. // Release meshes
  137944. while (this.meshes.length) {
  137945. this.meshes[0].dispose(true);
  137946. }
  137947. while (this.transformNodes.length) {
  137948. this.transformNodes[0].dispose(true);
  137949. }
  137950. // Release cameras
  137951. while (this.cameras.length) {
  137952. this.cameras[0].dispose();
  137953. }
  137954. // Release materials
  137955. if (this.defaultMaterial) {
  137956. this.defaultMaterial.dispose();
  137957. }
  137958. while (this.multiMaterials.length) {
  137959. this.multiMaterials[0].dispose();
  137960. }
  137961. while (this.materials.length) {
  137962. this.materials[0].dispose();
  137963. }
  137964. // Release particles
  137965. while (this.particleSystems.length) {
  137966. this.particleSystems[0].dispose();
  137967. }
  137968. // Release postProcesses
  137969. while (this.postProcesses.length) {
  137970. this.postProcesses[0].dispose();
  137971. }
  137972. // Release textures
  137973. while (this.textures.length) {
  137974. this.textures[0].dispose();
  137975. }
  137976. // Release UBO
  137977. this._sceneUbo.dispose();
  137978. if (this._multiviewSceneUbo) {
  137979. this._multiviewSceneUbo.dispose();
  137980. }
  137981. // Post-processes
  137982. this.postProcessManager.dispose();
  137983. // Remove from engine
  137984. index = this._engine.scenes.indexOf(this);
  137985. if (index > -1) {
  137986. this._engine.scenes.splice(index, 1);
  137987. }
  137988. this._engine.wipeCaches(true);
  137989. this._isDisposed = true;
  137990. };
  137991. Object.defineProperty(Scene.prototype, "isDisposed", {
  137992. /**
  137993. * Gets if the scene is already disposed
  137994. */
  137995. get: function () {
  137996. return this._isDisposed;
  137997. },
  137998. enumerable: true,
  137999. configurable: true
  138000. });
  138001. /**
  138002. * Call this function to reduce memory footprint of the scene.
  138003. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  138004. */
  138005. Scene.prototype.clearCachedVertexData = function () {
  138006. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  138007. var mesh = this.meshes[meshIndex];
  138008. var geometry = mesh.geometry;
  138009. if (geometry) {
  138010. geometry._indices = [];
  138011. for (var vbName in geometry._vertexBuffers) {
  138012. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  138013. continue;
  138014. }
  138015. geometry._vertexBuffers[vbName]._buffer._data = null;
  138016. }
  138017. }
  138018. }
  138019. };
  138020. /**
  138021. * This function will remove the local cached buffer data from texture.
  138022. * It will save memory but will prevent the texture from being rebuilt
  138023. */
  138024. Scene.prototype.cleanCachedTextureBuffer = function () {
  138025. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  138026. var baseTexture = _a[_i];
  138027. var buffer = baseTexture._buffer;
  138028. if (buffer) {
  138029. baseTexture._buffer = null;
  138030. }
  138031. }
  138032. };
  138033. /**
  138034. * Get the world extend vectors with an optional filter
  138035. *
  138036. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  138037. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  138038. */
  138039. Scene.prototype.getWorldExtends = function (filterPredicate) {
  138040. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  138041. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  138042. filterPredicate = filterPredicate || (function () { return true; });
  138043. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  138044. mesh.computeWorldMatrix(true);
  138045. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  138046. return;
  138047. }
  138048. var boundingInfo = mesh.getBoundingInfo();
  138049. var minBox = boundingInfo.boundingBox.minimumWorld;
  138050. var maxBox = boundingInfo.boundingBox.maximumWorld;
  138051. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  138052. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  138053. });
  138054. return {
  138055. min: min,
  138056. max: max
  138057. };
  138058. };
  138059. // Picking
  138060. /**
  138061. * Creates a ray that can be used to pick in the scene
  138062. * @param x defines the x coordinate of the origin (on-screen)
  138063. * @param y defines the y coordinate of the origin (on-screen)
  138064. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  138065. * @param camera defines the camera to use for the picking
  138066. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  138067. * @returns a Ray
  138068. */
  138069. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  138070. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  138071. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138072. };
  138073. /**
  138074. * Creates a ray that can be used to pick in the scene
  138075. * @param x defines the x coordinate of the origin (on-screen)
  138076. * @param y defines the y coordinate of the origin (on-screen)
  138077. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  138078. * @param result defines the ray where to store the picking ray
  138079. * @param camera defines the camera to use for the picking
  138080. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  138081. * @returns the current scene
  138082. */
  138083. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  138084. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  138085. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138086. };
  138087. /**
  138088. * Creates a ray that can be used to pick in the scene
  138089. * @param x defines the x coordinate of the origin (on-screen)
  138090. * @param y defines the y coordinate of the origin (on-screen)
  138091. * @param camera defines the camera to use for the picking
  138092. * @returns a Ray
  138093. */
  138094. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  138095. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138096. };
  138097. /**
  138098. * Creates a ray that can be used to pick in the scene
  138099. * @param x defines the x coordinate of the origin (on-screen)
  138100. * @param y defines the y coordinate of the origin (on-screen)
  138101. * @param result defines the ray where to store the picking ray
  138102. * @param camera defines the camera to use for the picking
  138103. * @returns the current scene
  138104. */
  138105. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  138106. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138107. };
  138108. /** Launch a ray to try to pick a mesh in the scene
  138109. * @param x position on screen
  138110. * @param y position on screen
  138111. * @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
  138112. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  138113. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  138114. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  138115. * @returns a PickingInfo
  138116. */
  138117. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera, trianglePredicate) {
  138118. // Dummy info if picking as not been imported
  138119. var pi = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_15__["PickingInfo"]();
  138120. pi._pickingUnavailable = true;
  138121. return pi;
  138122. };
  138123. /** Use the given ray to pick a mesh in the scene
  138124. * @param ray The ray to use to pick meshes
  138125. * @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
  138126. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  138127. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  138128. * @returns a PickingInfo
  138129. */
  138130. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck, trianglePredicate) {
  138131. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138132. };
  138133. /**
  138134. * Launch a ray to try to pick a mesh in the scene
  138135. * @param x X position on screen
  138136. * @param y Y position on screen
  138137. * @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
  138138. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  138139. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  138140. * @returns an array of PickingInfo
  138141. */
  138142. Scene.prototype.multiPick = function (x, y, predicate, camera, trianglePredicate) {
  138143. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138144. };
  138145. /**
  138146. * Launch a ray to try to pick a mesh in the scene
  138147. * @param ray Ray to use
  138148. * @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
  138149. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  138150. * @returns an array of PickingInfo
  138151. */
  138152. Scene.prototype.multiPickWithRay = function (ray, predicate, trianglePredicate) {
  138153. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_27__["_DevTools"].WarnImport("Ray");
  138154. };
  138155. /**
  138156. * Force the value of meshUnderPointer
  138157. * @param mesh defines the mesh to use
  138158. */
  138159. Scene.prototype.setPointerOverMesh = function (mesh) {
  138160. if (this._pointerOverMesh === mesh) {
  138161. return;
  138162. }
  138163. var actionManager;
  138164. if (this._pointerOverMesh) {
  138165. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPointerOutTrigger);
  138166. if (actionManager) {
  138167. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(this._pointerOverMesh));
  138168. }
  138169. }
  138170. this._pointerOverMesh = mesh;
  138171. if (this._pointerOverMesh) {
  138172. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPointerOverTrigger);
  138173. if (actionManager) {
  138174. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_18__["ActionEvent"].CreateNew(this._pointerOverMesh));
  138175. }
  138176. }
  138177. };
  138178. /**
  138179. * Gets the mesh under the pointer
  138180. * @returns a Mesh or null if no mesh is under the pointer
  138181. */
  138182. Scene.prototype.getPointerOverMesh = function () {
  138183. return this._pointerOverMesh;
  138184. };
  138185. // Misc.
  138186. /** @hidden */
  138187. Scene.prototype._rebuildGeometries = function () {
  138188. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  138189. var geometry = _a[_i];
  138190. geometry._rebuild();
  138191. }
  138192. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  138193. var mesh = _c[_b];
  138194. mesh._rebuild();
  138195. }
  138196. if (this.postProcessManager) {
  138197. this.postProcessManager._rebuild();
  138198. }
  138199. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  138200. var component = _e[_d];
  138201. component.rebuild();
  138202. }
  138203. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  138204. var system = _g[_f];
  138205. system.rebuild();
  138206. }
  138207. };
  138208. /** @hidden */
  138209. Scene.prototype._rebuildTextures = function () {
  138210. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  138211. var texture = _a[_i];
  138212. texture._rebuild();
  138213. }
  138214. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_TextureDirtyFlag);
  138215. };
  138216. // Tags
  138217. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  138218. if (tagsQuery === undefined) {
  138219. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  138220. return list;
  138221. }
  138222. var listByTags = [];
  138223. forEach = forEach || (function (item) { return; });
  138224. for (var i in list) {
  138225. var item = list[i];
  138226. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  138227. listByTags.push(item);
  138228. forEach(item);
  138229. }
  138230. }
  138231. return listByTags;
  138232. };
  138233. /**
  138234. * Get a list of meshes by tags
  138235. * @param tagsQuery defines the tags query to use
  138236. * @param forEach defines a predicate used to filter results
  138237. * @returns an array of Mesh
  138238. */
  138239. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  138240. return this._getByTags(this.meshes, tagsQuery, forEach);
  138241. };
  138242. /**
  138243. * Get a list of cameras by tags
  138244. * @param tagsQuery defines the tags query to use
  138245. * @param forEach defines a predicate used to filter results
  138246. * @returns an array of Camera
  138247. */
  138248. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  138249. return this._getByTags(this.cameras, tagsQuery, forEach);
  138250. };
  138251. /**
  138252. * Get a list of lights by tags
  138253. * @param tagsQuery defines the tags query to use
  138254. * @param forEach defines a predicate used to filter results
  138255. * @returns an array of Light
  138256. */
  138257. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  138258. return this._getByTags(this.lights, tagsQuery, forEach);
  138259. };
  138260. /**
  138261. * Get a list of materials by tags
  138262. * @param tagsQuery defines the tags query to use
  138263. * @param forEach defines a predicate used to filter results
  138264. * @returns an array of Material
  138265. */
  138266. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  138267. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  138268. };
  138269. /**
  138270. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  138271. * This allowed control for front to back rendering or reversly depending of the special needs.
  138272. *
  138273. * @param renderingGroupId The rendering group id corresponding to its index
  138274. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  138275. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  138276. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  138277. */
  138278. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  138279. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  138280. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  138281. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  138282. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  138283. };
  138284. /**
  138285. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  138286. *
  138287. * @param renderingGroupId The rendering group id corresponding to its index
  138288. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  138289. * @param depth Automatically clears depth between groups if true and autoClear is true.
  138290. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  138291. */
  138292. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  138293. if (depth === void 0) { depth = true; }
  138294. if (stencil === void 0) { stencil = true; }
  138295. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  138296. };
  138297. /**
  138298. * Gets the current auto clear configuration for one rendering group of the rendering
  138299. * manager.
  138300. * @param index the rendering group index to get the information for
  138301. * @returns The auto clear setup for the requested rendering group
  138302. */
  138303. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  138304. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  138305. };
  138306. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  138307. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  138308. get: function () {
  138309. return this._blockMaterialDirtyMechanism;
  138310. },
  138311. set: function (value) {
  138312. if (this._blockMaterialDirtyMechanism === value) {
  138313. return;
  138314. }
  138315. this._blockMaterialDirtyMechanism = value;
  138316. if (!value) { // Do a complete update
  138317. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_22__["Constants"].MATERIAL_AllDirtyFlag);
  138318. }
  138319. },
  138320. enumerable: true,
  138321. configurable: true
  138322. });
  138323. /**
  138324. * Will flag all materials as dirty to trigger new shader compilation
  138325. * @param flag defines the flag used to specify which material part must be marked as dirty
  138326. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  138327. */
  138328. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  138329. if (this._blockMaterialDirtyMechanism) {
  138330. return;
  138331. }
  138332. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  138333. var material = _a[_i];
  138334. if (predicate && !predicate(material)) {
  138335. continue;
  138336. }
  138337. material.markAsDirty(flag);
  138338. }
  138339. };
  138340. /** @hidden */
  138341. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  138342. var _this = this;
  138343. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  138344. this._activeRequests.push(request);
  138345. request.onCompleteObservable.add(function (request) {
  138346. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  138347. });
  138348. return request;
  138349. };
  138350. /** @hidden */
  138351. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  138352. var _this = this;
  138353. return new Promise(function (resolve, reject) {
  138354. _this._loadFile(url, function (data) {
  138355. resolve(data);
  138356. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  138357. reject(exception);
  138358. });
  138359. });
  138360. };
  138361. // Statics
  138362. Scene._uniqueIdCounter = 0;
  138363. /** The fog is deactivated */
  138364. Scene.FOGMODE_NONE = 0;
  138365. /** The fog density is following an exponential function */
  138366. Scene.FOGMODE_EXP = 1;
  138367. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  138368. Scene.FOGMODE_EXP2 = 2;
  138369. /** The fog density is following a linear function. */
  138370. Scene.FOGMODE_LINEAR = 3;
  138371. /**
  138372. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  138373. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  138374. */
  138375. Scene.MinDeltaTime = 1.0;
  138376. /**
  138377. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  138378. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  138379. */
  138380. Scene.MaxDeltaTime = 1000.0;
  138381. /** The distance in pixel that you have to move to prevent some events */
  138382. Scene.DragMovementThreshold = 10; // in pixels
  138383. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  138384. Scene.LongPressDelay = 500; // in milliseconds
  138385. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  138386. Scene.DoubleClickDelay = 300; // in milliseconds
  138387. /** If you need to check double click without raising a single click at first click, enable this flag */
  138388. Scene.ExclusiveDoubleClickMode = false;
  138389. return Scene;
  138390. }(_abstractScene__WEBPACK_IMPORTED_MODULE_11__["AbstractScene"]));
  138391. /***/ }),
  138392. /***/ "./sceneComponent.ts":
  138393. /*!***************************!*\
  138394. !*** ./sceneComponent.ts ***!
  138395. \***************************/
  138396. /*! exports provided: SceneComponentConstants, Stage */
  138397. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  138398. "use strict";
  138399. __webpack_require__.r(__webpack_exports__);
  138400. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  138401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  138402. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  138403. /**
  138404. * Groups all the scene component constants in one place to ease maintenance.
  138405. * @hidden
  138406. */
  138407. var SceneComponentConstants = /** @class */ (function () {
  138408. function SceneComponentConstants() {
  138409. }
  138410. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  138411. SceneComponentConstants.NAME_LAYER = "Layer";
  138412. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  138413. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  138414. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  138415. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  138416. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  138417. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  138418. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  138419. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  138420. SceneComponentConstants.NAME_SPRITE = "Sprite";
  138421. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  138422. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  138423. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  138424. SceneComponentConstants.NAME_OCTREE = "Octree";
  138425. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  138426. SceneComponentConstants.NAME_AUDIO = "Audio";
  138427. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  138428. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  138429. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  138430. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  138431. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  138432. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  138433. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  138434. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  138435. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  138436. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  138437. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  138438. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  138439. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  138440. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  138441. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  138442. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  138443. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  138444. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  138445. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  138446. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  138447. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  138448. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  138449. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  138450. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  138451. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  138452. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  138453. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  138454. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  138455. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  138456. return SceneComponentConstants;
  138457. }());
  138458. /**
  138459. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  138460. * @hidden
  138461. */
  138462. var Stage = /** @class */ (function (_super) {
  138463. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  138464. /**
  138465. * Hide ctor from the rest of the world.
  138466. * @param items The items to add.
  138467. */
  138468. function Stage(items) {
  138469. return _super.apply(this, items) || this;
  138470. }
  138471. /**
  138472. * Creates a new Stage.
  138473. * @returns A new instance of a Stage
  138474. */
  138475. Stage.Create = function () {
  138476. return Object.create(Stage.prototype);
  138477. };
  138478. /**
  138479. * Registers a step in an ordered way in the targeted stage.
  138480. * @param index Defines the position to register the step in
  138481. * @param component Defines the component attached to the step
  138482. * @param action Defines the action to launch during the step
  138483. */
  138484. Stage.prototype.registerStep = function (index, component, action) {
  138485. var i = 0;
  138486. var maxIndex = Number.MAX_VALUE;
  138487. for (; i < this.length; i++) {
  138488. var step = this[i];
  138489. maxIndex = step.index;
  138490. if (index < maxIndex) {
  138491. break;
  138492. }
  138493. }
  138494. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  138495. };
  138496. /**
  138497. * Clears all the steps from the stage.
  138498. */
  138499. Stage.prototype.clear = function () {
  138500. this.length = 0;
  138501. };
  138502. return Stage;
  138503. }(Array));
  138504. /***/ })
  138505. /******/ });
  138506. });
  138507. //# sourceMappingURL=babylon.max.js.map